fix: guard against re-injecting discuss prompt when session already in flight

When no milestone exists, both /gsd and /gsd auto reach showSmartEntry
and call dispatchWorkflow — overwriting pendingAutoStart and restarting
the conversation mid-interview every time the user re-ran the command.

Add a pendingAutoStart check at the top of the !activeMilestone branch.
If a discuss session is already in progress, notify the user instead of
re-dispatching.

Fixes #6
This commit is contained in:
Lex Christopherson 2026-03-11 00:30:06 -06:00
parent 006c17c2c2
commit 19f02f7fdb

View file

@ -486,6 +486,15 @@ export async function showSmartEntry(
const state = await deriveState(basePath);
if (!state.activeMilestone) {
// Guard: if a discuss session is already in flight, don't re-inject the prompt.
// Both /gsd and /gsd auto reach this branch when no milestone exists yet.
// Without this guard, every subsequent /gsd call overwrites pendingAutoStart
// and fires another dispatchWorkflow, resetting the conversation mid-interview.
if (pendingAutoStart) {
ctx.ui.notify("Discussion already in progress — answer the question above to continue.", "info");
return;
}
const milestoneIds = findMilestoneIds(basePath);
const nextId = `M${String(milestoneIds.length + 1).padStart(3, "0")}`;
const isFirst = milestoneIds.length === 0;