@devries-cameron20 / t3code-1 / commits / 8a1811e269
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): branches whose names start with a parenthesis are no longer reported as detached (#35780)

Julius Marminge committed Nov 12, 2026 at 18:02 UTC 8a1811e269e81ba0ebc59db34d4dc4e24986df2c
4 files changed +16 -8
apps/server/src/storageCleanup.test.ts
+1 -6
@@ -2618,17 +2618,12 @@ describe("storage cleanup reports and local file policies", () => {
2618 it.live("compares the checked-out branch without a full status", () =>
2619 runCleanupTest(
2620 Effect.gen(function* () {
2621 - const { service, fs, repo, worktree, command, setThreads, fullStatusCalls } =
2622 - yield* cleanupFixture();
2621 + const { service, fs, repo, worktree, command, fullStatusCalls } = yield* cleanupFixture();
2622 const changed = { outcome: "kept", reason: "Repository or branch changed" };
2623 yield* command(worktree, ["checkout", "--detach"]);
2624 expect((yield* service.runNow).entries[0]).toMatchObject(changed);
2625 yield* command(worktree, ["switch", "--orphan", "other"]);
2626 expect((yield* service.runNow).entries[0]).toMatchObject(changed);
2628 - yield* command(worktree, ["switch", "-c", "(feature)", "feature"]);
2629 - setThreads([shell({ branch: "(feature)", worktreePath: worktree })]);
2630 - expect((yield* service.runNow).entries[0]).toMatchObject(changed);
2631 - setThreads([shell({ branch: "feature", worktreePath: worktree })]);
2627 yield* command(worktree, ["tag", "feature", "feature"]);
2628 // Newer Git refuses to create a tag named HEAD, but still reads one.
2629 yield* command(worktree, ["update-ref", "refs/tags/HEAD", "refs/heads/feature"]);
apps/server/src/storageCleanup.ts
+1 -1
@@ -706,7 +706,7 @@ const make = Effect.gen(function* () {
706 if (head === null) return true;
707 const ref = head.exitCode === 0 ? head.stdout.trim() : "";
708 const name = ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length).trim() : null;
709 - return (name?.startsWith("(") ? null : name) !== branch;
709 + return name !== branch;
710 });
711
712 // Git status and non-forced worktree removal both skip assume-unchanged and skip-worktree files.
apps/server/src/vcs/GitVcsDriverCore.test.ts
+13
@@ -709,6 +709,19 @@ it.effect("reads the project's own repository when the server inherited GIT_DIR"
709 ).pipe(Effect.provide(layerTest)),
710 );
711
712 +it.effect("reads a branch whose name starts with a parenthesis as attached", () =>
713 + Effect.scoped(
714 + Effect.gen(function* () {
715 + const cwd = yield* makeTmpDir();
716 + yield* initRepoWithCommit(cwd);
717 + yield* git(cwd, ["switch", "-c", "(topic"]);
718 + const driver = yield* GitVcsDriver.GitVcsDriver;
719 + const status = yield* driver.statusDetailsLocal(cwd, { includeDivergence: false });
720 + assert.equal(status.branch, "(topic");
721 + }),
722 + ).pipe(Effect.provide(layerTest)),
723 +);
724 +
725 it.effect.each(["on a branch", "detached", "unborn"] as const)(
726 "reads only the repository root for review requests that ignore the branch when %s",
727 (state) =>
apps/server/src/vcs/GitVcsDriverCore.ts
+1 -1
@@ -2322,7 +2322,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2322 const line = statusRecords[index]!;
2323 if (line.startsWith("# branch.head ")) {
2324 const value = line.slice("# branch.head ".length).trim();
2325 - refName = value.startsWith("(") ? null : value;
2325 + refName = value === "(detached)" ? null : value;
2326 continue;
2327 }
2328 if (line.startsWith("# branch.upstream ")) {