You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Google Docs–style real-time collaboration on a single code file in VS Code or Cursor. See who's in the room and where their cursor is (presence + gutter).
Quick start
Open this folder in Cursor or VS Code (File → Open Folder → select this project).
Get your public key from Liveblocks (create a project, copy the Public key)
In .vscode/settings.json, replace pk_your_liveblocks_public_key with your real key
Commit settings.json so collaborators use the same key (public keys are safe to commit)
Build & run: Terminal → Run Task → npm: compile (or npm run compile), then press F5.
In the new window that opens: open a file → Command Palette (Cmd+Shift+P) → Collab Code: Start collaboration → share the room ID with others.
Setup (one key for the whole project)
Only one person needs a Liveblocks account. Everyone else just clones the repo—they don’t need to add any key.
Step
What to do
1
Get your public key from Liveblocks (create a project → copy Public key).
2
In this repo: copy .vscode/settings.json.example to .vscode/settings.json.
3
In .vscode/settings.json, replace pk_your_liveblocks_public_key with your real key.
4
Commit .vscode/settings.json. Anyone who clones the repo will use that key automatically.
Optional (per user, in their own settings): collabCode.displayName, collabCode.cursorColor.
Project structure
CoLabCode/
├── src/ # Extension source (TypeScript)
│ ├── extension.ts # Entry point: activates commands, wires editor events to presence
│ ├── commands.ts # Start / Join / Leave / Copy link; room ID handling and API key checks
│ ├── state.ts # In-memory state: current room ID and collaborative file URI
│ ├── liveblocks.ts # Liveblocks client, room join/leave, Yjs provider and shared Y.Doc
│ ├── binding.ts # Two-way sync: VS Code TextDocument ↔ Y.Text (doc ↔ Liveblocks)
│ └── presence.ts # Presence UI: status bar (“who’s here”), gutter cursors, selection highlights
├── out/ # Compiled JS (from npm run compile); do not edit
├── .vscode/
│ ├── settings.json.example # Template for Liveblocks public key
│ ├── settings.json # Your key (create from example; safe to commit)
│ ├── launch.json # F5 runs Extension Development Host
│ └── tasks.json # npm: compile task
├── package.json # Extension manifest, scripts, dependencies (Liveblocks, Yjs)
├── build.mjs # Build script (esbuild) — compiles src/*.ts → out/*.js
└── collab-code-0.1.0.vsix # Packaged extension (after npm run package)
Layer
Role
extension.ts
Registers commands and hooks editor selection/active-editor changes to presence. On deactivate: leaves room, unbinds document, detaches presence.
commands.ts
Implements the four commands; reads workspace config (API key, display name, cursor color); creates/joins Liveblocks room and binds the open file.
state.ts
Holds currentRoomId and currentFileUri so the rest of the extension knows which room and file are active.
liveblocks.ts
Liveblocks client + room lifecycle; provides the Yjs document that syncs with the room. Defines CollabPresence (cursor, selection, name, color).
binding.ts
Binds a TextDocument to a Y.Text: local edits go to Yjs (then Liveblocks); remote updates from Yjs are applied to the document (with local-origin filtering to avoid echo).
presence.ts
Subscribes to others’ presence; updates status bar; draws gutter decorations and selection ranges for other users’ cursors.
Running the extension
Option A – Development (F5)
Open this project folder in Cursor or VS Code.
Ensure .vscode/settings.json exists with your real pk_... key (see Setup).
Terminal → Run Task → npm: compile (or npm run compile).
Press F5. A new window opens with the extension loaded.
In that new window: open a file → Collab Code: Start collaboration (or Join with code).
Option B – Install from VSIX (when F5 / Extension Host doesn’t work)
In this project: npm run compile then npx @vscode/vsce package.
In Cursor: Cmd+Shift+P → Extensions: Install from VSIX → select the .vsix from this project.
Reload the window. Open any folder that has .vscode/settings.json with your Liveblocks key and use Collab Code: Start collaboration there.
Commands
Command
What it does
Collab Code: Start collaboration
Start a session; copies room ID to clipboard. Share that ID so others can join.