fix(worktree): correct merge failure notification command from /complete-milestone to /gsd dispatch complete-milestone (#1901)

Fixes #1891

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher 2026-04-05 01:05:12 -04:00 committed by GitHub
parent 2a40f3f35d
commit 1c95b94720
2 changed files with 38 additions and 3 deletions

View file

@ -550,6 +550,40 @@ test("mergeAndExit failure message tells user worktree and branch are preserved
);
});
test("mergeAndExit failure message references /gsd dispatch complete-milestone, not /complete-milestone (#1891)", () => {
// Regression test: the failure notification previously told users to
// "retry /complete-milestone" — a command that does not exist. The correct
// recovery command is "/gsd dispatch complete-milestone".
const s = makeSession({
basePath: "/project/.gsd/worktrees/M001",
originalBasePath: "/project",
});
const deps = makeDeps({
isInAutoWorktree: () => true,
getIsolationMode: () => "worktree",
mergeMilestoneToMain: () => {
throw new Error("dirty working tree");
},
});
const ctx = makeNotifyCtx();
const resolver = new WorktreeResolver(s, deps);
resolver.mergeAndExit("M001", ctx);
const warning = ctx.messages.find((m) => m.level === "warning");
assert.ok(warning, "a warning message is emitted");
// Must reference the correct dispatch command
assert.ok(
warning!.msg.includes("/gsd dispatch complete-milestone"),
"warning references /gsd dispatch complete-milestone, not bare /complete-milestone",
);
// Must NOT contain the bare (incorrect) command without the dispatch prefix
assert.ok(
!warning!.msg.match(/retry\s+\/complete-milestone(?!\S)/),
"warning must not reference the non-existent /complete-milestone command",
);
});
// ─── mergeAndExit Tests (branch mode) ────────────────────────────────────────
test("mergeAndExit in branch mode merges when on milestone branch", () => {

View file

@ -497,10 +497,11 @@ export class WorktreeResolver {
});
// Surface a clear, actionable error. The worktree and milestone branch are
// intentionally preserved — nothing has been deleted. The user can retry
// /gsd dispatch complete-milestone or merge manually once the underlying issue is fixed
// (e.g. checkout to wrong branch, unresolved conflicts). (#1668)
// /gsd dispatch complete-milestone or merge manually once the underlying
// issue is fixed (e.g. checkout to wrong branch, unresolved conflicts).
// (#1668, #1891)
ctx.notify(
`Milestone merge failed: ${msg}. Your worktree and milestone branch are preserved — retry /gsd dispatch complete-milestone or merge manually.`,
`Milestone merge failed: ${msg}. Your worktree and milestone branch are preserved — retry with \`/gsd dispatch complete-milestone\` or merge manually.`,
"warning",
);