VSChat Host Sync
Local multi-host VS Code chat session synchronization and compressed archive bundles across Windows, macOS, and Linux.
Repository: https://github.com/OlyMarco/vschat-host-sync
Table of Contents
Why This Extension Exists
When you connect to a remote server in VS Code using Remote-SSH, VS Code stores local chat histories on your client machine under User/workspaceStorage/<workspace-hash>/chatSessions/*.jsonl and indexes them in state.vscdb (chat.ChatSessionStore.index).
That <workspace-hash> is derived from the full workspace URI, including the exact SSH Host alias string. If you connect to the same physical server and same directory through two different network paths or aliases, for example:
ssh-remote+192.168.10.20 -> /home/dev/project (direct LAN)
ssh-remote+100.64.0.10 -> /home/dev/project (VPN / overlay)
VS Code treats them as two completely isolated workspaces. Conversations created via one address vanish from the chat sidebar when you open the exact same folder via the other address.
Meanwhile:
- VS Code Settings Sync synchronizes settings, keybindings, and extensions, not
workspaceStorage/*/chatSessions.
- GitHub Copilot cloud session sync (
chat.sessionSync.enabled) targets GitHub.com-backed Copilot accounts and repositories, leaving local / custom-model (BYOK) chat sessions isolated on your disk.
- Changing
.ssh/config to force a single alias is not always desirable when distinct aliases represent intentional network or workflow profiles.
VSChat Host Sync solves this at the VS Code storage layer without altering your SSH workflow.
How to Use
- Open the Control Room
- Click
ChatSync in the bottom-right VS Code status bar, or run VSChat Host Sync: Open Control Room from the Command Palette.
- Link Equivalent Hosts
- Click Host Groups and add a group, for example
name: "lab-gpu", hosts: ["192.168.10.20", "100.64.0.10"].
- Alternatively, if two SSH entries already opened the same remote path, the Control Room shows a detection banner, checks reachability (ping/TCP probe) first, and -- if accessible -- connects via non-interactive SSH to verify whether they share the same
/etc/machine-id. Unreachable or unauthenticated hosts are skipped cleanly.
- Navigate and Select
- The left panel starts at Level 1 (
Hosts). Click any host card to drill down into Level 2 (workspaces under that host), then click <- Hosts to return.
- Each workspace row has a checkbox (plus a Select All toggle) for batch operations.
- Each session row has a checkbox for session-level operations.
- Push (Up-Sync) and Pull (Down-Sync) - strictly manual
- Group Pool is the single source of truth for a Host Group. It is initialized from the current window's host when the group is first created or linked, and afterwards it changes only when you Push.
- Push (up) publishes the chosen sessions (content, title renames, Mark as Done / Pinned / Read,
+ / - diff stats, and local deletions as tombstones) from the current host into the Group Pool. Other hosts are not modified.
- Pull (down) applies the Group Pool state into the current host: restores missing or updated sessions, applies renames and Done/Pinned states, and deletes sessions tombstoned in the Group Pool.
- Session-level: tick the session checkboxes, then click the icon buttons in the session batch bar, or click the upload/download icons in the session row next to Export .gz.
- Workspace-level: tick workspace checkboxes and use the batch bar in Level 2, or use the icon buttons next to Export .gz / Import .gz in the workspace header.
- Local edits, new chats, renames, and deletions never affect the Group Pool or sibling hosts until you explicitly Push.
- Compressed Bundles (
.vschat.gz)
- Global: Export Global / Import Global backs up or restores all local workspaces at once.
- Host: Export Host / Import Host covers all workspaces under the selected host.
- Workspace / Session: Export .gz / Import .gz in the workspace header, or Export .gz on an individual session row.
- Resolve legacy diverged branches
- Direct host-to-host sync (
Keep Host A / Keep Host B / Fork Both) remains available on session rows flagged Diverged for resolving pre-Pool conflicts.
Features
- Cross-platform UI extension (
extensionKind: ["ui"])
Runs on the local UI extension host across Windows, macOS, and Linux, resolving User/workspaceStorage from VS Code's own user-data directory (context.globalStorageUri), so Insiders, portable installs, and custom --user-data-dir profiles work out of the box.
- Host Equivalence Groups & Auto-Detection
Group multiple SSH aliases or IP addresses under a single logical host name. The Control Room automatically spots identical remote paths opened under different hosts, checks reachability, and verifies machine identity via non-interactive SSH.
- Group Pool with deletion tombstones
Each Host Group owns one Group Pool. Push writes content, renames, Done/Pinned/Read states,
+/- stats, and deletions (tombstones) into the Pool; Pull applies them to the target host. Deleted sessions are never resurrected.
- Git-style diff against the Group Pool
Synced: host content, title, and state match the Group Pool.
Unsync: exists on this host but not yet in the Pool, or in the Pool but not yet on this host. A host that has never pushed shows every session as Unsync, never Deleted.
Updated / State Diff: content or Done/Pinned/Read state differs from the Pool.
Deleted: tombstoned in the Pool and previously synced on this host.
Diverged: legacy direct-sync conflicts (see How to Use).
- Streaming URI rewrite & large-file safety
Chat
.jsonl logs frequently grow to tens or hundreds of megabytes and embed vscode-remote://ssh-remote%2B<host>/... references. Hashing, host-URI rewriting, and gzip bundling run via Node streams without loading entire logs into memory. Canonical hashing ignores host aliases, volatile UI patches (responderUsername, selectedModel, modelState), and customTitle lines, so renames never cause spurious Updated states.
- Concurrent-host lock guard
If another VS Code window is already open on a different host entry for the same logical workspace, sync actions are blocked for the second session, with a warning notification and status-bar indicator.
- Compressed bundles (
.vschat.gz)
Export and import at three granularities: individual session/workspace, host, or global.
- Full session fidelity
Synchronizes
chat.ChatSessionStore.index (including stats), agentSessions.state.cache (Mark as Done / Archived, Pinned, Read/Unread), agentSessions.model.cache (changes for + / - line counts), and chatEditingSessions/<sessionId>/ snapshots with host URI rewriting. Empty scratch chats (isEmpty: true) and orphan .jsonl files without an index entry are ignored, matching VS Code's own history filtering.
- Control Room UI
Built with zero external frontend dependencies in a warm paper-and-ink control room layout.
Safety Model
- Exactly one definition of the group truth
The Group Pool is the only shared state. Host workspaces never copy from each other directly during Push/Pull; local changes stay local until you Push, and sibling hosts stay unchanged until you Pull there.
- Concurrent-host lock
Each open multi-host workspace acquires a heartbeat lock file in the extension's
globalStorage/locks/ directory keyed by the logical workspace. Opening a second window on a different host alias for the same logical folder blocks Push/Pull for that second session and shows: "Another host entry (...) for this workspace is already open. This session will NOT sync to prevent conflicting chat histories."
- Active-window handling
VS Code caches
chat.ChatSessionStore.index and session states in memory for open windows and flushes state.vscdb on idle (about 60 seconds) or exit. Pull therefore writes the Group Pool state to disk and replays it through agentSession.* commands, with a short-lived live-state overlay keeping the Control Room accurate until the disk catches up. Deleted sessions are removed via agentSession.delete plus on-disk cleanup. chatEditingSessions/ copies are deferred until after live registration so partial preview-tab initialization cannot truncate working-set snapshots.
- Backups
When
createBackups is enabled, a .bak copy is taken before overwriting an existing .jsonl or state.vscdb.
- Pure WASM SQLite (
sql.js)
Database reads and index updates use WebAssembly SQLite with no native C++ addons, avoiding Electron ABI mismatches across OSes and VS Code upgrades.
Configuration
| Setting |
Type |
Default |
Description |
vschatHostSync.hostGroups |
Array<{ name, hosts }> |
[] |
Equivalent SSH host aliases belonging to the same physical server. |
vschatHostSync.workspaceStoragePath |
string |
"" |
Optional override path to VS Code User/workspaceStorage. Leave empty to auto-resolve. |
vschatHostSync.createBackups |
boolean |
true |
Create .bak copies before overwriting an existing .jsonl or state.vscdb. |
vschatHostSync.probeTimeoutMs |
number |
1500 |
Reachability probe timeout in milliseconds before attempting SSH verification. |
Example settings.json:
{
"vschatHostSync.hostGroups": [
{
"name": "lab-gpu",
"hosts": ["192.168.10.20", "100.64.0.10"]
}
]
}
Project Layout
vschat-host-sync/
|-- package.json
|-- tsconfig.json
|-- tsconfig.test.json
|-- esbuild.config.mjs
|-- media/
| |-- icon.svg # Vector icon used in the Webview UI
| `-- icon.png # 128x128 extension icon for Marketplace
|-- src/
| |-- extension.ts # Activation, status bar, watchers, command handlers
| |-- config.ts # Cross-platform storage resolution & baseline persistence
| |-- errors.ts # Structured error codes
| |-- engine/
| | |-- types.ts # Shared workspace, diff, lock, and bundle schemas
| | |-- hostMapper.ts # URI parsing, host normalization, auto-suggestions
| | |-- hostProbe.ts # Reachability probe & non-interactive SSH machine-id check
| | |-- editingSession.ts # Working-set snapshot copy & URI rewrite for +/- diff stats
| | |-- jsonlStream.ts # Streaming canonical SHA-256 & ssh-remote URI rewriter
| | |-- sqliteStore.ts # Pure WASM sql.js reader/writer for state.vscdb
| | |-- scanner.ts # Local workspaceStorage scanner with hash cache
| | |-- diffEngine.ts # Diff classifier against the Group Pool
| | |-- lockManager.ts # PID + heartbeat cross-window lock manager
| | |-- sharedPool.ts # Group Pool: manual Push (Up-Sync) & Pull (Down-Sync)
| | |-- syncManager.ts # Legacy direct host-to-host sync (diverged resolution)
| | `-- bundle.ts # Streaming .vschat.gz export and import
| |-- ui/
| | `-- controlRoomPanel.ts # WebviewPanel RPC bridge
| `-- web/
| |-- index.html # Control Room markup
| |-- styles.css # Warm paper palette styles
| `-- app.js # Vanilla JS state and diff UI
`-- tests/
|-- hostMapper.test.ts
|-- diffEngine.test.ts
|-- lockManager.test.ts
`-- syncAndBundle.test.ts
| |