Skip to content

Worktree threads wait at most 2 s for the AI branch name - #80

Merged
collissimo merged 1 commit into
collin/mainfrom
t3/branch-name-deadline
Nov 26, 2026
Merged

collissimo merged 1 commit into
collin/mainfrom
t3/branch-name-deadline

Conversation

@collissimo

Copy link
Copy Markdown
Owner

New worktree threads took about 9 s to start. The server trace shows why: worktree fetch and checkout take about 1.2 s, then the launch waits for the AI branch name (Codex CLI, gpt-6-luna). That call took 3.8 to 8.3 s on this machine, and effort or model changes don't make it faster (an immediately failing call still takes ~3 s; Haiku via claude -p took 2.4 to 4.7 s).

Change

  • The rename now races the AI name against a name built from the first six words of the prompt ([STT] dropped, usual prefix). The prompt name wins only once 2 s have passed since the worktree exists and a blocking setup script has ended, so a setup script that takes longer gives the AI its full time at no cost. The AI call is stopped when it loses.
  • An AI call that fails before the deadline still leaves the temporary name plus the notice, as upstream.
  • Fork-only logic lives in instantBranchName.ts; ThreadLaunchService.ts gets a Deferred and the race. Documented in FORK.md.

Verification

  • ThreadLaunchService.test.ts: 86/86. Upstream's "starts the agent on the temporary branch when branch naming hangs" is replaced by "names the branch from the prompt when the AI branch name is late" (the behavior this PR changes on purpose); one new test covers a blocking setup script. Each new test fails when its part of the change is removed.
  • vp run check:changed: typecheck (43 packages) and format pass. Lint, test, and react-compiler failures are in untouched fork files (dictation, orchestrator, voice input); "unused patches" needs pnpm on PATH.
  • End to end on a test server built from this branch, launching real treeroute worktree threads:
    • no setup script: worktree ready 1.27 s, agent started 3.34 s (was 8.4 s), branch t3/why-do-worktrees-rn-take-9seconds
    • treeroute setup script (async: false, ~4 s): agent started 5.56 s with the AI name t3/sativa-veraltete-preise, node_modules and database in place

🤖 Generated with Claude Code

A new worktree thread's agent waited for the AI branch name (a Codex CLI call,
4 to 8 s measured), so a worktree took about 9 s to start. The rename now races
the AI against the first six words of the prompt, which win once 2 s have passed
since the worktree exists and a blocking setup script has ended. The AI call is
stopped when it loses.

Verified: ThreadLaunchService tests 86/86 (the two new ones fail when the race or the setup wait is removed); check:changed typecheck and format pass, its lint/test/react-compiler failures are in untouched fork files; e2e on a patched test server against treeroute: agent started at 3.34 s (was 8.4 s) with prompt name, and at 5.56 s with the AI name while a 4 s setup script ran
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@collissimo
collissimo merged commit f604256 into collin/main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant