* feat: add initial VS Code extension plan and implementation tasks * feat(vscode): added initial version of an Openchamber VSCode extension * feat(vscode): enhance VS Code extension with theme integration and session management * feat(vscode): implement connection status handling and overlay in VSCode layout * feat: move extension to secondary sidebar * chore: upgrade @opencode-ai/sdk to 1.0.150 * vscode: editor bridge, file picker, click-to-open in tool parts * vscode: layout session lifecycle, theme sync, typography overrides * ui: compact mode for vscode, model search, autocomplete width fixes * perf: scroll force flag, raf placeholder, git polling backoff * ui: tool output styling, markdown code block fix, gitignore * refactor: update typography handling for VSCode runtime, remove unused styles * docs: update README with VS Code extension details and add extension image * docs: update changelog with new features and performance improvements
5.2 KiB
5.2 KiB
VS Code Extension Plan
Chat UI sidebar panel for VS Code that connects to OpenCode backend.
Goals
- Sidebar webview panel with OpenChamber chat UI
- Reuse
@openchamber/uicomponents (ChatView, stores, hooks) - Auto-detect VS Code theme (light/dark) and adapt
- Use workspace folder as OpenCode directory
- Support
@filementions via VS Code workspace API
Package Structure
packages/vscode/
├── src/
│ ├── extension.ts # Extension entry, registers webview
│ ├── ChatViewProvider.ts # WebviewViewProvider for sidebar
│ ├── bridge.ts # Webview <-> Extension host messaging
│ └── theme.ts # VS Code theme detection
├── webview/
│ ├── main.tsx # Webview React entry
│ ├── App.tsx # Minimal App (chat-only, no layout)
│ └── api/
│ ├── index.ts # createVSCodeAPIs()
│ ├── files.ts # File listing via extension host
│ └── settings.ts # Theme/config from VS Code
├── package.json # Extension manifest
├── tsconfig.json
├── tsconfig.webview.json
└── vite.config.ts # Webview bundler
Implementation Tasks
Phase 1: Extension Scaffold
- Create
packages/vscode/directory structure - Create
package.jsonwith extension manifest- Sidebar view contribution
- Commands (new session)
- Configuration (API URL)
- Create
tsconfig.jsonfor extension host (Node.js) - Create
tsconfig.webview.jsonfor webview (browser) - Create
vite.config.tsfor webview bundling - Add workspace reference in root
pnpm-workspace.yaml
Phase 2: Extension Host
src/extension.ts- activate/deactivate, register providersrc/ChatViewProvider.ts- WebviewViewProvider implementation- Generate HTML with CSP
- Handle webview lifecycle
- Pass workspace folder to webview
src/bridge.ts- Message handler for webview requestsfiles:list- list directory contentsfiles:search- fuzzy file searchworkspace:folder- get workspace root
src/theme.ts- Detect VS Code color theme kind
Phase 3: Webview Runtime
webview/main.tsx- React entry pointwebview/App.tsx- Simplified app shell- No MainLayout/Header/Sidebar
- Just ChatView + essential providers
- Theme sync with VS Code
webview/api/index.ts- createVSCodeAPIs()- RuntimeAPIs implementation
- IPC bridge to extension host
webview/api/files.ts- FilesAPI via postMessagewebview/api/settings.ts- SettingsAPI (theme from VS Code)
Phase 4: Theme Integration
- Listen to
vscode.window.onDidChangeActiveColorTheme - Map VS Code theme kind to OpenChamber light/dark
- Post theme changes to webview
- Apply theme CSS variables dynamically
Phase 5: File Context Support
- Implement
files:listin extension host usingvscode.workspace.fs - Implement
files:searchusingvscode.workspace.findFiles - Wire up to ChatInput
@fileautocomplete
Phase 6: Build & Package
- Add build scripts to
packages/vscode/package.json - Add root-level scripts (
vscode:dev,vscode:build,vscode:package) - Configure
.vscodeignorefor clean packaging - Test extension in VS Code Extension Host
Dependencies
Extension Host (Node.js)
@types/vscode- VS Code API typesesbuild- Bundle extension.ts
Webview (Browser)
@openchamber/ui(workspace) - Shared UI componentsvite+@vitejs/plugin-react- Bundle React app@opencode-ai/sdk- OpenCode API client
Extension Manifest Highlights
{
"contributes": {
"views": {
"explorer": [{
"type": "webview",
"id": "openchamber.chatView",
"name": "OpenChamber"
}]
},
"commands": [{
"command": "openchamber.newSession",
"title": "OpenChamber: New Chat Session"
}],
"configuration": {
"properties": {
"openchamber.apiUrl": {
"type": "string",
"default": "http://localhost:47339"
}
}
}
}
}
Reused from @openchamber/ui
| Module | Status |
|---|---|
components/chat/* |
Reuse all |
components/views/ChatView |
Reuse |
stores/useSessionStore |
Reuse |
stores/useConfigStore |
Reuse |
stores/useUIStore |
Partial (no sidebar state) |
hooks/useEventStream |
Reuse |
hooks/useMessageSync |
Reuse |
lib/opencode/client |
Reuse |
lib/theme/* |
Reuse (CSS generation) |
components/layout/* |
Skip |
components/views/GitView |
Skip |
components/views/DiffView |
Skip |
components/views/TerminalView |
Skip |
Not Needed (handled by VS Code)
- Terminal API (VS Code integrated terminal)
- Git API (VS Code SCM)
- Notifications API (VS Code notifications)
- Permissions API (VS Code handles sandbox)
- Directory picker (workspace folder used)
Decisions
- View location: Explorer sidebar
- Sidebar icon: Reuse from
packages/web/public/(tab icon) - Marketplace icon: Reuse from
packages/desktop/src-tauri/icons/app-icon-checkpoint.svg - Publisher:
fedaykindev(dev.azure.com/fedaykindev, artmore@protonmail.com)