Repository navigation
Fixes #347106: keep Cmd/Ctrl+B, Cmd/Ctrl+O, Cmd/Ctrl+Shift+E and Ctrl+Shift+G in the chat window that has focus - #347613
Merged
Sandeep Somavarapu (sandy081) merged 6 commits intoNov 11, 2026
Conversation
… has focus In a chat window, Cmd/Ctrl+B toggled the main window's side bar and Cmd/Ctrl+O (New Session in Folder...) started the new session in the main window. - Cmd/Ctrl+B: #346039 made the Agents window's Toggle Side Bar not apply in chat windows, but VS Code's generic Toggle Primary Side Bar Visibility, also loaded in the Agents window, still claimed the key there and toggled the main layout. It no longer applies in windows with layout modes either, so the key does nothing in a chat window, which has no side bar of its own. - Cmd/Ctrl+O: the command now resolves the chat window it runs in and opens the new session there as Cmd/Ctrl+N does, aimed at the picked folder, through a new provider-neutral `folder` option of IChatWindowService.openNewChat. An unsent new session that is active there is aimed at the folder instead. The main window is unchanged. Fixes #347106 Co-authored-by: Copilot <[email protected]>
New Session in Folder in a chat window re-aimed an unsent active composer by changing only what it requested, which its mounted composer does not follow: it kept its draft in the previous folder. A picked folder now always opens a new composer, which creates its draft through the composer's own path, including its trust gate. It replaces the active composer when closing it loses nothing (no input and no request under way); otherwise it opens as a tab of it. The composer also starts with the session type of the provider that resolved the folder, so that this provider creates its draft, as a new session in a folder of a provider starts in the main window. Co-authored-by: Copilot <[email protected]>
… opened A composer that New Session in Folder replaces in a chat window was checked for losing nothing only before the new composer opened, which is awaited: input typed into it, or a request it sent, meanwhile was lost as it closed. It is now checked again before it closes. A composer opened for a folder from a composer that has not sent its session also joins the custom group of the sessions list that composer's sessions join; its draft is not in a group yet. Co-authored-by: Copilot <[email protected]>
Federico Brancasi (federicobrancasi)
previously approved these changes
Nov 11, 2026
Contributor
|
Base:
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change keeping chat shortcuts scoped to the invoking Agents window.
No open issues 🎉
What changed in this PR
Fixes #347106 by keeping Cmd/Ctrl+B and Cmd/Ctrl+O scoped to the invoking Agents chat window, without changing main-window behavior.
Changes:
- Prevents the shared sidebar shortcut from applying in chat windows.
- Routes folder-based new sessions into the invoking chat window, preserving provider and custom-group context while protecting existing input and pending sends.
- Adds regression tests for shortcut resolution, window targeting, and composer replacement.
No actionable findings. The PR reports passing validation; tests were not rerun here.
| File | Description |
|---|---|
src/vs/workbench/contrib/chatWindow/browser/chatWindow.ts |
Adds provider-neutral folder options for new chats. |
src/vs/workbench/browser/actions/layoutActions.ts |
Excludes layout-mode windows from the sidebar shortcut. |
src/vs/sessions/test/browser/layoutActions.test.ts |
Tests sidebar shortcut resolution across platforms and window contexts. |
src/vs/sessions/contrib/chatWindow/test/browser/sessionsChatWindowProvider.test.ts |
Tests folder targeting, safe composer replacement, and group inheritance. |
src/vs/sessions/contrib/chatWindow/browser/sessionsChatWindowProvider.ts |
Creates folder-targeted composers and replaces only pristine ones. |
src/vs/sessions/contrib/chatWindow/browser/chatWindowComposer.ts |
Exposes a pristine-state check covering input and foreground requests. |
src/vs/sessions/contrib/chat/test/browser/newSessionFolderQuickPickAction.test.ts |
Tests chat-window and main-window command routing. |
src/vs/sessions/contrib/chat/browser/newSessionFolderQuickPickAction.ts |
Captures the invoking window and opens the selected folder there. |
Review effort: Balanced
…w with a new session In a chat window whose active chat is a new-session composer, Cmd/Ctrl+Shift+E opened the Files view in the main window's auxiliary bar rather than a Files tab in the chat window; Changes did the same. - The keys of a host's session took the workspace of the chat it shows only, so while a composer shows no chat yet, its session counted as one without a workspace, although its draft has a folder, and the chat window's Files and Changes keys did not apply. The workspace is now the session's while the host shows no chat of it. - Where those keys did not apply, the open commands of the Files and Changes view containers claimed them and opened the main window's auxiliary bar. The keys of a view container's open command no longer apply in a window with layout modes, whose parts are not the main window's. Their commands, as in the Command Palette, are unchanged. Fixes #347106 Co-authored-by: Copilot <[email protected]>
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
Resolves the import conflict in sessionsChatWindowProvider.ts: #347609 moved getChatWindowMainPartOptions into chatWindow.ts, and this branch imports IChatWindowNewChatFolder from it; the provider imports both. Co-authored-by: Copilot <[email protected]>
Alex Ross (alexr00)
approved these changes
Nov 11, 2026
Picks up #347655 (cached Linux packages in PR checks) for the PR checks; no conflicts. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
deleted the
agents/fix-347106-chat-window-keybindings
branch
November 11, 2026 18:23
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.
Fixes #347106
In a chat window of the Agents window, Cmd/Ctrl+B toggled the main window's side bar, and Cmd/Ctrl+O (New Session in Folder...) showed its folder pick in the chat window but started the new session in the main window. With a new session (an unsent composer) active in a chat window, Cmd/Ctrl+Shift+E (Files) and Ctrl+Shift+G (Changes) opened the Files or Changes view in the main window's auxiliary bar instead of a tab in the chat window.
Reproduction
Agents window with a sent chat moved into a chat window (Open in New Window), with the chat window focused.
Before:
After:
Root cause
LayoutModeContext.negate()precondition so that its key would not apply in chat windows. VS Code's own Toggle Primary Side Bar Visibility (workbench.action.toggleSidebarVisibility) is also loaded in the Agents window, through the editor and part contributions, and binds the same key with no precondition. With the Agents rule out of the way, it took the key and toggled the main layout. The test of that change checked the command id, not how the key resolves.ISessionsService.openNewSession, which targets the main window. Agents window: start a new session in a chat window #346678 made Cmd+N start a new session in the chat window it runs in, but not this command.Fix
workbench.action.toggleSidebarVisibilityno longer applies in a window with layout modes (LayoutModeContext.negate(), as the Agents window's toggle and the terminal's Move to Panel do). In VS Code, whereLayoutModeContextis unset, nothing changes.resolveChatWindow, as Cmd+N does) and opens the new session there throughIChatWindowService.openNewChat, with a new, provider-neutralfolderoption ({ uri, providerId? }). Elsewhere it does what it did.openNewSessionwith a provider that is not available fails without a draft.Cmd/Ctrl+Shift+E and Ctrl+Shift+G with a new session in a chat window
Before: with an unsent composer active in a chat window, Cmd+Shift+E opened the Files view in the main window's auxiliary bar; with a sent chat active it opened a Files tab in the chat window. Changes (Ctrl+Shift+G) behaved the same.
Root cause:
SessionWithWorkspaceContext).setHostSessionContextKeystook that workspace from the chat the host shows only. A composer shows no chat until its session is created, in its chat editor and in its chat window's host, so its session counted as one without a workspace, although its draft has a folder.ViewsServiceregisters with the same keys, claimed them and opened the main window's auxiliary bar. A quick chat in a chat window, sent or not, has no workspace, so its keys did the same.Fix:
setHostSessionContextKeys: the workspace is that of the chat the host shows, or that of the session while it shows no chat of it, such as a composer's draft. A chat without a workspace still counts as one. The callers that pass a session without a chat are the composer's chat editor and the chat window's host; the main window's grid and the automations dialog always pass a chat.ViewsService: the keybinding of a view container's open command no longer applies in a window with layout modes (LayoutModeContext.negate()added to itswhen), whose parts are not the main window's. The commands themselves, in the Command Palette or run by code, are unchanged.Breadth of the
ViewsServicechange: view container open commands with keybindings are Files (Cmd+Shift+E) and Changes (Ctrl+Shift+G), both Agents window only and both opening the main window's auxiliary bar, and VS Code's Explorer, Extensions and Run and Debug, which are not registered in the Agents window. Chat, Search and SCM register no view container open command; Markers, Output, Terminal and Chat bind their keys to view open commands, which are unchanged.LayoutModeContextis only set in chat windows, so VS Code is unchanged.Tests
src/vs/sessions/test/browser/layoutActions.test.ts: resolves the actual Cmd/Ctrl+B key throughKeybindingResolverover all default keybindings on macOS, Linux and Windows, in the main Agents window, in a chat window and in VS Code. Failed before the fix, with the key resolving toworkbench.action.toggleSidebarVisibilityin a chat window.src/vs/sessions/contrib/chat/test/browser/newSessionFolderQuickPickAction.test.ts: the command opens the picked folder's session in the chat window it runs in, and in the main window elsewhere. Failed before the fix.src/vs/workbench/contrib/sessions/test/common/sessionContextKeys.test.ts: a host showing a session with a workspace but no chat of it publishes the session's workspace; once it shows a chat without a workspace, it publishes none. Failed before the fix.src/vs/workbench/services/views/test/browser/viewsService.test.ts(new): the keybinding of a view container's open command applies in a window without layout modes and not in one with them. Failed before the fix.src/vs/sessions/contrib/chatWindow/test/browser/sessionsChatWindowProvider.test.ts: a composer aimed at the folder with its provider's session type, opened from a sent chat; a composer that loses nothing replaced; composers with input or with a request under way kept; a composer that gets input while the new one opens kept; the custom group inherited from a composer.Validation:
./scripts/test.sh --runon the five files above: 80 passing../scripts/test.sh --runGlobover all ofvs/sessionsand the chat window, sessions, session changes, views and workbench part test folders: 10795 passing, 0 failing.pnpm run typecheck-client,pnpm run valid-layers-check, and eslint on the changed files: all pass.Live verification
A Code - OSS build of this branch, in the Agents window (
--agents), with a chat window holding a sent chat. The automation ran with the windows in the background, so a focused chat window was simulated: CDP focus emulation on the chat window only, plusdocument.hasFocusreturning true there and false in the main window. The workbench confirmed it:IChatWindowService.activeWindowwas the chat window for every chat window step.Review
Reviewed by a separate reviewer on a different model across design, correctness, patterns, performance and lifecycle, security and trust, compatibility, UX, tests and hygiene. Its findings (re-aiming a mounted composer only changed its metadata; a composer with a request under way counted as unsent; the folder's provider was only a fallback; a race while the new composer opened; the custom group lost from a composer) are fixed in the later commits. The Cmd/Ctrl+Shift+E fix was reviewed by the same reviewer, including every caller of
setHostSessionContextKeysand every view container open command with a keybinding. Final verdict: approved, with no known actionable findings.