Repository navigation
voice: honor the new_session flag on send_to_chat - #330859
Merged
Megan Rogge (meganrogge) merged 3 commits intoAug 14, 2026
Merged
Megan Rogge (meganrogge) merged 3 commits into
Megan Rogge (meganrogge) merged 3 commits into
Conversation
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
`newSessionAsTarget()` disposed the only model reference immediately, and `ChatService` deletes empty untitled local sessions once their last reference goes away (`willDisposeModel`). Disposal is deferred behind an await, so a chat pane re-acquiring the model usually revived it in time — but when `_chat.voice.switchToSession` is unavailable or fails, nothing re-acquires. For `send_to_chat(new_session=true)` with empty text there is no send path to reacquire either, so the session was deleted and `_targetSession` was left pointing at a resource that no longer exists, silently losing a bare "start a new session". Retain the reference in a `MutableDisposable` and release it only once the switch reports a host has adopted the session, when voice retargets elsewhere, when another new session replaces it, or on disposal. Holding it slightly longer than necessary is harmless; releasing it early is the bug. Cover both directions with a chat service fake that refcounts references and drops the session at zero, mirroring `willDisposeModel`, plus a test that seeds `_pinnedSubmitSession` so the pin-clearing order in the `send_to_chat` branch is actually exercised. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Honors send_to_chat.new_session while preserving newly created sessions until adopted.
Changes:
- Routes explicit new-session requests to a fresh chat session.
- Retains new session model references during adoption.
- Removes the unreachable
new_sessionsdispatch handler and adds tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
voiceSessionController.ts |
Handles new-session routing and reference lifecycle. |
voiceToolDispatchService.ts |
Removes obsolete new_sessions support. |
voiceSessionController.test.ts |
Tests routing, pin precedence, and lifecycle behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Ensure explicit new-session sends bypass focused Omni and centralize target mutations so retained model references are released on retarget and disconnect. Co-authored-by: Copilot <[email protected]> Copilot-Session: 8758b568-a297-46b1-a605-b85a60efac1f
Collaborator
|
Addressed all review findings in 25597d8:
Validation: 184 targeted voice controller tests pass; ESLint is clean on both changed files. |
Megan Rogge (meganrogge)
enabled auto-merge (squash)
August 14, 2026 16:13
Megan Rogge (meganrogge)
approved these changes
Aug 14, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 14, 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.
Problem
The voice backend advertises a
new_sessionboolean on thesend_to_chattool and sets it when the user explicitly asks for a fresh session ("start a new session and refactor the upload service"). The controller'ssend_to_chatbranch never read the flag, so those requests were submitted into the current session instead.Separately,
voiceToolDispatchServicestill carried anew_sessionshandler. It is not in the controller'sallowedToolslist, so the backend can never reach it.Solution
Read
new_sessionin the controller'ssend_to_chatbranch. When set, clear any pinned submit session and then create and target a new one. Pin clearing has to come first:_sendTranscriptionToChatresolves its target as_consumePinnedSubmitSession() ?? _targetSession, so a pin left by an earlier focus change would otherwise outrank the session just created.Empty
textwithnew_session: truecreates and focuses a session without sending, which is what the backend emits for a bare "start a new session".This lives in the controller rather than the dispatch service on purpose:
send_to_chatis routed through the controller so it honors_targetSession, the workbench chat commands, stop-phrase stripping and send suppression. The oldnew_sessionshandler bypassed all of them, so it and its action label are removed.Keeping the new session alive
newSessionAsTarget()previously disposed its only model reference synchronously and then firedswitchToSession.ChatModelStore.destroyReferencedObjectis asynchronous - it marks the key pending, awaitswillDisposeModel, then disposes - andcreateReferencedObjectcancels that via_modelsToDispose.delete(key). So the old code survived by racing: the pane re-acquired the model before the await resolved.It does not survive when nothing re-acquires.
willDisposeModeldeletes empty untitled local sessions with no custom title, so ifswitchToSessionis unavailable or fails, the model is disposed, the session row is deleted, and_targetSessionpoints at a URI that no longer exists. For the text form_sendTranscriptionToChatre-acquires viaacquireOrLoadSession; for the empty-text form there is no send path at all, so the bare "start a new session" is silently lost.The reference is now retained in a
MutableDisposableand released only onceswitchToSessionconfirms a host adopted the session, on retarget, on replacement, or on controller disposal. It errs toward holding: too long is a bounded cost, too early is the bug.Test plan
ESLint clean on the touched files;
tsc --noEmit -p src/tsconfig.jsonreports 0 errors.Both new tests were mutation-checked rather than trusted green:
ref.dispose()fails the lifecycle test withtargetStillExists: false_consumePinnedSubmitSession()line fails the pin test, sending to the pinned URI instead of the new oneThe lifecycle test uses a refcounting fake that drops the session at zero, mirroring
willDisposeModel, rather than a shallow mock.Risks
newSessionAsTarget()now holds a reference, so its other callers keep the created session alive longer. That is the intended fix - it is what stops the session being deleted underneath them too - andMutableDisposablemeans at most one is retained at a time.Removing
new_sessionsis a behavior change only if something outsideallowedToolswas dispatching it. Nothing in the tree references the name after this change.Non-goals
Model selection and file attachment are out of scope.
No structured verdict is added for
send_to_chat. The controller answers everysend_to_chatfrom a sharedsendPromise.finally(() => sendToolResult(callId, 'ok')), so changing it to report failure is an all-calls contract change with its own blast radius across every voice tool. This PR leaves that.finally()untouched, so the verdict can be threaded through the same place later. Noting it as a known owed follow-up: #329490's "tool failures cause an honest failure response" criterion is not fully closed by this PR alone.Supersedes #330682 by Arthur Cnops (@accnops) (re-opened from a fork we can push to). Original commit authorship preserved.