Skip to content

feat(server): make the worktree branch prefix configurable - #6651

Closed
RaitP1 wants to merge 3 commits into
pingdotgg:mainfrom
RaitP1:feat/worktree-branch-prefix
Closed

feat(server): make the worktree branch prefix configurable#6651
RaitP1 wants to merge 3 commits into
pingdotgg:mainfrom
RaitP1:feat/worktree-branch-prefix

Conversation

@RaitP1

@RaitP1 RaitP1 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Added a global setting, worktreeBranchPrefix, default t3code/. It is applied when the first turn renames a worktree thread's branch.
  • Moved buildGeneratedWorktreeBranchName into packages/shared/src/git.ts, which deletes a verbatim copy of sanitizeBranchFragment in ProviderCommandReactor.ts.
  • Added a "Worktree branch prefix" row to Settings → General.

Why

Every generated worktree branch is forced under a hard-coded t3code/ prefix. A team whose repository requires feat/ or fix/ 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 separate feature/ 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
t3code-branch-prefix-before

After
t3code-branch-prefix-after

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • Not applicable — the change has no animation or interaction

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 worktreeBranchPrefix to server settings (default t3code/, patchable including empty string) and wires it into first-turn worktree renames from temporary t3code/<hex> branches.

buildGeneratedWorktreeBranchName and sanitizeBranchPrefix move to @t3tools/shared/git, replacing the reactor’s local builder so names use the configured prefix, strip echoed t3code/ or prefix namespaces, and sanitize fragments. ProviderCommandReactor passes settings.worktreeBranchPrefix when 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-backoff when prefix is feat/.

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

  • Adds worktreeBranchPrefix to the ServerSettings schema (defaulting to "t3code/") and ServerSettingsPatch, allowing users to override the prefix used for generated worktree branch names.
  • Introduces sanitizeBranchPrefix and buildGeneratedWorktreeBranchName in packages/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.
  • Adds a UI control in General Settings (SettingsPanels.tsx) to view, edit, and reset the prefix, with input sanitized via sanitizeBranchPrefix before saving.
  • Makes the prefix discoverable via settings search under the id "worktree-branch-prefix".
  • Behavioral Change: ProviderCommandReactor now calls the shared buildGeneratedWorktreeBranchName instead of a local implementation, applying the user-configured prefix and additional sanitization rules.

Macroscope summarized 2898611.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 985bb71c-7f2b-40fe-b05c-9b9b184e742a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 15, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread apps/web/src/components/settings/settingsSearch.ts Outdated
Comment thread packages/shared/src/git.ts
Comment thread packages/shared/src/git.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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 CDVolvik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RaitP1
RaitP1 force-pushed the feat/worktree-branch-prefix branch from e6ecb1b to 2898611 Compare August 15, 2026 12:31
@RaitP1 RaitP1 closed this by deleting the head repository Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants