Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): slow worktree checkout no longer uses up the branch-name timeout #48304

Openjuliusmarmingewants to merge 2 commits intomain fromrefs/pull/48304/headopened View on GitHub

juliusmarmingecommented

When a new worktree thread was created, the 20-second limit on generating its branch name started before Git's checkout did. A slow checkout could use up that limit, so a name that was ready before checkout finished was thrown away. The thread then kept its temporary t3/<hex> branch and showed a "Branch not renamed" notice. Now the limit only covers how long the agent waits for the name after checkout is done, and when the limit is hit the pending naming call is stopped.

Fixes pingdotgg/t3code#48296

Reproduction on main

Commit 43328e8f0a (origin/main). Real server (apps/server/src/bin.ts serve, fresh --base-dir, T3CODE_DEV_SEED=0), no injected code. Branch naming used the real OpenCode provider (enabled in settings, textGenerationModelSelection = opencode / openai/gpt-5.5-pro via the hub); the agent turn used the recorded Replay provider. Repo: the reporter's synthetic repo, with 8 files behind a CPU-heavy git smudge filter and checkout.workers=1. Launched with t3 thread start <repo> "Inspect the fixture files and summarize them" --worktree main --wait --json, then read the branch and the system_notice rows from statev2.sqlite. Driver: https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/a7039c83cd69c1ad/repro.sh. The same OpenCode naming call run alone took 37.7 s, 36.9 s and 36.8 s. Results: (1) 3.6 CPU s per file: git worktree add exited 0 after 29.0 s, the thread stayed on t3/0e7cd216, notice "Branch not renamed — … Timed out after 20 seconds." This case does not isolate the bug, because naming (~37 s) outlasted checkout. (2) and (3) 6.5 CPU s per file: git worktree add exited 0 after 52.2 s both times, so the name (~37 s) would have been ready ~15 s before checkout finished. Both threads still stayed on t3/07609617 and t3/af128a84 with the same 20 s timeout notice. A unit test in ThreadLaunchService.test.ts, cherry-picked from the earlier factory/repro-48267 branch, also fails on main: vp test run src/orchestration-v2/ThreadLaunchService.test.ts -t "outlasts its timeout" from apps/server. It holds checkout and naming on deferreds, advances TestClock 21 s, then releases both, and the 'Branch not renamed' notice is present.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

  • vp test run src/orchestration-v2/ThreadLaunchService.test.ts -t "outlasts its timeout" (apps/server), on the unfixed code: 1 failed (bug reproduced)
  • vp test run src/orchestration-v2/ThreadLaunchService.test.ts (apps/server), with the fix: 95 passed, before the new test was added
  • vp test run src/orchestration-v2/ThreadLaunchService.test.ts -t "timeout": 2 passed (the repro test and the new test that the timeout still fires after checkout)
  • vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and test (2 files) all passed
  • vp run typecheck (apps/server): no errors, only schemaClassMissingBrand suggestions in files this change does not touch

Not in this change

  • The 20 s BRANCH_NAME_TIMEOUT value itself is unchanged.
  • The timeout still starts when the rename fiber is forked right after checkout, not after the setup script, so a slow setup script can still use part of the 20 s; that matches how it worked before for that stage.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

    1. tanstack-source added labelsbug

    2. Approvability

      Verdict: Approved at 7101189

      Macroscope's review found this PR approvable — Slow checkout no longer consumes the branch-name waiting budget; the post-checkout wait remains capped at 20 seconds and cancels unfinished generation. Existing branch eligibility and cleanup safeguards remain unchanged.

      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.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.5 KiB92.5 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded78.3 KiB78.3 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows75750 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded79.2 KiB79.2 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows75750 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: 43328e8 · PR result: 7101189 · 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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

    4. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The branch-name timeout now applies after checkout instead of during name generation. Tests cover a name that becomes available before checkout finishes and a timeout when naming remains pending after checkout.

      Changes: Branch-name timeout

      Layer / File(s)Summary
      Apply the timeout after checkout
      apps/server/src/orchestration-v2/ThreadLaunchService.ts, apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
      Name generation no longer times out during checkout. After checkout, preparation times out while waiting for the name and interrupts background generation. Tests check the branch rename when naming finishes during checkout and the temporary branch plus notice when naming remains pending.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: yash-singh1, maria-rcks

      Merge Risk: Minimal · up to 71011

      Worktree branch naming no longer loses its 20-second budget to a slow Git checkout. If naming is still pending 20 seconds after checkout, the thread keeps its temporary branch and shows the existing notice. No merge-blocking issue was found.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: a slow worktree checkout no longer consumes the branch-name timeout. The raw summary says the timeout now applies only after checkout, which matches the title. The tit…
      Description checkPassedThe description covers the problem, the change, and the verification steps. It links the issue (#48296) under the fix. It names the tests run and their results, and it lists what is out of scope. The …
      Linked Issues checkPassed[#48296] The issue requires that a worktree thread use the generated branch name when the name is ready before Git checkout finishes, instead of timing out during checkout. The diff to apps/server/src…
      Out of Scope Changes checkPassedAll changes are tied to #48296. The production change is limited to the branch-name timeout placement in ThreadLaunchService.ts, with a comment explaining the timeout now bounds only the post-checkout…
      Full details: Title check

      Explanation

      The title names the main change: a slow worktree checkout no longer consumes the branch-name timeout. The raw summary says the timeout now applies only after checkout, which matches the title. The title follows the conventional commit format the template asks for.

      Full details: Description check

      Explanation

      The description covers the problem, the change, and the verification steps. It links the issue (#48296) under the fix. It names the tests run and their results, and it lists what is out of scope. The Evidence section says before/after proof is still being captured and that the section must be filled in before merge. The Scope section does not state that the issue shows a bug, although the linked issue is cited. Overall, the description is mostly complete.

      Full details: Linked Issues check

      Explanation

      [#48296] The issue requires that a worktree thread use the generated branch name when the name is ready before Git checkout finishes, instead of timing out during checkout. The diff to apps/server/src/orchestration-v2/ThreadLaunchService.ts removes the 20-second Effect.timeoutOrElse from the generateBranchNameFor pipeline. The timeout now wraps only the post-checkout step, which joins the pending naming fiber (Fiber.join(branchName)) or runs generateBranchNameFor when no fiber was forked. A name finished during checkout is therefore returned at join time and applied. On timeout, the code interrupts the pending naming call (stopBranchName) and fails with TextGenerationError, which keeps the existing 'Branch not renamed' path for real timeouts. The PR also adds two tests in ThreadLaunchService.test.ts covering naming that outlasts the timeout during checkout (rename applied, no notice) and after checkout (temporary branch kept, notice shown). The PR reports the repro test failed on the unfixed code and passed with the fix, and that the 'timeout' test subset passed (2 tests). I did not execute the tests. I did not confirm the definition of stopBranchName in the reviewed file because the file was too large to read in one pass; the PR reports a passing typecheck, which supports that it is in scope.

      Full details: Out of Scope Changes check

      Explanation

      All changes are tied to #48296. The production change is limited to the branch-name timeout placement in ThreadLaunchService.ts, with a comment explaining the timeout now bounds only the post-checkout wait. The added tests in ThreadLaunchService.test.ts directly exercise that behavior. The PR description states that the BRANCH_NAME_TIMEOUT value is unchanged and that the setup-script timing is not changed. No unrelated files or behavior changes appear in the reviewed summary or the inspected hunk.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 43328e8f0a680a491c84995b398f5c635ff37a90 and 7101189ca97c3a0fca6052f479f637914ceb86c0.

      Files selected for processing: 2

      • apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
      • apps/server/src/orchestration-v2/ThreadLaunchService.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign in to join this conversation.