Skip to content

Allow editor/terminal dictation to take over an active Chat dictation session - #328830

Merged
Megan Rogge (meganrogge) merged 12 commits into
mainfrom
copilot/fix-dictation-editor-terminal-issue
Aug 5, 2026
Merged

Allow editor/terminal dictation to take over an active Chat dictation session#328830
Megan Rogge (meganrogge) merged 12 commits into
mainfrom
copilot/fix-dictation-editor-terminal-issue

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

Chat, editor, and terminal dictation share a single on-device speech engine, so only one can run at a time. While Chat dictation was active, "Start Dictation in Editor" and "Start Dictation in Terminal" silently did nothing: the editor path early-returned from startDictation (the shared _active session was owned by Chat), and the terminal path aborted when the engine was busy.

The fix lets a new surface take over: each surface already tears down its own UI when it observes the engine go Idle, so a new start just cancels the current session before attaching its own listeners.

  • dictationSession.ts (startDictation) — instead of no-op returning when a session is active, cancel the current session (Chat, another editor, or terminal) and take over; the previous surface cleans up via its own Idle listener and keeps whatever transcript it had inserted. Same-editor re-entry still returns early (toggle handled by callers).
  • editorDictation.ts (startBuiltin) — register the "self-teardown on Idle" listener after startDictation so the takeover's cancel of the previous surface can't tear down the just-started editor session.
  • terminalVoice.ts (_startBuiltin) — replace the "abort when busy" guard with a service.cancel() takeover (before subscribing), keeping a defensive bail-out if the engine somehow stays busy.
  • dictationSession.test.ts — added coverage for cross-surface takeover (first editor keeps its text, second becomes active); updated the mock cancel() to emit the real Idle transition.

Takeover is now symmetric across the reported directions (Chat → editor, Chat → terminal) as well as editor ↔ terminal, with no cross-contribution imports.

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 20:30
Copilot AI changed the title [WIP] Fix issue where dictation does not start in editor or terminal Allow editor/terminal dictation to take over an active Chat dictation session Aug 3, 2026
@meganrogge
Megan Rogge (meganrogge) marked this pull request as ready for review August 4, 2026 21:19
Copilot AI balanced review requested due to automatic review settings August 4, 2026 21:19
@vs-code-engineering

vs-code-engineering Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminalContrib/voice/browser/terminalVoice.ts
  • src/vs/workbench/contrib/terminalContrib/voice/test/browser/terminalVoice.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables editor and terminal dictation to take over the shared speech engine from another surface.

Changes:

  • Cancels active dictation before starting on another surface.
  • Adjusts editor listener ordering to avoid premature teardown.
  • Adds editor-to-editor takeover coverage.
Show a summary per file
File Description
terminalVoice.ts Adds terminal takeover behavior.
editorDictation.ts Delays editor idle-listener registration.
dictationSession.ts Adds shared-session takeover logic.
dictationSession.test.ts Tests editor takeover and realistic cancellation.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread src/vs/workbench/contrib/chat/browser/speechToText/dictationSession.ts Outdated
Comment thread src/vs/workbench/contrib/terminalContrib/voice/browser/terminalVoice.ts Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-editor-terminal-issue

# Conflicts:
#	src/vs/workbench/contrib/chat/test/browser/dictationSession.test.ts
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) August 4, 2026 22:05
@meganrogge

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>

Copilot AI commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in c4b13ce. Conflicting hunks in the dictation files were merged (combined DictationSettingId + isDictationActiveOnSurface import in newChatInput.ts, kept the surface-aware test helpers in dictationSession.test.ts); all other conflicted files were taken from main. Also updated terminalVoice.test.ts's mock cancel() to be async to match the new Promise<void> signature. Remaining typecheck-client errors are pre-existing on main (agentHost).

@meganrogge
Megan Rogge (meganrogge) merged commit 371f6fd into main Aug 5, 2026
29 checks passed
@meganrogge
Megan Rogge (meganrogge) deleted the copilot/fix-dictation-editor-terminal-issue branch August 5, 2026 23:59
@vs-code-engineering vs-code-engineering Bot added this to the 1.133.0 milestone Aug 6, 2026
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.

Can't start in editor or terminal once Chat dictation has started

6 participants