Skip to content

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 into
mainfrom
agents/fix-347106-chat-window-keybindings
Nov 11, 2026
Merged

Sandeep Somavarapu (sandy081) merged 6 commits into
mainfrom
agents/fix-347106-chat-window-keybindings

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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:

  • Cmd+B hid the main window's side bar.
  • Cmd+O showed the pick in the chat window, and picking a folder switched the main window's composer to that folder; the chat window was unchanged.

After:

  • Cmd+B does nothing in a chat window, which has no side bar of its own; the main window's side bar keeps its state. Cmd+B in the main window still toggles its side bar.
  • Cmd+O opens the new session in the chat window, as a tab of its active chat, aimed at the picked folder, as Cmd+N opens one there. The main window's composer is untouched. Cmd+O in the main window is unchanged.

Root cause

  • Cmd/Ctrl+B: this is an incomplete fix of c4e701c (Chat windows follow-ups: proportional resize, keyboard shortcuts, and drag-out/close fixes #346039). That change gave the Agents window's Toggle Side Bar a 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.
  • Cmd/Ctrl+O: long-standing. The command always called 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.toggleSidebarVisibility no 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, where LayoutModeContext is unset, nothing changes.
  • New Session in Folder... resolves the chat window it runs in (resolveChatWindow, as Cmd+N does) and opens the new session there through IChatWindowService.openNewChat, with a new, provider-neutral folder option ({ uri, providerId? }). Elsewhere it does what it did.
  • The Agents chat window provider opens a new composer aimed at that folder:
    • It always opens a new composer, whose draft goes through the composer's own creation path, including its workspace trust prompt. It never re-aims an existing composer.
    • When the active chat is a composer whose closing loses nothing (no input, no request under way, checked again once the new composer shows), the new one replaces it. A composer with input, or with a request under way, is kept, and the new one opens as a tab beside it.
    • Plain Cmd/Ctrl+N is unchanged: it reveals an unsent composer.
    • A composer opened from a composer joins the custom group of the sessions list that this composer's sessions join.
    • When the picked folder came with the provider that resolved it before (a recent folder), the composer starts with that provider's first session type for the folder, so that this provider creates its draft, as a new session in a folder of a provider starts in the main window.
    • When that provider cannot serve the folder at that moment, the composer behaves as picking that folder in the composer itself does: its picked or preferred agent, with that provider as the fallback, and its agent picker shows which one it uses. This differs from the main window, where openNewSession with 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:

  • In a chat window, the Agents window's Files and Changes keys apply while the chat window's session has a workspace (SessionWithWorkspaceContext). setHostSessionContextKeys took 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.
  • Where those keys did not apply, the open commands of the Files and Changes view containers, which ViewsService registers 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.
  • Long-standing: new sessions in chat windows come from Agents window: start a new session in a chat window #346678; quick chats in chat windows had the fallthrough before that.

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 its when), whose parts are not the main window's. The commands themselves, in the Command Palette or run by code, are unchanged.

Breadth of the ViewsService change: 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. LayoutModeContext is 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 through KeybindingResolver over 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 to workbench.action.toggleSidebarVisibility in 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 --run on the five files above: 80 passing.
  • ./scripts/test.sh --runGlob over all of vs/sessions and 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, plus document.hasFocus returning true there and false in the main window. The workbench confirmed it: IChatWindowService.activeWindow was the chat window for every chat window step.

  • Cmd+B in the chat window: the main side bar keeps its state, both hidden and shown. Before: it toggled.
  • Cmd+B in the main window: toggles its side bar, as before.
  • Cmd+O in the chat window with the sent chat active: a New Session tab opens beside it in the chat window, with its workspace picker, title bar and terminal on the picked folder. The main window's composer is unchanged. Before: the main window's composer switched to the folder.
  • Cmd+O again with that untouched composer active: it is replaced by one for the next folder.
  • Cmd+O with text typed in the composer: it keeps its text and folder, and a new tab opens for the picked folder.
  • Cmd+O in the main window: the main window's composer moves to the picked folder; the chat window is unchanged.
  • Cmd+Shift+E and Ctrl+Shift+G in the chat window with a sent chat active: a Files tab, then a Changes tab of that chat, open in the chat window.
  • Cmd+Shift+E and Ctrl+Shift+G with a new session (from Cmd+N) active in the chat window: the Files tab and a Changes tab open in the chat window. The main window's auxiliary bar stays closed. Before: Cmd+Shift+E opened the Files view in the main window's auxiliary bar.
  • Cmd+Shift+E and Ctrl+Shift+G in a chat window with a quick chat, sent or a new one: nothing happens; the main window's auxiliary bar stays closed.
  • Cmd+Shift+E and Ctrl+Shift+G in the main window: Files and Changes open there, as before.

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 setHostSessionContextKeys and every view container open command with a keybinding. Final verdict: approved, with no known actionable findings.

… 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]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 12:42
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.147.0 milestone Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Base: 85fa073a Current: e0127fa5

No screenshot changes.

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.

🟢 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]>
@sandy081 Sandeep Somavarapu (sandy081) changed the title Fixes #347106: keep Cmd/Ctrl+B and Cmd/Ctrl+O in the chat window that has focus Fixes #347106: keep Cmd/Ctrl+B, Cmd/Ctrl+O, Cmd/Ctrl+Shift+E and Ctrl+Shift+G in the chat window that has focus Nov 11, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/workbench/contrib/sessions/common/sessionContextKeys.ts

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]>
Picks up #347655 (cached Linux packages in PR checks) for the PR checks; no
conflicts.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) merged commit 893eeb0 into main Nov 11, 2026
52 of 53 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/fix-347106-chat-window-keybindings branch November 11, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctrl+B and ctrl+O affect the main window while focused on a chat window

4 participants