OpenCode for VS Code
A VS Code extension for OpenCode v2. It talks to the OpenCode v2 server API, so a session you start here also shows up in the TUI, the desktop app and the web UI, and the other way round.
Requirements
- VS Code 1.95 or newer
- The OpenCode v2 CLI (
opencode --version should print 2.x). If opencode is not on your PATH, set OpenCode: Binary Path.
- At least one model provider connected (
opencode auth, or Settings → Providers in the extension).
Getting started
- Open the OpenCode view in the activity bar, or press
Ctrl+Alt+O (Cmd+Esc on macOS).
- Type a request and press
Enter.
- Select code in the editor and press
Ctrl+Alt+K (Cmd+Alt+K) to attach the selection to the chat.
Features
Chat
- Text, reasoning and tool calls stream in as they happen. Tool calls show as cards: file edits with inline diffs, shell commands with output, searches, web fetches, subagent tasks, todo lists and MCP tools.
@ mentions files and folders (fuzzy search), subagents and the current selection. / runs server commands (/init, /review, custom commands), skills and built-in actions. A message starting with ! runs a shell command.
- You can paste or drop images and files, or attach them with the paperclip button.
- Agent and model pickers. The model picker first shows the models grouped by provider, then a second step picks a variant such as reasoning effort (or default).
Tab cycles primary agents, so you can switch between Build and Plan.
- The MCP button in the composer shows the configured MCP servers and their live status. Start or stop any server from the popup to match what the session needs (a green count badge shows how many are connected). This is runtime only: the server forgets the change on restart, and the Manage in settings link opens the full MCP pane.
- If you send while the agent is working, the message is queued. steer delivers it into the running turn; queue waits until the turn finishes (
Esc stops the response). The session list is a popover off the header's history button in both surfaces; an editor tab's chat header is minimal (history + More actions, the latter including All sessions).
- A chat lives in one surface at a time. Open in new tab (header menu, session list, or the sidebar's Open Chat in New Tab button,
Ctrl+Alt+Shift+O, Cmd+Shift+Esc on macOS) moves the current session into an editor tab and frees the sidebar; an editor-tab chat has a Move to side panel button that does the reverse and closes the tab.
- The composer shows how much of the context window is used and what the session has cost so far. Clicking the meter opens a breakdown by token category, the session totals and the cost.
- Find in session (🔍 in the chat header) searches the loaded messages: it shows
n / total, jumps to each match with a brief highlight, and Enter / ↑ / ↓ move between them.
- A reply that failed (error) or was truncated (hit the max output tokens) shows a Retry / Regenerate button that re-sends the prompt that produced it, dropping the bad reply first (there is no server-side retry in OpenCode v2, so this reverts to the turn's prompt and resends it).
- A new (empty) session shows the working directory, the active agent · model, and starter chips that fill the composer; copy buttons appear on messages, tool output, commands and diffs.
Permissions and questions
- Permission requests appear inline with the command or diff. Reply with Allow once, Always allow or Reject, optionally adding feedback for the agent. The keyboard shortcuts are
1, 2 and 3.
- Questions from the agent appear as a form with the choices, multi-select, free text, numbers, booleans and conditional fields. Once answered, the question's tool card in the transcript shows the choices and highlights the one you picked (no raw JSON).
- OpenCode: Auto Approve approves requests automatically, like
opencode --auto. It only applies to sessions open in this window.
Sessions
- Sessions are reached from the chat header's history button, which opens the searchable session list as a popover: open, open in a new tab, rename, fork, archive and delete inline, plus Import… and New session in the footer. Searching by at least two characters queries the server (with Load more); shorter queries filter the loaded list.
- The session list is grouped under Today / Yesterday / This week / Earlier headers. Rows show a coloured dot for the agent that ran the session and a dot when the session has an unsent draft.
Alt+Down / Alt+Up (Alt+Cmd+Down / Up on macOS) switch to the next/previous session while the chat is focused.
- Undo (
/undo, or the edit button on a message) reverts the conversation and file changes to that point and puts the prompt back in the composer. Redo (/redo) restores it.
/compact summarises the conversation to free up context.
- Subagent sessions open from their task card, with a back button to the parent session.
Diffs and editor integration
- Open diff shows an edit in the VS Code diff editor. The right-hand side is the real file, so you can keep editing it.
- Review session changes and Working tree changes open every changed file in the multi-file diff editor.
- File paths in responses are clickable, and image links open in the built-in image preview (other binary files are revealed in the Explorer). Code blocks have Copy, Insert at cursor and Open in new file buttons.
- Editor and Explorer context menus include Add Selection to Chat, Add File to Chat, Explain Selection and Fix Problems in File.
The extension makes VS Code's language features available to the agent as an MCP server named vscode. The tools are vscode_get_diagnostics, vscode_get_open_editors, vscode_get_selection, vscode_open_file, vscode_workspace_symbols, vscode_document_symbols, vscode_go_to_definition, vscode_find_references and vscode_hover. You can turn them off with opencode.ide.enableMcpBridge.
Terminals
- OpenCode: Open TUI in Terminal starts the TUI on the same server and session.
- New Server Terminal and Attach to Server Terminal connect to server-side PTYs.
- Follow on a running shell tool streams that command's output into a terminal.
Settings panel
Open it from the gear icon. It has an icon rail on the left and a content pane on the right; each rail icon jumps to one section, and icons show live signals (counts, and a red dot when something needs attention — a failed MCP server, a disabled provider or a connection error). The Search settings box in the header narrows the rail to the sections that match (by label or keyword) and pre-filters their rows — it shares one filter with each section's own filter box. It covers:
- General: connection status, server and version, workspace folder, reconnect/restart/reload, and the chat settings as toggles (shown here in user scope —
opencode.chat.* and opencode.autoApprove are read from user settings, so a repo cannot change them)
- Providers: configured providers, stored credentials, and connecting a provider (API key, OAuth and CLI login flows)
- Models: the available models with the current default; each model has a Use button that applies it to the current session (or to the next session when none is open), and the active model is marked
- MCP: servers (connect, disconnect, add and remove — statuses update live via server events, no polling) and their resources
- Agents, Skills, Commands: what the server offers
- Permissions: saved “Always allow” rules
- Worktrees: list, create and remove
- Schedules: view, pause/resume and delete (schedules are created by the agent, so this pane has no create button)
- Processes: agent shell commands and server terminals
- Usage: all-time statistics and budget limits with spent/limit meters
Connection modes
opencode.server.mode controls how the extension finds a server:
| Mode |
Behaviour |
auto (default) |
Uses the OpenCode background service if one is running. If not, it starts the service, or starts a private server when the service is disabled (opencode service get disabled). |
service |
Always uses the shared background service, starting it when needed. |
standalone |
Starts a private opencode serve that belongs to this VS Code window and stops with it. |
url |
Connects to opencode.server.url. You are asked for the password once and it is kept in VS Code secret storage. |
Settings
| Setting |
Default |
Description |
opencode.server.mode |
auto |
See Connection modes. |
opencode.server.url |
|
Server URL for url mode. |
opencode.server.username |
opencode |
Basic auth username for url mode; the password is kept in VS Code secret storage. |
opencode.binaryPath |
|
Path to the opencode executable. |
opencode.autoApprove |
false |
Approve permission requests automatically (all sessions). Read from user settings only. A per-session override can be enabled from the shield toggle in the composer — even before the first message, in which case it applies to the session your next message starts; it asks for confirmation and lasts until turned off or the window reloads. |
opencode.ide.enableMcpBridge |
true |
Make IDE tools available to the agent. |
opencode.ide.mcpName |
vscode |
Name of the IDE MCP server the agent sees. |
opencode.chat.defaultDelivery |
steer |
How messages sent while the agent is busy are delivered. |
opencode.chat.showReasoning |
true |
Show reasoning blocks. |
opencode.chat.expandToolOutput |
false |
Expand tool call cards by default. |
opencode.chat.includeActiveEditorContext |
true |
Offer the active editor / selection as a one-click attachment. |
opencode.chat.enterToSend |
true |
Enter sends; Shift+Enter adds a new line. |
opencode.diff.autoOpen |
false |
Open a diff editor every time the agent edits a file. |
opencode.showEditorTitleButton |
true |
Show the OpenCode button in the editor title bar. |
opencode.notifications.onComplete |
whenHidden |
Notify when a turn finishes. |
opencode.statusBar.enabled |
true |
Show the OpenCode status bar item. |
The chat settings are also editable in the Settings panel (General section); the panel writes them to user scope. Server settings (opencode.server.*, opencode.binaryPath) are machine-scoped on purpose, and so is opencode.autoApprove — a repository cannot change the server, the executable, or whether tool calls are auto-approved.
The extension is disabled in VS Code Restricted Mode: trust the workspace before using it.
Keyboard shortcuts
| Shortcut |
Action |
Ctrl+Alt+O / Cmd+Esc |
Focus chat |
Ctrl+Alt+N / Cmd+Alt+N |
New session (chat focused) |
Ctrl+Alt+Shift+O / Cmd+Shift+Esc |
Open chat in a new tab |
Ctrl+Alt+K / Cmd+Alt+K |
Add selection to chat |
Alt+Down / Alt+Up (mac Alt+Cmd+Down / Alt+Cmd+Up) |
Next / previous session (chat focused; wraps at the ends) |
Enter / Shift+Enter |
Send / new line |
Tab / Shift+Tab (empty composer) |
Cycle agents |
Esc then Tab (empty composer) |
Move focus out of the composer |
↑ / ↓ (at start / end of the composer) |
Prompt history |
Esc |
Stop the response |
Ctrl+Alt+Backspace / Cmd+Alt+Backspace |
Stop the current response (works even when the chat is not focused) |
In the chat, the header's 🔍 Find in session button opens an in-session search over the loaded messages: type to jump between matches (n / total), Enter / ↓ next, ↑ previous, Esc closes. A failed or truncated reply shows a Retry / Regenerate button that re-sends the prompt that produced it.
Troubleshooting
Where are the logs? Run OpenCode: Show Logs (or the Logs link in the chat's disconnected banner) to open the output channel. For a full snapshot of versions, the server URL and mode, the resolved binary, connection state and the last 100 log lines, run OpenCode: Show Diagnostics (also available from the view's overflow menu and the Diagnostics link in the banner). It never includes your password or auth header.
The CLI is not found / binaryPath. If the connection fails with "opencode CLI was not found", install OpenCode v2 or point OpenCode → Binary Path (opencode.binaryPath) at the executable. opencode --version should print 2.x.
Windows .cmd shim. On Windows the npm opencode shim is a .cmd file, which Node's spawn (without a shell) cannot run directly. The extension unwraps the shim to the real .exe automatically, so a PATH-resolved install works; if you set opencode.binaryPath, prefer the real .exe over the .cmd.
URL-mode authentication. With opencode.server.mode set to url, the password is asked once and kept in VS Code secret storage. After the extension ID or server URL changes, or if you get an authentication error, re-enter it with OpenCode: Reconnect to Server. Use https:// for any remote server: over http:// the password is sent unencrypted, which the extension warns about.
Corporate proxy / localhost not reachable. If connections to 127.0.0.1 hang under a corporate proxy, add 127.0.0.1,localhost to VS Code's http.noProxy (and NO_PROXY in the environment) so traffic to the local server bypasses the proxy.
Restricted Mode. The extension is disabled in VS Code Restricted Mode because OpenCode executes tools and loads project configuration (opencode.json, plugins, MCP servers) from the workspace. Trust the workspace to use it.
Standalone port. In standalone mode the extension starts a private opencode serve bound to 127.0.0.1 on a random free port, so it is not reachable from other machines. If local security software blocks it, switch to service/auto to use the shared background service instead.
| |