Skip to content

fix(worktrees): remove t3code branch prefix - #9275

Closed
meik1998dev wants to merge 1 commit into
pingdotgg:mainfrom
meik1998dev:t3code/remove-worktree-branch-prefix
Closed

meik1998dev wants to merge 1 commit into
pingdotgg:mainfrom
meik1998dev:t3code/remove-worktree-branch-prefix

Conversation

@meik1998dev

@meik1998dev meik1998dev commented Sep 2, 2026 •

Copy link
Copy Markdown

New worktrees start on branches such as t3code/aa34ff6b, and generated names keep the same product prefix. This exposes an unnecessary T3 Code namespace in user repositories.

Generate temporary branches as bare eight-character hashes and keep generated semantic names unprefixed. Legacy t3code/<hash> and UUID branch names remain recognized so existing threads can still rename their branches.

Tests:

  • vp test run packages/shared/src/git.test.ts apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts (65 passed)
  • targeted format and lint checks
  • vp run --filter @t3tools/shared --filter t3 typecheck

Implemented with gpt-5.6-sol in the Codex harness.

Note

Remove t3code prefix from temporary worktree branch names

  • buildTemporaryWorktreeBranchName in git.ts and buildGeneratedWorktreeBranchName in ProviderCommandReactor.ts now return the bare sanitized eight-hex token instead of prepending the legacy worktree branch prefix
  • TEMP_WORKTREE_BRANCH_PATTERN expanded to match bare eight-hex refs as the canonical form while still accepting legacy prefixed eight-hex and prefixed UUID forms
  • isTemporaryWorktreeBranch now classifies bare eight-hex branch refs as temporary; normalization and legacy matching behavior are otherwise unchanged
  • Behavioral Change: existing worktrees created with the old t3code-prefixed branch names are still recognized by isTemporaryWorktreeBranch, but all newly generated branches use the unprefixed form
📊 Macroscope summarized 8a6b6e6. 2 files reviewed, 2 issues evaluated, 0 issues filtered, 2 comments posted

🗂️ Filtered Issues


Note

Medium Risk
Changes how new git branches appear in customer repositories and relies on legacy regex matching for migration; misclassification could skip or mishandle branch rename on first turn.

Overview
New worktree and generated branch names no longer use the t3code/ prefix in user repos. Temporary branches are created as bare 8-character hex refs (e.g. 1234abcd), and LLM-driven renames keep only the sanitized fragment (e.g. feature/gpt-5-6-luna) instead of nesting under t3code/.

Shared git helpers (buildTemporaryWorktreeBranchName, isTemporaryWorktreeBranch) treat unprefixed 8-hex as canonical while still recognizing legacy t3code/<8-hex> and t3code/<uuid> so existing threads can be detected and renamed on first turn. Tests were updated for unprefixed temps and explicit renameBranch expectations.

Reviewed by Cursor Bugbot for commit 8a6b6e6. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 2, 2026
.replace(/[^0-9a-f]/g, "")
.slice(0, 8);
return `${WORKTREE_BRANCH_PREFIX}/${token}`;
return token;

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.

🟠 High src/git.ts:104

buildTemporaryWorktreeBranchName returns an unnamespaced eight-hex branch name, so a token matching an existing user branch makes the bootstrap worktree creation fail: createWorktree passes it to git worktree add -b, which refuses the existing ref instead of retrying. Restore the t3code/ namespace to keep generated names separate from ordinary user branches.

Suggested change
return token;
return `${WORKTREE_BRANCH_PREFIX}/${token}`;
🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/shared/src/git.ts around line 104:

`buildTemporaryWorktreeBranchName` returns an unnamespaced eight-hex branch name, so a token matching an existing user branch makes the bootstrap worktree creation fail: `createWorktree` passes it to `git worktree add -b`, which refuses the existing ref instead of retrying. Restore the `t3code/` namespace to keep generated names separate from ordinary user branches.

// eligible for branch regeneration.
const TEMP_WORKTREE_BRANCH_PATTERN = new RegExp(
`^${WORKTREE_BRANCH_PREFIX}\\/(?:[0-9a-f]{8}|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$`,
`^(?:[0-9a-f]{8}|${WORKTREE_BRANCH_PREFIX}\\/(?:[0-9a-f]{8}|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}))$`,

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.

🟡 Medium src/git.ts:19

isTemporaryWorktreeBranch classifies any local branch named exactly eight hexadecimal characters as temporary, so a normal branch such as deadbeef is renamed by maybeGenerateAndRenameWorktreeBranchForFirstTurn on the first user message. Restrict the matcher to the generated branch prefix so user-owned branches are not changed.

Suggested change
`^(?:[0-9a-f]{8}|${WORKTREE_BRANCH_PREFIX}\\/(?:[0-9a-f]{8}|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}))$`,
`^${WORKTREE_BRANCH_PREFIX}\\/(?:[0-9a-f]{8}|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$`,
🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/shared/src/git.ts around line 19:

`isTemporaryWorktreeBranch` classifies any local branch named exactly eight hexadecimal characters as temporary, so a normal branch such as `deadbeef` is renamed by `maybeGenerateAndRenameWorktreeBranchForFirstTurn` on the first user message. Restrict the matcher to the generated branch prefix so user-owned branches are not changed.

@macroscopeapp

macroscopeapp Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This changes the default branch names created for worktree threads and broadens temporary-branch detection across server and client consumers. Removing the namespace can collide with user branches or cause ordinary branches to be treated as temporary during automatic renaming, so the behavioral impact warrants human review.

Not approved because:

  • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@t3dotgg

t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-6 Astra (preview) responding on behalf of Theo

This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened.

Closing this alternative in favor of #8082, which allows an empty final branch prefix without changing temporary-branch detection. This patch also treats every eight-character hexadecimal branch as temporary, so a user branch such as deadbeef can be renamed on its first worktree turn. Review of configurable prefixes continues on the retained PR.

@t3dotgg t3dotgg closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 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