Files
openchamber/packages/vscode
Bohdan Triapitsyn 51c8d52ab5 perf(ui): improve VS Code chat session switching
Improve chat session switching and history pagination, with most of the aggressive limits scoped to the VS Code webview where the freezes were observed.

Session history loading and pagination:

- Reduce the VS Code message page size to 30 records so switching sessions does not immediately hydrate large histories into the webview.

- Keep manual Load older messages in VS Code fixed at 30 records per request instead of growing the request size over time.

- Add a bounded VS Code initial-tail expansion path from 30 to 50, 80, and 120 records only when the initial page has no user-message turn boundary, preventing large final turns from rendering as an empty chat.

- Lower the normal web message page size from 200 to 150 for a mild shared optimization without adopting the aggressive VS Code limits.

- Make session pagination metadata reactive per session so ChatContainer receives cursor updates from materialization and reconnect paths without requiring a switch away and back.

- Write pagination metadata before publishing newly materialized messages so the first render sees the correct has-more state.

- Store cursor information from direct materialization and reconnect message fetches in the shared session prefetch metadata cache.

VS Code cache and memory pressure reductions:

- Use a shared per-directory session recency map so cache eviction is based on app-level recency instead of whichever useSync instance happened to run.

- Limit VS Code warm session cache retention to 4 sessions and evict heavy inactive message caches after switching away from a large session.

- Disable sidebar session prefetch in VS Code because warming extra sessions was increasing webview memory and GC pressure during navigation.

- Remove dropdown background message prefetch so opening the switcher does not start additional session materialization work.

- Drop cached session-message-record snapshots when evicting session data so stale derived records do not remain after the raw session cache is cleared.

- Add bounded LRU caching for session message record snapshots, with much smaller VS Code limits and a VS Code cap that avoids caching snapshots above 30 messages.

- Bound the turn-window model cache in VS Code and avoid caching turn models for sessions above the VS Code message-page size.

Chat render-path reductions:

- Reuse ChatContainer's already-materialized message records in plan detection instead of adding a second active-session message subscription.

- Add a no-op guard when marking session plan availability so repeated detections do not create new Map references and fan out renders.

- Add no-op guards for session switcher and dropdown open state updates to avoid unnecessary store updates and renders.

- Convert several session-specific hooks to useSyncExternalStore with empty-session no-subscribe behavior so empty IDs do not subscribe to broad store updates.

- Remount the chat viewport when the current session changes, isolating per-session viewport and list state.

- Change the virtualized message-list fallback to render only a tail window when the virtualizer has not produced rows yet, instead of rendering an entire large history.

VS Code layout and header improvements:

- Remove the broad useSessions subscription from the VS Code layout header path and subscribe only to the active session title and initial-session existence.

- Unmount the compact VS Code session sidebar when the user is in chat view instead of keeping the hidden session list mounted and subscribed.

- Compute the latest assistant model and latest context-token usage in a single reverse scan of current-session messages instead of scanning the same list twice.

- Remove switcher git-status warmup work so the switcher reads already-loaded branch labels without starting extra background git status requests.

Markdown and file-reference safeguards:

- Skip expensive syntax highlighting for very large code blocks, with a 200-line cap in VS Code and a softer 1200-line cap in web.

- Add an LRU cap to file-reference stat lookups so the cache cannot grow without bound across many rendered messages.

- Limit the number of file references annotated per render to 40 in VS Code and 200 in web to prevent large assistant outputs from spawning too many stat checks.

- Clear file-link annotations when file-reference mode is disabled so stale attributes and handlers do not remain on previously annotated nodes.

Assistant-message action and preview reductions:

- Skip preview URL scanning on VS Code, mobile, and mini-chat surfaces so assistant text and tool output are not scanned where the preview action is unavailable.

- Skip Save-as-Plan project lookup on VS Code, mini-chat, and mobile surfaces.

- Hide Save-as-Plan and Start MultiRun assistant-message actions on VS Code, mini-chat, and mobile surfaces.

- Resolve the current session directory on demand for assistant actions instead of subscribing each assistant message to the full session list.

Tool and task rendering optimizations:

- Prefer finalized task metadata summaries without fetching child-session messages when the summary is already present.

- Avoid polling or final-fetching task child sessions once a final metadata summary is available.

- Use VS Code-specific task child fetch limits of 30 records for initial, active, and idle fetches.

- Parse diff stats by scanning patch text line-by-line instead of splitting large patches into arrays.

- Count write-tool lines by scanning content instead of allocating a split array for large files.

- Avoid trimming large patch strings just to test whether they contain content.

- Memoize diff and write statistics so unchanged tool parts do not recalculate them on every render.

VS Code bridge improvements:

- Return JSON and text proxy responses through the VS Code bridge as bodyText instead of base64 so the webview avoids synchronous base64 decoding for common API responses.

- Keep binary responses on the base64 path while making bodyBase64 optional in the bridge contract.

- Strip content-length, content-encoding, and transfer-encoding headers from proxied responses because the bridge reconstructs the Response body.

Validation:

- bun run type-check

- bun run lint

- bun run vscode:build
2026-05-21 15:45:44 +03:00
..
2025-12-13 16:34:17 +02:00
2026-05-19 19:26:38 +03:00
2025-12-13 16:34:17 +02:00
2026-05-19 19:26:38 +03:00
2025-12-25 17:57:31 +02:00

OpenChamber VS Code Extension

GitHub stars GitHub release Discord Support the project

OpenCode AI coding agent, right inside your editor. No tab-switching, no context loss.

VS Code Extension

Like the extension? There's also a desktop app and web version with even more features.

What you get

  • Chat beside your code — responsive layout that adapts to narrow and wide panels
  • Agent Manager — run the same prompt across multiple models in parallel, compare results side by side
  • Right-click actions — add context, explain selections, and improve code in-place
  • Click-to-open — file paths in tool output open directly in your editor; edit-style results land in a focused diff view
  • Session editor panel — keep chat sessions open alongside files
  • Theme-aware — adapts to your VS Code light, dark, and high-contrast themes

Plus everything from the shared OpenChamber UI: branchable timeline, smart tool UIs, voice mode, Git workflows, and more.

Commands

Command Description
OpenChamber: Focus Chat Focus the chat panel
OpenChamber: New Session Start a new chat session
OpenChamber: Open Sidebar Open the OpenChamber sidebar
OpenChamber: Open Agent Manager Launch parallel multi-model runs
OpenChamber: Open Session in Editor Open current or new session in an editor tab
OpenChamber: Settings Open extension settings
OpenChamber: Restart API Connection Restart the OpenCode API process
OpenChamber: Show OpenCode Status Debug info for development or bug reports

Right-click menu

Select code in the editor, right-click, and find the OpenChamber submenu:

Action Description
Add to Context Attach selection to your next prompt
Explain Ask the agent to explain the selected code
Improve Code Ask the agent to improve the selection in-place

Configuration

Setting Default Description
openchamber.apiUrl (empty) URL of an external OpenCode API server. Leave empty to auto-start a local instance.
openchamber.opencodeBinary (empty) Absolute path to the opencode CLI binary. Useful when PATH lookup fails. Requires window reload to apply.

Requirements

  • OpenCode CLI installed and available in PATH (or set OPENCODE_BINARY env var)
  • VS Code 1.85+
Development
bun install
bun run vscode:dev

bun run vscode:dev now starts watchers + opens an Extension Development Host automatically. Webview UI changes use Vite HMR automatically.

Optional overrides:

  • OPENCHAMBER_VSCODE_BIN=cursor bun run vscode:dev
  • OPENCHAMBER_VSCODE_DEV_WORKSPACE=/path/to/workspace bun run vscode:dev
  • bun run vscode:dev /path/to/workspace

To package manually:

bun run --cwd packages/vscode build
cd packages/vscode && bunx vsce package --no-dependencies

Install locally: code --install-extension packages/vscode/openchamber-*.vsix

License

MIT