From 60508c2ec28bd6769044c4b0f3ac24197098ec7d Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Wed, 18 Mar 2026 12:54:28 -0400 Subject: [PATCH] fix: prevent branch-mode merge fallback from firing in worktree isolation (#1183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The milestone merge dispatcher in dispatchNextUnit had two 'else if' blocks that matched when !isInAutoWorktree() && getIsolationMode() !== 'none'. In worktree mode, if isInAutoWorktree() returned false (e.g., after cwd was changed back to project root), the branch-mode fallback fired and ran 'git checkout main' — which fails because main is already checked out at the project root. Changed the condition from 'getIsolationMode() !== "none"' to 'getIsolationMode() === "branch"' so the branch-mode merge path only fires when the user explicitly configured branch isolation. Worktree mode now correctly falls through without attempting an invalid checkout. Both instances (all-complete path and milestone-transition path) are fixed. Fixes #1179 --- src/resources/extensions/gsd/auto.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resources/extensions/gsd/auto.ts b/src/resources/extensions/gsd/auto.ts index acdcbba22..d153d5b54 100644 --- a/src/resources/extensions/gsd/auto.ts +++ b/src/resources/extensions/gsd/auto.ts @@ -1212,7 +1212,7 @@ async function dispatchNextUnit( try { process.chdir(s.basePath); } catch { /* best-effort */ } } } - } else if (s.currentMilestoneId && !isInAutoWorktree(s.basePath) && getIsolationMode() !== "none") { + } else if (s.currentMilestoneId && !isInAutoWorktree(s.basePath) && getIsolationMode() === "branch") { try { const currentBranch = getCurrentBranch(s.basePath); const milestoneBranch = autoWorktreeBranch(s.currentMilestoneId); @@ -1314,7 +1314,7 @@ async function dispatchNextUnit( try { process.chdir(s.basePath); } catch { /* best-effort */ } } } - } else if (s.currentMilestoneId && !isInAutoWorktree(s.basePath) && getIsolationMode() !== "none") { + } else if (s.currentMilestoneId && !isInAutoWorktree(s.basePath) && getIsolationMode() === "branch") { try { const currentBranch = getCurrentBranch(s.basePath); const milestoneBranch = autoWorktreeBranch(s.currentMilestoneId);