Skip to content
TypeScript

feat: new branches use the shorter t3/ prefix (#16220)

Theo Browne2afe87ea4bb9
diff --git a/apps/mobile/src/features/settings/components/BranchNamingSettings.tsx b/apps/mobile/src/features/settings/components/BranchNamingSettings.tsx
index 5f4737d7e9f..4a1a7d780ff 100644
--- a/apps/mobile/src/features/settings/components/BranchNamingSettings.tsx
+++ b/apps/mobile/src/features/settings/components/BranchNamingSettings.tsx
@@ -48,7 +48,7 @@ export function BranchNamingSettings(props: {
{props.mode === "static" ? (
<View className="gap-2 px-4 py-3">
<Text className="text-sm text-foreground-muted">
- Use t3code or t3code/ for t3code/add-search. Leave empty for no prefix.
+ Use t3 or t3/ for t3/add-search. Leave empty for no prefix.
</Text>
<AppTextInput
key={props.prefix}
diff --git a/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts b/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
index 1c83edb8cc3..9b986f9fe86 100644
--- a/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
@@ -1104,7 +1104,7 @@ it.effect("names the worktree itself when the client provides no branch", () =>
yield* waitUntil(() => Effect.sync(() => harness.createWorktree.mock.calls.length === 1));
assert.match(
harness.createWorktree.mock.calls[0]?.[0]?.newRefName ?? "",
- /^t3code\/[0-9a-f]{8}$/u,
+ /^t3\/[0-9a-f]{8}$/u,
);
yield* waitUntil(() =>
threads
@@ -1115,7 +1115,7 @@ it.effect("names the worktree itself when the client provides no branch", () =>
}),
);
-it.effect("renames a temporary t3code/<hash> branch off the provisioning critical path", () =>
+it.effect("renames a temporary t3/<hash> branch off the provisioning critical path", () =>
Effect.gen(function* () {
const branchNameStarted = yield* Deferred.make<void>();
const allowBranchName = yield* Deferred.make<void>();
@@ -1138,11 +1138,11 @@ it.effect("renames a temporary t3code/<hash> branch off the provisioning critica
command: "command:launch:temp-branch",
thread: "thread:launch:temp-branch",
message: "Build the feature",
- workspace: { type: "worktree", baseRef: "main", branch: "t3code/abcd1234" },
+ workspace: { type: "worktree", baseRef: "main", branch: "t3/abcd1234" },
}),
);
yield* Deferred.await(branchNameStarted);
- assert.equal(harness.createWorktree.mock.calls[0]?.[0]?.newRefName, "t3code/abcd1234");
+ assert.equal(harness.createWorktree.mock.calls[0]?.[0]?.newRefName, "t3/abcd1234");
yield* waitUntil(() =>
threads
.getThreadProjection(launched.threadId)
@@ -1150,7 +1150,7 @@ it.effect("renames a temporary t3code/<hash> branch off the provisioning critica
);
assert.equal(
(yield* threads.getThreadProjection(launched.threadId)).thread.branch,
- "t3code/abcd1234",
+ "t3/abcd1234",
);
yield* Deferred.succeed(allowBranchName, undefined);
yield* waitUntil(() =>
@@ -1160,17 +1160,17 @@ it.effect("renames a temporary t3code/<hash> branch off the provisioning critica
);
assert.deepEqual(harness.renameBranch.mock.calls[0]?.[0], {
cwd: "/repo-worktrees/temp",
- oldBranch: "t3code/abcd1234",
+ oldBranch: "t3/abcd1234",
newBranch: "generated-branch",
});
}).pipe(Effect.provide(harness.layer));
}),
);
-it.effect("provisions under t3code-<hash> when a plain t3code branch blocks t3code/*", () =>
+it.effect("provisions under t3-<hash> when a plain t3 branch blocks t3/*", () =>
Effect.gen(function* () {
const harness = makeHarness({
- hasCommit: (input) => Effect.succeed(input.refName === "refs/heads/t3code"),
+ hasCommit: (input) => Effect.succeed(input.refName === "refs/heads/t3"),
createWorktree: (input) =>
Effect.succeed({
worktree: { path: "/repo-worktrees/temp", refName: input.newRefName, headSha: "abc" },
@@ -1184,7 +1184,7 @@ it.effect("provisions under t3code-<hash> when a plain t3code branch blocks t3co
command: "command:launch:blocked-namespace",
thread: "thread:launch:blocked-namespace",
message: "Build the feature",
- workspace: { type: "worktree", baseRef: "main", branch: "t3code/abcd1234" },
+ workspace: { type: "worktree", baseRef: "main", branch: "t3/abcd1234" },
}),
);
yield* waitUntil(() =>
@@ -1192,8 +1192,8 @@ it.effect("provisions under t3code-<hash> when a plain t3code branch blocks t3co
.getThreadProjection(launched.threadId)
.pipe(Effect.map((projection) => projection.thread.branch === "generated-branch")),
);
- assert.equal(harness.createWorktree.mock.calls[0]?.[0]?.newRefName, "t3code-abcd1234");
- assert.equal(harness.renameBranch.mock.calls[0]?.[0]?.oldBranch, "t3code-abcd1234");
+ assert.equal(harness.createWorktree.mock.calls[0]?.[0]?.newRefName, "t3-abcd1234");
+ assert.equal(harness.renameBranch.mock.calls[0]?.[0]?.oldBranch, "t3-abcd1234");
}).pipe(Effect.provide(harness.layer));
}),
);
@@ -1235,11 +1235,11 @@ it.effect("keeps the temporary branch when branch generation fails", () =>
command: "command:launch:branch-fallback",
thread: "thread:launch:branch-fallback",
message: "Build the feature",
- workspace: { type: "worktree", baseRef: "main", branch: "t3code/abcd1234" },
+ workspace: { type: "worktree", baseRef: "main", branch: "t3/abcd1234" },
}),
);
yield* waitUntil(() => Effect.sync(() => harness.generateBranchName.mock.calls.length === 1));
- assert.equal(harness.createWorktree.mock.calls[0]?.[0]?.newRefName, "t3code/abcd1234");
+ assert.equal(harness.createWorktree.mock.calls[0]?.[0]?.newRefName, "t3/abcd1234");
yield* waitUntil(() =>
threads
.getThreadProjection(launched.threadId)
@@ -1248,7 +1248,7 @@ it.effect("keeps the temporary branch when branch generation fails", () =>
assert.equal(harness.renameBranch.mock.calls.length, 0);
assert.equal(
(yield* threads.getThreadProjection(launched.threadId)).thread.branch,
- "t3code/abcd1234",
+ "t3/abcd1234",
);
}).pipe(Effect.provide(harness.layer));
}),
@@ -1267,8 +1267,8 @@ it.effect("renames a temporary branch on an existing worktree to a generated nam
message: "Build the feature",
workspace: {
type: "existing_worktree",
- worktreePath: "/repo-worktrees/t3code-abcd1234",
- branch: "t3code/abcd1234",
+ worktreePath: "/repo-worktrees/t3-abcd1234",
+ branch: "t3/abcd1234",
},
}),
);
@@ -1278,8 +1278,8 @@ it.effect("renames a temporary branch on an existing worktree to a generated nam
.pipe(Effect.map((projection) => projection.thread.branch === "generated-branch")),
);
assert.deepEqual(harness.renameBranch.mock.calls[0]?.[0], {
- cwd: "/repo-worktrees/t3code-abcd1234",
- oldBranch: "t3code/abcd1234",
+ cwd: "/repo-worktrees/t3-abcd1234",
+ oldBranch: "t3/abcd1234",
newBranch: "generated-branch",
});
}).pipe(Effect.provide(harness.layer));
diff --git a/apps/server/src/orchestration-v2/ThreadLaunchService.ts b/apps/server/src/orchestration-v2/ThreadLaunchService.ts
index 6f8fb5c0ae6..d8aff311d77 100644
--- a/apps/server/src/orchestration-v2/ThreadLaunchService.ts
+++ b/apps/server/src/orchestration-v2/ThreadLaunchService.ts
@@ -304,7 +304,7 @@ const make = Effect.gen(function* () {
});
// The server owns worktree naming: without an explicit branch, provision
- // under a temporary `t3code/<hash>` name so the worktree never waits on
+ // under a temporary `t3/<hash>` name so the worktree never waits on
// name generation, then rename in the background below.
const requestedBranch = input.workspaceStrategy.branch;
let branch: string | null;
diff --git a/apps/web/src/components/settings/BranchNamingSettings.tsx b/apps/web/src/components/settings/BranchNamingSettings.tsx
index 527f798e148..d6167d0934a 100644
--- a/apps/web/src/components/settings/BranchNamingSettings.tsx
+++ b/apps/web/src/components/settings/BranchNamingSettings.tsx
@@ -76,7 +76,7 @@ export function BranchNamingSettings() {
serverScoped
settingKeys={["branchNamePrefix"]}
title="Branch prefix"
- description="For example, t3code or t3code/ produces t3code/add-search. Leave empty for no prefix."
+ description="For example, t3 or t3/ produces t3/add-search. Leave empty for no prefix."
resetAction={
prefixMixed ||
settings.branchNamePrefix !== DEFAULT_SERVER_SETTINGS.branchNamePrefix ? (
diff --git a/docs/user/project-settings.md b/docs/user/project-settings.md
index d1affc3f079..20c41f0ae9b 100644
--- a/docs/user/project-settings.md
+++ b/docs/user/project-settings.md
@@ -42,7 +42,7 @@ and other phone-only settings ignore the filter.
In **Settings → Source Control → Worktree branch naming**, choose a static prefix,
a model-selected semantic prefix such as `feat/` or `fix/`, or custom instructions
-for the complete name. The static prefix defaults to `t3code/`; a trailing slash is
+for the complete name. The static prefix defaults to `t3/`; a trailing slash is
optional, and an empty prefix adds nothing. Invalid characters in a static prefix
are replaced with hyphens. Custom instructions are appended to
the naming prompt and can specify issue IDs, namespaces, and casing.
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index 7efd0612463..20fc7b7ddd3 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -1085,10 +1085,10 @@ it("validates remote device hosts and rejects ambiguous host ids", () => {
});
describe("branch naming settings", () => {
- it("defaults existing settings to the t3code static prefix", () => {
+ it("defaults existing settings to the t3 static prefix", () => {
expect(decodeServerSettings({})).toMatchObject({
branchNamingMode: "static",
- branchNamePrefix: "t3code",
+ branchNamePrefix: "t3",
branchNameInstructions: "",
});
});
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index ff14bcaab91..f4d1c771971 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -1368,7 +1368,7 @@ export const ServerSettings = Schema.Struct({
branchNamingMode: BranchNamingMode.pipe(
Schema.withDecodingDefault(Effect.succeed("static" as const)),
),
- branchNamePrefix: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed("t3code"))),
+ branchNamePrefix: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed("t3"))),
branchNameInstructions: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
removeAgentCreditsOnMerge: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
sourceControlWritingStyle: SourceControlWritingStyleSettings.pipe(
diff --git a/packages/shared/src/git.test.ts b/packages/shared/src/git.test.ts
index 093b15d0ea3..1a0cfe97b3b 100644
--- a/packages/shared/src/git.test.ts
+++ b/packages/shared/src/git.test.ts
@@ -190,34 +190,37 @@ describe("isTemporaryWorktreeBranch", () => {
);
});
- it("matches legacy UUID-shaped temporary worktree refs from older mobile builds", () => {
+ it("matches legacy t3code temporary worktree refs", () => {
+ expect(isTemporaryWorktreeBranch("t3code/deadbeef")).toBe(true);
+ expect(isTemporaryWorktreeBranch("t3code-deadbeef")).toBe(true);
+ expect(isTemporaryWorktreeBranch("t3code/f4ae4e0e-f971-4d48-b4f2-9cf0aa54ab12")).toBe(true);
expect(
isTemporaryWorktreeBranch(`${WORKTREE_BRANCH_PREFIX}/f4ae4e0e-f971-4d48-b4f2-9cf0aa54ab12`),
- ).toBe(true);
+ ).toBe(false);
});
it("rejects UUID-shaped refs that are not RFC 4122 v4", () => {
// version nibble is not 4
- expect(
- isTemporaryWorktreeBranch(`${WORKTREE_BRANCH_PREFIX}/f4ae4e0e-f971-1d48-b4f2-9cf0aa54ab12`),
- ).toBe(false);
+ expect(isTemporaryWorktreeBranch("t3code/f4ae4e0e-f971-1d48-b4f2-9cf0aa54ab12")).toBe(false);
// variant nibble is not [89ab]
- expect(
- isTemporaryWorktreeBranch(`${WORKTREE_BRANCH_PREFIX}/f4ae4e0e-f971-4d48-c4f2-9cf0aa54ab12`),
- ).toBe(false);
+ expect(isTemporaryWorktreeBranch("t3code/f4ae4e0e-f971-4d48-c4f2-9cf0aa54ab12")).toBe(false);
});
- it("matches the flat fallback used when a plain t3code branch exists", () => {
+ it("matches the flat fallback used when a plain t3 branch exists", () => {
const flat = flattenTemporaryWorktreeBranchName(`${WORKTREE_BRANCH_PREFIX}/deadbeef`);
expect(flat).toBe(`${WORKTREE_BRANCH_PREFIX}-deadbeef`);
expect(isTemporaryWorktreeBranch(flat)).toBe(true);
expect(isTemporaryWorktreeBranch(`${WORKTREE_BRANCH_PREFIX}-deadbeef-extra`)).toBe(false);
expect(isTemporaryWorktreeBranch(`${WORKTREE_BRANCH_PREFIX}-feature`)).toBe(false);
- expect(
- flattenTemporaryWorktreeBranchName(
- `${WORKTREE_BRANCH_PREFIX}/f4ae4e0e-f971-4d48-b4f2-9cf0aa54ab12`,
- ),
- ).toBe(`${WORKTREE_BRANCH_PREFIX}-f4ae4e0e`);
+ expect(flattenTemporaryWorktreeBranchName("t3code/f4ae4e0e-f971-4d48-b4f2-9cf0aa54ab12")).toBe(
+ `${WORKTREE_BRANCH_PREFIX}-f4ae4e0e`,
+ );
+ expect(flattenTemporaryWorktreeBranchName("t3code-deadbeef")).toBe(
+ `${WORKTREE_BRANCH_PREFIX}-deadbeef`,
+ );
+ expect(flattenTemporaryWorktreeBranchName("t3code/deadbeef")).toBe(
+ `${WORKTREE_BRANCH_PREFIX}-deadbeef`,
+ );
});
it("rejects non-temporary refName names", () => {
diff --git a/packages/shared/src/git.ts b/packages/shared/src/git.ts
index 06cdacfbba7..6efef3f70ac 100644
--- a/packages/shared/src/git.ts
+++ b/packages/shared/src/git.ts
@@ -11,14 +11,18 @@ import * as Arr from "effect/Array";
import * as Result from "effect/Result";
import { detectSourceControlProviderFromRemoteUrl } from "./sourceControl.ts";
-export const WORKTREE_BRANCH_PREFIX = "t3code";
-// Canonical form is `t3code/<8 hex>`. Older mobile builds generated `t3code/<uuid>`
-// via Crypto.randomUUID() (always RFC 4122 v4), so the matcher also accepts exactly
-// that shape — version nibble `4`, variant nibble `[89ab]` — to keep those threads
-// eligible for branch regeneration without loosening beyond what was ever generated.
-// `t3code-<8 hex>` is the fallback when a plain `t3code` branch blocks the namespace.
+export const WORKTREE_BRANCH_PREFIX = "t3";
+// Canonical form is `t3/<8 hex>`. `t3-<8 hex>` is the fallback when a plain `t3`
+// branch blocks the namespace. The matcher also accepts every legacy shape, so
+// existing threads stay eligible for branch regeneration: `t3code/<8 hex>` and
+// `t3code-<8 hex>` from before the prefix was shortened, and `t3code/<uuid>` from
+// older mobile builds that used Crypto.randomUUID() (always RFC 4122 v4, so version
+// nibble `4` and variant nibble `[89ab]`). Nothing looser than what was generated.
+const TEMP_WORKTREE_HEX_TOKEN = "[0-9a-f]{8}";
+const TEMP_WORKTREE_UUID_V4_TOKEN =
+ "[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}";
const TEMP_WORKTREE_BRANCH_PATTERN = new RegExp(
- `^${WORKTREE_BRANCH_PREFIX}(?:-[0-9a-f]{8}$|\\/(?:[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}[-/]${TEMP_WORKTREE_HEX_TOKEN}|t3code(?:[-/]${TEMP_WORKTREE_HEX_TOKEN}|\\/${TEMP_WORKTREE_UUID_V4_TOKEN}))$`,
);
/**
@@ -125,15 +129,14 @@ export function buildTemporaryWorktreeBranchName(
}
/**
- * Git stores refs as paths, so a plain `t3code` branch makes every `t3code/<hex>`
- * ref impossible. This moves a temporary name to the flat `t3code-<hex>` sibling.
+ * Git stores refs as paths, so a plain `t3` branch makes every `t3/<hex>`
+ * ref impossible. This moves a temporary name to the flat `t3-<hex>` sibling.
*/
export function flattenTemporaryWorktreeBranchName(refName: string): string {
- // Keep only the canonical 8-hex token so legacy UUID names stay recognizable.
- const token = refName
- .trim()
- .toLowerCase()
- .slice(WORKTREE_BRANCH_PREFIX.length + 1, WORKTREE_BRANCH_PREFIX.length + 9);
+ // Keep only the canonical 8-hex token so legacy `t3code/` and UUID names map cleanly.
+ const normalized = refName.trim().toLowerCase();
+ const tokenStart = normalized.search(/[-/]/) + 1;
+ const token = normalized.slice(tokenStart, tokenStart + 8);
return `${WORKTREE_BRANCH_PREFIX}-${token}`;
}