Skip to content

Sessions: session hosts replace the active session - #346171

Merged
Sandeep Somavarapu (sandy081) merged 29 commits into
mainfrom
agents/session-hosts
Nov 5, 2026
Merged

Sandeep Somavarapu (sandy081) merged 29 commits into
mainfrom
agents/session-hosts

Conversation

@sandy081

Copy link
Copy Markdown
Member

Sessions: session hosts replace the active session

The Agents window had one global "active session" that UI, commands and services read. Chat windows kept a copy of the session so their UI could read it too. With several windows, and several panes per window, that global no longer described what a given piece of UI shows, so UI in one window could act on another window's session.

This PR replaces it with session hosts (ISessionHost): a host is a surface that shows a chat, such as the main window, a chat window, a grid pane, a chat editor, a composer or the automation dialog. Hosts nest, and a host's chat is its source of truth: its session derives from that chat, and it has no notion of an active chat beyond the one it shows.

  • UI injects the host it is created in. Each host provides itself to what it creates through a child instantiation service, so DI resolves the innermost host. The root has no ISessionHost; the main window's parts are created in a child scope that provides the main window's (the grid's) host.
  • Lookups: ISessionHostService finds hosts by id, window, editor group, chat or session. It has no selection.
  • Window-independent consumers, such as voice and tours, use IFocusedSessionHostService: the host of the window that last gained focus.
  • One command resolver, resolveSessionCommandTarget, resolves what a command acts on. Arguments can name a host, editor group, window, chat or session; without arguments it resolves the focused host; arguments that name something not found resolve to nothing, so the command does nothing.
  • Chat windows show their chats as chat editors, and no longer keep a copy of the session.
  • ISessionsService no longer exposes activeSession, mainWindowActiveSession or windowSessions. It owns the grid, and the grid's host (gridHost). ISessionScope and ISessionContext are removed.

src/vs/sessions/SESSIONS.md describes the contract in its new "Session hosts" section.

Commits

The commits are ordered so that each compiles on its own and keeps behaviour, except the commits that are behaviour fixes, which come with tests.

  1. sessions: add session hosts backed by the current state
  2. sessions: add the session command resolver
  3. sessions: move Changes, feedback overlay and terminals to session hosts
  4. sessions: move session pickers to session hosts
  5. sessions: pass the pane session down to new-chat composers
  6. sessions: move canvases and session input banners to session hosts
  7. sessions: open canvases in the window that shows their chat (behaviour fix)
  8. sessions: move the title bar widget and chat groups to session hosts
  9. sessions: act on the last focused window while the app is in the background (behaviour fix)
  10. sessions: move window-independent consumers to the focused host
  11. sessions: look up shown sessions through session hosts
  12. sessions: treat sessions shown in any window as in use (behaviour fix)
  13. sessions: run host lookup tests on the real host service
  14. chatWindow: commands named for another window act on no chat window (behaviour fix)
  15. sessions: move the Run action to session hosts
  16. sessions: resolve command targets through session hosts
  17. chatWindow: let a chat window show several chats
  18. sessions: show the chats of a chat window as chat editors
  19. sessions: drop the session copies of chat windows
  20. sessions: lay out the main window from its session host
  21. sessions: route voice and tours to their owner hosts
  22. sessions: resolve command targets without the active session
  23. sessions: give the grid its host and drop the active session from the sessions service
  24. sessions: remove the session scope and context in favour of session hosts
  25. sessions: create the main window's parts with its own session host scope
  26. sessions: tell the grid's panes apart through the grid, not their sessions

Behaviour changes

UI follows the host it is in

  • Pickers (Agent Host mode, permissions, approvals and config, the Copilot mode picker, the mobile config picker, the model picker) act on the host they are created in. Outside a pane, composer or dialog, they act on their window's host instead of the globally active session.
  • New-session and new-chat-in-session composers show their own pane's draft, not the globally active session.
  • The command center's session title shows the session of its own window.
  • Session input banners show their window's session and chat.
  • The chat groups view no longer moves focus across windows, and activating a chat with preserveFocus in a chat window no longer moves the focused host.
  • The Sync Changes button in a chat editor shows the sync state of the editor's own chat. It used to show the main grid's active session, because chat editors provided no session context. When it disappears while focused, focus returns to its own surface: its grid pane, revealed first, or the chat editor's input. It never goes to the grid's pane of the same session.

Focus and windows

  • While the app is in the background, commands without arguments act on the window that last had focus, not the main window.
  • While a window that just gained focus is still loading its chat, such as a chat window restoring, the previously focused window stays focused until it has loaded.
  • Floating editor windows belong to the main window's host.
  • A canvas opens in the main part of the chat window that shows its owner's chat, else in the main window. It used to open in the window whose editor group was active.

Lookups

  • Composers and the automation dialog no longer own sessions or chats in host lookups; only windows and panes do.
  • Worktree cleanup never offers a session that any window shows. Before, only the focused session was protected.
  • Pull request polling polls draft CI and merged PRs for every shown session, once per session, and stops when no host shows it. Before, it polled the focused session only.

Commands

  • Chat window commands run with arguments that name the main window, or any other window that is not a chat window, no longer act on the focused chat window.
  • A session shown by several hosts resolves to the host in the focused window. A host's own session object, as its toolbars pass it, resolves to that host, including a detached pane.
  • Grid commands (chat tabs, close, delete, rename, pin, splits, focus and move in a direction) neither run nor match their keybindings while a chat window is the focused host, so the chat window's editors keep those keys. Before, they acted on the main grid from the chat window.
  • Focus Chat Input in a chat window focuses that window's chat input. Before, it focused the main window's grid.
  • A side chat started from a chat window is no longer sent in the background when the main grid switches sessions; only navigation in the window that shows its source chat counts.
  • Delegating to an Agent Host takes the folder of the focused host's session.
  • Export Agent Host Debug Logs and Open Agent Host State File, run with a session that no longer exists, do nothing. Without arguments they still export or open as before.

Chat windows

  • A chat window shows its chats as chat editors in its own editor groups, and can show several chats, split side by side. Its title row and Session Activity Bar follow the active chat editor.
  • A chat window no longer keeps a copy of the session. A chat it shows is held out of the main grid while it shows it, and the session leaves the grid when that was the only chat it showed there.
  • Closing a chat from a chat editor's header closes that chat editor; the window closes with its last chat. A chat editor's header doesn't offer Pin, which applies to the main grid.
  • Move to Main Window moves all of the window's chats to the grid.
  • Terminals that a chat window gets for a session stay that session's. If the window shows a chat of another session by the time they're ready, or while their editors are still opening, they wait in the panel's background and show when the window shows their session again; they don't show for the other session or become its terminals. Show Terminals shows only the terminals of the session the window shows. A terminal the user moves into the window, or opens there with New Terminal, still becomes the terminal of the session the window shows.

Pickers outside session hosts

  • The Agent Host session pickers on the workbench chat input menus (agent, mode, config, permission mode, Codex approvals) show only in session host scopes:
    • Quick Chat in the Agents window no longer shows them. They used to act on the grid's session.
    • The Inbox detail chat no longer shows them. They used to act on the grid's session, not the session the detail shows.
    • The workbench Chat view and chat editor would not show them either, if an Agent Host chat showed there; no UI path does that in the Agents window.

Known deviations and follow-ups

  • Hosts of one session keep their own views of it. A pane host's session is the pane's own view of the session: a grid slot and a detached pane of one of its chats have different views, with their own tab strip and pin state. Code outside the grid compares hosts' sessions by resource, and asks the grid which pane is active or detached (ISessionsService.isActivePane / isDetachedPane). scopedChatResource stays an internal grid identity, used for detached panes, their persistence, pane identity and opener checks. Sharing one session object across hosts needs the grid's detach representation reworked, so it is a follow-up: a canonical session object, and removing scopedChatResource.
  • The Inbox detail chat has no host of its own. It is created in the main window's scope today. A follow-up gives it a host of its own, which brings back its session pickers, bound to the session it shows.
  • Hidden subagent chats keep a grid slot. When a session's only visible chat moves into a chat window, the grid keeps the session's slot, with the new-chat composer, if the session has a hidden subagent chat: the "only chat" check counts hidden chats. This predates this PR (the same check as before) and is tracked separately.
  • A composer logs an error when its session leaves the grid. When a session leaves the grid while its pane shows a new-chat composer, disposing the composer logs "InstantiationService has been disposed": the session view disposes its scoped instantiation service before its chat groups. This ordering predates this PR and is tracked separately.
  • Floating editor windows aren't covered by unit tests. A real floating editor window can't be opened in a unit test. The floating and modal editor parts are created through the same scope, and the modal path is covered by a test.
  • The terminal editor service forgets moved terminal editors. Moving an inactive terminal editor between groups makes the terminal editor service forget its input. This affects regular VS Code too; it is worked around in sessions: fix terminals leaked by chat windows #346125 and tracked separately.
  • A 2×2 GridView leaks its sash link. A grid that is exactly 2×2 doesn't dispose its sash link. Pre-existing; tracked separately.
  • "View: Move Editor into New Window" closes a chat window. On the chat of a chat window closes the window without reopening the chat. It reproduces on main; pre-existing and tracked separately.

Validation

Based on e934a7a384a. Each commit compiles on its own, and the tip passes the suites below.

Per commit: all 26 commits passed. The command, which also logged each commit's result locally:

git rebase -x "bash -c 'set -o pipefail; corepack pnpm run typecheck-client 2>&1 | tail -20'" origin/main

Tip

  • set -o pipefail; corepack pnpm run typecheck-client: passed.
  • corepack pnpm run build-fast --client-only: passed.
  • git diff --name-only --diff-filter=ACMR origin/main HEAD -- '*.ts' | xargs ./node_modules/.bin/eslint: passed (304 files).
  • corepack pnpm run valid-layers-check: passed.
  • corepack pnpm run check-cyclic-dependencies: no cyclic dependencies found.

Unit tests, Electron, ./scripts/test.sh --reporter dot --glob <glob>:

Glob Result
vs/sessions/**/*.test.js 10389 passing, 27 pending
vs/workbench/contrib/chatWindow/**/*.test.js 156 passing
vs/workbench/test/browser/parts/editor/**/*.test.js 375 passing
vs/workbench/services/editor/test/**/*.test.js 287 passing
vs/workbench/contrib/terminal/test/**/*.test.js 603 passing, 4 pending
vs/base/test/browser/ui/grid/**/*.test.js 73 passing

Unit tests, Chromium, node test/unit/browser/index.js --browser chromium --reporter dot --glob <glob>:

Glob Result
vs/sessions/**/*.test.js 10115 passing, 23 pending
vs/workbench/contrib/chatWindow/**/*.test.js 155 passing
vs/workbench/test/browser/parts/editor/**/*.test.js 374 passing
vs/workbench/services/editor/test/**/*.test.js 286 passing
vs/workbench/contrib/terminal/test/**/*.test.js 579 passing, 4 pending
vs/base/test/browser/ui/grid/**/*.test.js 72 passing

No failures in any of them. The vs/sessions, chat window and terminal suites ran at this tip. The editor (parts/editor, services/editor) and grid results are from the previous tip on the same base: the last changes since touch only the Sessions terminal files, which those suites don't load, so they weren't run again.

Live checks in a Code OSS dev build with --agents, launched in the background:

  • Chat windows as chat editors (commit 18): opening a chat in a new window, opening a subagent from the window beside the chat, switching groups by clicking, the Session Activity Bar with two split chats, the chat editor header menu, and closing one of two chats all behaved as described above.
  • The strict host scopes (commits 25 and 26): the window starts with all its parts, and the console has no unknown-service errors. The main title bar, a grid pane's chat with its pickers, the Changes view and editor, a chat window with its pickers and its Changes editor, the Inbox, and the Inbox detail chat without the session pickers all render.

Manual checks (keyboard and focus)

These depend on keyboard input or real window focus, so they weren't covered by the background live checks. Run them with sessions.chatWindows.enabled: true.

Chat windows

  1. In a chat window with two chat editors, drag one chat editor's tab, or run View: Move Editor into Group Below, to split below. The title row and Changes follow the focused group.
  2. Close the last chat editor of a window: the window closes. Move one chat out to another window, or to the main window by dragging.
  3. Open a chat of session B into a chat window of session A, add an ordinary editor beside it, then run Move to Main Window. All chats go to the grid, including a previously closed peer and a subagent, A is active, and the editor reopens.
  4. Open a chat window from a session link, such as a notification. Open the session's resource into an existing window: the chat stays and becomes active. Reload with a split of A and B, A active: both restore, A active.
  5. With a chat window focused and the same session in the main grid:
    • in the Command Palette, Split Chat Group Right and Focus Session 1 are unavailable;
    • Cmd+W closes the active chat editor;
    • middle-clicking the header title closes it;
    • the main grid is unchanged.
  6. On macOS, the window controls sit in the title row. The Stacked layout shows only the input. Start a fork or a subagent beside a chat in the main window, then switch to a chat window before it finishes: focus isn't taken back.
  7. Terminal, Run and Changes in a chat window act on the active chat editor's session.

Host scopes

  1. Quick Chat: open it with its keybinding. Its input toolbar has no Agent, Mode or Permissions pickers, and Tab and the arrow keys never land on a hidden item.
  2. Detached pane: in a session, Ask in a Side Chat, then run Detach Chat into New Pane from the Command Palette. The detached pane renders, its header and toolbar work, and commands from its header act on the detached pane, not on the session's slot.

Introduce ISessionHost, ISessionHostService and IFocusedSessionHostService.
The main window, chat windows, session views, the shared chat input composer
and the automation dialog provide a host, nested through DI. ISessionScope
reads the window host. Behaviour is unchanged.

Co-authored-by: Copilot <[email protected]>
resolveSessionCommandTarget resolves what a Sessions command acts on from its
arguments: a host, editor group, window, chat or session, or the focused host
without arguments. Arguments that name something that is not found resolve to
nothing. The existing resolvers now read the hosts instead of the scoped
services of chat windows.

Co-authored-by: Copilot <[email protected]>
The Changes scope carries the session and chat of its window host and whether
that is the main window, instead of comparing observables with the main
window's active session. The feedback overlay and chat window terminals look
up the host of their editor group or window. Root services of the main window
look up its host. Helpers that read the selected chat now take the host's chat.

Co-authored-by: Copilot <[email protected]>
The agent host mode, permission, approvals and config pickers, the Copilot mode
picker, the mobile config picker and the model picker take the session and chat
of the host they are created in (ISessionChatSource) instead of the session
context, and read that chat instead of the session's selected chat. The phone
input context and the worktree suggestion take the chat explicitly.

Co-authored-by: Copilot <[email protected]>
The session view passes its session to the chat views it creates
(IChatViewOptions.session). The new-session and new-chat-in-session widgets
show the draft of their pane instead of reading the active session, which
could be another pane's or another window's.

Co-authored-by: Copilot <[email protected]>
The canvas context service finds the window that shows a canvas owner through
the host of its chat: a chat window that shows the chat, else the main window
while it shows the session. The canvas contexts follow the focused host. The
session input banners show the session and chat of their window host.

Co-authored-by: Copilot <[email protected]>
A canvas opens in the main part of the chat window that shows its owner's chat,
else in the main window, instead of in the window whose editor group is active.
A canvas of a chat window opened while another window had focus no longer
lands in that other window.

Co-authored-by: Copilot <[email protected]>
The command center's session title shows the session and chat of the window
whose title bar shows it, created with that title bar's services. A chat group
view compares its session with that of its window host rather than with the
active session. The workspace display info takes the chat explicitly.

Co-authored-by: Copilot <[email protected]>
…ground

Without a focused document, the focused host is the window host that last had
focus instead of the main window, which getActiveWindow falls back to. Commands
without arguments run from the background, such as from the dock, act on that
window.

Co-authored-by: Copilot <[email protected]>
Services and contributions that follow focus read the session and chat of
IFocusedSessionHostService.focusedHost instead of ISessionsService.activeSession
and its selected chat: agent feedback, browser views, canvases, Changes
activity, workspace handoff, AI customizations, artifacts, voice, turn changes,
code review, tours, agent host pickers and presenters, customizations, the
workspace folders and labels, and telemetry. Behaviour is unchanged.

Co-authored-by: Copilot <[email protected]>
The Agent Host provider, GitHub pull request polling, worktree cleanup and the
Agent Host customization lookup no longer read the view state of
ISessionsService. Shown sessions come from the session hosts, the main
window's session from its window host, and the focused session from the focused
host. The providers no longer depend on ISessionsService. Behaviour is
unchanged.

Co-authored-by: Copilot <[email protected]>
Worktree cleanup no longer offers the worktree of a session that any host
shows, and pull request polling keeps polling draft CI checks and merged pull
requests while any host shows their session, not only the focused one. Polling
stays one per session and stops once no host shows it.

Co-authored-by: Copilot <[email protected]>
sessionHostServiceOf registers plain hosts for the state of ISessionsService in
a real SessionHostService, so the tests of host lookups go through the real
nesting, ownership and window rules instead of a parallel fake.

Co-authored-by: Copilot <[email protected]>
resolveChatWindow fell back to the chat window that has focus when its
arguments named a group or window that is not a chat window's, such as a
command run from the main window while a chat window had focus. Arguments that
name where a command runs now resolve to that chat window or to none; only
commands without them act on the focused chat window.

Co-authored-by: Copilot <[email protected]>
The Run actions act on the session and chat of the focused host, and the Run
button of a title bar on those of the window host it shows in, instead of the
active session and ISessionScope. Behaviour is unchanged.

Co-authored-by: Copilot <[email protected]>
Commands that take a session, a chat, a session resource or nothing resolve
what they act on with resolveSessionCommandTarget, and the chat-window tab
entries, the Changes editor's changeset selection and Open in VS Code read
session hosts. resolveSessionActionTarget, findSessionByResource,
findSessionByChatOrResource, getFocusedWindowSession and getChatWindowSession
are removed.

A session that several windows show resolves to its host in the focused
window, with the chat that host shows, as the old resolver did.

Co-authored-by: Copilot <[email protected]>
A chat window shows a list of chats, each an editor of its chat part, in any
group and grid shape of the part. The provider's content is window-level and
resolves chats one at a time. The window's chat, chat editor and title are those
of its active chat: the chat editor last active in the window. Closing or ending
one chat removes only that chat, and the window closes with its last chat.
Moving one of several chats out of the window takes only that chat out. Move to
Main Window carries all its chats, and restoring keeps the list and the active
chat, still reading the entries of one chat or session.

The Agents window's provider still shows one chat per window.

Co-authored-by: Copilot <[email protected]>
A chat window now holds chats in plain editor groups, one chat editor per
chat, rather than a session view of a copied window session. Each chat
editor shows one chat, with no inner chat tabs, in a pane host nested in
its window's host, which follows the active chat editor.

- The chat editor moves to contrib/chatEditor, without depending on chat
  window services.
- A chat a window shows stays out of the main window's grid through
  ISessionsService.hideChatFromGrid.
- Opening a chat a window shows reveals it there, and a chat opened beside
  one it shows opens beside it, through IChatHostOpenerService.
- Focusing a chat window no longer makes its session the active session.
- Move to Main Window carries all chats of the window.

Co-authored-by: Copilot <[email protected]>
Chat windows show chats as chat editors, so the sessions service no
longer shows sessions in windows of their own. Removes showSessionInWindow
and the window sessions of the visibility model, with their activation on
window focus, and the window session views of the sessions part.
windowSessions stays empty, and mainWindowActiveSession is the active
session, until the session API shrinks.

Co-authored-by: Copilot <[email protected]>
Main-window-only UI (the layout controller and its strategies, the sessions list, the sessions view, the mobile title bar and the comparison grid) reads what the main window's session host shows instead of the sessions service's active session. The grid exposes `activePaneId` and `focusActiveSession()` for its own pane identity and focus.

Co-authored-by: Copilot <[email protected]>
Voice reads the focused session host, so it follows the chat window the user talks to; new sessions still open in the main window, whose composer it checks. The new-session view tours read the main window host, which owns the new-session view they guide through.

Co-authored-by: Copilot <[email protected]>
Commands that act on a session or chat resolve it with resolveSessionCommandTarget: their arguments, else the focused host. Commands of the main window's grid act on the grid's active pane through ISessionsPartService.getActiveSessionView(), and neither match their keybindings nor act while a chat window is the focused host, so its chat editors and editor groups keep their keys. Follow-ups after opening a new session, and the main window's Changes and sessions list, read the main window host.

- Focus Chat Input focuses the input of the chat the focused chat window shows.
- A side chat is sent in the background only when the window that shows its source chat navigates away from it.
- Delegating to an agent host takes the folder of the focused host's session, and opens beside it when the grid shows it.
- The chat input toolbar finds the session of a chat among the grid's panes.

Co-authored-by: Copilot <[email protected]>
… sessions service

SessionsService creates the main window's host on the grid's selection and exposes it as gridHost; the host lookups register that instance, and the main window's UI injects it, through a temporary alias that C10 removes. activeSession, mainWindowActiveSession and windowSessions leave ISessionsService: the grid's selection stays internal to the service, and others read the windows' hosts.

Test mocks keep the grid state they model as test fields, typed by ITestSessionsGridState, from which the session host test helpers derive the hosts.

Co-authored-by: Copilot <[email protected]>
…osts

UI reads the session and chat of the host it is in. The Sync Changes button reads its host, so in a chat editor it shows the editor's chat rather than the grid's active session, and returns focus to its own surface. SESSIONS.md describes the session host contract.

Co-authored-by: Copilot <[email protected]>
The root no longer provides a session host: the main window's parts (the sessions grid, custom views, panel, sidebar, auxiliary bar, editors and title bars) and window canvases are created from a child scope that provides the grid host, so a root singleton that injects a session host fails instead of silently getting the main window's. The focused host and the automation dialog look their hosts up. Items of workbench-wide chat input menus that apply in session hosts only show nothing elsewhere, such as in Quick Chat.

Co-authored-by: Copilot <[email protected]>
…sions

A pane host's session is the pane's own view of the session: a slot of the
grid and a detached pane of one of its chats have different views of it.
Code outside the grid no longer reads the grid's detached-pane field off a
host's session, nor compares hosts' sessions as objects to find the
session's pane.

- The grid answers for a pane's own session whether it is the active pane
  and whether it is detached (ISessionsService.isActivePane and
  isDetachedPane, backed by its detached panes).
- getHostOfSession picks, of the panes of a window that show a session, the
  window's active pane (the grid's, or the one that shows the window's
  chat), else the one that is not detached.
- The session a pane's toolbars pass still names that pane, detached or not.
- The pin and close commands check the chat the passed pane shows, and the
  comparison grid asks the grid whether its Judge pane is detached.
- Opening a session in a chat window no longer filters detached panes out of
  the grid's visible sessions, which never include them.

A canonical session object shared by all hosts of a session is left to a
follow-up that removes the grid's detached-pane field.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 03:36
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Kyle Cutler (@kycutler)

Matched files:

  • src/vs/sessions/contrib/browserView/browser/sessionBrowserNetwork.ts
  • src/vs/sessions/contrib/browserView/browser/sessionBrowserView.ts
  • src/vs/sessions/contrib/browserView/test/browser/sessionBrowserNetwork.test.ts

Joaquín Ruales (@jruales)

Matched files:

  • src/vs/sessions/contrib/browserView/browser/sessionBrowserNetwork.ts
  • src/vs/sessions/contrib/browserView/browser/sessionBrowserView.ts
  • src/vs/sessions/contrib/browserView/test/browser/sessionBrowserNetwork.test.ts

Ulugbek Abdullaev (@ulugbekna)

Matched files:

  • src/vs/sessions/contrib/canvases/electron-browser/sessionCanvasService.ts
  • src/vs/sessions/contrib/canvases/test/browser/pinnedCanvasService.test.ts
  • src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasRegistryService.test.ts
  • src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasService.test.ts
  • src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasWorkingSet.test.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/chatHostOpener.ts
  • src/vs/sessions/services/sessions/browser/sessionActionTarget.ts
  • src/vs/sessions/services/sessions/browser/sessionCommandTarget.ts
  • src/vs/sessions/services/sessions/browser/sessionContext.ts
  • src/vs/sessions/services/sessions/browser/sessionHost.ts
  • src/vs/sessions/services/sessions/browser/sessionHostService.ts
  • src/vs/sessions/services/sessions/browser/sessionOpenTelemetryService.ts
  • src/vs/sessions/services/sessions/browser/sessionScope.ts
  • src/vs/sessions/services/sessions/browser/sessionScopedContextKeys.ts
  • src/vs/sessions/services/sessions/browser/sessionsPartService.ts
  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/browser/visibleSessions.ts
  • src/vs/sessions/services/sessions/common/sessionContextKeys.ts
  • src/vs/sessions/services/sessions/common/sessionsManagement.ts
  • src/vs/sessions/services/sessions/test/browser/sessionActionTarget.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionCommandTarget.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionHost.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionHostTestUtils.ts
  • src/vs/sessions/services/sessions/test/browser/sessionOpenTelemetryService.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionScope.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts
  • src/vs/sessions/services/sessions/test/browser/visibleSessions.test.ts

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.

🟡 Changes recommended

Missing session-host service registrations cause artifact-details, Changes view, and title-bar fixtures to fail with unknown-service errors instead of rendering.

3 open issues
What changed in this PR

Replaces global active-session access with scoped session hosts so Agents window UI, commands, and services target the chat shown by the appropriate surface.

Changes:

  • Migrates session consumers and command targeting to scoped or focused hosts.
  • Updates window-part creation, chat composers, and editor integration.
  • Adapts tests, fixtures, documentation, and localization registration.
File Description
src/​vs/​workbench/​test/​browser/​componentFixtures/​sessions/​sessionsTitleBarWidget.fixture.ts Updated as part of this pull request.
src/​vs/​workbench/​test/​browser/​componentFixtures/​sessions/​changesView.fixture.ts Updated as part of this pull request.
src/​vs/​workbench/​test/​browser/​componentFixtures/​fixtureUtils.ts Updated as part of this pull request.
src/​vs/​workbench/​contrib/​chatWindow/​test/​browser/​chatWindowLayoutActions.test.ts Updated as part of this pull request.
src/​vs/​workbench/​contrib/​chatWindow/​browser/​chatWindowLayoutActions.ts Updated as part of this pull request.
src/​vs/​sessions/​test/​common/​chatLayout.test.ts Updated as part of this pull request.
src/​vs/​sessions/​test/​browser/​workbench.test.ts Updated as part of this pull request.
src/​vs/​sessions/​test/​browser/​vscodeActions.test.ts Updated as part of this pull request.
src/​vs/​sessions/​test/​browser/​sessionWorkspace.test.ts Updated as part of this pull request.
src/​vs/​sessions/​test/​browser/​sessionViewTestUtils.ts Updated as part of this pull request.
src/​vs/​sessions/​test/​browser/​sessionView.test.ts Updated as part of this pull request.
src/​vs/​sessions/​sessions.common.main.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​workspaceFolderLabel/​browser/​workspaceFolderLabelService.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionOpenTelemetryService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​sessions/​common/​sessionsManagement.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​sessions/​browser/​sessionScopedContextKeys.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​sessions/​browser/​sessionScope.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​sessions/​browser/​sessionOpenTelemetryService.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​presentation/​browser/​chatPhoneInputContext.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​chatView/​browser/​chatViewFactory.ts Updated as part of this pull request.
src/​vs/​sessions/​services/​canvas/​browser/​windowCanvasService.ts Updated as part of this pull request.
src/​vs/​sessions/​LAYOUT.md Updated as part of this pull request.
src/​vs/​sessions/​electron-browser/​parts/​titlebarPart.ts Updated as part of this pull request.
src/​vs/​sessions/​electron-browser/​actions/​vscodeActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​worktreeSuggestion/​test/​browser/​worktreeSuggestionService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​workspace/​test/​browser/​workspaceFolderManagement.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​workspace/​browser/​workspaceFolderManagement.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​terminal/​test/​browser/​chatWindowTerminalActions.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsWorkspaceSelectionTelemetry.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsTitleBarWidgetRemoteHost.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsTitleBarWidget.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsTelemetry.contribution.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsSessionManagementActions.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListTestUtils.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListFixtureUtils.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListContextMenu.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​customizationsToolbar.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​automationsView.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​automationsView.fixture.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​aiCustomizationShortcutsWidget.fixture.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsWorkspaceSelectionTelemetry.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsTypedCharactersTracker.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsTelemetry.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​browser/​mobile/​mobileOverlayContribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​sessions/​browser/​customizationsNavigationState.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​test/​browser/​remoteAgentHostSessionsProvider.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​remoteAgentHostActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​copilotChatSessions/​test/​browser/​modePicker.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​copilotChatSessions/​browser/​copilotChatSessionsActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentMergeActions.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostSessionConfigPicker.fixture.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostPolicyContinuationPresenter.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostModePicker.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostForkActions.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostCodexApprovalsPicker.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostClaudePermissionModePicker.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostAgentPicker.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​openAgentHostStateFileAction.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​mobile/​mobileChatPhoneInputPresenter.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​exportDebugLogsAction.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​codexCustomizationSettings.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​codexContinuation.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentMergeActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostSettings.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostPolicyContinuationPresenter.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostPermissionPickerActionItem.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostForkActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostClaudePermissionModePicker.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​policyBlocked/​test/​browser/​sessionsPolicyBlocked.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​policyBlocked/​test/​browser/​sessionsPolicyBlocked.fixture.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​policyBlocked/​browser/​sessionsPolicyBlocked.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​test/​browser/​parallelTasksTour.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​test/​browser/​newSessionViewV3Prompt.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​test/​browser/​newSessionViewTourTrigger.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​test/​browser/​agentsWindowInvitationOnboarding.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​browser/​parallelTasksTourContribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​browser/​newSessionViewV3TourContribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​browser/​newSessionViewV2TourContribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​browser/​newSessionViewTourTrigger.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​browser/​newSessionViewTourContribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​onboardingTours/​browser/​agentsWindowInvitationOnboarding.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​layout/​test/​browser/​chatLayoutOwnership.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​layout/​browser/​desktop/​desktopLayoutStrategy.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​layout/​browser/​desktop/​desktopDetailPanelCoordinator.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​inboxOne/​browser/​inboxNotificationsView.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​github/​test/​browser/​githubService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​github/​browser/​issueActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​github/​browser/​createSessionFromPullRequestAction.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​getStarted/​test/​browser/​getStartedTourRunner.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​editor/​browser/​editor.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​editor/​browser/​addTabActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​codeReview/​test/​browser/​codeReviewService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​codeReview/​browser/​codeReview.contributions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chatWindow/​browser/​chatWindow.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionsWorkbenchFixtureUtils.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionsGrid.fixture.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionsChatAccessibilityHelp.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​runScriptAction.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​responseSelectionSideChatController.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newSessionPickerTryout.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatWidget.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatVoiceTarget.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​newChatInSessionWidget.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​modelPicker.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​artifactIntegrationPresentation.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​artifactIntegrationPresentation.fixture.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​aiCustomizationWorkspaceService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​agentsWindowWorkspaceHandoff.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​electron-browser/​chat.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​sideChatProvider.contribution.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionTurnChanges.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionsChatAccessibilityHelp.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​newSessionAction.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​newChatVoice.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​newChatInSessionWidget.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​chatView.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​artifactActivitiesModel.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​chat/​browser/​agentHostDelegation.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​test/​browser/​sessionChangesEditorInput.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​test/​browser/​sessionActionsHost.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​test/​browser/​sessionActionContextKeys.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​test/​browser/​checksActions.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​test/​browser/​changesActivity.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​browser/​sessionActionsHost.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​browser/​checksActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​browser/​changesetReviewActions.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​changes/​browser/​changesActivity.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​canvases/​test/​electron-browser/​sessionCanvasWorkingSet.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​canvases/​test/​electron-browser/​sessionCanvasRegistryService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​canvases/​test/​browser/​pinnedCanvasService.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​browserView/​test/​browser/​sessionBrowserNetwork.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​browserView/​browser/​sessionBrowserNetwork.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​automations/​test/​browser/​automationDialog.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​applyCommitsToParentRepo/​browser/​applyChangesToParentRepo.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​agentFeedback/​test/​browser/​agentFeedbackPRReviewSeeder.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​agentFeedback/​test/​browser/​agentFeedbackItemsBackend.test.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​agentFeedback/​browser/​agentFeedbackPRReviewSeeder.ts Updated as part of this pull request.
src/​vs/​sessions/​contrib/​agentFeedback/​browser/​agentFeedbackItemsBackend.ts Updated as part of this pull request.
src/​vs/​sessions/​common/​contextkeys.ts Updated as part of this pull request.
src/​vs/​sessions/​common/​chatLayout.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​sessionWorkspace.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​parts/​titlebarPart.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​parts/​mobile/​contributions/​mobileChangesView.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​parts/​customViewGridParts.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​parts/​chatView.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​parts/​chatGroupView.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​paneCompositePartService.ts Updated as part of this pull request.
src/​vs/​sessions/​browser/​actions/​vscodeActions.ts Updated as part of this pull request.
src/​vs/​sessions/​AI_CUSTOMIZATIONS.md Updated as part of this pull request.
build/​lib/​i18n.resources.json Updated as part of this pull request.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Base: 14a0f1a9 Current: 4a35297e

No screenshot changes.

The fixtures model the grid with a test sessions service. Since the title bar
and the grid commands read the main window's host, the focused host and the
grid's pane queries, the fixtures give the main window's host and the
focused host the grid's active session, and their sessions service answers the
pane queries for its slots. The title bar shows the active session again, and
Maximize and Pin act on their pane.

Co-authored-by: Copilot <[email protected]>
The test opens a terminal in the window's main part, which moves it to the
part that holds the window's terminals on a timeout. The test waits for it,
so the move does not outlive the test (it leaked on WebKit).

Co-authored-by: Copilot <[email protected]>
Components now read the window's session host, the host lookups or the
focused host instead of the sessions service: the Changes view, the title
bar, the input banners, the sessions list, the new chat widget, the
automation dialog, artifact activities and session changes. Their fixtures
only modelled the session on the sessions service, so they failed to
construct. They now stub the main window's host showing the fixture's
session, the host lookups and, where needed, the focused host. The title
bar's mock session reports itself created, as a real host reads that.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) merged commit a617266 into main Nov 5, 2026
59 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/session-hosts branch November 5, 2026 06:32
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 5, 2026
Christof Marti (chrmarti) added a commit that referenced this pull request Nov 5, 2026
…5832)

<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:

https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

Fixes microsoft/vscode-internalbacklog#10484

## What changed

"Open in Agents Window" from an SSH, WSL or Tunnel editor window opened
the Agents Window without the folder. Only local folders and local Dev
Containers were handed off, so the composer fell back to an unrelated
local folder, and telemetry recorded `unsupportedWorkspace`.

- **Same folder, same host.** The window-opening handoff resolves
`vscode-remote` folders through a new provider-neutral
`IRemoteWorkspaceHandoffService` (`sessions/common`), implemented by the
remote agent host contribution. It matches the registered SSH, WSL or
Tunnel host, or registers it the way Remotes management does. It then
preselects the folder in that host's `vscode-agent-host` URI space,
reveals the host, and starts a user-initiated connection.
- **Dev Containers** on SSH and Tunnel hosts, and in WSL (identified by
a `\\wsl.localhost\…` source path), resolve to the source folder on that
host with the Dev Container preferred. This is the inverse of the
existing Open in Editor mapping.
- **No silent fallback.** Remotes that can't be used start with no
workspace and a notification explaining why, with a Choose Workspace
action. This covers Codespaces, attached containers, WSL on another
machine, and failed host lookups.
- **Inferred defaults** ("Open Agents Window", `folderUriIsDefault`)
only replace an automatic default. They never add or connect a host
while a created session is visible. `selectNoWorkspace` now returns a
`WorkspaceSelectionResult` and honors `isDefault`, like
`selectWorkspace`.
- **A restored Chat choice no longer cancels the handoff.** When the
composer started, restoring a saved "no workspace" choice reported a
user selection and a navigation. That cancelled a pending handoff before
its remote folder resolved, so the Agents Window silently kept the
previous choice. It now restores like the automatic fallback next to it.
- **Signing in to find a tunnel.** When no signed-in account lists the
tunnel and an account needs to sign in first, a dialog explains which
account is needed and why. If the user selects **Sign In**, the handoff
signs in with that account and looks again. Declining the dialog or
cancelling the sign-in explains that signing in is needed. A tunnel the
Agents Window already knows gets the same check before the handoff
connects it; previously a signed-out account made that connection fail
with "No cached authentication available to connect the tunnel." An
account without tunnel configuration (Code OSS has no Microsoft tunnel
scopes) no longer hides the sign-in behind "No authentication is
available to enumerate tunnels."
- **SSH user and port.** Like Remote - SSH, an SSH authority without a
config alias uses the user and port of SSH config where it omits them.
The handoff matches and stores hosts by those effective values, so an
omitted user doesn't match another account's host. A stored host without
a port is compared on SSH config's port, the one it connects on.
- **Cancelled handoffs change nothing.** Once a handoff is cancelled,
for example by picking another workspace, it stops before storing a
host, caching a distribution or tunnel, clearing a tunnel dismissal or
offering a sign-in.
- **Starting without a workspace** counts as applied only once Chat has
opened. Until a quick-chat target is available, the handoff keeps
trying.
- **Telemetry.** `agents/firstTimeWindowOpen` and
`agents/workspaceSelectionOutcome` gain a bounded
`workspaceArgumentRemoteKind`: none, ssh, wsl, tunnel, codespaces,
attachedContainer or other. For Dev Containers it is the host of the
source folder. It never contains an authority.
- **Authority formats** are checked against the Remote - SSH, WSL,
Tunnels and Dev Containers extension sources:
  - Remote - SSH hex JSON and plain `[user@]host[:port]`
  - `wsl+default` and `wsl+<distro>@<host>`
- `tunnel+<name>` and `tunnel+<id>.<cluster>`, looked up with both the
GitHub and Microsoft accounts
  - the `\\wsl\`, `\\wsl$\` and `\\wsl.localhost\` prefixes

`sshAuthorityString` (Open in Editor) now mirrors Remote - SSH's
`HostInfo.toAuthorityString`, so an SSH config alias with uppercase
letters is encoded the same way Remote - SSH encodes it.

The remote agent host provider spec gains a paragraph on this
registration path.

## Reviewer notes

- A chat draft handed off to a remote that is slow to connect still hits
the existing 15-second handoff timeout and its Retry notification.
- Remote - SSH ignores an encoded port for a configured alias; the
Agents Window keeps it. This only affects `alias:port` typed by hand.
- Codespaces are not supported yet; they get a dedicated notification.
- A restored Chat choice still wins over an inferred default
(`_getWorkspaceDefaultBlocker`). Because the restore no longer cancels
the handoff, an inferred default from a remote editor window now
finishes resolving and connects that host even when the Chat choice
stays. Without a saved Chat choice, that already happened.
- The tunnel sign-in happens for inferred defaults too, because
resolving the folder needs it. The browser tunnel service has no
`signIn`, so on the web the handoff still only explains that signing in
is needed.
- SSH hosts added manually in Remotes management without a port are
still keyed as port 22, although they connect on SSH config's port. That
keying predates this PR.

## How to test

1. From an SSH, WSL or Tunnel editor window, run **Open in Agents
Window**. The same folder is preselected on the matching remote agent
host, which is added if needed and connected.
2. From a Codespaces window, or with `code --agents --folder-uri
vscode-remote://codespaces+demo/workspaces/project`, the composer starts
in Chat with no workspace and shows "The Agents Window cannot open
folders from GitHub Codespaces yet."
3. `code --agents --folder-uri
vscode-remote://wsl+NoSuchDistro/home/me/project` starts with no
workspace and explains that the WSL distribution was not found.
4. In the Agents Window, select Chat (no workspace) and close the
window. Then run **Open in Agents Window** from a remote editor window
again: its folder replaces the restored Chat choice.
5. From a Tunnel editor window, with the Agents Window not signed in to
tunnels, run **Open in Agents Window**. A dialog explains that signing
in with GitHub is needed to find the tunnel. After **Sign In** and the
GitHub sign-in, the folder is preselected on the tunnel. If you select
**Cancel** in the dialog, or cancel the sign-in, the notification says
"Sign in to find tunnel '<name>'." The same dialog appears for a tunnel
the Agents Window already knows, if its account is signed out.

## Validation

After rebasing onto `main` at `8b007fabde2`. The rebase adapted the
inferred-default check to the focused session host, which replaced
`ISessionsService.activeSession` in #346171:

- `pnpm run typecheck-client`: passed.
- `pnpm run eslint <changed files>`: passed.
- `node --experimental-strip-types build/hygiene.ts <changed files>`:
passed.
- `.\scripts\test.bat --run <the 9 test files this PR changes, including
electron-browser>`: 422 passing.
- `pnpm run test-browser-no-install --run <the 8 browser test files of
those> --browser chromium`: 408 passing.
- `pnpm run valid-layers-check`: passed before the rebase; not rerun.

Manually checked in a dev build of the Agents window, before the rebase:

- The Codespaces and unavailable WSL notifications.
- With temporary logging, since removed: from a Tunnel editor window,
the restored Chat choice cancelled the handoff as `userChanged` about
1.6 s after the window opened. The tunnel lookup that kept running found
GitHub needing a sign-in and Microsoft unconfigured.
- From a Tunnel editor window, before the confirmation dialog was added:
the handoff started a GitHub sign-in, then preselected the folder on the
tunnel.
- With the dialog, for a tunnel the Agents Window already knew while
signed out of GitHub: the dialog appeared, and after signing in the
folder was preselected and the tunnel connected.
Sandeep Somavarapu (sandy081) added a commit that referenced this pull request Nov 6, 2026
* Sessions: remove unused ResourceOverrideSession

`VisibleSessions.updateResourceOfSession` and its `ResourceOverrideSession`
adapter have no production caller. Remove both, and keep the metadata
forwarding test for the visible session wrapper.

First commit towards one canonical session object shared by all session
hosts (follow-up of #346171).

Co-authored-by: Copilot <[email protected]>

* Sessions: pickers read the model and mode of the chat a host shows

The model and mode pickers read `IActiveSession.modelId`/`mode`, which a
session wrapper of the Agents window overrides with its active chat's. Once
hosts share one session object, there is no such wrapper. Read the chat the
host shows instead:

- `SessionModelSelection` takes an `ISessionChatSource` (session and chat)
  and reads the chat's model, re-binding when the chat changes. A composer
  bound to another chat than its session's active one now selects that
  chat's model.
- `ScopedModePickerModelCache` is keyed by the source and reads its chat's
  mode; the agent-host agent picker reads the focused host's chat.
- The phone input context and the chat view's preparation input read the
  chat's model.

Co-authored-by: Copilot <[email protected]>

* Sessions: read whether a session is created from its status

`IActiveSession.isCreated` is the session wrapper's map of `status`:
created once it is no longer untitled. Hosts will show the provider's
session, which has no such member. Add `isSessionCreated(session, reader?)`
next to the other status helpers and read it at every place that asked a
host's or a pane's session, keeping narrowing where the session was
optional.

Test fakes that set `isCreated` now set the `status` that agrees with it,
through the shared `withCreatedStatus` test helper; the layout test session
derives `isCreated` from its status.

Co-authored-by: Copilot <[email protected]>

* Sessions: ask the grid about panes by their hosts

The grid answers which of its panes is active or detached for a pane's own
session object (`isActivePane`/`isDetachedPane`), which identifies a pane only
while each pane has its own copy of the session. Add host-addressed queries
that do not depend on that identity:

- `ISessionGridPanes.isActivePaneHost`/`isDetachedPaneHost`/`isGridPaneHost`:
  the grid host stands for the grid's active pane, the host of a slot's or a
  detached pane's view for that pane, including the new-session slot; other
  hosts, such as a chat window's, for none.
- `ISessionsPartService.getSessionViewOfHost` finds the view of a host.
- `getHostOfSession` keeps its URI signature and uses them.

The session-addressed queries stay until their last caller moves.

Co-authored-by: Copilot <[email protected]>

* Sessions: pane commands find their pane by its host, not its session object

Pane commands, such as Pin, Close or Toggle Maximize, found their pane by
the identity of the session object the pane's toolbars pass. Once panes
share one session object, that names no pane. Name the pane by its host:

- The menus of a pane's header, toolbars and chat tabs append the host's
  command context to their arguments (`sessionMenuArgs`:
  `[session, chat | undefined, hostContext]`), so session-level commands
  shared with the sessions list still get the session first.
- `resolvePaneCommandTarget` resolves the pane of the host the arguments
  name: its view and session for a pane of the grid, else the opener of
  the surface that shows its chat (`getChatHostOpenerOfHost`); without a
  host, as from keybindings, the grid's active pane.
- `resolveSessionCommandTarget` no longer names a host by the identity of
  a session object; a session resolves by its resource.
- The Changes view's action bars pass the command context of their
  window's host too, so its actions, such as skill buttons, act on a chat
  window's chat.
- `ISessionsService.getPaneSessionOfHost` maps a host to the grid's view of
  its pane's session until the pane API replaces it.

Co-authored-by: Copilot <[email protected]>

* Sessions: the grid publishes a pane object per grid slot

Add `ISessionGridPane` (sessionGridPane.ts): a pane of the main window's
grid, a slot or a detached pane, with its kind, the session and chat it
shows, its pin and its tab strip. The grid owns it, and it lives as long
as its grid slot: its id is the slot id, which a replacement of the
session, such as a draft graduating, keeps.

- `VisibleSessions.panes`/`activePane`/`getPane` publish the panes in the
  same transaction as the wrapper arrays and the active session, so no
  reader sees a pane list and a session list that disagree.
- Until the views move to the pane, each pane shows the state of the
  current adapter (`VisibleSession`) of the session incarnation it shows.
  A replacement gives the pane a new adapter, as it gives the grid a new
  wrapper today, and keeps the pane and its id, so views that rebind on a
  new wrapper keep rebinding.
- `ISessionGridPanes.getPaneOfHost(host)`: the grid host stands for the
  active pane, including the new-session slot's; the host of a view of the
  grid for the pane of its slot (`ISessionsPartService.getPaneIdOfHost`);
  other hosts for none. The `*Host` booleans are reimplemented over it.
- Tests: panes of a slot and a detached pane share the session object and
  keep their ids; same- and different-id replacement keeps the panes and
  publishes atomically; a detached active pane writes the remembered
  active chat while closed tabs stay the slot's; a layout of only a
  detached pane saves, restores, closes and reopens.

Co-authored-by: Copilot <[email protected]>

* Sessions: address panes of the grid by pane objects, not session wrappers

`ISessionsService` gains the pane API: `panes`, `slotPanes`, `activePane`,
`activatePane`, `closePane`, `collapseToPane`, `detachChat(pane, chat)`, and
focus, move and resize in a direction by pane. `closeChat` takes the
session. Until the views move to panes, the pane members act through the
adapter of the session incarnation a pane shows.

- `ISessionGridPanes` takes its final shape: `getPaneOfHost(host)`, and
  `isActivePane(host)`/`isDetachedPane(host)`, renamed from the `*Host`
  queries together with their last callers. The queries by session
  wrapper, `isGridPaneHost`, `getPaneSessionOfHost`, `activePaneId` and
  `getSessionPaneId` are removed.
- The part fires `onDidFocusPane` with the slot id of the view that gains
  focus, and focuses a pane by `focusPane`.
- Pane commands act on `IPaneCommandTarget.pane`.
- Migrated to panes: the comparison grid controller (pane ids for its
  isolated judge), Back/Forward's current entry (the active pane's session
  and chat), reopen-closed focus, the window notifier, Sync Changes, the
  conversation actions, and agent feedback channels.
  Request telemetry counts the slots that show a session, as before.
- Focus moves into the active pane when the pane or the session it shows
  changes, but not into the grid's initial pane, and the active pane's
  view listeners rebind for either.
- Test fakes of the sessions service publish panes for their sessions
  (`testGridPanes`, `testGridPane`).

Co-authored-by: Copilot <[email protected]>

* Sessions: hosts of the grid show the provider's session object

A host's session is the provider's `ISession`, one object for every host
that shows it; the state of the pane that shows it, its pin and tab strip,
is the pane's.

- `IHostSession` is `ISession`. `ISessionPaneTabs` and the new
  `IPaneViewState` (pin, tab strip, detached) move to the common layer.
- `setHostSessionContextKeys(session, chat, paneState, ...)` reads the pin
  and tab keys from the pane state. Without a pane, as for the Changes
  view's scoped session actions, the session is not pinned and shows no tab
  strip; only grid-window commands and the session header read those keys.
- `SessionHost` shows a session and a chat of it, observing both without
  owning them. `ActiveSessionHost`, which the chat windows, composers and
  the automation dialog still use, is a subclass that shows a session
  view's active chat.
- The grid host shows the active pane's session and chat. A view's host
  shows the provider's session of the grid's view it binds
  (`canonicalSessionOf`, until views bind their pane).
- `findSessionOfChat`, the input toolbar and its pills take `ISession`. A
  pill action activates the pane of the grid that shows its session
  (`activateSessionPane`): through `setActive` for a session view, else
  the first pane that shows the session object, the pane that showed it
  before.

Co-authored-by: Copilot <[email protected]>

* Sessions: pane views take the content of their pane

The pane chrome takes the content of the pane it is a view of,
`ISessionPaneContent`: the provider's session, the chat the pane shows,
the pane's state (pin, tab strip, detached), and how to close the pane.
A view cannot close its pane by closing the session it shows any more: for
a detached pane that would close the session's slot.

- ChatGroupsView runs on the content: whether the pane is detached
  decides the carried layout, the drop target and persistence; its tabs
  come from the pane's state; closing its last group closes the pane.
- The chat group context, ChatHeader, SessionHeaderBar, ChatCompositeBar
  and SessionRemoteConnection take the provider's session; a chat drag
  and the parent context read whether the pane is detached, and closing
  the main chat's tab closes the pane.
- SessionView builds the content of the grid's view it binds, and closes
  its own pane (`closePane` of its host's pane) only while it still shows
  that content: a content kept past a rebind, such as a replacement of
  the session, or past its pane leaving the grid, closes nothing.
- A chat window's editor builds the content of its window's view of the
  session, and closes through its opener until the window shows the
  provider's session.
- Until the views bind their pane, ChatGroupsView and SessionHeader also
  take a view of a session, as their tests still give them.

Co-authored-by: Copilot <[email protected]>

* Sessions: composers show the provider's session object

The new-session composer, the composer of a new chat in a session and the
automation dialog run on the provider's `ISession`, not a view of it: the
draft a pane or the dialog shows is the provider's draft object itself.

- `IChatViewOptions.session` is the provider's session; a pane passes the
  chat it shows as `chat`. A chat window's editor passes its window's
  active chat the same way.
- NewChatWidget shows the provider's draft (`newSession`) or its pane's
  session without wrapping it; quick chat creation returns the session.
- NewChatInSessionWidget, SharedChatInputComposer, the composer input,
  the migration notice and the worktree suggestion take `ISession`; the
  composer's host is a `SessionHost` of the chat it shows.
- The automation dialog observes the provider's automation draft
  non-owningly; its host and model selection show that draft and its
  main chat.
- `shownChatOf`/`readShownChat` resolve the chat a composer shows while
  views of a session still reach it: the explicit chat, else the view's
  active chat, else the main chat.

Co-authored-by: Copilot <[email protected]>

* Sessions: chat windows show the provider's session object

A chat window shows the provider's `ISession` and the chat of it, which it
observes without owning, instead of a copy of the session scoped to the
chat: closing the window or moving its chat disposes no session.

- A window's chat holds the provider's session and chat; its editor's pane
  shows them as a detached pane does, its one chat. Closing the pane closes
  the chat in its window, through the window's opener, only while the
  window still shows that chat of that session: a content kept past the
  chat being replaced, or ending, closes nothing.
- The window's host and its editor's host are hosts of the provider's
  session and chat; the editor binds the keys of its pane's content.
- The grid no longer special-cases a copy that another surface shows:
  `setActive` and `closeSession` act on the grid only.
- A pill activates the pane its host is in, also from a host nested in
  it. A host of the main window outside its panes, such as the Inbox's,
  activates the pane of this grid that shows the chat it acts on: the
  detached pane of the chat, else the session's slot. A pill in a chat
  window leaves the grid as it is.

Co-authored-by: Copilot <[email protected]>

* Sessions: remove ActiveSessionHost

No host shows a view of a session any more: every host shows the
provider's session and the chat it shows of it. The tests and component
fixtures that built hosts of views of sessions build `SessionHost`s,
giving the chat they show explicitly.

Co-authored-by: Copilot <[email protected]>

* Sessions: the grid's views show its panes

The sessions part renders the grid's panes rather than views of sessions:
the view of each grid slot shows that slot's pane, and binds again as the
pane shows another session, such as a replacement of it, while it follows
the pane's chat and tabs. Code outside the grid's model reads its panes.

- The sessions service renders the panes (`updatePanes`), also as a
  pane's session changes, before it moves focus into the active pane.
  `SessionView.openPane(pane)` binds to the pane's session, and follows a
  replacement by the same object through the pane's tabs and chat.
- The part looks up panes by position, neighbor and view, and maximizes,
  resizes and focuses a pane; `updateVisibleSessions` and the lookups that
  returned views of sessions are removed.
- Moving, focusing and resizing in a direction act on the exact pane, a
  detached one too. The chat commands of the grid read the active pane's
  tabs and chat.
- The readers of the sessions the grid shows read its slot panes, and
  the main window's context keys its active pane.
- The sync-changes button returns focus to the view of its own host.
- Views of sessions remain only for tests, deprecated.

Co-authored-by: Copilot <[email protected]>

* Sessions: service tests show sessions and chats, not views of sessions

The host and pane test helpers take what a host or pane shows (the
provider's session and a chat of it, with a pane's pin, tab strip and
detached state), and accept the old views of sessions transitionally.
Six service suites build their hosts and panes from those.

Co-authored-by: Copilot <[email protected]>

* Sessions: the focused host stub follows the active window entry

stubSessionHostsFromSessionsService found the focused chat window by the
session it shows, so with one session in two windows it always picked
the first. It now picks the window of the active entry.

Co-authored-by: Copilot <[email protected]>

* Sessions: management service tests drive the grid's panes

The tests read the grid through its panes (the active pane, the slots and
the detached panes, and each pane's session, chat, tabs and pin) and act
on panes, rather than through views of sessions.

Co-authored-by: Copilot <[email protected]>

* Sessions: the canvas focus test compares the session it had before

The check compared two reads of the active pane's session after the
operation, which agree whenever the pane does. It now captures the pane
and its session before opening the canvas and compares those.

Co-authored-by: Copilot <[email protected]>

* Sessions: navigation from a detached pane's views stays in that pane

The views of a detached pane passed their own view of the session to
openChat and openNewChatInSession, which kept the navigation in that
pane. Since they pass the provider's session, opening another chat of a
session whose slot is closed replaced another session's slot. They now
pass their host: from a host that stands for a detached pane of the
session, the navigation stays in that pane and the session's slot goes
beside it. Without a host, as from the sessions list, nothing changes.

Co-authored-by: Copilot <[email protected]>

* Sessions: tests fake the active session as a session with its shown chat

A mechanical rename of the IActiveSession type to ITestSessionWithChat in
the tests whose fakes are only ever seen as a session and the chat its
host shows. ITestSessionWithChat, a session fake carrying activeChat,
lives in the test utilities; new tests use ITestShownChat. The tests whose
fakes still reach members typed IActiveSession move in later commits.

Co-authored-by: Copilot <[email protected]>

* Sessions: the parts tests show session fakes through panes and pane contents

The parts tests give their views panes (SessionView.openPane) and pane
contents (ChatGroupsView and SessionHeader setSession) instead of views
of sessions, through test helpers that keep one pane and one content per
session fake, so a view given the same fake keeps what it shows. Their
fakes are sessions that carry the pane state the grid gave them.

No fallout fixes were needed in other tests or fixtures: the shared
session fake keeps lastClosedChat, so it still satisfies the members that
take IActiveSession until they are removed.

Co-authored-by: Copilot <[email protected]>

* Sessions: the chat, chat editor and chat window tests fake sessions with the chat they show

The tests fake the sessions their hosts show as sessions carrying the
chat they show, and give UI a source of the session and chat
(testChatSourceOf), a pane (testPaneOf) or a pane content
(testPaneContentOf) instead of views of sessions. Their sessions service
stubs model the grid's panes with gridShown rather than visibleSessions.

Type-only: the openQuickChat fake in newSessionAction.test returns the
type of ISessionsService.openQuickChat.

Co-authored-by: Copilot <[email protected]>

* Sessions: the contrib tests fake sessions with the chat they show and act on panes

The remaining contrib tests (apart from the providers) fake the sessions
their hosts show as sessions carrying the chat they show, model the
grid's panes with gridShown, and their fakes of the sessions service
and part override the pane members production calls instead of the
members kept for views of sessions.

ITestSessionWithChat now declares, as optional, the pane state legacy
fakes carry (tab strip, pin, isCreated, the chat of a detached pane).

Type-only fixes:
- sessionsActions.test: two openQuickChat fakes return the type of
  ISessionsService.openQuickChat.
- sessionsActions.test and sessionsPolicyBlocked.test: the fakes of
  focusActiveSession pass their session to the part's focusSession as its
  parameter type.
- newChatMigrationNotice.test: isCreated overrides the member it declares
  again.

Co-authored-by: Copilot <[email protected]>

* Sessions: Open in Editor transfers only sessions their provider created

getChatSessionToOpenInEditor decided that a session was created from an
isCreated member, treating its absence as created, so a provider's draft
session (status Untitled, no such member) and its chat could be handed to
another window. It now reads the provider's status (isSessionCreated).
Without a chat, Open in VS Code opens the folders of the session's main
chat rather than of an active chat the session does not have.

Co-authored-by: Copilot <[email protected]>

* Sessions: Sync Changes from a composer syncs the composer's chat

The composer's repository toolbar passes its session to Sync Changes,
which read the active chat of that session. Composers have shown the
provider's session, which has no active chat, so Sync Changes from a
composer threw. The toolbar now passes the chat the composer shows with
its session, and the action syncs that chat.

Changed expectation: the sessionSyncChanges test of the menu action, which
mirrors the composer's argument, now expects { session, chat } instead of
{ session }, as the composer passes.

Co-authored-by: Copilot <[email protected]>

* Sessions: subagent chat links look up the sessions of the grid's slots

The subagent chat lookup reads the sessions of the grid's slots from its
panes rather than from the views of sessions the grid kept for them: the
same sessions in the same order, without the new-session slot. Its tests
fake the grid with the slot panes, and a test pins the order and the
skipped new-session slot.

Co-authored-by: Copilot <[email protected]>

* Sessions: the provider tests fake sessions with the chat they show

The provider tests fake the sessions their hosts show as sessions carrying
the chat they show, give UI a source of the session and chat
(testChatSourceOf) instead of views of sessions, and model the grid's
panes with gridShown rather than visibleSessions.

Co-authored-by: Copilot <[email protected]>

* Sessions: the fixtures fake sessions with the chat they show

The component fixtures fake sessions as the tests do: as the provider's
session with the chat a pane shows (`ITestSessionWithChat`), with the
grid's shown sessions in `gridShown` and its slot panes built from them,
instead of the deprecated `IActiveSession` and `visibleSessions`.

- The grid fixture activates a focused pane through a fixture-local
  `activate`, and maximizes the left session through its view's pane.
- The workbench fixture utils count slot panes for the multiple-sessions
  key, and the part fake maximizes a pane.

No fixture renders differently: every `sessions/**/Light` fixture renders
the same before and after this change.

Co-authored-by: Copilot <[email protected]>

* Sessions: the session pills fixtures provide the window's session host

The session chat input toolbar takes the host it is shown in since chat
windows show the provider's session object, and the session pills and
chat reference fixtures failed to render without one. Their services now
provide the main window's host of the fixture session and chat, which the
input banners already used, so the toolbar and the banners share it.

Co-authored-by: Copilot <[email protected]>

* Sessions: the workbench session fixtures fake sessions with the chat they show

The session component fixtures under the workbench fake sessions as the
other fixtures do: as the provider's session with the chat a pane shows
(`ITestSessionWithChat`), and the grid's shown sessions in `gridShown`
with its slot panes built from them, instead of `IActiveSession` and the
deprecated `visibleSessions`.

- The pills fixture's session carries no pane state, so it is an
  `ISession`.
- The header fixture gives the header its pane's content
  (`testPaneContentOf`), which the header built from the session before.
- The composite bar's fake keeps its tab strip's `shouldShowChatTabs`
  required.

No fixture renders differently: every `sessions/` fixture renders the same
before and after this change.

Co-authored-by: Copilot <[email protected]>

* Sessions: remove the session-view entry points of the grid, its part and its views

The grid, its part and its views are addressed by pane only. The members
that took a view of a session in a pane (`IActiveSession`) go, with the
helpers that converted one. `IActiveSession` remains only inside the
grid's model, which the next commits rewrite.

- `ISessionsService` loses `visibleSessions`, `visibleSessionPanes`,
  `setActive`, `focusSessionInDirection`, `moveSessionInDirection`,
  `resizeSession` and `collapseToSession`. The service keeps the ones
  its model still drives as private members.
- `ISessionsPartService` loses `focusSession` and
  `toggleMaximizeSession`. `focusNewSessionSlot` replaces
  `focusSession(undefined)`, the one use left, and focuses the same view.
- `SessionView.openSession` goes. `SessionHeader.setSession` and
  `ChatGroupsView.setSession` take their pane's content only, and the
  header no longer depends on the sessions service.
- `paneContentOf`, `isSessionPaneContent`, `canonicalSessionOf`,
  `paneViewStateOfActiveSession`, `setActiveSessionContextKeys`,
  `sessionChatSourceOf` and `readShownChat` go.
- A surface given no chat shows its session's main chat: `shownChatOf`
  and the composer's bound chat no longer read the active chat of a view
  of a session. No surface relies on it: the grid's composers pass their
  pane's chat, and other composers show provider sessions.
- `openQuickChat` returns the provider's session. The github PR and
  issue actions take sessions.

Tests:
- Fakes of the service and the part override the pane members and
  `focusNewSessionSlot`, keeping their recorded labels. Service fakes
  record `focusActiveSession` themselves instead of through the part.
  Host stubs read `gridShown` only.
- `testPaneContentOf` gives the main chat when a fake has no active
  chat, as a session view gives its content.
- Tests that relied on the active-chat fallback pass their chat.
- Changed expectation: the composer test now pins the main chat
  ("binds the host's chat when it has one, otherwise the session's main
  chat"); with the old fallback it binds the fake's active chat.

Co-authored-by: Copilot <[email protected]>

* Sessions: the grid's model publishes panes, not its views of sessions

The grid's model publishes its panes and the sessions of its slots, the
provider's sessions, instead of the views of sessions it keeps per pane.
The sessions service reads the grid only through its panes. The model
still keeps a view of each session inside, which the next commit
replaces.

Model:
- `gridSessions`, `activeSession`, `visibleSessions`, `getGridSession`
  and `getAdapterOfPane` are no longer public, and `isActivePane`,
  `isDetachedPane` and `isGridPane`, which nothing called, go.
- `slotSessions` publishes the sessions of the slots as `visibleSessions`
  published their views: in the same order and transactions, with
  `undefined` for the new-session slot.
- `setActive` takes a session or one of the grid's own panes, and ignores
  another grid's pane. `getChatPane` returns the detached pane.

Service:
- The chat a detached pane shows, its `chat`, replaces the scoped chat of
  its view. A pane's active chat follows its pane.
- `closePane` attaches the chat of a detached pane back to its slot;
  `closeSession` closes a slot. Closed-session history and the new-session
  discard get the provider's session.
- The reactions to the active pane read the chat it shows of their
  session only while it shows that session, as they read the chat of the
  session's view before.
- The grid state saves its bindings from the panes, as version 1 did.

Tests:
- The model's tests read panes. Two tests whose subject was the view
  are renamed for the pane, with the same expectations: "the active pane
  shows the provider's session itself, with its metadata" and "replaces
  the session of the pane even when the session id is unchanged".
- The atomic replacement test reads the slot sessions and the active
  pane's session; its four variants and expected values are unchanged.
- New: "a stored grid of slots and a detached chat restores and saves
  back byte for byte (v1)", which also passes on the previous commit.

Co-authored-by: Copilot <[email protected]>

* Sessions: the tab tests of a session's slot drive the grid

The tests of a session's tab state drive a grid that shows the session in
a slot, instead of the view of the session the grid keeps per slot: the
grid seeds the slot from the session's persisted state, the tab
operations go through the grid, and the state is read from the slot's
pane. Their bodies and expectations are unchanged.

The test of the view forwarding every session property goes: a pane shows
the provider's session itself, which "the active pane shows the
provider's session itself, with its metadata" covers.

Co-authored-by: Copilot <[email protected]>

* Sessions: the grid round-trip test compares what the restored grid writes

The test of a stored grid restoring and saving back byte for byte removes
the stored state after the restore, so it compares what the restored grid
writes with what it was restored from. Before, the stored state was still
there, and the test passed even if the restored grid wrote nothing.

Co-authored-by: Copilot <[email protected]>

* Sessions: the provider's model selection test shows the draft's own chat

The test of the shared model selection for automation drafts gives the
selection the draft and its main chat, as the composer shows them,
instead of a view of the draft that the grid keeps per slot. Its
expectations are unchanged.

Co-authored-by: Copilot <[email protected]>

* Sessions: a pane keeps the state of the session it shows, not a view of it

The grid's model no longer wraps the sessions it shows. Each pane keeps
the state of the incarnation of the session it shows, and a replacement
of the session swaps that state in one transaction, keeping the pane:
- the state of a session's slot: its active chat, and its tab strip
  with the chats closed in it, the subagent chats shown in it and the
  chats other panes or windows show;
- the state of a detached pane: the one chat of its session it shows,
  and that chat as its tab strip.

The state is not a session: it doesn't forward the session's properties
or carry its active chat's model and mode, and `IActiveSession` goes. A
detached pane is its state's kind, not a session scoped to a chat.

Co-authored-by: Copilot <[email protected]>

* Sessions: the session of a host is ISession, and the last session-view names go

- `IHostSession`, an alias of `ISession`, goes: hosts show the provider's
  session itself (by tool, 28 files).
- The test-only fake's detached flag is `detachedChat`, not
  `scopedChatResource`, which production no longer has (by tool).
- The sessions part's `toggleMaximizeSession`, which nothing calls, goes,
  and its `focusSession` is `focusNewSessionSlot`: it was only called to
  focus the new-session slot, which it finds as before.

Co-authored-by: Copilot <[email protected]>

* Sessions: document one session object per session

The session host contract and the layout documents describe the grid
after the session views went: every host shows the provider's session
object, and the grid keeps each pane's state (the chat it shows, its tab
strip, its pin), with a detached pane as a kind of pane.

Co-authored-by: Copilot <[email protected]>

* Sessions: a pane view keeps showing its session until it binds the next one

A pane outlives the sessions it shows, and a view of it bound its content to the pane's own tabs and chat. Opening a session over the one a slot shows changed those before the view was bound to the new session: for a moment the view showed the old session with the new session's tabs, so its chat group found no chat of the old session, built a new-chat composer, and then a chat view again for the new session, instead of handing its chat view over.

The content a view binds now follows the pane only while the pane shows that session, and keeps what it last was afterwards (paneShownOfSession). The view keeps its chat view and hands it to the next session, as before panes were introduced.

Co-authored-by: Copilot <[email protected]>

* Sessions: the grid fixtures fake the pane lookups the pane commands use

The header's pane commands resolve their target from the host their menu
passes: the part service's view of that host, then the sessions service's
activatePane (Maximize) and closePane (Close). The grid fixtures' fakes
lacked those, so Maximize from a pane's More Actions threw before it
maximized, failing the Playwright test "sessions grid header actions
update their owning state".

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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.

4 participants