Skip to content

voice: honor the new_session flag on send_to_chat - #330682

Closed
Arthur Cnops (accnops) wants to merge 1 commit into
microsoft:mainfrom
accnops:arthurcnops/voice-new-session-flag
Closed

Arthur Cnops (accnops) wants to merge 1 commit into
microsoft:mainfrom
accnops:arthurcnops/voice-new-session-flag

Conversation

@accnops

Copy link
Copy Markdown
Contributor

Problem

The voice backend advertises a new_session boolean on the send_to_chat tool and sets it when the user explicitly asks for a fresh session ("start a new session and refactor the upload service"). The controller's send_to_chat branch never read the flag, so those requests were submitted into the current session instead.

Separately, voiceToolDispatchService still carried a new_sessions handler. It is not in the controller's allowedTools list, so the backend can never reach it.

Solution

Read new_session in the controller's send_to_chat branch. When set, clear any pinned submit session and then create and target a new one. Pin clearing has to come first: _sendTranscriptionToChat resolves its target as _consumePinnedSubmitSession() ?? _targetSession, so a pin left by an earlier focus change would otherwise outrank the session just created.

Empty text with new_session: true creates and focuses a session without sending, which is what the backend emits for a bare "start a new session". The existing text.trim() ? … : Promise.resolve() guard already handles that, so no extra branch is needed.

This lives in the controller rather than the dispatch service on purpose: send_to_chat is routed through the controller so it honors _targetSession, the workbench chat commands, stop-phrase stripping and send suppression. The old new_sessions handler bypassed all of them, which is the second half of this change - it and its action label are removed.

Test plan

Three tests added to voiceSessionController.test.ts, covering new_session with text, new_session with empty text, and the unchanged default path:

node test/unit/browser/index.js --browser chromium \
  --run src/vs/workbench/contrib/chat/test/browser/voiceClient/voiceSessionController.test.ts
# 121 passing

node test/unit/browser/index.js --browser chromium \
  --run src/vs/workbench/contrib/chat/test/browser/voiceClient/voiceToolDispatchService.test.ts
# 27 passing

ESLint clean on the three touched files. tsc --noEmit -p src/tsconfig.json reports no errors in voice files.

Risks

newSessionAsTarget() is existing code; this change only calls it from a new place. The default send_to_chat path is unchanged and covered by the third test.

Removing new_sessions is a behavior change only if something outside allowedTools was dispatching it. Nothing in the tree references the name after this change.

Non-goals

Model selection and file attachment are out of scope. focus_session already returns a structured result and retargets on main; no change needed there.

The voice backend advertises a `new_session` boolean on `send_to_chat` and
sets it when the user explicitly asks for a fresh session, but the controller
never read it, so those requests landed in the current session.

Read the flag in the `send_to_chat` branch: clear any pinned submit session
(an explicit "new session" outranks a pin left by a focus change), then create
and target a new session. An empty `text` creates and focuses without sending,
which is what the backend emits for a bare "start a new session".

Also drop the `new_sessions` dispatch handler and its action label. It is not
in the controller's allowedTools list, so it is unreachable, and it bypassed
the target session, stop-phrase stripping and send suppression that
`send_to_chat` goes through.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c568e3e0-eabb-48db-84a4-a7976df7c474
Copilot AI balanced review requested due to automatic review settings August 13, 2026 16:35

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

Honors voice send_to_chat.new_session requests and removes the unreachable legacy handler.

Changes:

  • Creates and targets a fresh session when requested.
  • Removes obsolete new_sessions dispatch logic.
  • Adds coverage for new, empty, and default session routing.

Reviewed changes

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

File Description
voiceSessionController.ts Handles new_session routing.
voiceToolDispatchService.ts Removes legacy handler and label.
voiceSessionController.test.ts Tests session-routing behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

// outranks a pin left by a focus change, which would
// otherwise win in _sendTranscriptionToChat.
this._consumePinnedSubmitSession();
this.newSessionAsTarget();
// Clear the pin first: an explicit "start a new session"
// outranks a pin left by a focus change, which would
// otherwise win in _sendTranscriptionToChat.
this._consumePinnedSubmitSession();
@meganrogge

Copy link
Copy Markdown
Collaborator

Superseded by #330859, which preserves the original authorship and includes the session-lifecycle, focused-Omni routing, URI comparison, and cleanup fixes from review.

@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 21, 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.

4 participants