- Node and npm
- VS Code extension development setup
opencodeCLI available, or configured throughopencode.cli.path
npm run compileTypeScript checknpm run buildBuild extension host and webviewnpm run watchWatch extension and webview builds
Use the workspace debug config and run the extension host with F5.
Expected debug flow:
- build runs automatically
- extension host window opens
- OpenCode sidebar appears in the activity bar
- Output channel shows server and sidebar logs
Healthy startup usually looks like:
Extension activateProcess state: stopped -> startingSidebar resolveWebviewViewSidebar received message: readySidebar bootstrap startSidebar post message: bootstrap
For message, state, or UI changes verify all of these:
- Sidebar opens without blank state.
- Connection state transitions to connected.
- Existing sessions appear.
- New session creation works.
- Session switching works.
- Prompt send works.
- Streaming output does not freeze the sidebar.
- Attach active file and attach selection work.
- Model, variant, and agent controls still behave correctly.
- Archive, compact, revert, and open-diff flows still work.
- Removed context chips do not reappear after reloading or reopening the sidebar.
- Raw message viewing opens formatted JSON as a readonly document.
- File links in the transcript open the correct file in the editor.
- Todo panel shows and updates during task runs.
- Permission card approve and deny actions work.
- Question card answer flow works (single-select, multi-select, custom text).
The extension should target:
- the current workspace folder
- active editor workspace folder
OPENCODE_WORKSPACE_ROOTif explicitly set
It should not silently fall back to the extension repository.
This is implemented in SidebarProvider.root().
Three settings affect runtime behavior (defined in package.json):
opencode.server.url(string, defaulthttp://localhost:13001) — the preferred server URL; the port is parsed as the starting port for the managed serveropencode.cli.path(string, defaultopencode) — path to theopencodeCLI binary; supports~expansion and is validated before spawningopencode.server.requireAuth(boolean, defaulttrue) — when true, the managed server starts with HTTP basic auth using a random password set viaOPENCODE_SERVER_PASSWORD
- Keep bootstrap small.
- Hydrate session details lazily.
- Coalesce frequent updates.
- Avoid adding unnecessary host/webview chatter.
Recommended order:
- update shared DTOs and protocol if needed
- update host state and SDK integration
- update webview rendering
- verify compile and build
- manually exercise the sidebar in the debug host
If the sidebar looks broken:
- confirm the intended workspace root is selected
- confirm
readyis received by the host - confirm
bootstrapis posted - confirm the webview acknowledges host messages if that path is in use
- confirm bootstrap is not loading too much state
- confirm snapshots are not being posted on every tiny streaming delta
- check the
OpenCode Serveroutput channel for process and connection errors - confirm the CLI binary exists at the configured path and is executable