Repository navigation
sessions: Share SSH, WSL and tunnel agent hosts as GitHub environments - #347402
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can expose GitHub tokens in debug logs, leave or restore sharing after disablement, sign-out, or unsharing, and prevent credential refresh after reconnects.
5 open issues
Redact credentials from registration request logs · New Reconcile sharing changes across application windows · New Withdraw registrations when the owning GitHub account is lost · New Prevent stale registration attempts from bypassing sharing gates · New Re-register remotes after soft reconnects · New
What changed in this PR
Adds GitHub environment sharing for SSH, WSL, and Dev Tunnel agent hosts through the Remotes editor, allowing other supported applications to reach those hosts using the same GitHub account.
Changes:
- Adds capability-gated registration methods for direct clients and keeps registered remote servers alive.
- Introduces persistent sharing choices, reconnect synchronization, and duplicate-environment filtering.
- Adds sharing controls, accessible status descriptions, and focused tests.
| File | Description |
|---|---|
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/test/browser/remotesWidget.test.ts |
Extends the widget test model with sharing operations. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/test/browser/remotesWidget.fixture.ts |
Adds sharing support to the component fixture. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/test/browser/remotesModel.test.ts |
Tests sharing gates, deduplication, and removal ordering. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/browser/remotesWidget.ts |
Handles sharing actions and accessible row state. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/browser/remotesTable.ts |
Renders sharing controls, indicators, and tooltips. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/browser/remotesModel.ts |
Integrates sharing state and withdrawal before removal. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/browser/missionControlAgentHostContribution.ts |
Excludes shared remotes from duplicate picker entries and auto-connect. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/browser/media/remotesWidget.css |
Styles sharing indicators and their hidden state. |
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/remoteGitHubEnvironmentSharingService.test.ts |
Tests registration, gating, account changes, and deferred withdrawal. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteGitHubEnvironmentSharingService.ts |
Implements persistent remote sharing and synchronization. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHost.contribution.ts |
Registers the remote sharing service. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.ts |
Reuses the extracted authentication helper. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/gitHubEnvironmentAccount.ts |
Centralizes GitHub account and session selection. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/electron-browser/remotesEditor.test.ts |
Updates the editor test model for sharing. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/missionControlAgentHostContribution.test.ts |
Tests shared-remote picker and auto-connect exclusions. |
src/vs/sessions/contrib/providers/remoteAgentHost/electron-browser/remotes.contribution.ts |
Documents sharing in accessibility help. |
src/vs/server/test/node/serverAgentHostManager.test.ts |
Tests registration-based server lifetime retention. |
src/vs/server/node/serverAgentHostManager.ts |
Keeps the server alive while client sharing is registered. |
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts |
Tests direct-client registration and relay restrictions. |
src/vs/platform/agentHost/test/node/missionControlClientRegistration.test.ts |
Tests ownership, credential refresh, and failure cleanup. |
src/vs/platform/agentHost/node/protocolServerHandler.ts |
Advertises and handles gated registration methods. |
src/vs/platform/agentHost/node/missionControl/missionControlClientRegistration.ts |
Manages host registration for one client account. |
src/vs/platform/agentHost/node/agentHostMain.ts |
Wires registration into CLI-launched hosts and lifetime notifications. |
src/vs/platform/agentHost/common/missionControlEnvironment.ts |
Defines the remote sharing service contract. |
src/vs/platform/agentHost/common/meta/agentHostGitHubEnvironmentMeta.ts |
Defines and reads the sharing capability. |
src/vs/platform/agentHost/common/agentService.ts |
Adds registration methods and lifetime events to interfaces. |
src/vs/platform/agentHost/common/agentHostExtensionProtocol.ts |
Defines registration requests, validators, and results. |
src/vs/platform/agentHost/browser/agentHostProtocolClient.ts |
Sends capability-checked registration and withdrawal requests. |
Review effort: Balanced
Adds a Share as GitHub Environment action to the Remotes table. A directly connected client registers the remote agent host with its own GitHub account through a VS Code-private AHP extension method, so other apps that support GitHub environments can reach that agent host. Co-authored-by: Copilot <[email protected]>
The share action kept a fixed label and only set checked, which the Remotes toolbar does not render. Swap the label like Connect/Disconnect instead. Co-authored-by: Copilot <[email protected]>
The agent host now reports its GitHub environment registration in the initialize and reconnect metadata and broadcasts changes to its direct clients. The Remotes editor derives Share/Stop Sharing from that status, so the state stays correct across windows, machines, host restarts and GitHub accounts, and shows a disabled state when another account or the host itself registered the remote. Co-authored-by: Copilot <[email protected]>
Runs when the WSL AgentHost is of the client's build, as in Azure product builds, and checks that the Remotes editor offers to share it as a GitHub Environment. Co-authored-by: Copilot <[email protected]>
5555c5c to
92bdab8
Compare
There was a problem hiding this comment.
🟡 Changes recommended
GitHub tokens are exposed in transport logs, and signing out or changing accounts can leave prior remote shares and credentials active.
7 open issues
Prevent stale registration attempts from bypassing sharing gates Withdraw registrations when the owning GitHub account is lost Reconcile sharing changes across application windows Redact credentials from registration request logs Invalidate sync state when a remote disconnects · New Persist failed withdrawals for retry · New Re-register remotes after soft reconnects
Review effort: Balanced
Redact registration credentials in AHP logs, follow sharing changes from other windows, withdraw shares when the account signs out, re-register after protocol reconnects, and retry stopping shares from other computers after the next connection. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
An adopted share is marked synchronized even when the window’s availability/AI gate is closed, causing sync to skip withdrawal and leave the registration active.
1 open issue
7 resolved since last review
Prevent stale registration attempts from bypassing sharing gates Withdraw registrations when the owning GitHub account is lost Reconcile sharing changes across application windows Redact credentials from registration request logs Persist failed withdrawals for retry Invalidate sync state when a remote disconnects Re-register remotes after soft reconnects
Review effort: Balanced
A window whose GitHub environments are disabled no longer marks a share another window added as synchronized, so it withdraws the registration while keeping the stored choice. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because a stalled operation can block unrelated remotes’ sharing withdrawals, allowing disconnection before withdrawal and leaving an environment shared.
No open issues 🎉
1 resolved since last review
Review effort: Balanced


Adds a Share {0} as GitHub Environment row action to SSH, WSL and Dev Tunnel remotes in the Remotes editor. Sharing registers the remote's existing agent host as a GitHub environment with the user's GitHub account, so other apps that support GitHub environments can reach it. Once a remote is shared, the action changes to Stop Sharing {0} as GitHub Environment.
How it works
vscode/registerGitHubEnvironment(account id + credential) andvscode/unregisterGitHubEnvironment(account id)._metakeyvscode.githubEnvironmentin the initialize and reconnect results, and broadcast changes with thevscode/githubEnvironment/changednotification. The status is{ instanceId, registration?: { accountId, environmentId, name }, registeredByHost? }:instanceIdidentifies the agent host process. A registration doesn't survive a restart, so a new id tells clients to register again.registeredByHostmeans the host registered itself through the CLI--github-environmentbootstrap.MissionControlClientRegistrationregisters the host with the client's credential (projects: []), keeps the registration fresh and reports its status. It serves one owner account per agent host and refuses a host that is already registered through the bootstrap. It is only created for agent hosts launched by the VS Code CLI (SSH, WSL and tunnel servers).IRemoteGitHubEnvironmentSharingServicecombines it with the user's stored choice per remote:instanceId): registers again with a fresh credential.vscode/registerGitHubEnvironmentrequests.Notes for reviewers
true. Clients now ignore that value and treat the host as unsupported; the protocol is unreleased.WSL_DISTRO_NAMEfor the environment name. I haven't verified that this variable reaches the agent host process.Smoke test
The
Agents Window (WSL AgentHost, Kerberos proxy)suite gets a test that opens the Remotes editor, connects the WSL remote if needed, and waits for its Share … as GitHub Environment action. The action appears only if the WSL agent host reports a GitHub environment status, so the test covers the host side, the protocol and the client. Sharing itself needs a GitHub account and isn't exercised.The test runs only when the WSL agent host is of the client's commit, as in Azure product builds, which run this build's Linux server in WSL. PR CI runs a published server, so the test skips there.
Validation
pnpm run oxlint <changed files>: passedpnpm run typecheck-client: passedpnpm run valid-layers-check: passedpnpm run build-fast --client-only: passedtest/smoke:pnpm run compile: passedscripts\test.bat --reporter dot --run src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts --run src/vs/platform/agentHost/test/node/missionControlClientRegistration.test.ts --run src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/remoteGitHubEnvironmentSharingService.test.ts --run src/vs/workbench/contrib/sessions/providers/remoteAgentHost/test/browser/remotesModel.test.ts --run src/vs/workbench/contrib/sessions/providers/remoteAgentHost/test/browser/remotesWidget.test.ts: passedscripts\test.bat --reporter dot --run src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts: passedscripts\test.bat --reporter dot --run src/vs/platform/agentHost/test/common/ahpJsonlLogger.test.ts --run src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/remoteGitHubEnvironmentSharingService.test.ts: passed (after the review fixes)serverAgentHostManager.test.ts,missionControlEnvironmentService.test.ts,missionControlAgentHostContribution.test.tsandremotesEditor.test.ts.Run WSL Kerberos proxy smoke tests (Electron)and passed (Offers to share a WSL AgentHost as a GitHub Environment).Windows / Electron-Smoke (WSL)as expected).Sharing and the share status were tested manually against a WSL agent host built from this branch.