fix(server): slow worktree checkout no longer uses up the branch-name timeout #48304
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 addedvp 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 passedvp 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
7101189Macroscope'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).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows75 75 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows75 75 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
43328e8· PR result:7101189· Source CI: successScenario 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.
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.tsName 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 to71011-
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:
4-
Check name Status Explanation Title check 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 tit… Description check 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 …Linked Issues check [ #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 check 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…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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-48296
- File: .coderabbit.config.ts
- Commit: 7101189
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
eafd9b7a-aec7-40a3-9e2a-66909956ad5e
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.tsapps/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.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes