OpenCode Chat
A chat interface for a local OpenCode server
(opencode serve) right inside VS Code: token streaming, sessions,
context attachments, model selection and tool-permission approval.
Deutsch: README.de.md
Screenshot

Features
- Chat in the secondary sidebar or as a full editor tab
- Markdown with syntax-highlighted code blocks (copy / insert at
cursor / open in new file)
- Token streaming with stop, regenerate, edit-and-resend your last
message, copy any message
Enter sends, Shift+Enter new line; input locked while running
- Auto-scroll pauses when you scroll up ("jump to latest" button),
loading skeletons, empty state with example prompts, error banner
with retry
- Sessions – 1:1 with OpenCode sessions: create, switch, rename
(display title), searchable list
- Context – attach the active file, the current selection or any
files (picker or
@-mention), removable as chips; optionally include
the workspace folder (name + path) in the prompt
- Model selection – models served by the server, choice remembered
per workspace, falls back to the server default
- Context gauge – a small ring in the composer shows the model's
used context (color by load), updated live after every step; hover
for details (used / total / load / remaining) and a compact
session button (server-side summary frees context). The chat header
shows the overall balance (tokens + cost in USD) with a hover tooltip
- Permissions & questions – permission requests in the chat with
once / always / deny; collapsible tool activity; question cards
(single/multi choice + free text, one tab per question) answered
inline
- Connection – status bar (connected / connecting / disconnected /
auth error), health check by ping, "rebuild connection", automatic
SSE reconnection (inside the SDK and in the extension host)
- Accessibility & layout – ARIA roles, full keyboard operation,
prefers-reduced-motion, first-class RTL (Persian/Arabic, detected
via navigator.language), VS Code theme colors throughout
Requirements
- VS Code ≥ 1.90
- The OpenCode CLI (
opencode) installed and signed in
- Linux / WSL (the server typically runs under WSL; VS Code via the WSL
client or a Remote Tunnel)
Getting started
The extension can start the server for you (recommended) – no
password entry needed:
- Open the chat (or run OpenCode Chat: Start local server): if the
server (on localhost) is not reachable, the extension starts
opencode serve automatically (once per connection episode,
switchable via opencodeChat.autoStartServer).
- The server always requires a password. Without a stored one it
generates a random one – the extension reads it from the server
output and stores it in SecretStorage itself. Everything just works
afterwards.
- OpenCode Chat: Stop local server stops the server again; a
server started by the extension is stopped when the window closes.
You can set your own password any time via OpenCode Chat: Set server
password (command palette) or the opencodeChat.password setting; if
the extension already runs a server, it is restarted with the new
password automatically. The password lives in SecretStorage or
(optionally) the setting – a non-empty setting value wins.
Prefer the command over the setting. A value in opencodeChat.password
is stored in plain text in settings.json and may be synced to other
machines via Settings Sync. Set server password keeps it in the
encrypted SecretStorage instead.
The started server binds 127.0.0.1 only, and its output goes to the
"OpenCode Server" output channel.
Alternatively, start it manually in a terminal:
# Example: fixed password
export OPENCODE_SERVER_PASSWORD="a-secure-password"
opencode serve --port 4096
In that case the password must match exactly (set it via
Set server password). Base URL is http://127.0.0.1:4096 (other
port → adjust opencodeChat.serverUrl).
Quick start
- Open the chat: OpenCode icon in the editor title bar (right of the
tabs) or
Ctrl+Alt+C (Cmd+Alt+C) – opens the chat in the sidebar;
the local server starts automatically (no password needed).
- If the connection fails: OpenCode Chat: Rebuild connection.
- Optional: set a default model,
opencodeChat.defaultModel, in the
format providerID/modelID.
Settings
| Setting |
Default |
Meaning |
opencodeChat.serverUrl |
http://127.0.0.1:4096 |
Base URL of the OpenCode server |
opencodeChat.password |
(empty) |
Server password as a setting; non-empty wins over the SecretStorage value (command "Set server password") |
opencodeChat.defaultModel |
(empty) |
Default model providerID/modelID; empty = server default |
opencodeChat.requestTimeout |
30000 |
Timeout (ms) for non-streaming calls |
opencodeChat.includeWorkspace |
false |
Attach the workspace folder (name + path) as context (off by default – the server already runs in the workspace) |
opencodeChat.autoStartServer |
true |
Automatically start an unreachable local server (localhost) |
opencodeChat.serverCommand |
opencode |
Command used to start the server: name from PATH or absolute path |
Commands & keyboard
| Command |
Shortcut |
| Open chat |
Ctrl+Alt+C / Cmd+Alt+C |
| New chat |
Ctrl+Alt+N / Cmd+Alt+N |
| Stop response |
Esc (chat focused) |
| Open chat in editor |
– |
| Rebuild connection |
– |
| Print diagnostics |
– |
| Set server password |
– |
| Start / restart / stop local server |
– |
| Attach selection as context |
– |
| Copy message |
– |
| Insert code at cursor |
– |
| Open code in new file |
– |
Troubleshooting
| Symptom |
Cause / fix |
| "OpenCode server not reachable at …" |
Server not running or wrong port/URL. Run "Start local server" (or auto-start if opencodeChat.autoStartServer is on), check opencodeChat.serverUrl. |
| "Could not start the OpenCode server …" |
opencode not on the extension host's PATH (e.g. only added in .bashrc). Set opencodeChat.serverCommand to the absolute path (under WSL typically ~/.opencode/bin/opencode). Server output: channel "OpenCode Server". |
| "Wrong server password …" |
Fix via the banner/status-bar button "Set password", the "Set server password" command, or opencodeChat.password. For a server started by the extension it is restarted automatically; for a manual server set OPENCODE_SERVER_PASSWORD there. |
Changed an API key in opencode.json, server still uses the old one |
Config is only read at start → "Restart local server" (menu under the gear button in the chat header or the command palette). |
| "The server does not support this API version" |
OpenCode server too old → opencode update. |
| Response aborted (timeout) |
Non-streaming calls take too long → raise opencodeChat.requestTimeout. |
| Status bar stuck on "connecting …" |
SSE stream has problems → "Rebuild connection". |
| Connection status "unreachable" persists |
Run "OpenCode Chat: Print diagnostics" (F1) – logs target, fetch self-test, SDK call and event stream to the "OpenCode Chat" output channel. |
Known limitations
- Sessions cannot be deleted – the OpenCode v2 API has no
session-delete; the extension hides sessions deleted on the server
(via server event); more would require an API change.
- Renaming is a local display title only – the API has no
session-rename; the name is remembered locally per workspace.
- Tool activity is shown collapsed in the webview; individual tool
results are not expanded in full text.
Development
npm install
npm run build # esbuild: dist/extension.js + dist/webview.js
npm test # vitest: unit + integration tests against a mock server
npm run typecheck # tsc --noEmit (strict)
npm run lint # eslint + prettier
npm run package # .vsix (vsce) + local install
The integration tests run against a mock OpenCode server
(test/integration/mockOpencode.ts) that replays the verified v2
routes (HTTP Basic Auth, Location envelope, named errors, SSE with
Last-Event-ID) – no real provider is ever called.
License
MIT