Skip to content

fix: start the live chat list over on a new connection - #3

Merged
Priveetee merged 2 commits into
mainfrom
fix/live-chat-new-connection
Nov 7, 2026
Merged

Priveetee merged 2 commits into
mainfrom
fix/live-chat-new-connection

Conversation

@Toastienergy

Copy link
Copy Markdown
Collaborator

What

A new live chat connection now starts the message list over, as the web client does.

Why (real data)

Checked against a real YouTube live on watch.typetype.video: the server numbers the messages of each connection chat-1, chat-2, … and opens a new connection with the chat's recent backlog (56 messages in the first 9 s). LiveChatBuffer de-duplicated by id across connections, so after a reconnect (or after the Chat chip is switched off and on) it would have taken the new chat-1…chat-N for already seen and dropped them. Keeping the old list instead would have shown the backlog twice. Ids are still de-duplicated within one connection.

Changes

  • LiveChatBuffer: .connected clears the list and the remembered ids.
  • Tests: a new connection starts over with the same ids again; a message sent twice inside one connection shows once; a decoder test on the first message of the real live (no moderator field, avatar address).

Verification

40 XCTest cases of the shared live chat code pass with Swift 6.0.3 on a Linux host, on top of main after PR #2. The iOS CI job on this PR is the check for the rest.

Not verified: a reconnect on a device. I did not see the two fixes you added after PR #2 until after this was written: the Accept header (my request asked for text/event-stream only, the web client sends text/event-stream, application/json) and the chat opening while the live starts (CoreMedia -16845). Thanks for catching both.

AI disclosure

Prepared with AI assistance (Claude).

Toastienergy and others added 2 commits November 6, 2026 19:51
Checked against a real YouTube live on watch.typetype.video: the server numbers the messages of each connection chat-1, chat-2, ... and starts a new connection with the chat's recent backlog. Keeping ids across connections would have dropped the new messages after a reconnect as already seen, and keeping the list would have shown the backlog twice. The web client starts over on reconnect; so does the buffer now.
@Priveetee
Priveetee merged commit d969073 into main Nov 7, 2026
@Priveetee
Priveetee deleted the fix/live-chat-new-connection branch November 7, 2026 06:40
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.

2 participants