fix: prevent branch-mode merge fallback from firing in worktree isolation (#1183)

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
This commit is contained in:
Tom Boucher 2026-03-18 12:54:28 -04:00 committed by GitHub
parent c442e2d97e
commit 60508c2ec2

View file

@ -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);