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
feat: Real-Time Invoice Collaboration with Live Cursors (#451)
Implements real-time collaborative editing layer for invoice pages
using Server-Sent Events (SSE) for cross-user cursor and presence
sharing.
Adds:
- app/api/collab/[invoiceId]/route.ts - SSE broker endpoint for
broadcasting cursor and presence events between connected clients
- hooks/useInvoiceCollaboration.ts - React hook managing SSE
connection, exponential backoff reconnection, cursor/presence
state, and permission gating
- components/CursorOverlay.tsx - Renders colored per-user cursor
indicators above focused form fields
- components/PresencePill.tsx - Shows colored avatars for
currently editing collaborators
- components/ReconnectionBanner.tsx - Dismissible banner indicating
connection loss with automatic reconnect
Modifies:
- app/invoice/[id]/page.tsx - Integrates collaboration hook,
cursor overlays on payment fields, presence indicators, and
permission-gated socket opening
- app/invoice/new/page.tsx - Integrates collaboration hook and
cursor overlays on key form fields (token, deadline, amount)
- components/CoCreatorPanel.tsx - Exports canUserEditInvoice()
utility for permission checks across the app
Key behaviors:
- Co-creators with edit/admin permission see each other's cursor
position within 200ms of field focus
- Users without write permission cannot open a collaboration socket
- On WebSocket disconnect, a reconnection banner appears with
exponential backoff (1s → 30s)
- Presence indicators are removed within 5s of tab close
- Cursor positions stale after 5s TTL
closes#398
Co-authored-by: isaac4real-art <isaac4real-art@users.noreply.github.com>
Co-authored-by: Emmanuel Chukwunyere <emmanuelanalaba@gmail.com>
0 commit comments