fix(web): stop replays from duplicating the transcript on reconnect - #94
Merged
Merged
Conversation
Deploying infinity with
|
| Latest commit: |
2273092
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://057a9060.infinity-dc7.pages.dev |
| Branch Preview URL: | https://sandbox-fd248ca1-ee54-4173-8.infinity-dc7.pages.dev |
shadaj
marked this pull request as ready for review
August 8, 2026 00:10
* `infinity-web/src/App.tsx`: a `Replay` always carries the complete transcript for the connected thread, so the handler now clears the message state (bumping the generation to invalidate MessageList's prefix cache), pending choices, and streaming flag before processing the replayed history. Previously the WS-reconnect path (`Welcome` → re-`Connect`) never reset the transcript — unlike `navigateTo` / `MigrateComplete` — so each reconnect appended a full extra copy of the history to the messages array and DOM, making the page progressively laggier with every disconnect/reconnect cycle. The input draft is deliberately preserved (unlike `resetMessages`). * `crates/infinity-daemon/src/session/thread_worker.rs`: `handle_subscribe` now replaces an existing subscription on the same channel (`same_channel`) instead of pushing a duplicate. The web client re-sends `Connect` every 5s until `Connected` arrives; when a resume was slow, each retry stacked another subscriber for the same client, causing every display event (and another full `Replay`) to be delivered N times from then on. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #94
shadaj
force-pushed
the
sandbox-fd248ca1-ee54-4173-83ff-9564bd4cef9f
branch
from
August 10, 2026 17:49
ad2e37a to
2273092
Compare
MingweiSamuel
approved these changes
Aug 10, 2026
Comment on lines
+422
to
+426
| subs.retain(|sub| !sub.tx.same_channel(&tx)); | ||
| subs.push(Subscriber { | ||
| tx, | ||
| keeps_session_alive, | ||
| }); |
Member
There was a problem hiding this comment.
Would sub.tx.same_channel actually be true in the re-connect case?
Member
Author
There was a problem hiding this comment.
Not if it's a reconnect on a new TCP channel, but yes if the client just sends a second Connect to the same thread ID.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
infinity-web/src/App.tsx: aReplayalways carries the completetranscript for the connected thread, so the handler now clears the
message state (bumping the generation to invalidate MessageList's
prefix cache), pending choices, and streaming flag before processing
the replayed history. Previously the WS-reconnect path (
Welcome→re-
Connect) never reset the transcript — unlikenavigateTo/MigrateComplete— so each reconnect appended a full extra copy ofthe history to the messages array and DOM, making the page
progressively laggier with every disconnect/reconnect cycle. The
input draft is deliberately preserved (unlike
resetMessages).crates/infinity-daemon/src/session/thread_worker.rs:handle_subscribenow replaces an existing subscription on the samechannel (
same_channel) instead of pushing a duplicate. The webclient re-sends
Connectevery 5s untilConnectedarrives; when aresume was slow, each retry stacked another subscriber for the same
client, causing every display event (and another full
Replay) to bedelivered N times from then on.