feat(FN-3185): preserve progress on task reset with explicit confirmation d

This merge implements a "preserve progress" option for task resets across the system. FN-3185 adds a `preserveProgress` flag to `moveTask` that keeps status/history when resetting tasks back to `todo`, with required explicit confirmation dialogs to prevent accidental resets. The feature is wired thr

Fusion-Task-Id: FN-3185
This commit is contained in:
Fusion
2026-05-02 10:17:56 -07:00
committed by gsxdsm
parent 62de4b1be3
commit 44cc899eb9
18 changed files with 394 additions and 50 deletions

View File

@@ -2667,6 +2667,12 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
* "move back to todo" actions, which still want a clean slate.
*/
preserveResumeState?: boolean;
/**
* Preserve step progress (step statuses + currentStep) when reopening
* to todo/triage, while still clearing per-run execution state
* (worktree and wall-clock timing fields).
*/
preserveProgress?: boolean;
},
): Promise<Task> {
return this.withTaskLock(id, async () => {
@@ -2739,18 +2745,26 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
task.status = undefined;
task.error = undefined;
task.blockedBy = undefined;
const hasNonPendingStepProgress = task.steps.some((step) => step.status !== "pending");
const preserveStepProgress =
options?.preserveResumeState || (options?.preserveProgress === true && hasNonPendingStepProgress);
if (!options?.preserveResumeState) {
task.worktree = undefined;
// Reset wall-clock runtime so the next run gets a fresh timer.
task.executionStartedAt = undefined;
task.executionCompletedAt = undefined;
this.resetAllStepsToPending(task);
await this.resetPromptCheckboxes(dir);
} else {
// executionCompletedAt is never set on an in-progress task; clear
// it defensively in case we are bouncing from done/in-review.
task.executionCompletedAt = undefined;
}
if (!preserveStepProgress) {
this.resetAllStepsToPending(task);
await this.resetPromptCheckboxes(dir);
}
}
// Clear recovery metadata when task reaches in-review (successful completion)