Skip to content

feat: move cursor updates from Presence to Broadcast#14

Merged
trmquang93 merged 1 commit intomainfrom
feat/cursor-broadcast-refactor
Mar 18, 2026
Merged

feat: move cursor updates from Presence to Broadcast#14
trmquang93 merged 1 commit intomainfrom
feat/cursor-broadcast-refactor

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Cursor transport: Switches remote cursor updates from Supabase Presence track() to Broadcast channel.send(), eliminating CRDT merge overhead and spurious join/leave events (~20/sec per user)
  • Three-layer cleanup: Cursors are removed via Presence sync (clean disconnect), a 4s stale timer (crash/network drop), and leaveRoom() reset
  • Throttle increase: Cursor broadcast throttle raised from 50ms to 150ms (~3x fewer messages, still smooth with 80ms CSS transition)
  • Lint fix: Removes unused captureDragSnapshot dependency in useHotspotInteraction

Test plan

  • Verify npm run lint passes with zero warnings
  • Verify npm test passes (264 tests, including 17 new cursor tests)
  • Manual: Create a collab room, confirm remote cursors appear and move smoothly
  • Manual: Close a guest browser tab abruptly, confirm cursor disappears within ~4s
  • Manual: Guest leaves cleanly, confirm cursor removed immediately

Supabase Presence fires join/leave on every track() call, causing
unnecessary CRDT churn and spurious peer initialization at ~20 events/sec
per user. This switches cursor updates to lightweight Broadcast messages,
adds three-layer cursor cleanup (Presence sync, stale timer, leaveRoom),
and increases throttle from 50ms to 150ms to reduce bandwidth.

Also removes unused captureDragSnapshot dependency in useHotspotInteraction.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flow-forge Ready Ready Preview, Comment Mar 18, 2026 3:33pm

@trmquang93 trmquang93 merged commit 6e91e68 into main Mar 18, 2026
3 checks passed
@github-actions github-actions bot deleted the feat/cursor-broadcast-refactor branch March 18, 2026 15:38
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