Repository navigation
sessions: Open remote editor folders on their remote agent hosts - #345832
Merged
Christof Marti (chrmarti) merged 7 commits intoNov 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues can route handoffs to the wrong SSH account or endpoint, allow cancelled requests to mutate state, and falsely report success when workspace-less session creation fails.
4 open issues
What changed in this PR
This PR carries remote editor folders into the Agents Window on the matching remote agent host, rather than falling back to an unrelated local workspace.
Changes:
- Adds SSH, WSL, Tunnel, and remote Dev Container folder resolution, host registration, and connection.
- Adds explicit no-workspace handling for unavailable remotes while preserving existing sessions and user choices.
- Extends remote-kind telemetry, SSH authority encoding, tests, and provider documentation.
| File | Description |
|---|---|
| src/vs/sessions/test/browser/resolveRemoteAuthority.test.ts | Tests SSH authority encoding compatibility. |
| src/vs/sessions/sessions.desktop.main.ts | Registers the desktop handoff implementation. |
| src/vs/sessions/contrib/sessions/test/browser/sessionsWorkspaceSelectionTelemetry.test.ts | Updates selection telemetry expectations. |
| src/vs/sessions/contrib/sessions/test/browser/sessionsWindowOpenTelemetry.test.ts | Tests remote-kind opening telemetry. |
| src/vs/sessions/contrib/sessions/test/browser/sessionsActions.test.ts | Updates the no-workspace test stub. |
| src/vs/sessions/contrib/sessions/browser/sessionsWorkspaceSelectionTelemetry.ts | Records remote kind in selection outcomes. |
| src/vs/sessions/contrib/sessions/browser/sessionsWindowOpenTelemetry.ts | Records remote kind in opening events. |
| src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteWorkspaceHandoffService.test.ts | Tests parsing, host registration, and connection. |
| src/vs/sessions/contrib/providers/remoteAgentHost/REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md | Documents remote handoff registration. |
| src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteWorkspaceHandoffService.ts | Resolves folders and registers matching hosts. |
| src/vs/sessions/contrib/chat/test/electron-browser/agentsWindowWorkspaceHandoff.test.ts | Tests desktop remote-intent forwarding. |
| src/vs/sessions/contrib/chat/test/browser/newChatWidget.test.ts | Tests inferred no-workspace defaults. |
| src/vs/sessions/contrib/chat/test/browser/agentsWindowWorkspaceHandoff.test.ts | Tests remote selection and unavailable-host handling. |
| src/vs/sessions/contrib/chat/test/browser/agentsWindowOpenIntent.test.ts | Tests remote classification and folder mapping. |
| src/vs/sessions/contrib/chat/electron-browser/chat.contribution.ts | Forwards remote intent and telemetry context. |
| src/vs/sessions/contrib/chat/browser/newChatWidget.ts | Adds acknowledged no-workspace selection. |
| src/vs/sessions/contrib/chat/browser/chatView.ts | Returns widget selection outcomes. |
| src/vs/sessions/contrib/chat/browser/agentsWindowWorkspaceHandoff.ts | Coordinates remote resolution and fallback notifications. |
| src/vs/sessions/contrib/chat/browser/agentsWindowOpenIntent.ts | Parses remote and Dev Container source folders. |
| src/vs/sessions/common/workspaceSelection.ts | Defines bounded remote-kind telemetry values. |
| src/vs/sessions/common/remoteWorkspaceHandoff.ts | Defines the provider-neutral handoff contract. |
| src/vs/sessions/browser/parts/sessionView.ts | Propagates no-workspace selection results. |
| src/vs/sessions/browser/parts/chatView.ts | Extends the no-workspace selection contract. |
| src/vs/sessions/browser/parts/chatGroupView.ts | Propagates results through individual groups. |
| src/vs/sessions/browser/parts/chatGroupsView.ts | Propagates results through the active group. |
| src/vs/sessions/browser/openInVSCodeUtils.ts | Aligns SSH authority encoding with Remote - SSH. |
Review effort: Balanced
Opening the Agents Window from an SSH, WSL or Tunnel editor window lost the folder: only local folders and local Dev Containers were handed off, so the composer fell back to an unrelated local folder. The window opening handoff now resolves the remote folder through a provider-neutral IRemoteWorkspaceHandoffService, which matches or adds the remote agent host on the same machine, preselects the folder and connects the host. Dev Containers on SSH, Tunnel and WSL hosts resolve to their source folder on that host. Remotes that cannot be used start without a workspace and explain why instead of falling back to a local folder. Authority parsing and the SSH authority encoding of Open in Editor now mirror the Remote - SSH, WSL, Tunnels and Dev Containers extensions. Telemetry gains a bounded workspaceArgumentRemoteKind. Fixes microsoft/vscode-internalbacklog#10484 Co-authored-by: Copilot <[email protected]>
…andoffs Restoring a saved 'no workspace' choice when the composer starts reported a user selection and a navigation. That cancelled a pending handoff from an editor window before its remote folder resolved, so the Agents Window silently kept the previous choice. Restore it without either, like the automatic fallback next to it. Co-authored-by: Copilot <[email protected]>
When no signed-in account lists the tunnel and an account needs to sign in first, sign in with that account and look again. Cancelling the sign-in explains that signing in is needed. An account without tunnel configuration failing to list no longer hides the sign-in behind 'No authentication is available to enumerate tunnels.' Co-authored-by: Copilot <[email protected]>
Opening the folder of a Tunnel editor window started a sign-in without explanation. Ask first, naming the account and why it is needed. Declining explains that signing in is needed, like cancelling the sign-in. Co-authored-by: Copilot <[email protected]>
Like Remote - SSH, an SSH authority without a user or port connects with the user and port of SSH config. Match and store hosts by those effective values, so an omitted user no longer matches another account's host and an omitted port no longer stands for port 22. An entry without a port connects on SSH config's port, so it matches by that port. A cancelled handoff no longer stores a host, caches a distribution or tunnel, clears a tunnel dismissal or asks to sign in. Every lookup now fails once the handoff is cancelled, even if the lookup already completed. Co-authored-by: Copilot <[email protected]>
Starting without a workspace for a window-open handoff reported success as soon as the picker showed no workspace, even when no quick chat could be opened yet and the previous draft stayed the session. Report it as not ready instead, so the handoff keeps trying until a quick-chat target is available. Co-authored-by: Copilot <[email protected]>
A tunnel the Agents Window already knew skipped the sign-in check, so a signed-out account made the connection fail with 'No cached authentication available to connect the tunnel.' Before connecting a known tunnel, check that its account can authenticate, and otherwise explain and offer the sign-in, as for a tunnel that still has to be found. Declining explains that signing in is needed to connect. Co-authored-by: Copilot <[email protected]>
Christof Marti (chrmarti)
force-pushed
the
chrmarti/agents-window-remote-handoff
branch
from
November 5, 2026 10:30
9303ebb to
1886939
Compare
Christof Marti (chrmarti)
marked this pull request as ready for review
November 5, 2026 11:12
Alexandru Dima (alexdima)
approved these changes
Nov 5, 2026
Christof Marti (chrmarti)
deleted the
chrmarti/agents-window-remote-handoff
branch
November 5, 2026 13:06
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes 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-remotefolders through a new provider-neutralIRemoteWorkspaceHandoffService(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'svscode-agent-hostURI 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.selectNoWorkspacenow returns aWorkspaceSelectionResultand honorsisDefault, likeselectWorkspace.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/firstTimeWindowOpenandagents/workspaceSelectionOutcomegain a boundedworkspaceArgumentRemoteKind: 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:
[user@]host[:port]wsl+defaultandwsl+<distro>@<host>tunnel+<name>andtunnel+<id>.<cluster>, looked up with both the GitHub and Microsoft accounts\\wsl\,\\wsl$\and\\wsl.localhost\prefixessshAuthorityString(Open in Editor) now mirrors Remote - SSH'sHostInfo.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
alias:porttyped by hand._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.signIn, so on the web the handoff still only explains that signing in is needed.How to test
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."code --agents --folder-uri vscode-remote://wsl+NoSuchDistro/home/me/projectstarts with no workspace and explains that the WSL distribution was not found.Validation
After rebasing onto
mainat8b007fabde2. The rebase adapted the inferred-default check to the focused session host, which replacedISessionsService.activeSessionin #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:
userChangedabout 1.6 s after the window opened. The tunnel lookup that kept running found GitHub needing a sign-in and Microsoft unconfigured.