Skip to content

feat: support the VS Code Agents window - #1213

Draft
EhabY wants to merge 3 commits into
mainfrom
feat/agents-window-support
Draft

EhabY wants to merge 3 commits into
mainfrom
feat/agents-window-support

Conversation

@EhabY

@EhabY EhabY commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1218
Part of VSC-62

Makes the extension work in the VS Code Agents window, in three commits:

  • feat: declares capabilities.agentsWindow.supported, and skips the "Remote SSH not found" error there (the Agents window disables Remote SSH).
  • refactor(remote): pulls the window-independent connection steps (CLI, compatibility, workspace readiness, SSH config) out of Remote into ConnectionSetup, with no behavior change. The tests moved with the code. Best reviewed on its own.
  • feat: adds Coder: Open Workspace in Agents Window. It picks a workspace, starts it if needed, writes the SSH config to ~/.ssh/config for plain ssh, and opens the Agents window on the template's directory or the last folder opened on the workspace. Telemetry span: workspace.agents_window.open.

Verified live on dogfood with VS Code Insiders 1.148 and the packaged VSIX: the Agents window opened on the workspace over SSH, including when it was already open on a local folder. coder.open in an editor window still connects after the refactor.

The MCP server is in the stacked PR, #1214.

Generated by Coder Agents on behalf of @EhabY.

Plan and decision log

Coder extension in the VS Code Agents window

Status: phases 1 and 2 in feat/agents-window-support (#1213), phase 3 in feat/mcp-server stacked on it; the Microsoft issue is drafted, not filed.

Findings (verified)

Source: microsoft/vscode main at ede881c5 (2026-11-20). Test: VS Code Insiders 1.148.0 (35cb524) under xvfb, with a test build of v1.18.2 that adds capabilities.agentsWindow.supported: true plus onStartupFinished (test only).

  1. The Agents window is a separate window with its own extension host. openAgentsWindow opens the agent-sessions workspace with forceNewWindow: true (windowsMainService.ts:304-340). isSessionsWindow is fixed when the window is created (:1670). In the test, window1 (isSessionsWindow: true) and window2 (false) each activated coder.coder-remote separately, and both ran at the same time. No window is ever "switched", so nothing re-activates. Each window activates on its own events.
  2. Activation is clean in the Agents window. There were no errors. Commands registered and the log said "Not currently logged in". vsce package accepts the capability.
  3. Storage:
    • globalStorageUri is shared: the extension host gets defaultProfile.globalStorageHome (localProcessExtensionHost.ts:540). The test showed /User/globalStorage in the Agents window.
    • Settings, extensions and MCP are shared: the Agents profile has useDefaultFlags for them.
    • context.globalState is not shared. It is PROFILE scope (extensionStorage.ts:161), and the Agents profile has no globalState default flag. Its storage is profiles/builtin/agents/globalStorage/state.vscdb, so URL history, deployment access times, surfaced banners and startupMode are separate.
    • Secrets are APPLICATION scope (secrets.ts:206-208), so they are expected to be shared. This needs a live check together with the windowBroadcast login sync.
  4. Microsoft's own extensions adjust behaviour at runtime instead of skipping activation. git and copilot branch on vscode.workspace.isAgentSessionsWorkspace, for example git/src/repository.ts:375,385 (no progress UI) and copilot .../sessionSyncStatus.ts:54. That API is proposed (agentSessionsWorkspace), so Marketplace extensions can't use it on Stable. Other proposed hooks: agentsWindowConfiguration (per-setting defaults in the Agents window) and chat.registerRemoteAgentHost.
  5. Unsupported UI is filtered by the host. Views, view containers, the status bar and walkthroughs are not rendered (extensionManifestPropertiesService.ts:76-89). Our registration code for them does no harm.
  6. SSH in the Agents window:
    • The host picker skips wildcard hosts (sshConfigParsing.ts:32), so coder-vscode.<host>--* is never listed.
    • Connections resolve with ssh -G and run ProxyCommand with %h expanded (sshProxyCommand.ts:16), so a typed Coder host should work.
    • "Open in Agents" from an editor window maps ssh-remote+<alias> to sshConfigHost: <alias> (remoteWorkspaceHandoffService.ts:63-70). That means an editor window connected to Coder should hand off to the same workspace without the picker.
  7. Unverified: a live connection to a Coder deployment from the Agents window, secret sharing, and the HTTP(S)_PROXY and CODER_TRACE_SESSION_ID variables. Today applySshEnvironment sets these in our extension host's process.env, which the Agents window's ssh process does not inherit.

Proposed work

Phase 1: declare support (commit c28659d)

  • package.json: capabilities.agentsWindow.supported: true; CHANGELOG entry.
  • Remote-SSH is disabled in the Agents window, so activation showed "Remote SSH extension not found". It is now skipped there through isAgentsWindow().
  • Still to check with a dogfood login: login, coder.open, support bundle, notifications.

Phase 2: behave well in the Agents window (commits 1f9c097 refactor, ea77c68 command)

  • Detect the Agents window (see decision 1).
  • No polling to skip: workspace views only fetch while visible, and the Agents window never shows them.
  • Verified live (dogfood, Insiders 1.148): from an editor window, workbench.action.openAgentsWindow with { folderUri: vscode-remote://ssh-remote+<coder host>/<dir> } opens the Agents window and connects over SSH through a Coder ProxyCommand. Auth none succeeds, VS Code installs its CLI on the workspace and starts an agent host there, and the Copilot CLI, Claude and Codex agents register on the workspace.
  • Command "Coder: Open Workspace in Agents Window":
    1. pick a workspace and agent (reuse pickWorkspace and maybeAskAgent);
    2. start it if stopped, wait for the agent (reuse WorkspaceStateMachine);
    3. write the SSH config (reuse updateSSHConfig), so the host resolves;
    4. run workbench.action.openAgentsWindow with the folder URI; if that command is missing, show the host alias to type in the SSH picker.
  • Steps 2 and 3 live inside Remote.setupCoderRemote, mixed with work only an editor window needs (label formatter, monitor, inbox, status bar, SSH process monitor). Split out as ConnectionSetup (decision 4).
  • Known gap: proxy variables (HTTP(S)_PROXY, NO_PROXY) reach coder ssh only through our process environment, which the Agents window's ssh does not inherit.

Phase 4: Microsoft issue (draft below, not filed)

Decisions

  1. Detection: check the workspace filename, in src/vscode/agentsWindow.ts. VS Code marks a window as the Agents window by this exact path (windowsMainService.ts:1670), and the name is unchanged since the prototype (19209a8c, 2026-01-23). isAgentSessionsWorkspace is unchanged and still proposed since 2026-01-26, so we don't use it.
  2. Autostart: option A, a prepare command that starts the workspace through the API. Note: the existing "workspace is not running" prompt (workspaceStateMachine.ts:124) runs only from remote.setup, which runs only when the window has an ssh-remote authority (extension.ts:468). The Agents window has none, so connecting to a stopped workspace there fails in coder ssh --disable-autostart with no prompt. Start buttons in the Workspaces panel are hidden there too.
  3. globalState: keep separate per window. Remove the memento move from phase 2.
  4. Refactor Remote: extract ConnectionSetup (src/remote/connectionSetup.ts): CLI resolution, compatibility, workspace readiness, SSH config writing. One instance is created in extension.ts and shared by Remote and Commands. The caller passes the SSH config file and ssh path: Remote passes Remote-SSH's, and the Agents window passes undefined (~/.ssh/config, plain ssh), because the Agents window resolves hosts with ssh -G -- <host> (sshRemoteAgentHostService.ts:1405). Separate commit, no behavior change; moved bodies diffed against the originals.
  5. Folder: the template's dir (agent.expanded_directory), then recently opened folders on the workspace, through a chooseFolder helper shared with coder.open. With neither, warn and open the Agents window without a folder.
  6. Already-open Agents window: pass reveal: "new", otherwise VS Code ignores folderUri for an open Agents window (mainImpl.js vN). Verified live.
  7. Availability: context key coder.agentsWindowSupported, set at activation when workbench.action.openAgentsWindow exists. No fix-it button.
  8. Code layout: connection prep in src/remote/agentsWindowConnection.ts; picking and handoff in Commands.openInAgentsWindow; VS Code specifics (command ID, reveal) in src/vscode/agentsWindow.ts.
  9. Start prompt dismissed: typed WorkspaceStartCancelledError (same message as before), so the command records an abort instead of an error.
  10. Telemetry: span workspace.agents_window.open (like workspace.dev_container.open) with the workspace.open attributes, abort stage start_prompt, and phases named as in remote.setup.
  11. Proxy limitation: VS Code's shared process spawns the ProxyCommand without our environment, so HTTP(S)_PROXY/NO_PROXY from settings don't reach coder ssh in the Agents window. Documented, not fixed (writing proxy env into the ProxyCommand would put credentialed URLs on disk).

Live verification (dogfood, Insiders 1.148, real VSIX)

  • Fresh Agents window: command picks ehab/vscode-agents-window-research, downloads the CLI, waits for agent dev, writes ~/.ssh/config include, opens the Agents window on /home/coder/vscode-coder; VS Code server and agent host start on the workspace.
  • Agents window already open on a local folder: it switches to the workspace folder.
  • Editor window coder.open after the refactor: Remote setup complete.

Draft Microsoft issue (microsoft/vscode)

Title: Agents window: let extensions contribute SSH hosts, and activate contributed MCP collections

Disclosure: drafted with Coder Agents on behalf of .

Context. The Coder extension (coder.coder-remote) declares capabilities.agentsWindow.supported. It writes a wildcard SSH config block (Host coder-vscode.<deployment>--*) whose ProxyCommand runs coder ssh --stdio %h, so each Coder workspace is an SSH host for Remote - SSH.

Problem.

  1. parseSSHConfigHostEntries skips patterns, so Coder workspaces never appear in the Agents window SSH picker. Users must know and type coder-vscode.<deployment>--<owner>--<workspace>.
  2. chat.registerRemoteAgentHost (proposed) accepts only a WebSocket address. Coder can't register a host that is reached over SSH with a ProxyCommand. The alternative, exposing a WebSocket port on localhost, would mean running and securing a separate agent host server.
  3. workspace.isAgentSessionsWorkspace is proposed, so Marketplace extensions can't adjust their behaviour the way git and copilot do.
  4. The Agents window lists extension MCP servers only from extensions that are already active. The Coder extension contributes mcpServerDefinitionProviders (id coder), but onMcpCollection:coder never fires there, so its server is missing until the extension activates for another reason.

Ask.

  • An API to contribute SSH hosts to the environment picker: a name, an SSH config alias or destination, and an optional "prepare" callback run before connecting, for example to start a stopped workspace. Or let registerRemoteAgentHost accept an SSH destination.
  • Finalize isAgentSessionsWorkspace (or an equivalent env flag).
  • Activate extensions that contribute mcpServerDefinitionProviders (onMcpCollection:<id>) when the Agents window builds its MCP server list. Today it only activates a collection when one of its servers starts, so a lazily activated extension's servers never appear there and extensions must use onStartupFinished.

Repro. Install Coder, sign in, open any workspace once (this writes the SSH config), open the Agents window, choose SSH: no Coder hosts are listed. Typing the alias connects. (The connection must be confirmed against a live deployment before filing.)

…mote

Move CLI resolution, compatibility checks, workspace readiness and SSH config writing into ConnectionSetup so a window without Remote-SSH can reuse them. The SSH config file and ssh path are now passed in by the caller.
Coder: Open Workspace in Agents Window starts the workspace if needed, writes the SSH config to ~/.ssh/config for plain ssh, and opens the template's directory (or the last folder opened on the workspace) in the Agents window. The command shows only where VS Code has the Agents window.
@linear-code

linear-code Bot commented Nov 25, 2026

Copy link
Copy Markdown

VSC-62

This branch has not been deployed

No deployments
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.

1 participant