Repository navigation
Feat/custom worktree branch name - #6428
MrSimmmons wants to merge 9 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
| // A custom name skips the server's LLM branch naming: | ||
| // only temporary-pattern branches get renamed. | ||
| branch: | ||
| customWorktreeBranchName ?? buildTemporaryWorktreeBranchName(randomHex), |
There was a problem hiding this comment.
🟠 High components/ChatView.tsx:5248
customWorktreeBranchName can pass Git-invalid names such as feature.lock or foo.lock/bar to prepareWorktree.branch, so the conflict check passes and the first send fails during worktree creation. Validate the final branch name against Git's full ref-format rules, including slash-separated components ending in .lock, before dispatching it.
Also found in 1 other location(s)
packages/shared/src/git.ts:133
normalizeWorktreeBranchNamecan return names Git rejects because it never removes or rejects a slash-separated component ending in.lock(for example,feature.lockorteam.lock/topic). Git's ref-format rules explicitly forbid such components. The conflict query will not flag a nonexistent invalid ref, so send proceeds with this custom name and worktree/branch creation fails instead of creating the new thread.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/ChatView.tsx around line 5248:
`customWorktreeBranchName` can pass Git-invalid names such as `feature.lock` or `foo.lock/bar` to `prepareWorktree.branch`, so the conflict check passes and the first send fails during worktree creation. Validate the final branch name against Git's full ref-format rules, including slash-separated components ending in `.lock`, before dispatching it.
Also found in 1 other location(s):
- packages/shared/src/git.ts:133 -- `normalizeWorktreeBranchName` can return names Git rejects because it never removes or rejects a slash-separated component ending in `.lock` (for example, `feature.lock` or `team.lock/topic`). Git's ref-format rules explicitly forbid such components. The conflict query will not flag a nonexistent invalid ref, so send proceeds with this custom name and worktree/branch creation fails instead of creating the new thread.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a new custom worktree-branch workflow spanning the composer UI, persisted drafts, shared Git helpers, RPC contracts, and server-side worktree creation. Its asynchronous validation and unresolved risks around Git-invalid names, case/path collisions, and mobile layout behavior require human review. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
85e8859 to
efd6128
Compare
There was a problem hiding this comment.
Three consistency issues in the new BranchToolbarWorktreeNameInput control, all within the composer context strip it joins.
Posted via Macroscope — UI Consistency
listRefs matches the query as a substring and pages the result, so an exact branch could fall off a 20-ref page and the gate would report the name as available. Ask for local refs only at the schema's max page size, and export that ceiling so the two stay in step.
There was a problem hiding this comment.
One finding: the new worktree-name input is rendered as a direct child of the context strip in the mobile layout, where useLabelsOverflow's width accounting only sums a child's children, so the field's width is invisible to the compact/expand heuristic.
Posted via Macroscope — UI Consistency
| previousWorktreeLabel={previousWorktreeLabel} | ||
| onUsePreviousWorktree={onUsePreviousWorktree} | ||
| /> | ||
| {worktreeNameInput} |
There was a problem hiding this comment.
In the mobile branch this input becomes a direct child of the strip, but useLabelsOverflow treats every direct child as a group and measures it with contentWidth(child), which sums child.children. An <input> has no element children, so it contributes 0 to needed (only the extra 8px strip gap is counted) even though it occupies up to w-44 (176px).
Because the same undercount applies in both directions, the expand test in compact mode (needed > available - 16) can conclude the expanded layout fits when it doesn't: the strip expands, the branch label then clips, needed > available fires, and it flips back to compact — a flap loop with FLIP animations at widths where the field is the deciding factor. In the desktop branch the input sits inside the flex min-w-0 flex-1 group div and is measured correctly, so only the mobile path is affected.
Smallest fix: give the mobile pair the same group container the desktop layout uses, e.g. wrap MobileRunContextSelector and {worktreeNameInput} in <div className="flex min-w-0 items-center gap-2"> (same gap the strip uses, so spacing is unchanged). Alternatively, have contentWidth fall back to the child's own offsetWidth when it has no element children.
Posted via Macroscope — UI Consistency
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 64bb942. Configure here.
| */ | ||
| function refCollidesWithName(refName: string, name: string): boolean { | ||
| return refName === name || refName.startsWith(`${name}/`) || name.startsWith(`${refName}/`); | ||
| } |
There was a problem hiding this comment.
Collision check ignores letter case
Medium Severity
refCollidesWithName compares refs with case-sensitive equality and prefix checks. Sibling helpers in the same package already treat branch collisions as case-insensitive, and git with core.ignorecase (default on macOS and Windows) refuses a new branch that differs from an existing one only by case. The input can mark a name available and the send path will proceed, then git worktree add -b fails.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 64bb942. Configure here.
| const checked = | ||
| deferredNormalizedValue === normalizedValue && | ||
| (conflictRefsQuery.data !== null || conflictRefsQuery.error !== null); | ||
| const conflict = checked && (conflictRefsQuery.data?.totalCount ?? 0) > 0; |
There was a problem hiding this comment.
Slash and dash names share paths
Medium Severity
The new collision check only compares git ref hierarchy, but createWorktree turns every / in the branch name into - for the worktree directory. Names such as feat/foo and feat-foo are treated as available even when they map to the same path, so the second create fails after the UI has already cleared the name for send.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 64bb942. Configure here.
|
Note 🤖 GPT-5.6 Sol responding on behalf of Theo We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together. This adds custom worktree branch names across server, contracts, web, and mobile. We are not adding this new worktree naming path through the current backlog. If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed. |


What Changed
Allows the setting of a custom branch name when creating a new worktree from a new thread
Why
Fixes #6421, also adds a workflow / fixes a potential bug for #3044, #5359 #5734 and #967
Was initially developed on top of #6427 to round out some worktree features I found missing when comparing to other apps like VS Code, but its a pretty good stand alone feature addition so this gets its own PR
UI Changes
Before:

After:


Happy to make changes to the UI if the idea seems sound :D
Checklist
Note
Medium Risk
Touches first-message worktree creation and send gating; incorrect collision logic or stale async checks could block sends or allow invalid branch names, though server-side git would still reject duplicates.
Overview
Adds an optional custom branch name field in the composer context strip when starting a new thread in New worktree mode (before the first send, no existing worktree). The name is sanitized as you type, persisted on the draft (
worktreeBranchName), and used inprepareWorktree.branchinstead of the randomt3code/…temporary name when it passes validation.Conflict checks call
listRefswith a newqueryMode: "collision"on the Git VCS driver, which returns local refs that would collide with the typed name (exact match, parent, or child under Git’s ref rules—not substring search). The input shows inline errors and blocks send while the check is in flight or if a collision is found;ChatViewmirrors those gates with thread errors.Supporting changes:
sanitizeWorktreeBranchNameInput/normalizeWorktreeBranchNamein shared git helpers (with tests),queryModeonVcsListRefsInput, and minor toolbar layout tweaks (shrink/flex-auto) so the new control fits beside existing selectors.Reviewed by Cursor Bugbot for commit 64bb942. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add custom worktree branch name input with collision validation
sanitizeWorktreeBranchNameInputand normalized withnormalizeWorktreeBranchNameto comply with Git ref rulescollisionquery mode tolistRefs(VcsListRefsInput) backed by the newrefCollidesWithNamehelper in GitVcsDriverCore, returning only refs that would collide with the given nameworktreeBranchNamefield in composerDraftStorefilterBranchesForListQuerynow accepts an optionalqueryModeparameter; callers that omit it retain the existing substring behavior, but any out-of-tree consumers ofVcsListRefsInputshould be aware of the new optional field📊 Macroscope summarized 64bb942. 5 files reviewed, 3 issues evaluated, 3 issues filtered, 0 comments posted
🗂️ Filtered Issues
apps/web/src/components/BranchToolbarWorktreeNameInput.tsx — 0 comments posted, 2 evaluated, 2 filtered
normalizeWorktreeBranchNameleaves the special branch nameHEADunchanged, so the collision query can report it as available and the send path uses it forgit worktree add -b. Git rejectsHEADas a branch name, meaning typingHEADpasses the new validation but causes worktree creation to fail. [ Already posted ]listRefslookup is treated ascheckedand therefore produces theavailablestate at lines 65-78. If the lookup failed while a local branch with the requested name already exists, the send path accepts that status and attemptsgit worktree add -b; Git then rejects the colliding ref, so the UI shows the name as available but the first send fails instead of asking the user to retry validation or choose another name. [ Already posted ]apps/web/src/components/ChatView.tsx — 0 comments posted, 1 evaluated, 1 filtered
worktreeBranchNameStatusis truthy. Immediately after entering a name (before the input's effect publishes itscheckingstatus),draftWorktreeBranchNameis non-null but the status is stillnull, so the send proceeds and line 5879 falls back to a generated branch. Thus a user can submit a first worktree message quickly and silently lose the requested custom branch name instead of waiting for validation. [ Already posted ]