Skip to content

sessions: Reveal tunnel sessions across Editor and Agents windows - #346290

Merged
Christof Marti (chrmarti) merged 4 commits into
mainfrom
chrmarti/remote-session-reveal
Nov 8, 2026
Merged

Christof Marti (chrmarti) merged 4 commits into
mainfrom
chrmarti/remote-session-reveal

Conversation

@chrmarti

@chrmarti Christof Marti (chrmarti) commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #345832 (microsoft/vscode-internalbacklog#10484).

What changed

When you switch between an editor window and the Agents Window, the open session is revealed in the other window for local Copilot sessions. Remote sessions weren't revealed. A remote editor window treats the agent host on its remote machine as its own and names those sessions agent-host-<provider>:, while the Agents Window names the same sessions remote-<authority>-<provider>: after its connection to that host. Neither window could find the other's session.

  • Editor → Agents Window. For a session of its own agent host, a remote editor window now also sends its remote authority (the new revealRemoteAuthority option) and its workspace folder, so the Agents Window can identify the machine. The Agents Window resolves the host with the new IRemoteWorkspaceHandoffService.resolveHost, which reuses the folder handoff's matching, registration, sign-in and connection steps. It then maps the scheme with toRemoteAgentHostSessionType and opens the session once it appears, unless that chat is already shown.
  • Agents Window → Editor. getEditorWindowSessionResource maps a remote session back to the editor window's local scheme with toLocalAgentHostSessionType. Both the desktop and web Open in Editor actions use it.
  • Visible Open in Agents Window. The editor action that reveals the session was contributed only to the title-bar Chat menu. That menu evaluates when clauses against the window context, but the chatSessionType key the action checks exists only in the Chat view's scoped context, so the action never appeared. It now appears in the Chat view's title "..." menu after the Move Chat actions, and is reported with the chatViewTitle open source.
  • Tunnels only. Only code tunnel bridges its VS Code servers to one agent host, so only tunnels share sessions between the two window types. SSH, WSL and Dev Container editor windows use an agent host started by their VS Code server, with a session registry separate from the agent host the Agents Window starts. The window's folder opens instead of the session. Moving a session from the Agents Window to such an editor window also shows a notification instead of failing silently. In the other direction, the Agents Window selects the editor window's remote and folder without a notification, as the folder handoff does.
  • Tunnels whose gateway selected an editor's agent host. A protocol-v6 tunnel gateway can connect the Agents Window to a running editor's agent host instead of the standalone one the tunnel's VS Code server uses. The tunnel services now record the server type the gateway selected (ITunnelAgentHostService.getSelectedServerType). When it is 'editor', both directions treat the handoff as unsupported, with a notification and the same folder fallback.
  • The remote agent host provider spec gains a paragraph on this.

Reviewer notes

  • Unifying the SSH, WSL and Dev Container hosts, e.g. by bridging the VS Code server to the CLI-started agent host as tunnels do, would extend this to those remotes. That is out of scope here and tracked in Share agent host sessions between the Agents Window and WSL, SSH and Dev Container editor windows #346859.
  • OpenChatSessionInAgentsWindowAction is still offered only for Copilot CLI sessions. The chat editor still doesn't show it, because its title menu can't see the widget's scoped context. The title-bar "Open in Agents" still opens only the workspace.
  • If the tunnel's connection fails, the handoff reports the failure itself. If the session doesn't appear on the connected host, a notification says it couldn't be found.
  • The selected server type is a client-side approximation of host identity. Full instance-identity verification is deferred, because the gateway's instance ID doesn't reach the VS Code server's agent host. With several standalone instances on one machine, the server and the gateway could still pick different ones.

How to test

  1. In a tunnel editor window, open a Copilot CLI agent host session in the Chat view and run Open in Agents Window from the view's "..." menu. The Agents Window connects the tunnel's remote agent host and opens the same session.
  2. In the Agents Window, open a session on a tunnel's remote agent host and run Open in Editor. The editor window opens the folder and the same session.
  3. Repeat both from an SSH or WSL window or host. The window's folder opens instead of the session. Going to the editor, a notification also explains that the session can't be opened there.

Validation

  • pnpm run typecheck-client: passed.
  • pnpm run valid-layers-check: passed.
  • pnpm run eslint <14 changed TypeScript files>: passed.
  • pnpm run build-fast --client-only, then .\scripts\test.bat --reporter dot --run <7 affected test files>: 198 passing.
  • .\scripts\test.bat --reporter dot --run for the resolveRemoteAuthority, chatWindowEditorArea and agentHostConnectionsService tests: 65 passing.
  • After the menu change, .\scripts\test.bat --run for the agentSessionsActions and agentSessionsDraftHandoff tests: 99 passing; pnpm run eslint on the changed files: passed.
  • After rebasing and addressing review feedback:
    • pnpm run typecheck-client: passed.
    • pnpm run valid-layers-check: passed.
    • pnpm run eslint <25 changed TypeScript files>: passed.
    • pnpm run build-fast --client-only, then .\scripts\test.bat --reporter dot --run for the agentsWindow, agentSessionsActions, agentsWindowWorkspaceHandoff, both vscodeActions, remoteWorkspaceHandoffService, tunnelAgentHost.contribution, browserTunnelAgentHostService and tunnelAgentHostServiceImpl tests: 166 passing.
  • After dropping the SSH/WSL notification in the Agents Window: pnpm run build-fast --client-only, then .\scripts\test.bat --run for the agentsWindowWorkspaceHandoff tests: 16 passing; pnpm run eslint on the changed files: passed.
  • After rebasing onto main at 21fe348d869: pnpm run typecheck-client: passed; pnpm run eslint <28 changed TypeScript files>: passed; pnpm run build-fast --client-only, then .\scripts\test.bat --reporter dot --run <9 changed test files>: 201 passing.
  • Agents Window → Editor manually verified against a real tunnel in Code OSS, with an Insiders commit and quality in product.overrides.json so the tunnel serves a matching server. Editor → Agents Window and SSH/WSL remotes not yet verified end to end.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 16:52

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

Unresolved handoff bugs can discard workspace folders, route sessions to the wrong agent host without warning, and leave the wrong chat visible.

3 open issues
What changed in this PR

Extends the existing remote-folder handoff to reveal tunnel-hosted sessions when switching between Editor and Agents windows.

Changes:

  • Adds session-type translation and remote-host resolution for cross-window session reveals.
  • Updates desktop and web Open in Editor actions, with notifications for unsupported remote sessions.
  • Adds handoff tests and documents the tunnel-specific behavior.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​electron-browser/​agentSessionsDraftHandoff.test.ts Adds the environment-service test stub.
src/​vs/​workbench/​contrib/​chat/​test/​electron-browser/​agentSessionsActions.test.ts Tests remote-machine context in session handoffs.
src/​vs/​workbench/​contrib/​chat/​electron-browser/​agentSessions/​agentSessionsActions.ts Sends remote workspace context with session reveals.
src/​vs/​sessions/​test/​electron-browser/​vscodeActions.test.ts Tests tunnel translation and unsupported-remote notifications.
src/​vs/​sessions/​test/​browser/​vscodeActions.test.ts Updates web action test dependencies.
src/​vs/​sessions/​electron-browser/​actions/​vscodeActions.ts Maps sessions before opening desktop Editor windows.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​test/​browser/​remoteWorkspaceHandoffService.test.ts Tests host resolution and connection outcomes.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md Documents cross-window session handoffs and limitations.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​remoteWorkspaceHandoffService.ts Extracts host resolution and reports connection completion.
src/​vs/​sessions/​contrib/​chat/​test/​electron-browser/​agentsWindowWorkspaceHandoff.test.ts Tests remote session routing and failure notifications.
src/​vs/​sessions/​contrib/​chat/​electron-browser/​chat.contribution.ts Resolves tunnel hosts and reveals mapped sessions.
src/​vs/​sessions/​common/​remoteWorkspaceHandoff.ts Defines the host-resolution contract.
src/​vs/​sessions/​browser/​openInVSCodeUtils.ts Adds shared session mapping and notification helpers.
src/​vs/​sessions/​browser/​actions/​vscodeActions.ts Applies session mapping to web Open in Editor links.
src/​vs/​platform/​agentHost/​common/​agentHostSessionType.ts Adds local/remote session-type conversion helpers.

Review effort: Balanced

A tunnel's editor windows and the Agents Window share code tunnel's agent host, but name its sessions differently: agent-host-<provider> in the editor window and remote-<authority>-<provider> in the Agents Window. Map the session scheme in both directions so the open session is revealed when switching windows, as it already is for local sessions. The editor window passes its folder so the Agents Window can resolve and connect the host first.

SSH, WSL and Dev Container editor windows use an agent host started by their VS Code server, with a session registry separate from the one the Agents Window starts, so their sessions can't move between windows. Both directions now explain this instead of failing silently.

Co-authored-by: Copilot <[email protected]>
The action was only contributed to the title-bar Chat menu, which evaluates its when clause against the window context. The session type it checks is set only in the Chat view's scoped context, so the action never appeared. Move it to the Chat view's title menu, next to the Move Chat actions, and report it as a separate open source.

Co-authored-by: Copilot <[email protected]>
- Treat a tunnel whose gateway selected an editor's agent host as a different host, in both directions
- Fall back to opening the remote window's folder when its session can't be revealed
- Compare the focused host's shown chat in the fast path

Co-authored-by: Copilot <[email protected]>
@chrmarti
Christof Marti (chrmarti) force-pushed the chrmarti/remote-session-reveal branch from cfe53d2 to f47d830 Compare November 8, 2026 20:12
@chrmarti
Christof Marti (chrmarti) marked this pull request as ready for review November 8, 2026 20:36
@chrmarti
Christof Marti (chrmarti) merged commit 864824b into main Nov 8, 2026
52 checks passed
@chrmarti
Christof Marti (chrmarti) deleted the chrmarti/remote-session-reveal branch November 8, 2026 21:19
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants