Repository navigation
Voice: narrate confirmations/responses stranded on the user_speaking latch - #326378
Merged
Megan Rogge (meganrogge) merged 3 commits intoJul 17, 2026
Merged
Megan Rogge (meganrogge) merged 3 commits into
Megan Rogge (meganrogge) merged 3 commits into
Conversation
…he user_speaking latch
In hands-free mode the controller opens a passive auto-listen mic turn on
connect (and for barge-in), leaving the turn open (ptt_start sent, no
ptt_end). The backend latches user_is_speaking on ptt_start, so a
client-driven request_narration issued while that latch is set is NACK'd
`busy: user_speaking` and deferred until a narration_unblocked nudge.
For a SILENT passive turn that nudge never arrives: _prepareForPlayback ran
AFTER the request and used _finishPtt('auto') -> abortPtt(), which stops the
mic locally without emitting ptt_end, so the backend never learns the turn
ended and never clears the latch. The confirmation/response is stranded and
never spoken.
Fix: in _narrate, when the user is NOT actively dictating, end the open
listen turn with a genuine ptt_end BEFORE requesting the narration (WS
preserves order, so the backend clears the latch and accepts the request
immediately). When the user IS mid-utterance, leave the turn open and keep
the existing busy/defer + narration_unblocked path so their speech isn't cut
off.
- _prepareForPlayback(endOpenTurn) finishes via _finishPtt('local') (real
ptt_end) when true, else the prior 'auto' abort.
- _isActivelyDictating() detects a non-empty partial user transcript.
- IVoiceClientService.canRequestNarration gates the force-end so a
closed-socket path still queues a retry without tearing down a
freshly-entered listen on connect.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: d527ed3c-29a9-435f-8772-c8117077d394
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes stranded voice narration by ending passive listening turns before requesting playback.
Changes:
- Detects active user dictation.
- Adds narration readiness state.
- Selects local PTT completion for silent passive turns.
Show a summary per file
| File | Description |
|---|---|
voiceClientService.ts (common) |
Adds narration readiness to the service contract. |
voiceSessionController.ts |
Coordinates passive turns and narration playback. |
voiceClientService.ts (browser) |
Implements narration readiness detection. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 5
- Review effort level: Medium
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
…m comments
- The force-end path used `_finishPtt('local')` → `pttUp()`, which drains ~500ms
before `onPttEnd`/`ptt_end` fires, so the synchronous `requestNarration` still
raced ahead of `ptt_end` and was NACK'd `busy: user_speaking`. Add a
`_finishPtt('immediate')` reason that aborts the mic with no drain and sends
`ptt_end` synchronously, so the backend clears its latch before the narration
request frame.
- `_isActivelyDictating()` relied on recognized text, so it reported false in the
window between `speech_started` and the first transcription — force-ending a
user who had already begun speaking. Track a `_userSpeechActive` VAD flag
(set on `speech_started`, cleared on final transcription / turn end).
- Trim the oversized inline comments in `_narrate` and `_prepareForPlayback` to a
single non-obvious line each.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: d527ed3c-29a9-435f-8772-c8117077d394
Collaborator
Author
|
Addressed the review feedback in 0857117:
|
Paul (pwang347)
approved these changes
Jul 17, 2026
Megan Rogge (meganrogge)
deleted the
copilot/fix-voice-narration-user-speaking-latch
branch
July 17, 2026 17:43
Arthur Cnops (accnops)
pushed a commit
to accnops/vscode
that referenced
this pull request
Jul 17, 2026
Extend the passive open-mic flag to the auto-listen path (not just barge-in) so every hands-free turn opened without a deliberate user press sends ptt_start with passive:true. The backend then leaves user_is_speaking clear on those silent turns, so a client-driven narration request is accepted instead of being NACK'd busy: user_speaking and stranded. This supersedes the force-ptt_end workaround from microsoft#326378: a passive turn never latches in the first place, so there is no latch to force-clear. Remove that mechanism (_userSpeechActive, _isActivelyDictating, the _finishPtt 'immediate' variant, _prepareForPlayback(endOpenTurn), and canRequestNarration) and restore _narrate to unconditionally prepare for playback on a sent request. Depends on backend passive handling (yolo#56284): must be live in GA before this lands, or silent hands-free turns latch again on the old backend. Adds controller tests: auto-listen opens a passive mic turn; a deliberate press stays non-passive.
Arthur Cnops (accnops)
pushed a commit
to accnops/vscode
that referenced
this pull request
Jul 18, 2026
Extend the passive open-mic flag to the auto-listen path (not just barge-in) so every hands-free turn opened without a deliberate user press sends ptt_start with passive:true. The backend then leaves user_is_speaking clear on those silent turns, so a client-driven narration request is accepted instead of being NACK'd busy: user_speaking and stranded. This supersedes the force-ptt_end workaround from microsoft#326378: a passive turn never latches in the first place, so there is no latch to force-clear. Remove that mechanism (_userSpeechActive, _isActivelyDictating, the _finishPtt 'immediate' variant, _prepareForPlayback(endOpenTurn), and canRequestNarration) and restore _narrate to unconditionally prepare for playback on a sent request. Depends on backend passive handling (yolo#56284): must be live in GA before this lands, or silent hands-free turns latch again on the old backend. Adds controller tests: auto-listen opens a passive mic turn; a deliberate press stays non-passive.
Megan Rogge (meganrogge)
pushed a commit
that referenced
this pull request
Jul 20, 2026
…326405) * fix(voice): flag passive barge-in ptt_start so backend does not latch user speaking Thread a `passive` flag immutably through mic-start into the ptt_start frame instead of reading controller state at emit time, which could race with the async getUserMedia acquire in the cold-capture path. - micCaptureService: pttDown(turnId, passive = false) now captures passive per-press and fires it on onPttStart (Emitter<boolean>) at both the warm and post-acquire fire sites. - voiceClientService: sendPttStart(turnId, passive = false) serializes `passive: true` only when true, keeping the wire frame byte-identical for real presses / old clients. - voiceSessionController: onPttStart forwards the captured passive to sendPttStart; _startBargeInListen is the only caller passing passive=true (verified single true caller). Safe because barge-in promotion (a real press during a passive listen) does not re-send ptt_start, so the passive flag captured at listen-open time remains correct for the whole turn. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49 * fix(voice): adopt server session id and clear resuming flag on (re)init `_isResuming` was set on reconnect but never cleared, and a failed resume refused to adopt the server's fresh session_init id, leaving the client believing it still owned a dead session and stalling reconnect. On both `session_init` and `session_resumed`, always adopt `msg.session_id` and clear `_isResuming`; also reset `_isResuming` in `_cleanup()` for terminal disconnects. Adopting a fresh id on a failed resume is strictly more correct than the previous refusal. Extended the test createTestWindow harness to bind setInterval and clearInterval to the real window target (native timer methods are branded and throw Illegal invocation when called with a Proxy as this), which was needed to drive ws.onopen in the new tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49 * fix(voice): replay deferred narrations on reconnect `_deferredNarrations` (busy/interrupted narrations awaiting a narration_unblocked nudge) was never replayed on reconnect - only _pendingNarrationRetries was. The narration_unblocked nudge that would otherwise trigger a retry is itself lost with the dropped socket, so a narration deferred right before a disconnect could be silently lost forever. On session_init/session_resumed, now also replay _deferredNarrations by reusing _retryDeferredNarration for each entry - the same revalidation already used for the live narration_unblocked path: it re-checks _currentNarratable before firing and reuses the same narration_id when the text is unchanged, so backend idempotency returns accepted without re-synth for anything already spoken. Entries no longer warranted or no longer the shown session are dropped without speaking, same as before. _retryDeferredNarration now returns whether it actually sent a retry (mirrors _narrate's return) so the reconnect handler can gate entering auto-listen the same way it already does for _pendingNarrationRetries - a narration about to play should not be torn down by a listen that starts moments later. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49 * fix(voice): retry the specific unblocked narration id `_retryDeferredNarration` ignored the `narration_id` carried by `narration_unblocked` and always retried whatever was currently deferred for the session key. `_deferredNarrations` is latest-wins per session key, so if a second narration for the same session went busy before the first one's `narration_unblocked` arrived, the stale nudge would retry the newer (possibly still-busy) entry early instead of waiting for its own unblock. `_retryDeferredNarration` now takes an optional `unblockedNarrationId`; when it does not match the currently deferred entry's id, the retry is skipped - the correct nudge for that entry will arrive separately once its own guard clears. The reconnect replay path (no unblock event, no id to compare against) is unaffected and keeps retrying whatever is currently deferred. Low risk: retrying a superseded id was already an idempotent no-op server-side, so this only removes an unnecessary/early retry attempt. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49 * feat(voice): emit telemetry when narration is deferred or dropped client-side Add voiceNarrationDeferred/voiceNarrationDropped telemetry events (voiceTelemetry.ts) following the existing publicLog2 pattern used elsewhere in voiceSessionController.ts (owner meganrogge, SystemMetaData/ FeatureInsight classification). Only `kind` (response|confirmation) and a `reason` enum are logged - never narration text. Wired into the four client-side branches where a narration is deferred or dropped without ever playing: - _handleNarrationAck: 'invalid' disposition -> dropped (reason: invalid); 'busy' disposition -> deferred (reason: busy) - _handleNarrationInterrupted -> deferred (reason: interrupted) - _retryDeferredNarration: no longer warranted -> dropped (reason: stale); session no longer shown -> dropped (reason: session_changed) No dedicated unit test: voiceSessionController has no unit harness (per task scope, not building a new one). Verified via typecheck/eslint on the touched files and the unaffected voiceClientService.test.ts suite (15/15 passing). Co-authored-by: Copilot App <[email protected]> Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49 * voice: make passive ptt_start the canonical narration-latch fix Extend the passive open-mic flag to the auto-listen path (not just barge-in) so every hands-free turn opened without a deliberate user press sends ptt_start with passive:true. The backend then leaves user_is_speaking clear on those silent turns, so a client-driven narration request is accepted instead of being NACK'd busy: user_speaking and stranded. This supersedes the force-ptt_end workaround from #326378: a passive turn never latches in the first place, so there is no latch to force-clear. Remove that mechanism (_userSpeechActive, _isActivelyDictating, the _finishPtt 'immediate' variant, _prepareForPlayback(endOpenTurn), and canRequestNarration) and restore _narrate to unconditionally prepare for playback on a sent request. Depends on backend passive handling (yolo#56284): must be live in GA before this lands, or silent hands-free turns latch again on the old backend. Adds controller tests: auto-listen opens a passive mic turn; a deliberate press stays non-passive. * voice: preserve a held deliberate press when preparing for narration playback A deliberate (non-passive) ptt_start latches the backend's user_is_speaking, so its narration request is NACK'd busy and deferred. _prepareForPlayback previously aborted any held turn via _finishPtt('auto'), which sends no ptt_end and strands that latch (the later physical release no-ops because _pttHeld is already false). Track the current turn's passiveness and skip the abort for a held deliberate press, leaving its natural release to send ptt_end and clear the guard. Passive open-mic turns (auto-listen / barge-in), which never latch, are still torn down to free the mic for narration audio. * voice: document the drain-flush ordering that keeps ptt_end correct without a turn_id * voice: don't play buffered narration over a held deliberate press When a deliberate (non-passive) press is held, its natural release drives the narration_unblocked retry, so the playback slot must not be torn down under it (that sends no ptt_end and strands the backend latch). Three changes keep a held press intact without dropping or duplicating its buffered reply: - _flushDeferredResponse peeks the slot via _prepareForPlayback() (now returns a boolean) and only deletes/enqueues the buffered chunks once the slot is actually free; a held deliberate press leaves the buffer intact and reports `retained` plus the buffered reply's transcript. Passive open-mic turns (which never latched) are still torn down. - _activateShownSession skips a fresh narration only for the SAME reply the retained buffer will replay on release (matched by normalized transcript); otherwise it would double up with that buffer. An unrelated confirmation or a newer, different response for the session still narrates, because a stale buffered response can outlive its turn (thinking clears _deferredNarrations, not _deferredResponses). The pending indicator stays until the buffer plays. - Clear _pttCurrentTurnPassive when a passive barge-in listen is promoted to a deliberate press, so playback prep preserves the promoted press. --------- Co-authored-by: Arthur Cnops <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: Arthur Cnops <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
In hands-free voice mode, a confirmation (or completed response) is sometimes never read aloud. Trace shows:
…and no
narration_unblockedever follows, so the narration is stranded.Root cause
On connect (and for barge-in), the controller opens a passive auto-listen mic turn —
ptt_startis sent and the turn is left open with noptt_end. The backend latchesuser_is_speakingonptt_start, so a client-drivenrequest_narrationissued while that latch is set is NACK'dbusy: user_speakingand deferred, waiting for anarration_unblockednudge.For a silent passive turn that nudge never arrives:
_prepareForPlayback()ran after the request and used_finishPtt('auto')→abortPtt(), which stops the mic locally without emittingptt_end. The backend never learns the turn ended, never clears the latch, and never unblocks — so the confirmation/response is never spoken.Fix
In
_narrate, when the user is not actively dictating, end the open listen turn with a genuineptt_endbefore requesting the narration (the WebSocket preserves send order, so the backend clears the latch and accepts the request immediately). When the user is mid-utterance, leave the turn open and keep the existing busy/defer +narration_unblockedpath so their speech isn't cut off._prepareForPlayback(endOpenTurn)— finishes via_finishPtt('local')(realptt_end) whentrue, else the prior'auto'abort._isActivelyDictating()— true only when the transcript tail is a non-empty partial user turn.IVoiceClientService.canRequestNarration— gates the force-end so a closed-socket path still queues a retry without tearing down a freshly-entered listen on connect.Behavior
Validation
./node_modules/.bin/tsc --noEmit -p src/tsconfig.json(clean)Note: unit tests were not executed (no build output in the isolated worktree).