Skip to content

feat: expose active console as vscode.TextEditor via positron.window - #15154

Draft
samclark2015 wants to merge 5 commits into
mainfrom
issue-1507
Draft

feat: expose active console as vscode.TextEditor via positron.window#15154
samclark2015 wants to merge 5 commits into
mainfrom
issue-1507

Conversation

@samclark2015

@samclark2015 samclark2015 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #1507

Adds positron.window.activeConsoleEditor and positron.window.onDidChangeActiveConsoleEditor to the Positron extension API, exposing the console input as a vscode.TextEditor (parallel to VS Code's activeTextEditor and activeNotebookEditor). The console editor is registered with the extension host's text editor machinery via a Positron-specific path that preserves isSimpleWidget: true, so it is never surfaced as vscode.window.activeTextEditor -- only through the new Positron API.

Release Notes

New Features

  • Added positron.window.activeConsoleEditor and onDidChangeActiveConsoleEditor -- expose the active console input as a vscode.TextEditor so extensions can read and edit console text using the standard editor API (Console: API to get the active console #1507)

Bug Fixes

  • N/A

Validation Steps

@:console

  1. Start a Zed (or R/Python) console session in Positron.
  2. In the Zed console, run console active -- the output should show the console's inmemory:// URI, language ID, and current input text.
  3. Run console watch, then switch between different language consoles -- each switch should fire an event showing the new editor's URI. Run console watch stop to stop.
  4. Exercise the mutating vscode.TextEditor API against the console input:
    • console edit foo -- replaces the input with foo via TextEditor.edit().
    • console append bar -- inserts bar at the end via TextEditor.edit().
    • console insert baz -- inserts baz at the cursor via TextEditor.insertSnippet().
    • console select -- selects the whole input and reports TextEditor.selection.

samclark2015 and others added 3 commits July 10, 2026 11:57
…onsole API

Expose the currently active console and a change event via the Positron
extension API, with startup seeding to handle consoles active before the
ext host starts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tor API

Adds three commands to the Zed test runtime for manually exercising
the new positron.window.activeConsoleEditor and onDidChangeActiveConsoleEditor
APIs added in the previous commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Register the console Monaco editor with MainThreadDocumentsAndEditors so
it appears as a real vscode.TextEditor in the ext host, while preserving
isSimpleWidget: true so it never becomes vscode.window.activeTextEditor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:console

Why these tags?
Tag Source
@:critical Always runs (required)
@:console PR description

More on automatic tags from changed files.

readme  valid tags

samclark2015 and others added 2 commits July 28, 2026 11:32
The console input assigns its code editor before calling setModel(), so
onDidSetCodeEditor fired while the widget still had no model. registerConsoleEditor
then hit its `if (!model) return` guard and silently never registered the editor,
leaving positron.window.activeConsoleEditor permanently undefined.

Defer registration until a model is attached (via onDidChangeModel) instead of
giving up. Also add Zed `console edit/append/insert/select` commands that exercise
the mutating side of the TextEditor interface (edit(), insertSnippet(), selection).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a Vitest for MainThreadDocumentsAndEditors.registerConsoleEditor
covering the deferred-model branch: when the code editor starts without
a model, registration waits for onDidChangeModel rather than silently
skipping. A companion case covers the model-present path. Uses a real
ModelService + createTestCodeEditor so the model-attach event fires
genuinely, mirroring the sibling upstream Mocha suite's wiring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console: API to get the active console

1 participant