Repository navigation
voice: send request_narration only after session context is sent - #325928
Merged
Megan Rogge (meganrogge) merged 1 commit intoJul 15, 2026
Conversation
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. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 803dc35b-1aee-4354-85c7-df6076293a49
Megan Rogge (meganrogge)
approved these changes
Jul 15, 2026
Megan Rogge (meganrogge)
marked this pull request as ready for review
July 15, 2026 12:58
Megan Rogge (meganrogge)
merged commit Jul 15, 2026
7b02243
into
microsoft:megrogge/voice-backend-narrate-api
7 of 9 checks passed
This was referenced Jul 15, 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 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.
Stacked on #325682 (base =
megrogge/voice-backend-narrate-api), follow-up to the auto-narrate opt-out from #325799.Problem
requestNarrationonly checks that the socket isOPEN. A focus- or state-driven narration can therefore be sent in the window between the WebSocket opening andstart_session/resume_sessionbeing sent. The backend drops arequest_narrationthat 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 arrives. The narration is not queued for replay, so it is lost until the next focus/state event.Solution
Track whether
start_session/resume_session(which carriessession_context) has been sent on the current connection (_sessionContextSent, reset per connection inonopen, set after each send) and gaterequestNarrationon it. The WebSocket preserves send order, so this guarantees the backend has processed the session before it sees a narration request. Pre-session,requestNarrationnow returnsundefined, so_narratequeues the item in_pendingNarrationRetriesandonSessionInitreplays it once the session exists — reusing the existing retry path.Tests
None. This file has no existing unit tests and the change is a small ordering guard on the WS send path; adding a WebSocket-mocking harness for it is out of scope for this follow-up. Verified by tracing the client/backend ordering and the
_narrate/onSessionInitreplay interaction.Risks
Low. Behavior only changes in the pre-session-init window: narration is deferred to
session_initreplay instead of being sent-then-dropped. Steady-state narration is unaffected (_sessionContextSentis true once the session is established).Non-goals
No backend changes; no change to the narration payload or the
auto_narrateopt-out.