Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep events during thread subscription startup #9521

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/9521/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

A thread can lose its first live events while the initial snapshot or replay starts. A missed assistant-text event can leave an empty reply until the client reloads, even though the server saved the text.

Start the thread's live consumer immediately before reading state, as the shell subscription already does.

The existing snapshot test now publishes without a delay and waits for the synchronization marker. It fails before the fix and passes after it. Eleven focused subscription/coalescer tests and the server typecheck pass. Targeted lint reports only existing unused-parameter warnings in the test file.

Created with GPT-6 Astra (preview) in Codex.


Note

Medium Risk Changes real-time orchestration WebSocket delivery during subscription startup; incorrect behavior could still drop or reorder early thread events for clients.

Overview Fixes a race where thread WebSocket subscriptions could drop the first live events while the initial snapshot or replay was still loading—matching behavior subscribeShell already had via startImmediately: true on the scoped fork that feeds the live event coalescer.

The integration test no longer relies on a publish delay or TestClock.withLive; it publishes as soon as the snapshot hook runs, enables requestCompletionMarker, and reads until a synchronized frame so snapshot, event, and completion are all asserted.

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

Note

Start live-event consumer immediately in ws.subscribeThread subscription handler

  • The scoped fork that consumes the live thread-event stream now starts immediately, so live delivery is attached before the handler proceeds with snapshot or catch-up processing. This prevents events from being missed between the fork and snapshot/replay.
  • Updates the subscription test in server.test.ts to request a synchronization marker, collect items up to that marker, and assert the sequence contains snapshot, event, and synchronized items.
Macroscope summarized f4642cf.
    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.7 KiB13.8 KiB+10 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB+5 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.7 KiB6.7 KiB+5 B (+0.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded58.5 KiB58.5 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages10100 (0.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.5 KiB−75 B (−0.5%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−4 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB−71 B (−1.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.9 KiB57.8 KiB−88 B (−0.1%)66.4 KiB✅
      ClaudeLive turn messages108−2 (−20.0%)21✅

      Baseline: f8a14b2 · PR result: f4642cf · 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 f4642cf

      Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that starts the existing thread event consumer before snapshot or replay loading, preventing early events from being lost. The accompanying test deterministically verifies snapshot, event, and synchronization delivery without changing production interfaces or defaults.

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

Sign in to join this conversation.