Fix terminal Stop Dictation clearing text with the built-in engine - #328742
Open
meganrogge with Copilot wants to merge 6 commits into
Open
Fix terminal Stop Dictation clearing text with the built-in engine#328742meganrogge with Copilot wants to merge 6 commits into
meganrogge with Copilot wants to merge 6 commits into
Conversation
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix stop dictation keybinding clears text in terminal
Fix terminal Stop Dictation clearing text with the built-in engine
Aug 3, 2026
meganrogge
reviewed
Aug 3, 2026
meganrogge
approved these changes
Aug 3, 2026
meganrogge
marked this pull request as ready for review
August 3, 2026 16:34
meganrogge
enabled auto-merge (squash)
August 3, 2026 16:34
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @anthonykim1Matched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a race where terminal dictation teardown can interrupt built-in speech finalization.
Changes:
- Defers teardown while built-in transcription is finalizing.
- Adds a regression test for active-instance changes during finalization.
Show a summary per file
| File | Description |
|---|---|
terminalVoice.ts |
Guards built-in finalization from concurrent teardown. |
terminalVoice.test.ts |
Tests the finalization race. |
Review details
Suppressed comments (1)
src/vs/workbench/contrib/terminalContrib/voice/test/browser/terminalVoice.test.ts:118
- This multi-line inline comment exceeds the project's one-line limit for comments inside a function body and largely repeats the test name. Keep only a brief note about the ordering constraint.
// Stopping the built-in engine fetches its final transcript asynchronously.
// A teardown-only stop() racing in during that await (e.g. the active
// terminal instance changing as the command palette closes when the Stop
// Dictation command runs) must not cancel the engine and drop the text.
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
meganrogge
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With the built-in on-device engine, the terminal dictation transcript is only staged (shown as ghost text) until accepted. Accepting via Stop Dictation in Terminal is asynchronous —
stop(true)sets_builtinFinalizingand awaits the engine's final transcript in_finalizeBuiltinThenStop().TerminalVoiceSessionalso tears down ononDidChangeActiveInstance/onDidDisposeInstanceviastop()(send = false). When such a teardown races in during the finalize await (e.g. the active instance changing as the command palette closes while running the Stop command), it cancels the engine mid-transcribe and wipes the staged input. The finalize's guard then returns early, so the text is never committed and the ghost text just disappears — the reported "text gets cleared".Changes
terminalVoice.ts— Instop(), ignore a concurrent teardown-only (send = false) call while a built-in finalize is in flight, letting the finalize complete and commit the transcript:terminalVoice.test.ts— Added aTerminalVoiceSessionregression test that fires an active-instance change during the accept await and asserts the dictated text is still sent (fails without the fix).