Skip to content

Voice: client-driven narration via explicit requestNarration API - #325682

Closed
Megan Rogge (meganrogge) wants to merge 43 commits into
mainfrom
megrogge/voice-backend-narrate-api
Closed

Megan Rogge (meganrogge) wants to merge 43 commits into
mainfrom
megrogge/voice-backend-narrate-api

Conversation

@meganrogge

@meganrogge Megan Rogge (meganrogge) commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes https://github.com/microsoft/vscode-internalbacklog/issues/8430

responses.mov

What

Replaces the client-side machinery that tricked the backend into narrating voice replies/confirmations with a single explicit requestNarration API. The client now decides when narration happens; the backend only speaks when asked.

Why

The prior approach inferred narration from session_context state transitions and used a growing pile of workarounds to make the backend narrate the right thing at the right time — two-phase re-narration, reconcilers, renarrate watchdogs, background-idle holding (reporting thinking until focus), and summary-identity dedup. This was fragile: it depended on precise session_context delta timing, raced against eager model reloads, and dropped or double-read replies in several reproducible cases.

How

New API:

requestNarration(codingSessionId: string, kind: 'response' | 'confirmation', text: string): void;

Sends { type: 'request_narration', coding_session_id, kind, text } over the websocket.

The client fires it in exactly two places:

  • Live, when a narratable item lands on the session the user is looking at (_handleNarratableStateChange).
  • On focus, when the user focuses a session whose reply/confirmation arrived in the background (_activateShownSession → _currentNarratable).

A per-session last-narrated-text guard (_lastNarratedText) makes both paths idempotent — a reply already read live is not re-read on refocus — replacing all of the removed dedup/holding logic. The guard is cleared on a new turn (thinking) so a later identical reply still narrates.

Text is passed inline so the backend never depends on the latest session_context delta having arrived first.

Removed

  • _narrateResponseViaTwoPhase, _narrateConfirmationViaTwoPhase, _reconcile*Narration, _armResponseRenarrateWatchdog, _recordCompletionForRenarration
  • _maybeHoldBackgroundIdle (+ the bgHold / forceThinking / _narrationActiveOverride context plumbing)
  • _narratedSummaryById, _unheardResponseSessions, _responseRenarrateWatchdogs, _forceThinkingOnce, and the associated timers/consts

Net: ~486 lines removed.

Backend contract (required for this to work)

This is a coordinated client+backend change. The backend must:

  1. On {type:'request_narration', coding_session_id, kind, text, narration_id}, speak text (phrasing per kind) and echo the audio as audio_response tagged with coding_session_id.
  2. Echo narration_id on every audio_response chunk of that narration stream (the client sends a fresh uuid per request_narration). This lets the client route a response's chunks as one unit — deciding its live-vs-deferred fate once and keeping every chunk on that decision even when responses for different sessions interleave. If the backend can't echo narration_id, sending its own stable per-stream turn_id also works (msg.narration_id ?? msg.turn_id); if neither is present the client falls back to the legacy session-keyed heuristic (a response can be split or misrouted when two streams for the same session overlap).
  3. Stop auto-narrating idle / waiting_for_confirmation transitions inferred from session_context. If it still auto-narrates, replies will be read twice.

Follow-up

The audio-deferral subsystem (_deferredResponses / _shouldDeferResponse / _flushDeferredResponse / _enqueueAudio / _isRenarration) is retained and drives per-response routing for background (unfocused) sessions: their narration is buffered and flushed when the session is focused, keyed by narration_id via _responseRoutes.

Testing

Not runtime-testable until the backend implements request_narration; npm run typecheck-client is clean.

Megan Rogge (meganrogge) and others added 9 commits July 13, 2026 11:30
Deferral keyed off `_getActiveSessionId()`, which prioritizes the sticky
input `_targetSession` over the session the user is actually viewing. In the
floating voice window, browsing a session via `openSession` changes what is
shown but not `_targetSession`, so with target=A while viewing B:

- A's background narration played live over the unrelated shown session B
  ("a different session's response plays in an unrelated session"); and
- B's own reply was deferred with no focus change to ever flush it, leaving
  the controller idle/listening ("listening mode when a pending reply should
  have been read out on focus").

Add `_shownSessionId()` (the viewed session, ignoring `_targetSession`) and
key `_shouldDeferResponse` off it plus `_awaitingReplyForSession` (so the
awaited answer to the user's own utterance still plays live even if they
glanced away). No behavior change in the agents/sessions window: external
mode never sets `_targetSession`, so the resolved shown session is unchanged.

Co-authored-by: Copilot <[email protected]>
Address review: the 5s safety-net flush in _checkSessionStateChanges still
used _getActiveSessionId() (target-priority), so a background session's reply
could be flushed and played over the shown session on the next poll. Flush
_shownSessionId() instead. Also trim the _shownSessionId / _shouldDeferResponse
JSDoc and inline comment to the VS Code one/two-line convention and correct the
"targeted or focused" wording to the new shown-session contract.

Co-authored-by: Copilot <[email protected]>
A new response from a session whose previous response is still playing was
fast-pathed straight into playback. The TTS service holds a single playback
turn, and once the prior response's final chunk scheduled node.stop() at that
response's boundary, the new response's audio was appended into the same buffer
past the stop point and never heard. Track whether the current response has been
finalized and serialize a subsequent same-session response through the audio
queue so it gets a fresh turn.

Co-authored-by: Copilot <[email protected]>
The backend narrates one thing at a time and drops a session's completion
narration when another is in flight, so a reply that completes while its
session is in the background is never sent as audio - nothing to buffer, and
returning to the session finds it silent in listening mode. Track background
completions and, on focus, re-elicit narration via a forced thinking->idle
transition (mirroring the confirmation two-phase). Cleared when the reply's
audio actually arrives (played or deferred), on a new turn, or once re-elicited,
so a reply is never read twice.

Co-authored-by: Copilot <[email protected]>
Responses now re-assert once if their re-narration is preempted by another
session's narration, matching the bulletproof two-mechanism approach used for
confirmations (two-phase transition + preemption recovery).

Co-authored-by: Copilot <[email protected]>
The on-focus re-narration of a backend-dropped reply was gated to
non-external mode, so it never ran in the embedder-driven agents window
where the bug was actually reported. Confirmations run their two-phase
unconditionally in both modes; do the same for responses. The unheard
marker is already populated in both modes and is cleared on audio receipt,
so a genuinely heard reply is never re-narrated.

Co-authored-by: Copilot <[email protected]>
The unheard-reply marker was only set for completions of sessions NOT shown
at debounced-emit time. On a fast switch, a background session's completion
could arrive after the user already switched to it, so it was treated as
'narrates live', never marked, and — when the backend dropped its narration —
silently lost (no pending indicator, no re-narration).

Now mark every idle+summary completion as a candidate unheard reply and clear
the marker the moment its audio is actually heard (tagged, or the active
session's untagged live audio). A reply that narrates live is never re-read;
only a dropped one survives. Add a response re-narrate watchdog (mirroring the
confirmation flush watchdog) so a reply completing on the on-screen session is
re-checked and re-narrated if still unheard, covering the focus/emit ordering
race.

Co-authored-by: Copilot <[email protected]>
…drop

Fix several voice-mode narration reliability bugs on fast session switches,
address Copilot review feedback, and stop a passive backend query from
killing a just-started auto-listen.

- Hold a background completion as `thinking` (summary withheld) until its
  session is viewed, so the backend's first `->idle` sighting happens on
  focus and reliably narrates, instead of being deduped. Applied across all
  three `_buildSessionContext` branches (resident/no-model agent sessions and
  regular chat sessions), so both the agents window and the main window are
  covered.
- Decide "already narrated?" by summary identity (`_narratedSummaryById`,
  recorded when audio is actually heard) rather than the racy recently-read
  timing, so an eager-reload context push that leaks a raw idle+summary can no
  longer drop the on-focus re-narration.
- Route re-narration by the SHOWN session, not the sticky input target: add
  `_narrationActiveOverride` so `_buildSessionContext` marks the viewed session
  active during its two-phase, and gate phase-2 / preemption recovery /
  watchdog on `_shownSessionId()`.
- Serialize same-session responses: queue entries carry a `finalized` flag;
  every first chunk starts a fresh entry and continuation chunks attach only
  to an unfinished entry, so a later response can't be merged past a scheduled
  node.stop() and dropped.
- Share unheard-reply bookkeeping (`_recordCompletionForRenarration`) between
  the coalesced autorun path and `_checkSessionStateChanges`, so completions
  surfaced only by the direct path (remote/unloaded sessions) are recoverable.
- Don't finish PTT / churn voice state for passive backend queries
  (`get_session_info`/`get_session_changes`/`get_session_thread`); dispatching
  them like an action tool was ending auto-listen the instant the backend
  probed the session on connect. Also clear toggle mode in `_finishPtt` so no
  turn-end path leaves a stale toggle that self-kills the next listen.

Co-authored-by: Copilot <[email protected]>
Replace the client-side machinery that tricked the backend into
narrating (two-phase re-narration, reconcilers, renarrate watchdogs,
background-idle holding, and summary-identity dedup) with a single
explicit requestNarration(codingSessionId, kind, text) call. The
client now decides when a reply or confirmation is spoken: live when
an item lands on the shown session, and on focus for an item that
arrived in the background. A per-session last-narrated-text guard makes
both paths idempotent, replacing the removed dedup/holding logic.

Backend contract: on receiving {type:'request_narration',
coding_session_id, kind, text} the backend speaks the given text and
echoes audio tagged with coding_session_id; it must stop auto-narrating
idle / waiting_for_confirmation transitions.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 13, 2026 19:17

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

Replaces inferred voice narration with an explicit client-driven backend request.

Changes:

  • Adds the requestNarration API and WebSocket message.
  • Narrates shown-session responses and confirmations with per-session deduplication.
  • Refines audio queuing, session routing, and passive tool handling.
Show a summary per file
File Description
voiceClientService.ts (common) Defines the narration API contract.
voiceClientService.ts (browser) Sends narration requests over WebSocket.
voiceSessionController.ts Coordinates narration, deduplication, routing, and playback.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Medium

@meganrogge Megan Rogge (meganrogge) added this to the 1.130.0 milestone Jul 13, 2026
Megan Rogge (meganrogge) and others added 3 commits July 13, 2026 15:29
…clear, doc fixes

- requestNarration returns whether it sent; _narrate records the dedup
  entry only on a successful send and retries the shown item on
  session_init, so a narration dropped while the socket was down is no
  longer permanently suppressed.
- Clear the per-session dedup on a real thinking transition before
  coalescing (skipping eager-reload wobble), so a fast idle->thinking->idle
  burst that collapses to net-zero still lets an identical next-turn reply
  narrate.
- Update stale comments that described backend auto-narration via
  session_context; context is now state-tracking only.

Co-authored-by: Copilot <[email protected]>
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) July 13, 2026 19:42
@meganrogge

Copy link
Copy Markdown
Collaborator Author

Copilot resolve the merge conflicts in this pull request

…d-narrate-api

# Conflicts:
#	src/vs/workbench/contrib/chat/browser/voiceClient/voiceSessionController.ts
roblourens
roblourens previously approved these changes Jul 13, 2026
voice: opt out of backend auto-narration (auto_narrate: false)

This client drives narration itself via `requestNarration`, but the voice
backend still auto-narrates session-context state transitions by default
(the opt-out is per-session and defaults on for backward compatibility).
Without opting out, replies would be narrated twice.

Send `auto_narrate: false` on start_session and resume_session so the
backend suppresses its inferred auto-narration and speaks only on explicit
`request_narration`. The flag is sticky per session on the backend, so it
does not need to be repeated on every session_context delta.


Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49

Co-authored-by: Arthur Cnops <[email protected]>
Co-authored-by: Copilot App <[email protected]>

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.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 9
  • Review effort level: Medium

Megan Rogge (meganrogge) and others added 2 commits July 14, 2026 17:32
- Clear the audio queue before closeContext() on fatal disconnect so a
  synchronous onPlaybackStopped doesn't reschedule stale playback.
- Announce fatal disconnect via ARIA alert + localize the messages.
- Centralize _prepareForPlayback in _narrate so every narration path
  (live/on-focus/on-reconnect) exits listening before echoed audio.
- Track solicited narration ids and bypass the legacy re-narration
  content heuristic for them.
- Never treat a first chunk as a continuation of the current playback.
- Prune _pendingResponseSummaries in _pruneSessionCaches.
- Trim requestNarration JSDoc.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
The centralized _prepareForPlayback() in _narrate tore down the
just-entered listening on session_init, because the retry path narrated
whatever _currentNarratable() returned (e.g. a stale prior reply).

- _narrate now prepares playback only once a request is actually sent, so
  a closed-socket/no-op narrate never touches listening state.
- Drive the reconnect retry from real dropped requests
  (_pendingNarrationRetries) instead of _currentNarratable, and replay
  them before entering listening; a normal first connect has none and
  enters listening as before.
- Clear the new narration caches on terminal disconnect.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
roblourens
roblourens previously approved these changes Jul 14, 2026
The solicited-narration-id bypass disabled the content-based
re-narration guard (_isRenarration) for every narration the client
requested. Since _narrate re-fires whenever _lastNarratedText is cleared
by a thinking wobble (eager model reload) or keyed under a different
session id than the focus path recorded, the same reply's audio then
played on every re-trigger instead of being dropped once.

- Revert the _solicitedNarrationIds bypass so _isRenarration again drops
  a reply whose content was just read (audibly exactly-once).
- Clear the pending-response summary/indicator after narrating the shown
  session's reply in _handleNarratableStateChange, mirroring the focus
  path, so a stored summary is never resurfaced and re-read.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
Megan Rogge (meganrogge) and others added 7 commits July 14, 2026 18:02
… handled

- Re-add _solicitedNarrationIds so audio this client explicitly requested via
  requestNarration (responseId === the narration_id we sent) is never dropped by
  _isRenarration as an unsolicited duplicate, even when its transcript matches a
  reply recently read for the session. Fixes 'not read on first focus' where an
  on-focus narration's echoed audio matched _recentlyReadResponse and was dropped
  with no possible retry. Set is bounded and cleared on disconnect.
- _activateShownSession now clears the pending response indicator/summary only
  when the reply was actually handled (flushed from buffer, or a narration
  request was really sent). If the model was still loading or the request could
  not be sent, the durable summary is retained so a later focus/state event can
  retry, instead of discarding the only record of the unread reply.
- _onSessionShown no longer suppresses a duplicate 'shown' event for the same
  session when outstanding work remains (buffered audio, pending response summary,
  or pending confirmation), so an activation that ran before the model/deferred
  buffer was ready can be retried.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
…ng on connect

The pending-work-aware re-activation guard let a duplicate widget 'shown' event
re-activate an already-shown session that still had a pending response summary,
narrating it right after session_init and tearing down the freshly-entered
listening via _prepareForPlayback. Restore the original
key === _lastShownSessionId early-return. The solicited-narration exemption and
handled-only pending clear remain.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
When a session is already rendered/active in the Agents window while focus stays
on the sessions list, clicking its pending-voice indicator changed neither the
widget view-model nor the active-session observable, so the voice controller was
never told to narrate the held reply and nothing played.

- Add IVoiceSessionController.activateSession(resource): a deterministic entry
  that flushes/narrates a session's pending item even when it is already the
  active/shown session (external mode pins _activeSessionShown too so routing
  points there).
- Register _chat.voice.activateSession in the Agents voice bridge, passing the
  resource straight through so it matches the pending-indicator key.
- The sessions list invokes it on session open when hasPendingResponse is set.
- setActiveSessionShown's same-session re-pin branch now re-activates on a pending
  response summary or pending confirmation too, not only a stranded deferred
  buffer, so the autorun-driven path recovers the same cases.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
_reconcileResponseIndicators ran on every poll/autorun and cleared a session's
pending response summary the moment it became active - deleting the buffered
summary before the click/focus activation path narrated it, so the reply
silently disappeared (saw the mic indicator, clicked, nothing played). It
violated the 'clear only after handled' ownership model that _activateShownSession
already enforces.

- Remove _reconcileResponseIndicators and its two call sites (autorun + poll).
- _handleNarratableStateChange clears the shown session's pending response only
  when _narrate actually sent a request or the reply was already narrated
  (de-duped), retaining it on a socket-closed retry.
- _activateShownSession likewise treats an already-narrated reply as handled, so
  the indicator still clears on focus without the reconcile safety net while a
  genuinely undelivered reply (socket closed / model not loaded) is retained.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
…d-narrate-api

# Conflicts:
#	src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.ts
_activateShownSession skipped the stored pending-response summary whenever
_flushDeferredResponse returned flushed=true, and initialized handledResponse
from that same flag. But flushed=true only means some audio was enqueued - it
could be a different, partial, or older response (e.g. the user clicked while a
second reply was still streaming). That bypassed the reliable summary narration
and cleared the indicator, so the (correctly detected) second response was never
heard.

- Fall back to the stored summary unless that exact summary's normalized
  transcript is among flushResult.finalTranscripts (i.e. it was actually played).
- Initialize handledResponse from that same transcript-identity check
  (pendingSummaryFlushed), never from flushResult.flushed, so the indicator is
  cleared only when this session's own reply was really played or narrated.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
Pending-response summaries and the last-narrated dedupe were keyed by exact
string, while deferred audio already bridged the backend coding_session_id vs
UI resource id spaces via _matchDeferredKey. This left "indicator shown, click
does nothing": a summary stored under one id couldn't be found (or cleared)
when a focus/click passed the other.

- Add alias-aware helpers _matchPendingSummaryKey, _getLastNarratedText and
  _clearLastNarratedText (match by _isSameSession like _matchDeferredKey).
- _handleNarratableStateChange: compare shown session with _isSameSession and
  use the alias-aware helpers for dedupe/pending store/clear.
- _activateShownSession: resolve the pending summary via _matchPendingSummaryKey,
  read/clear via that key, and dedupe via _getLastNarratedText; add a diagnostic
  trace of the activation lookup.
- setActiveSessionShown re-pin: match pending summary via _matchPendingSummaryKey.
- _narrate and the autorun thinking-transition clear: alias-aware dedupe.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 58e4568c-e63b-44c0-b6b2-502f388da15b
Megan Rogge (meganrogge) and others added 2 commits July 14, 2026 19:12
…ident

_currentNarratable's Completed branch returned undefined for a non-resident
session with no cached summary (asymmetric with NeedsInput), so a completed
background reply focused after it settled stayed silent - the state-change
path can't help since there's no idle->idle transition. Load the model in that
branch and re-activate the shown session once it resolves so the now-resident
reply narrates directly (guarded by _lastNarratedText against double-reads).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 02c7340-e851-429b-a94b-e5bae931ca4b
…e transition

Responses were only observed as agent-state transitions, but a reply's
last_response_summary frequently arrives AFTER the thinking->idle transition
(or updates while the session stays idle). The model stays idle, so no state
transition fires and _handleNarratableStateChange never sees the completed
reply - it is silently dropped. Confirmations never hit this because they are
also detected as a same-state detail transition; responses had no equivalent.

Track the previous response summary in _prevSessionStates and treat an idle
summary becoming available/changing as its own narratable transition, mirroring
the confirmation detail transition. Thread fromResponseSummary through the
coalescing baseline (_pendingStateChanges) and recognize it as responseSummaryOnly
in _emitPendingStateChanges so a summary-only change isn't discarded as net-zero.
Applied to both the reactive autorun and the direct _checkSessionStateChanges
paths, and to regular chat sessions.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 02c7340-e851-429b-a94b-e5bae931ca4b
…del rehydration

A summary-only idle transition couldn't distinguish a freshly completed run
from an old last_response_summary becoming visible when a dormant model
rehydrates (unload wrote '' then reload exposed the old summary -> looked
like a new reply). Gate the summary-only transition on a per-session
_sessionsAwaitingResponseSummary marker armed only on a genuine
idle/waiting -> thinking transition (not during eager loading/replay) and
consumed once the completion is accepted, and preserve the cached summary
in prev-state instead of clobbering it with ''. Applied to both the autorun
processModel path and the direct _checkSessionStateChanges path (agent +
regular chat), and cleared on disconnect/prune.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 02c7340-e851-429b-a94b-e5bae931ca4b
Megan Rogge (meganrogge) and others added 3 commits July 14, 2026 20:45
…acceptance

_narrate() marked a reply narrated and cleared its pending indicator the moment
requestNarration() returned an id, conflating "request sent" with "reply heard".
If the solicited audio was then dropped, deferred, or never returned, the reply
was lost AND unrecoverable (_lastNarratedText now claimed it was read, so no
retry). This caused the Agents-window second session to show the right mic
indicator yet play nothing on focus.

Track each requested narration by its narration id in _pendingSolicitedNarrations
and only set _lastNarratedText / clear the pending indicator once the final audio
chunk for that id arrives (_markNarrationHeard). A safety timer releases the
in-flight guard if no audio ever comes so a later focus/state event can retry.
_narrate() no longer implies "handled": _activateShownSession and the live
shown-session path now clear the indicator only for an already-narrated reply,
and _narrate de-dupes concurrent in-flight requests for the same text.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 02c7340-e851-429b-a94b-e5bae931ca4b
…erruption

- onPlaybackStopped captures wasInterrupted before reset; marks the reply
  heard only when it actually played through. On interruption, leaves the
  pending summary+indicator intact (retryable) and eagerly drops the in-flight
  solicited-narration guard so re-clicking re-requests immediately.
- Reset _currentPlaybackResponseId at every playback-slot teardown
  (barge-in, disconnect, fatal disconnect, new-turn interrupt,
  _interruptAssistantPlayback) so a stale id can't be consumed by a later stop.
- Remove redundant _deleteDeferredResponsesForSession helper.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 02c7340-e851-429b-a94b-e5bae931ca4b
Replace the alias-aware-lookup/alias-unaware-cleanup pattern with one canonical
session key (_sessionKey = UI agent-host resource when known, else the id).
Every per-session collection is keyed by it, and _recordSessionAlias now re-keys
existing entries bare->UI on alias discovery so the two id spaces never diverge.
This deletes the _hasAliasedKey / _setPendingIndicatorForAliases /
_matchPendingSummaryKey iteration helpers and the alias-scanning branches of
_matchDeferredKey / _get/_clearLastNarratedText / _clear*Indicator /
_maybeHideIndicator / _reconcileConfirmationIndicators, so indicator ownership
is now plain O(1) map/set lookups that can't strand state under the other id.

Also fix a confirmation regression: persistent text dedup (_lastNarratedText)
and the pending indicator now apply to RESPONSES only. A confirmation is
transient actionable state - two tools can raise identical prompts - so it must
stay re-narratable; the in-flight dedup is now kind-aware too.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 02c7340-e851-429b-a94b-e5bae931ca4b
…5928)

requestNarration only checked that the socket was OPEN, so a focus- or
state-driven narration could be sent in the window between the WebSocket
opening and start_session/resume_session being sent. The backend drops a
request_narration that arrives before the session exists, but the client
still gets a narration id back and treats the audio as inbound: it tears
down listening via _prepareForPlayback, records a solicited narration id,
and arms a safety timer for audio that never comes. The narration is not
queued for replay, so it is lost until the next focus/state event.

Track whether start_session/resume_session (which carries session_context)
has been sent on the current connection and gate requestNarration on it.
The WebSocket preserves send order, so this guarantees the backend has the
session before it sees a narration request. Pre-session, requestNarration
now returns undefined, so _narrate queues the item in
_pendingNarrationRetries and onSessionInit replays it once the session
exists.


Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49

Co-authored-by: Arthur Cnops <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@meganrogge

Copy link
Copy Markdown
Collaborator Author

This does not fix it, thus closing.

@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants