Skip to content

OBJ-92 — YJS client wired (two-tab convergence) - #43

Merged
objectgyan merged 1 commit into
mainfrom
objectgyan/obj-92-m83-yjs-client-wired-two-tab-convergence
May 17, 2026
Merged

objectgyan merged 1 commit into
mainfrom
objectgyan/obj-92-m83-yjs-client-wired-two-tab-convergence

Conversation

@objectgyan

Copy link
Copy Markdown
Owner

Summary

  • Wires y-websocket client into the document editor via a useYDoc hook that creates a Y.Doc + WebsocketProvider per document id
  • Each field's value is bound to a shared Y.Map entry keyed by field id; local edits write to Y.Map and broadcast via /ws/docs/{id}; remote Y.Map changes update the React draft
  • Awareness publishes username + random color, renders colored peer dots next to active fields; connection status banner (green = connected)
  • Reconnect with exponential backoff via maxBackoffTime: 10_000 (y-websocket built-in)
  • Playwright two-context test: edit in ctx1 converged to ctx2 in 76ms (target <200ms); awareness dot DOM assertion passes

Test plan

  • pnpm lint passes
  • pnpm typecheck passes
  • pnpm build passes
  • scripts/validate-obj-92.ps1 exits 0
  • Playwright two-context test: 1/1 passed (76ms convergence)
  • Awareness indicator visible in ctx2 within 5s

Wire y-websocket client into the document editor. Each Field value is
bound to a shared Y.Map entry keyed by field id; opening the same doc
in two tabs shares one Y.Doc instance per client and converges via the
server's /ws/docs/{id} endpoint (OBJ-81).

- useYDoc hook: Y.Doc + WebsocketProvider with maxBackoffTime=10s
- ydispatch: SET_FIELD_BODY writes to Y.Map for broadcast
- observeDeep on Y.Map: remote changes dispatched into React draft
- AwarenessIndicator: colored dot per peer per field
- collab-status banner: connected / connecting indicator
- Playwright two-context test: 76ms convergence (target <200ms)
@linear-code

linear-code Bot commented May 17, 2026 •

Copy link
Copy Markdown
OBJ-92 M8.3 — YJS client wired (two-tab convergence)

Milestone: M8 · Wave: 3

Summary

Wire y-websocket client in the editor. Two browser tabs on the same document show real-time convergence + awareness (remote cursors).

Acceptance

  • Edits in tab A appear in tab B within ~200ms
  • Awareness shows the other user's cursor color/name
  • Disconnect + reconnect rejoins cleanly

Validation

  • DB check: snapshot row reflects converged state after both tabs disconnect
  • Live API check: Playwright UI test opens two contexts, edits both, asserts they converge
  • Script: scripts/validate-obj-NNN.ps1

Branch / PR

Branch from main; target main. No trailers/footer.

Review in Linear

@objectgyan
objectgyan merged commit f461349 into main May 17, 2026
3 of 5 checks passed
objectgyan added a commit that referenced this pull request May 17, 2026
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.

1 participant