Skip to content

Fix terminal Stop Dictation clearing text with the built-in engine - #328742

Open
meganrogge with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-stop-dictation-clears-text
Open

Fix terminal Stop Dictation clearing text with the built-in engine#328742
meganrogge with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-stop-dictation-clears-text

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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 _builtinFinalizing and awaits the engine's final transcript in _finalizeBuiltinThenStop().

TerminalVoiceSession also tears down on onDidChangeActiveInstance / onDidDisposeInstance via stop() (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 — In stop(), ignore a concurrent teardown-only (send = false) call while a built-in finalize is in flight, letting the finalize complete and commit the transcript:

    if (this._builtinFinalizing && !send) {
        return;
    }
  • terminalVoice.test.ts — Added a TerminalVoiceSession regression test that fires an active-instance change during the accept await and asserts the dictated text is still sent (fails without the fix).

  • Fixes microsoft/vscode-internalbacklog#8708

Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 15:45
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 16:15
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 16:18
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
Copilot AI requested a review from meganrogge August 3, 2026 16:19
Comment thread src/vs/workbench/contrib/terminalContrib/voice/browser/terminalVoice.ts Outdated
Copilot AI review requested due to automatic review settings August 3, 2026 16:33
@meganrogge
meganrogge marked this pull request as ready for review August 3, 2026 16:34
@meganrogge
meganrogge enabled auto-merge (squash) August 3, 2026 16:34
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

@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

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

Comment thread src/vs/workbench/contrib/terminalContrib/voice/browser/terminalVoice.ts Outdated
Comment thread src/vs/workbench/contrib/terminalContrib/voice/test/browser/terminalVoice.test.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI requested a review from meganrogge August 3, 2026 16:46
@meganrogge meganrogge added this to the 1.132.0 milestone Aug 3, 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.

3 participants