@devries-cameron20 / t3code Mirror · read-only / commits / 1b14aade4d
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 11:00 UTC

fix(mobile): recheck the current branch before selecting it (#37121)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 15, 2026 at 11:04 UTC 1b14aade4de1db0c82b8d61ccfd9c011b04c3810
2 files changed +5 -8
apps/mobile/src/features/threads/checkout-new-task-branch.test.ts
+2 -2
@@ -135,12 +135,12 @@ async function addRemote(remoteName: string, sourceRef = branch.name) {
135 }
136
137 describe("new-task branch checkout", () => {
138 - it("switches to a free branch and clears its historical worktree path", async () => {
138 + it("switches to a free branch despite stale current and worktree metadata", async () => {
139 const previousWorktree = NodePath.join(directory, "previous-worktree");
140 await git("worktree", "add", previousWorktree, branch.name);
141 await exec("git", ["-C", previousWorktree, "checkout", "-b", "other-branch"]);
142 const result = await checkoutNewTaskBranch({
143 - branch: { ...branch, worktreePath: previousWorktree },
143 + branch: { ...branch, current: true, worktreePath: previousWorktree },
144 project: { environmentId, workspaceRoot: cwd },
145 workspaceMode: "local",
146 readRefs,
apps/mobile/src/features/threads/checkout-new-task-branch.ts
+3 -6
@@ -34,13 +34,10 @@ export async function checkoutNewTaskBranch<E>(input: {
34 Cause.fail(new Error("The selected project is unavailable. Reconnect and try again.")),
35 );
36 }
37 - if (input.workspaceMode === "worktree" || input.branch.current) {
38 - return AsyncResult.success(
39 - input.branch.current ? { ...input.branch, worktreePath: null } : input.branch,
40 - );
41 - }
37 + if (input.workspaceMode === "worktree") return AsyncResult.success(input.branch);
38
43 - // Remote refs omit local worktrees, and historical thread metadata can be stale.
39 + // The picked ref's current flag, remote refs' missing worktrees and historical
40 + // thread metadata can all be stale, so Git is asked again before choosing.
41 const localName = localBranchName(input.branch);
42 let cursor: number | undefined;
43 for (;;) {