Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client): keep warm thread resumes live instead of flashing sync #9913

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/9913/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

#9740 closes a thread's live stream when its last consumer leaves and resumes from a retained cursor for five idle minutes. The retained state was downgraded to cached and the resubscribe forced synchronizing, so every return to a recently viewed thread flashed "Syncing messages..." above the composer until the server's completion marker arrived. Before #9740 the atom stayed alive and live, so returning showed nothing. Thread switching is the hottest navigation in the app; on a relay or tunnel connection the flash is several frames.

Keep a retained live status through the first cursor resume. The rest of the state machine is unchanged:

  • On servers that send the completion marker, a replayed event still moves the thread to synchronizing until the marker arrives, so a thread that actually missed events still shows sync progress.
  • A dropped connection still downgrades to cached through the connection watcher, and the reconnect shows synchronizing again.
  • A replacement session or app-foreground resubscribe still shows sync progress, since it may have missed events.

Verification

  • packages/client-runtime: vp test run src/state passes (31 files, 355 tests). Three new cases in threads-atoms.test.ts assert the observed status sequence on a warm return with nothing to replay (live only), with a replayed event (live → synchronizing → live), and after the connection dropped while away (cached, then synchronizing on reconnect). The first two fail on main.
  • tsgo --noEmit in packages/client-runtime is clean.

Browser check against a copy of real data (two long threads), navigating A → B → A. To capture the moment the pill is decided, the subscribeThread frame was held in the browser so the resubscribe stays pending:

Before (main)After
Return to thread A within the resume windowSyncing messages pill above the composerNo pill above the composer

Without holding the frame, a rendered-frame sampler on main observed the pill for about 2 s on localhost (two separate paints); with this change it never appeared. Pausing the server process while away and returning showed no pill and no stale label on this change, and the thread went live again once the server resumed.

This shared change applies to web, desktop, and mobile. No wire changes.

Found by an audit of the perf PRs merged on 2026-09-04. Created with Claude Fable 5 in Claude Code.


Note

Medium Risk Touches core thread status transitions and subscription resume logic used on every thread navigation; behavior is well-covered by new tests but incorrect edge handling could hide real sync needs.

Overview Fixes a UX regression where returning to a recently viewed thread briefly showed "Syncing messages..." even when nothing was missed.

Retained resume state no longer downgrades live to cached in cachedThreadState when thread data is still present, so the UI can stay live across the idle resume window.

First cursor resubscribe after that warm resume skips the initial synchronizing transition via a resumingLive guard; later resubscribes (new session, foreground wakeup) still call setSynchronizing because they may have missed events. Replay with a completion marker still moves through synchronizing when events actually arrive; connection loss while away still downgrades to cached and reconnect shows sync again.

Tests extend the atom harness with controllable connection/session refs and add cases for warm return (no replay vs replayed snapshot) and disconnect-while-away behavior.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b60ba9cab6e0013b7ee865a089a091478686d3a4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix warm thread resume flashing synchronizing status instead of staying live

  • In EnvironmentThreadState.make, adds a resuming-live flag so the first subscription after a retained live resume skips the synchronizing transition; the flag clears after that input so later resubscriptions sync normally
  • In cachedThreadState, a retained thread with live status and available data now stays live when cached, instead of being downgraded to a non-live status
  • Adds test coverage for warm resumes with and without replayed events, plus connection-drop and remount scenarios that verify cached data is shown without a new stream and later resumes from the cached cursor
  • Risk: cachedThreadState status logic now depends on the retained state having a live status with present data; non-live or deleted states are unchanged, but any caller expecting cached threads to always report a non-live status will see different behavior
Macroscope summarized b60ba9c.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.5 KiB13.6 KiB+69 B (+0.5%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB−3 B (−0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.6 KiB+72 B (+1.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.0 KiB57.1 KiB+88 B (+0.2%)66.4 KiB✅
      CodexLive turn messages810+2 (+25.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.6 KiB−6 B (−0.0%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−7 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.6 KiB6.6 KiB+1 B (+0.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.9 KiB57.9 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages10100 (0.0%)21✅

      Baseline: 2fb99a7 · PR result: b60ba9c · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. Approvability

      Verdict: Approved at b60ba9c

      Macroscope's review found this PR approvable — The production change is a narrowly scoped fix to retained thread resume status, preventing an unnecessary synchronization flash while preserving sync behavior when replay or reconnection is needed. Focused tests cover the relevant resume and connection-loss paths, and the companion harness changes have no production impact.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged thisf87ecf0

    5. juliusmarminge closed this

Sign in to join this conversation.