feat(server): make the worktree branch prefix configurable - #6651
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:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
One finding in the settings search catalog: the new "Worktree branch prefix" entry redirects search navigation to another row's anchor even though the new row renders its own anchor id.
Posted via Macroscope — UI Consistency
ApprovabilityVerdict: Approved e6ecb1b Simple additive feature making the worktree branch prefix configurable. The schema change is backwards-compatible with a sensible default, the refactoring is mechanical (parameterizing existing logic), and tests are comprehensive. You can customize Macroscope's approvability policy. Learn more. |
CDVolvik
left a comment
There was a problem hiding this comment.
git.test.ts + settings.test.ts on the PR files: 54/54.
Configurable worktree prefix belongs in server settings, not a hardcoded t3code/. Watch the sanitizer — a user-typed prefix has to stay a valid git ref fragment. The tests cover the contract trim; I did not create a worktree with a hostile prefix. MERGEABLE.
e6ecb1b to
2898611
Compare
What Changed
worktreeBranchPrefix, defaultt3code/. It is applied when the first turn renames a worktree thread's branch.buildGeneratedWorktreeBranchNameintopackages/shared/src/git.ts, which deletes a verbatim copy ofsanitizeBranchFragmentinProviderCommandReactor.ts.Why
Every generated worktree branch is forced under a hard-coded
t3code/prefix. A team whose repository requiresfeat/orfix/cannot follow its own convention.The configured value goes in front of the generated name verbatim, so
feat/,rait-, and an empty string all work without a special case. The default does not change, so no branch name changes until a user opts in.The temporary
t3code/<8 hex>branch keeps its fixed name on purpose: the clients build that name, including the mobile offline outbox drain, and four call sites match on its shape.Deliberately out of scope: a project-scoped prefix in
t3.json, the separatefeature/auto-branch, and the pre-existing silent rename failure when an existing branch shadows the prefix.Related: #272. #3954 proposes the same setting and has been open longer — close this one if that lands first.
UI Changes
The new row in Settings → General. Same window, viewport, theme, and settings state in both captures; only the checkout differs.
Before

After

Checklist
Written by Claude Opus 5 in Claude Code.
Note
Low Risk
Default prefix is unchanged; impact is limited to optional git branch naming on first turn plus settings UI, with sanitization and tests.
Overview
Adds
worktreeBranchPrefixto server settings (defaultt3code/, patchable including empty string) and wires it into first-turn worktree renames from temporaryt3code/<hex>branches.buildGeneratedWorktreeBranchNameandsanitizeBranchPrefixmove to@t3tools/shared/git, replacing the reactor’s local builder so names use the configured prefix, strip echoedt3code/or prefix namespaces, and sanitize fragments.ProviderCommandReactorpassessettings.worktreeBranchPrefixwhen renaming after branch-name generation.Settings → General gets a Worktree branch prefix field (commit sanitizes input), reset/dirty tracking, and search entry. Contract and shared git tests cover defaults and naming edge cases; the reactor test asserts
feat/safer-reconnect-backoffwhen prefix isfeat/.Reviewed by Cursor Bugbot for commit 2898611. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Make the worktree branch prefix configurable via server settings
worktreeBranchPrefixto theServerSettingsschema (defaulting to"t3code/") andServerSettingsPatch, allowing users to override the prefix used for generated worktree branch names.sanitizeBranchPrefixandbuildGeneratedWorktreeBranchNameinpackages/shared/src/git.ts; the builder normalizes the prefix, strips echoed namespaces, sanitizes the fragment, and falls back to"update"when the sanitized fragment is empty.SettingsPanels.tsx) to view, edit, and reset the prefix, with input sanitized viasanitizeBranchPrefixbefore saving."worktree-branch-prefix".ProviderCommandReactornow calls the sharedbuildGeneratedWorktreeBranchNameinstead of a local implementation, applying the user-configured prefix and additional sanitization rules.Macroscope summarized 2898611.