Skip to content

fix(web): stop replays from duplicating the transcript on reconnect - #94

Draft
shadaj wants to merge 1 commit into
mainfrom
sandbox-fd248ca1-ee54-4173-83ff-9564bd4cef9f
Draft

fix(web): stop replays from duplicating the transcript on reconnect#94
shadaj wants to merge 1 commit into
mainfrom
sandbox-fd248ca1-ee54-4173-83ff-9564bd4cef9f

Conversation

@shadaj

@shadaj shadaj commented Aug 6, 2026

Copy link
Copy Markdown
Member
  • 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.

* `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>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploying infinity with  Cloudflare Pages  Cloudflare Pages

Latest commit: ad2e37a
Status: ✅  Deploy successful!
Preview URL: https://abb09ada.infinity-dc7.pages.dev
Branch Preview URL: https://sandbox-fd248ca1-ee54-4173-8.infinity-dc7.pages.dev

View logs

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.

1 participant