Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): worktree launches name their branch while the worktree is created #36943

Closedprakharsharma13(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/36943/headopened View on GitHub

Summary

ThreadLaunchService.prepareInBackground started generateBranchNameFor only after fetchWorktreeBaseCommit and createWorktree finished. It then joined the rename fiber before prepared-run.release, leaving the entire LLM call latency on the critical path before releasing the agent.

This forks branch name generation at the start of preparation (using project.workspaceRoot or the existing worktree path) so the LLM call overlaps base branch fetching, checkout, and setup scripts, then joins the running fiber before renaming. If setup is cancelled or fails before renaming, the naming fiber is interrupted cleanly.

Fixes #36889

Tests

  • Added test "names a new worktree thread's branch while its worktree is being created" to ThreadLaunchService.test.ts.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. tanstack-source added labelsbug

    3. Approvability

      Verdict: Approved at 9f98934

      Macroscope's review found this PR approvable — Branch-name generation now overlaps worktree preparation, reducing startup waiting while preserving the rename-before-agent barrier. Cancellation cleanup covers the additional background task, with no product-default changes.

      Notes:

      • All code in this push has already been reviewed. Approvability was decided on eligibility alone.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thanks for this. #36904 makes the same change and is the one being kept.

      #36904 contains the same implementation and regression test, including cancellation cleanup and the requirement to finish renaming before starting the agent. It also includes before-and-after launch measurements, so we’ll continue with that earlier pull request.

      Your change addresses the same useful optimization. Neither version removes the remaining naming wait or makes that wait visible, so those concerns remain separate follow-up work.

      Closing as a duplicate.

    5. juliusmarminge closed this

Sign in to join this conversation.