Make /ralpi-reset select the loop to reset like resume
This commit is contained in:
38
index.ts
38
index.ts
@@ -201,13 +201,14 @@ async function selectLoopOptions(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* When multiple PRD loops have progress, prompt the user to select which one
|
* When multiple PRD loops have progress, prompt the user to select which one
|
||||||
* to resume. Returns the selected PRD key and sourcePath.
|
* to act on. Returns the selected PRD key and sourcePath.
|
||||||
* If only one PRD exists, returns it without prompting.
|
* If only one PRD exists, returns it without prompting.
|
||||||
* Returns null if no PRDs exist.
|
* Returns null if no PRDs exist.
|
||||||
*/
|
*/
|
||||||
async function selectPRDToResume(
|
async function selectPRD(
|
||||||
ctx: ExtensionContext,
|
ctx: ExtensionContext,
|
||||||
found: NonNullable<ReturnType<typeof findProgressFile>>,
|
found: NonNullable<ReturnType<typeof findProgressFile>>,
|
||||||
|
prompt: string,
|
||||||
): Promise<{ prdKey: string; sourcePath: string } | null> {
|
): Promise<{ prdKey: string; sourcePath: string } | null> {
|
||||||
const prds = listPRDsSorted(found.state);
|
const prds = listPRDsSorted(found.state);
|
||||||
if (prds.length === 0) return null;
|
if (prds.length === 0) return null;
|
||||||
@@ -230,10 +231,7 @@ async function selectPRDToResume(
|
|||||||
return `${relPath} — ${completed}/${total} done${failed ? `, ${failed} failed` : ""} · ${updated}`;
|
return `${relPath} — ${completed}/${total} done${failed ? `, ${failed} failed` : ""} · ${updated}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const selected = await ctx.ui.select(
|
const selected = await ctx.ui.select(prompt, options);
|
||||||
"Multiple loops found. Which to resume?",
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
if (!selected) return null;
|
if (!selected) return null;
|
||||||
|
|
||||||
const idx = options.indexOf(selected);
|
const idx = options.indexOf(selected);
|
||||||
@@ -1231,7 +1229,11 @@ async function handleResume(
|
|||||||
|
|
||||||
// When no specific task file is given, let the user select which loop
|
// When no specific task file is given, let the user select which loop
|
||||||
// to resume from multiple PRDs (sorted by most recent first).
|
// to resume from multiple PRDs (sorted by most recent first).
|
||||||
const selected = await selectPRDToResume(ctx, found);
|
const selected = await selectPRD(
|
||||||
|
ctx,
|
||||||
|
found,
|
||||||
|
"Multiple loops found. Which to resume?",
|
||||||
|
);
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
ctx.ui.notify("Resume cancelled.", "info");
|
ctx.ui.notify("Resume cancelled.", "info");
|
||||||
return;
|
return;
|
||||||
@@ -1301,11 +1303,23 @@ async function handleReset(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const projectDir = path.dirname(path.dirname(found.path));
|
const projectDir = path.dirname(path.dirname(found.path));
|
||||||
// Use the most recently updated PRD (first in sorted order)
|
|
||||||
const prds = listPRDsSorted(found.state);
|
// Multiple loops may have progress — let the user select which one to
|
||||||
const sourcePath =
|
// reset (sorted by most recent first), same as resume.
|
||||||
prds.length > 0 ? prds[0].prd.sourcePath : found.state.sourcePath;
|
const selected = await selectPRD(
|
||||||
const progress = new ProgressTracker(projectDir, sourcePath);
|
ctx,
|
||||||
|
found,
|
||||||
|
"Multiple loops found. Which to reset?",
|
||||||
|
);
|
||||||
|
if (!selected) {
|
||||||
|
ctx.ui.notify("Reset cancelled.", "info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const progress = new ProgressTracker(
|
||||||
|
projectDir,
|
||||||
|
selected.sourcePath,
|
||||||
|
selected.prdKey,
|
||||||
|
);
|
||||||
progress.reset();
|
progress.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user