Skip to content

Native Automerge Repo WebSocket sync (/automerge) and UC1–UC3 tests#48

Open
depatchedmode wants to merge 1 commit into
mainfrom
cursor/native-automerge-ws-sync-cda6
Open

Native Automerge Repo WebSocket sync (/automerge) and UC1–UC3 tests#48
depatchedmode wants to merge 1 commit into
mainfrom
cursor/native-automerge-ws-sync-cda6

Conversation

@depatchedmode
Copy link
Copy Markdown
Owner

Summary

Implements native Automerge Repo WebSocket sync on the sync server so peers using WebSocketClientAdapter can load the workspace document via CBOR, closing the gap described in #26 and GAP 1.

What changed

  • Dual WebSocket servers on the same MC_WS_PORT after auth:
    • / — existing JSON snapshot protocol for the Vite dev UI (unchanged behavior).
    • /automergeWebSocketServerAdapter for @automerge/automerge-repo clients; use ?ticket= from /automerge/ws-ticket (same as UI).
  • AutomergeStore: shareConfig restricts remote sync to the current workspace document id only (no broad document sharing).
  • Tests: test/sync-use-cases.test.js covers UC1–UC3; GAP 1 uses nativeAutomergeWsUrl. npm run test:gaps runs both files.
  • npm test: adds --test-force-exit so the adapter’s keep-alive interval does not hang the Node test runner.
  • README: documents dual paths, native vs HTTP merge semantics, and updates Phase 2 bullets.
  • Plan: committed .cursor/plans/multi-replica-sync-roadmap.plan.md for traceability.

Verification

  • npm test
  • npm run test:gaps

Notes / follow-ups

Open in Web Open in Cursor 

- Split WS upgrade: legacy JSON snapshots on /, WebSocketServerAdapter on /automerge
- Register adapter with store repo after init; workspace-only shareConfig for remote peers
- Add test/sync-use-cases.test.js (UC1–UC3); extend test:gaps; point GAP1 at native URL
- Use --test-force-exit in npm test so adapter keep-alive timers do not hang the runner
- Document dual WS paths and merge semantics in README; include multi-replica plan in repo

Co-authored-by: depatchedmode <depatchedmode@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants