Skip to content

Unread chat badge is lost when a message is recovered from the initial SSE snapshot #54

Done

Description

@a-wing

Summary

When a participant joins a room, there is a window between the UI becoming ready and the SSE subscription being established. If another participant sends a chat message during that window, the message can be recovered through the initial SSE snapshot, but the unread badge is never incremented.

This is reproducible through a higher-latency HTTPS reverse proxy. The same upstream test passes over a lower-latency direct connection.

Affected version

  • WOOM commit: 37f499a734592d8d29beeb2936d0543d9b92d4b2
  • Test browser: Chromium via Playwright
  • Media backend: Liveion 0.10.2 (not required to reproduce the chat-state issue)

Reproduction

Use the existing upstream test without modifying it:

E2E_REUSE_SERVER=true \
E2E_BASE_URL=https://<public-https-origin> \
npx playwright test tests/chat.spec.ts:7

The test performs these steps:

  1. Alice creates a meeting.
  2. Bob joins the meeting.
  3. Alice immediately sends hello from alice.
  4. The test expects Bob's chat-unread badge to become 1 within 15 seconds.

Actual behavior

The test times out waiting for chat-unread. In a full public HTTPS run, 30 of 32 tests passed; this test also failed on repeated runs through two different Cloudflare connector routes, so it is not specific to one proxy path.

A diagnostic run that waits three seconds for Bob's SSE subscription before Alice sends the message shows normal behavior: the SSE connection stays open and the live message arrives in about one second. This points to subscription timing rather than an SSE transport failure.

Expected behavior

The unread state should be correct whether a message is delivered as a live message event or recovered through a snapshot. Reconnecting or receiving a snapshot must not incorrectly clear the badge or double-count old messages.

Analysis

The frontend currently handles the two delivery paths differently:

  • applySnapshot replaces messages.value with data.messages, but does not update unread (webapp/components/layout.vue, around line 149).
  • The live message branch appends the message and increments unread when chat is closed (webapp/components/layout.vue, around lines 292–294).

Meanwhile, joinRoom becoming visible does not guarantee that openRoomEvents has already acquired its ticket and established the EventSource. A message sent during this interval can therefore arrive in a snapshot instead of the live message branch.

Suggested direction

Reconcile unread state on snapshots as well as on live messages. Ideally, track a last-read message cursor/timestamp or the participant's join/read position, rather than setting unread to the total message count, so historical messages and reconnect snapshots do not create false unread notifications.

Activity

  1. a-wing commented on Nov 24, 2026

    @a-wing
    MemberAuthor

    Fixed by #59 (commit 60217bd): applySnapshot in layout.vue now heals unread state for messages recovered through the initial snapshot — dedupe by message id and count unseen, post-join, non-self messages (ts >= joinAt, with joinAt/ ts both second-resolution). Covered by the recovery e2e specs (run in the SSE transport leg of the matrix; skipped under cable because cable resyncs through the same snapshot path).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions