Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(clients): a failed turn shows as failed while background work is pending #14184

Mergedjuliusmarmingemerged 1 commit intot3code/codex-turn-mapping fromrefs/pull/14184/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Addresses #13331 (item 5).

If a turn fails while background work (a subagent, background shell or monitor) is still pending, the thread shows as Waiting instead of Failed until that work drains. shellRuntime in packages/client-runtime parks the runtime at "idle" whenever pendingBackgroundTasks is non-empty, even if the latest run is "failed". The server does report a roster for a failed run, because derivePendingBackgroundWork treats failed as settled. The web resolveSidebarThreadStatus and the mobile resolveThreadListV2Status both return "waiting" for "idle" before they check for "failed". ThreadNotificationCoordinator only promotes a "ready" status to a failure toast, so that never fires either.

What changed

The runtime keeps "failed" when the latest run failed, and parks at "idle" otherwise, as before. The fix is in the two places that build a ThreadRuntimeSummary:

  • shellRuntime (shell / sidebar / mobile list): thread.status !== "failed".
  • deriveThreadRuntime (thread detail, also used to build mobile's selected-thread shell): latestRunProjection?.status !== "failed".

The fix is in the shared client runtime, not in each resolver, so web sidebar, web notifications, mobile list and mobile detail all follow it without separate changes. Only the latest run's status gates this; a leftover lastError on a non-failed run still parks at idle, as Sidebar.logic.test.ts already expects.

Verification

  • entities.test.ts, new test keeps a failed latest run failed while background tasks are still pending (shell path): fails on the base branch, passes with the fix.
  • entities.test.ts, a new failed-run assertion in the existing parks waiting runtime for a post-settlement roster… test (detail path): fails on the base branch, passes with the fix.
  • vp test run src/state/ in packages/client-runtime: 632 passed.
  • apps/web: Sidebar.logic.test.ts, ThreadNotificationCoordinator.test.tsx, ThreadNotificationCoordinator.badge.test.tsx: 173 passed.
  • apps/mobile: threadListV2.test.ts: 91 passed.
  • tsc --noEmit in packages/client-runtime: no errors. vp lint on the touched files: clean.
  • Not run: a real client. This is a status-derivation change with no layout change.

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 6d4b453

      Macroscope's review found this PR approvable — This is a small, tested client-runtime bug fix that changes only failure-status presentation while background work remains pending. An unresolved Medium-severity correctness finding indicates that an older waiting activity run may still mask a newer failure in some concurrent-run states.

      Notes:

      • This verdict was updated automatically after the outstanding correctness findings were resolved. Macroscope did not re-review the code.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.7 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.4 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—4.9 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.7 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—20.8 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: 6d4b453 · 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: 106.1 KiB
      • Claude decoded thread snapshot: 106.4 KiB

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

    4. juliusmarminge merged thise364854

    5. juliusmarminge closed this

Sign in to join this conversation.