Users can now attach Microsoft Office documents (.docx, .pptx, and .xlsx) and OpenDocument files (.odt, .odp, and .ods) from the shared web, desktop, mobile, and VS Code chat surfaces. Document text is extracted locally and sent as a text/plain file part with the original filename, keeping the visible user message clean. Supported embedded PNG, JPEG, GIF, and WebP images are sent as separate image parts, with matching [filename] citations preserved near their source paragraph, slide object, spreadsheet cell anchor, or OpenDocument position. Presentation notes, spreadsheet values, headers, and footers are included where available. Document expansion is metadata-validated and bounded against oversized entries, excessive uncompressed data, unsafe paths, invalid image signatures, attachment-name races, and dangling citations after truncation. Generated document parts are published to the composer atomically. Add fflate for worker-backed ZIP extraction and narrowly allow blob workers in the VS Code webview CSP without permitting blob scripts. Include focused fixtures for every supported format, extraction limits, positional citations, collision recovery, atomic attachment state, and CSP behavior.
3.5 KiB
VS Code Backend Modules
This document describes backend runtime modules used by the VS Code extension bridge (packages/vscode/src/bridge.ts).
Purpose
Keep bridge.ts as a thin orchestration layer that delegates message handling to cohesive domain runtimes while preserving API behavior.
Runtime modules
-
bridge.ts- Entry orchestration layer for bridge messages.
- Delegates to specialized runtimes in order and handles only unmatched fallthrough cases.
-
bridge-git-runtime.ts- Standard Git message handlers.
-
bridge-git-special-runtime.ts- Specialized Git flows (
pr-description,conflict-details) and generation helpers.
- Specialized Git flows (
-
bridge-git-process-runtime.ts- Git process execution and environment setup (
execGit), including SSH agent socket resolution.
- Git process execution and environment setup (
-
gitService.ts- Owns VS Code Git and worktree operations.
- Fast worktree creation reports bootstrap phases explicitly:
directory-created, thengit-readyafter Git population/upstream work, andsetup-readyafter setup commands. Existing worktrees without tracked bootstrap state fall back toready/setup-ready; shared webview consumers also accept legacy responses withoutphase. - Worktree removal waits for an active create/bootstrap task for the same directory so background Git and setup work cannot race deletion or restore stale bootstrap state.
-
bridge-fs-runtime.ts- Bridge handlers for filesystem-related message routes.
- Uses shared FS helpers via injected dependencies.
-
bridge-fs-helpers-runtime.ts- Filesystem/path/search helper functions:
- path normalization and resolution
- directory listing
- file search
- file read path safety checks
- dropped-file parsing and attachment reading
- models metadata fetch helper
- Filesystem/path/search helper functions:
The webview CSP permits blob: only for worker-src so shared UI parsers can run bounded local decompression off the main thread. Blob scripts remain disallowed by script-src.
-
bridge-localfs-proxy-runtime.ts- Local
/api/fs/readand/api/fs/rawproxy helpers and shared proxy utility helpers.
- Local
-
bridge-proxy-runtime.ts- Proxy route handlers (
api:proxy,api:session:message) with injected helper dependencies.
- Proxy route handlers (
-
bridge-config-runtime.ts- Config and skills message handlers (
api:config/*). - Includes OpenCode resolution diagnostics parity handler used by shared UI (
/api/config/opencode-resolution).
- Config and skills message handlers (
-
bridge-settings-runtime.ts- Settings read/write and OpenCode skills discovery via API for bridge consumers.
-
bridge-system-runtime.ts- System/editor/provider/quota/notification/update-check message handlers.
- Includes session activity snapshot bridge handler used by webview parity routes (
/api/session-activity). - Includes Zen utility model parity handler used by shared notification settings (
/api/zen/models).
-
bridge-permission-auto-accept-runtime.ts- Owns the persisted VS Code permission auto-accept policy and its GET/PUT bridge contract.
- Serializes reads and read-modify-write updates, persists a monotonic policy revision, and broadcasts the exact committed snapshot to every active OpenChamber webview. Permission replies remain foreground UI-owned because VS Code does not run the OpenChamber server runtime.
Extension guideline
When adding new bridge route families:
- Prefer creating or extending a domain runtime module under
packages/vscode/src/bridge-*-runtime.ts. - Keep
bridge.tsfocused on delegation order and minimal fallthrough behavior. - Inject dependencies into runtimes instead of reaching into unrelated modules directly.