Preserve explicit local chat editor sessions#324669
Merged
anthonykim1 merged 1 commit intoJul 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression (issue #324648) where switching from Copilot Agent Host to Local in the editor chat picker would flicker back to Copilot. Because local editor sessions open with a generic vscode-chat-editor resource, the editor input could not distinguish an explicit "Local" pick from a normal new-editor open, so last-used/default-provider resolution (reintroduced in #323914) would override the user's choice. The PR threads an explicit-intent signal through the editor options to preserve the Local selection.
Changes:
- Add
explicitSessionType?: stringtoIChatEditorOptionsand set it tolocalChatSessionTypeinopenChatSessiononly when the user picks Local for an editor session. - Make
ChatEditorInput.resolve()honor an explicit Local choice before last-used/default-provider resolution, and makeshouldReplaceEmptyLocalSession()skip replacing a session explicitly opened as Local. - Add unit tests covering a fresh explicit-Local session and preservation of an already-resolved empty Local session.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditor.ts |
Adds the explicitSessionType option to IChatEditorOptions with documentation of its narrow local-preservation purpose. |
src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditorInput.ts |
Prioritizes explicit Local in resolve() and prevents empty-local-session replacement when Local was explicitly chosen. |
src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts |
Sets explicitSessionType: localChatSessionType when opening a Local editor session from the picker. |
src/vs/workbench/contrib/chat/test/browser/widgetHosts/editor/chatEditorInput.test.ts |
New tests validating explicit-Local start and empty-local-session preservation. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Medium
bhavyaus
approved these changes
Jul 7, 2026
bhavyaus
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Tagging @DonJayamanne @benvillalobos also
DonJayamanne
approved these changes
Jul 7, 2026
justschen
approved these changes
Jul 7, 2026
This was referenced Jul 7, 2026
benvillalobos
added a commit
that referenced
this pull request
Jul 7, 2026
benvillalobos
added a commit
that referenced
this pull request
Jul 7, 2026
This reverts commit d97c4e5.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves: #324648
Mirror main: #324672
Regressed by: #323914
explicitSessionType?: stringtoIChatEditorOptionsso callers can preserve an explicit session picker choice when opening a new chat editor.explicitSessionType: localChatSessionTypeinopenChatSessiononly when the user picks Local for an editor session.ChatEditorInput.resolve()honor explicit Local before applying last-used-agent/default-provider resolution, so switching from Copilot AH to Local starts a local session instead of resolving back to Copilot.shouldReplaceEmptyLocalSession()skip replacing an empty session that was explicitly opened as Local, so it is not swapped back to the default provider on a later resolve.Regression history:
34a9b07).b802a62), and the removal was also cherry-picked torelease/1.127as Remove last-used session type and agent logic #323555.vscode-chat-editorresource, so the editor input could not distinguish "the user explicitly picked Local" from "open a normal new chat editor." This PR preserves that explicit Local intent.Evidence:
ChatWidgetService:recordLastUsedSessionType, called fromsetLastFocusedWidgetand the view-model change listener. NoterecordLastUsedSessionTypeintentionally never storeslocal, so an explicit Local picker choice needs a separate signal to bypass last-used non-local resolution.ChatEditorInput.resolve()back to readingChatLastUsedEditorSessionTypeStorageKeyand callinggetNewChatEditorSessionResource(...):chatEditorInput.ts#L236-L237.getNewChatEditorSessionType(...)prefers that last-used non-local session type whenchat.editor.defaultProvideris not explicitly configured:constants.ts#L319-L324.explicitSessionTypefromopenChatSessionand checking it before the last-used/default-provider path inChatEditorInput.resolve().Inspirations from:
explicitSessionTypebranching inresolve()follows the existingoptions.targethandling in the same method:ChatEditorInput.resolve().shouldReplaceEmptyLocalSession()guard extends the existing predicate rather than adding a new code path:shouldReplaceEmptyLocalSession.Validation:
git diff --checkclean.npm run typecheck-clientfails on unrelatedsrc/vs/workbench/api/node/proxyResolver.ts(115,52)/resolveProxyByURL, which is outside this PR's touched files.chatEditorInput.test.ts: explicit Local resolves to a fresh local session without consulting the default/last-used path, and an empty explicitly-Local session is preserved instead of replaced.Manual test:
chat.editor.defaultProviderset to a non-local provider -> explicit Local still sticks, including after a window reload with the empty session open./cc @benvillalobos