fix(chat): route mode switches to the originating pane when widgets share a session (#275200)#310970
Open
maruthang wants to merge 2 commits into
Open
fix(chat): route mode switches to the originating pane when widgets share a session (#275200)#310970maruthang wants to merge 2 commits into
maruthang wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a chat mode-routing bug (#275200): when two chat widgets share a session (e.g. a chat-view pane and a chat-editor pane after "Move Chat to Editor Area"), changing the mode in one widget's picker incorrectly changed the mode of the first-registered widget. The fix threads the hosting widget's unique inputUri from the picker delegate into the ToggleAgentModeActionId command args so the action resolves the exact widget via getWidgetByInputUri, preserving the sessionResource path as a fallback for older callers.
Changes:
- Added an optional
inputUritoIToggleChatModeArgsand reorderedToggleChatModeActionresolution to prefer input URI, then session resource, then editing-session context. - Added
inputUritoIModePickerDelegate, wired it throughModePickerActionItem.run, and supplied it fromChatInputPart. - Added two unit tests covering the multi-widget disambiguation and the
sessionResourceback-compat fallback.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts |
Adds inputUri to IToggleChatModeArgs and prefers input-URI resolution with session-resource/editing-context fallbacks. |
src/vs/workbench/contrib/chat/browser/widget/input/modePickerActionItem.ts |
Adds optional inputUri to the delegate and forwards it in the ToggleAgentModeActionId command call. |
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts |
Supplies the widget's unique inputUri to the mode picker delegate. |
src/vs/workbench/contrib/chat/test/browser/actions/chatExecuteActions.test.ts |
Adds a ToggleChatModeAction suite verifying inputUri-based targeting and sessionResource fallback. |
Collaborator
|
thanks! will give this a look! |
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.
What — When two chat widgets share a session (e.g. a chat-view pane and a chat-editor pane after "Move Chat to Editor Area"), changing the mode in one no longer silently flips the mode in the other.
Why —
ToggleChatModeActionresolved the target widget viagetWidgetBySessionResource(...), which returns the first match. With two widgets on the same session, the mode change always landed on whichever registered first — not the one whose picker was clicked (#275200).How — Each
ChatInputParthas a uniqueinputUri, andIChatWidgetService.getWidgetByInputUrialready disambiguates by it. ThreadedinputUrithroughIModePickerDelegate→ModePickerActionItem.run→IToggleChatModeArgsso the action can resolve the exact widget. The existingsessionResourcepath is preserved as a fallback for older callers.Test plan — Two new unit tests in
chatExecuteActions.test.ts: (1) with two widgets sharing a session, a toggle dispatched withinputUritargets widget B not widget A; (2) withoutinputUri, the existingsessionResourceresolution still works. Manual: open a chat session, "Move Chat to Editor Area", pick a different mode in the editor's picker — the panel mode should stay unchanged.Fixes #275200