Live updates: SSE multiplexer + read watermark + cross-tab sync #10
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
posta/chat#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
#2
What to build
Real time.
internal/sseopens one SSE-in per logged-in user to their posta-server, refcounted by active browser tabs with a 10s grace on disconnect. chat.posta.no exposes/eventsto browsers using htmx'ssseextension. posta-server SSE events translate to small opaque trigger events; htmx fireshx-gets for the affected fragments (one render path for first-paint and live updates). Read watermark POSTs on thread open; while a thread is open, the backend tracks that peer as "active" for the session and auto-advances the watermark on inbound for that peer before fanning out the trigger.Acceptance criteria
/events(cookie-authenticated)inboundandoutbound-stateevents fan out asthread-updatedtrigger (peer URL in data); sidebar getscontact-changedread-watermark-changedevent forwards to sidebar for unread re-renderresyncevent from posta-server fans out a "re-render now" trigger to all subscribed tabs/api/v1/contacts/readwith the highest visiblerowIdresynccascadeLast-Event-IDresumption works after transient disconnectsinternal/sse: refcount lifecycle, 10s grace period, reconnect with backoff,Last-Event-IDresumption,resyncforwarding, concurrent subscribe/unsubscribe racesBlocked by