opencode Attach (Remote Edition) — VS Code Extension
A VS Code extension that attaches to an already-running opencode server and lets you keep working with your AI coding session from anywhere, via VS Code Remote Tunnel + a remote-browser control UI.
Unlike the upstream opencode extension, this fork never auto-spawns a server — you start opencode yourself (locally, in a Docker container, on a remote host via SSH, etc.) and tell the extension which port it's listening on.
Why
When opencode runs an AI coding task, it often pauses and waits for you to react:
- Waiting for your input (it asked a question)
- Waiting for permission (a shell command / file write needs approval)
- Waiting for operation confirmation (a destructive or notable action)
- Task complete (and you didn't notice because you walked away)
- Build failed
- Test failed
- Agent error
Today, the only way to react is to be at your desk. This extension closes that loop:
- Tunnel. Uses VS Code Remote Tunnel to give your opencode session a stable public URL — no manual port forwarding, no auth to wire up.
- Watch. Observes the running opencode session for the seven event types above.
- Surface. Pushes them to a remote control UI you can open in any browser.
- Respond. Lets you approve a permission, send input, view logs, etc. — from anywhere with a browser.
Prerequisites
- opencode CLI installed (or any opencode server binary reachable from your machine).
- An opencode server already running, listening on a known port (e.g.
opencode serve --port 12345).
- VS Code Remote Tunnel enabled on this machine (sign in with GitHub / Microsoft, then turn the tunnel on). This extension reuses VS Code's tunnel — it does not start its own.
- A modern browser on any remote device (phone, tablet, or desktop — iOS Safari 16+, Android Chrome 110+, or any recent desktop browser).
Quick start
- Start an opencode server in a terminal:
opencode serve --port 12345
- In VS Code, press
Ctrl+Esc / Cmd+Esc. When prompted, enter the port (12345).
- A terminal named
opencode opens in the side panel with opencode attach http://localhost:12345 pre-filled. Press Enter to attach.
- Make sure VS Code Remote Tunnel is running. The tunnel URL is shown in the VS Code status bar (look for
Remote: <hostname>.devtunnels.ms or vscode.dev/tunnel/<...>). Click the status bar item, or run the Show Tunnel URL command from this extension to copy it.
- Open the tunnel URL in a browser on any remote device. The remote control UI loads automatically.
- Walk away. When opencode needs you, you get a notification and can respond without going back to the machine.
Features
Remote control UI
- Works through VS Code Remote Tunnel — no extra auth or open ports.
- Remotely synchronize local OpenCode sessions via the browser.
Event detection
The extension recognizes and surfaces the following opencode events to the remote UI:
| Event |
Surfaced as |
| Awaiting input |
"Opencode is asking a question" + input field |
| Awaiting permission |
"Opencode wants to run: <command>" + Allow / Deny |
| Awaiting operation confirmation |
"Confirm action: <action>" + Confirm / Cancel |
| Task complete |
"Done" summary |
| Build failed |
Build output excerpt + Open in VS Code link |
| Test failed |
Failing test names + Open in VS Code link |
| Agent error |
Error message + Reconnect / Open in VS Code link |
Local UX (still works without the tunnel)
The original attach helpers remain, so the extension is useful even when you're at the machine (not remote):
| Command |
Default Keybinding |
Description |
opencode-attach.openTerminal |
Ctrl+Esc / Cmd+Esc |
Open or focus the opencode terminal. If one already exists, focus it. Otherwise prompt for a port and create one. |
opencode-attach.openNewTerminal |
Ctrl+Shift+Esc / Cmd+Shift+Esc |
Always prompt for a port and create a new opencode terminal. |
opencode-attach.addFilepathToTerminal |
Ctrl+Alt+K / Cmd+Option+K |
Insert @relative/path#L1-L10 (or #L1-L10 for the current selection) into the active opencode terminal. |
Note: These keybindings conflict with the upstream opencode extension if both are installed. Resolve via Ctrl+K Ctrl+S → search opencode-attach → rebind.
Architecture
┌──────────────────────────┐ ┌──────────────────────────┐
│ Browser │◀─HTTP─▶│ VS Code Remote Tunnel │
│ (remote control UI) │ (TLS) │ (auth: GitHub / MS) │
└──────────────────────────┘ └────────────┬─────────────┘
│ (authenticated proxy)
▼
┌──────────────────────────┐
│ This VS Code Extension │
│ - localhost web server │
│ - SSE stream to browser │
│ - watches opencode │
└────────────┬─────────────┘
│
attaches to │ opencode attach
▼
┌──────────────────────────┐
│ opencode server │
│ (user-started, :12345) │
└──────────────────────────┘
Key design choices:
- Tunnel reuse, not DIY. VS Code's Remote Tunnel already handles auth, TLS, and connectivity. The extension binds to
localhost only; VS Code proxies to it.
- Attach-only. No
opencode spawn, no random-port server. The user owns the server lifecycle. (See docs/superpowers/specs/2026-08-31-opencode-vscode-attach-mode-design.md.)
- The extension is a thin adapter. It owns the tunnel endpoint, the web UI, and the event detector — it does not implement opencode itself.
Security
- The control UI binds to
127.0.0.1 only. It is reachable remotely exclusively through VS Code Remote Tunnel, which is authenticated with your GitHub / Microsoft account.
- The extension does not open any additional public ports and does not bypass VS Code's tunnel authentication.
- The extension does not store or transmit opencode credentials. It only attaches to the server the user started.
- Treat the tunnel URL like a private link — anyone with it and your tunnel account can reach your dev machine.
Coexistence with the upstream extension
This extension is published as yveguo.opencode-attach-vscode and registers all commands under the opencode-attach.* prefix. It does not touch the upstream sst-dev.opencode extension or its opencode.* commands. Both can be installed side by side.
Development
code . in this directory.
npm install (or bun install).
- Press
F5 to start debugging — this launches a new VS Code window with the extension loaded.
Testing the remote UI during dev
You can iterate on the remote UI without leaving your machine:
- The extension serves the UI on
http://localhost:<port> (shown in the VS Code Output panel under this extension's name).
- Open that URL in a desktop browser, with DevTools device emulation set to a mobile viewport, to preview the UI.
- To test the full remote flow, enable VS Code Remote Tunnel on the debug session and open the tunnel URL from a separate device.
Making changes
tsc and esbuild watchers run automatically during debugging. Changes are rebuilt in the background.
To reload after changes:
- In the debug VS Code window, press
Ctrl+Shift+P / Cmd+Shift+P.
- Search for
Developer: Reload Window.
- Reload to see your changes without restarting the debug session.
Packaging a .vsix
The repository's vscode:prepublish script assumes bun. To package without bun:
npx tsc --noEmit
npx eslint src
node esbuild.js --production
# temporarily swap "vscode:prepublish": "bun run package" to "node esbuild.js --production" in package.json
npx vsce package
# restore package.json
Support
This is a fork of anomalyco/opencode. Report issues at the upstream repo.