Skip to content

Voice: queue concurrent question forms instead of swapping them - #328205

Merged
Megan Rogge (meganrogge) merged 4 commits into
microsoft:mainfrom
accnops:arthurcnops/voice-concurrent-questionnaires
Jul 30, 2026
Merged

Megan Rogge (meganrogge) merged 4 commits into
microsoft:mainfrom
accnops:arthurcnops/voice-concurrent-questionnaires

Conversation

@accnops

@accnops Arthur Cnops (accnops) commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Follow-on to #327899, which made a spoken answer land on the right question form. That fix assumed one form at a time; with two pending in the same session it picks the wrong one.

The bug

Two functions independently decide which pending part voice is working on, and both took the last match: _getAgentStateInfo (the spoken agent_state_detail) and _buildPendingPayload (the structured pending an answer is resolved against). A second form arriving silently stole focus, so the user mid-answer on form A had their next utterance resolved against form B.

Fixing only the payload would be worse than the bug: _getAgentStateInfo would still hold the newest, its changed detail alone satisfies isDetailTransition, and the narration it triggers reads the payload and gets A. Questions aren't text-deduped, so form A would be re-read aloud every time B arrived. Both callers have to agree.

The fix

One _selectPendingPart, used by both, scanning oldest-first and returning the first still-open part. A form holds focus until it resolves; a second form waits its turn. This also matches the platform — chatModel._pendingInfo scans forward and its value already feeds the fallback _getAgentStateInfo uses. Newest-first was the deviation.

Split so the two callers can't drift again: _selectPendingPart (which part), _isOpenPendingPart (still open, per kind), _describePendingPart (the prose, lifted verbatim).

Also here

Send each session's label. The backend renders [SESSIONS] for its routing model and refuses to guess between waiting sessions — but every entry we sent was anonymous, so two concurrent forms arrived as two identical lines.

Drop active_session. The only place that would assign it is an empty try {} catch {}, so it has always been undefined and the delta never carried the field — removal is provably behaviour-preserving. The per-entry is_active flag names the focused session.

Verification

VoiceSessionController + VoiceClientService: 73 passing, 11 new — oldest-first selection, moving on once a form resolves, an executing tool not shadowing the form it opened, an older form surviving a newer arrival, payload and spoken detail agreeing, a newer form answered by mouse leaving focus untouched, and the session labels. Compile is clean in contrib/chat (the 90 total errors are pre-existing on main, in platform/agentHost, localTranscription and native).

Draft until the companion backend change lands and the two-form case has been driven end to end by voice.

Arthur Cnops and others added 2 commits July 30, 2026 13:43
Two forms can be pending on one request at once - askQuestions can open one
while an MCP elicitation attaches another outside the agent loop. Voice is a
serial channel, but both functions that decide which form is "current" picked
the newest one independently, so a form arriving silently retargeted the answer
the user was in the middle of giving, and dropped the first form's draft.

Both now go through one selector that returns the oldest still-open actionable
part, which is what the chat model itself does in _pendingInfo. Resolved parts
are already skipped, so the oldest open part is by construction the one voice
already published: the queue needs no stored state, and payload/detail
disagreement becomes unrepresentable.

Fixing only the payload would be worse than the bug: the detail would still
flip to the new form, isDetailTransition would fire on the detail alone, and
the narration path would read the OLD form aloud again.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1c4672e9-182f-4a2f-8a79-bd8b770961a1
The backend renders [SESSIONS] for the model and its prompt says "Do NOT
guess" when several sessions are waiting — but every entry we sent was
anonymous, so two concurrent question forms arrived as two identical lines
and there was nothing to disambiguate on. Send the label that already exists
on both session kinds: `label` for agent sessions, `title` for plain chats.

Drop `active_session` while here. It was declared on the wire type and
diffed on every context send, but the only place that would have assigned it
was an empty try/catch, so it has always been undefined: `activeChanged` was
permanently false and the delta never carried the field. The per-entry
`is_active` flag is what actually names the focused session.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1c4672e9-182f-4a2f-8a79-bd8b770961a1
Copilot AI review requested due to automatic review settings July 30, 2026 11:51

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

Queues concurrent voice question forms oldest-first and adds session labels for backend routing.

Changes:

  • Shares pending-part selection between narration and answer routing.
  • Adds session labels to voice context.
  • Removes unused active_session handling and adds queue regression tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
voiceSessionController.ts Implements queue selection and session labels.
voiceClientService.ts (common) Updates the wire context type.
voiceClientService.ts (browser) Removes unused active-session delta state.
voiceSessionController.test.ts Tests concurrent pending-part behavior.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@meganrogge
Megan Rogge (meganrogge) marked this pull request as ready for review July 30, 2026 14:03
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) July 30, 2026 14:03
The label is the only human-readable handle the backend has for a session,
so without it two waiting forms cannot be told apart by name. It was
emitted from two branches with no test on either; a refactor could have
made sessions anonymous again silently.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1c4672e9-182f-4a2f-8a79-bd8b770961a1
auto-merge was automatically disabled July 30, 2026 15:49

Head branch was pushed to by a user without write access

@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) July 30, 2026 18:18
@meganrogge
Megan Rogge (meganrogge) merged commit ecb3779 into microsoft:main Jul 30, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 13, 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.

5 participants