Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Fix worktree→local branch switch causing 'already used by worktree' error

Julius Marminged6ecf1580510
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx
index bc14843cf..9fd8774d0 100644
--- a/apps/web/src/components/BranchToolbar.tsx
+++ b/apps/web/src/components/BranchToolbar.tsx
@@ -128,13 +128,14 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B
return;
}
- // If the branch already lives in a secondary worktree, point the thread
- // there instead of trying to checkout (which git would reject).
- // Ignore the main worktree (project cwd) — that's just a normal local checkout.
- const isSecondaryWorktree = branch.worktreePath && branch.worktreePath !== activeProject?.cwd;
- if (isSecondaryWorktree) {
+ // If the branch already lives in a worktree, redirect there instead of
+ // trying to checkout (which git would reject with "already used by worktree").
+ if (branch.worktreePath) {
+ const isMainWorktree = branch.worktreePath === activeProject?.cwd;
setThreadError(null);
- setThreadBranch(branch.name, branch.worktreePath);
+ // Main worktree → switch back to local (project cwd, worktreePath=null).
+ // Secondary worktree → point the thread at that worktree path.
+ setThreadBranch(branch.name, isMainWorktree ? null : branch.worktreePath);
setIsBranchMenuOpen(false);
return;
}