fix(FN-1952): preserve explicit non-cleanup archive

This commit is contained in:
gsxdsm
2026-04-16 19:56:28 -07:00
parent 48e79cd46d
commit cc7f7bd6f8
2 changed files with 17 additions and 12 deletions

View File

@@ -6114,7 +6114,7 @@ Task with acceptance criteria
await store.archiveTask(task.id, false);
const dir = join(rootDir, ".fusion", "tasks", task.id);
expect(existsSync(dir)).toBe(false);
expect(existsSync(dir)).toBe(true);
await store.cleanupArchivedTasks();
@@ -6130,7 +6130,7 @@ Task with acceptance criteria
await store.archiveTask(task.id, false);
const cleaned1 = await store.cleanupArchivedTasks();
expect(cleaned1).toEqual([]);
expect(cleaned1).toContain(task.id);
const cleaned2 = await store.cleanupArchivedTasks();
expect(cleaned2).toHaveLength(0);
@@ -6458,7 +6458,7 @@ Task with acceptance criteria
expect(existsSync(dir)).toBe(false);
});
it("archiveTask(false) still removes active task storage", async () => {
it("archiveTask(false) preserves directory for explicit non-cleanup archives", async () => {
const task = await store.createTask({ description: "No cleanup" });
await store.moveTask(task.id, "todo");
await store.moveTask(task.id, "in-progress");
@@ -6469,7 +6469,7 @@ Task with acceptance criteria
expect(archived.column).toBe("archived");
const dir = join(rootDir, ".fusion", "tasks", task.id);
expect(existsSync(dir)).toBe(false);
expect(existsSync(dir)).toBe(true);
});
it("default cleanup parameter removes active task storage", async () => {

View File

@@ -2950,14 +2950,19 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
action: "Task archived",
});
if (cleanup) {
const cleanedBranches = await this.cleanupBranchForTask(task);
if (cleanedBranches.length > 0) {
task.log.push({
timestamp: new Date().toISOString(),
action: `Cleaned up branch: ${cleanedBranches.join(", ")}`,
});
}
if (!cleanup) {
await this.atomicWriteTaskJson(dir, task);
if (this.isWatching) this.taskCache.set(id, { ...task });
this.emit("task:moved", { task, from: "done" as Column, to: "archived" as Column });
return task;
}
const cleanedBranches = await this.cleanupBranchForTask(task);
if (cleanedBranches.length > 0) {
task.log.push({
timestamp: new Date().toISOString(),
action: `Cleaned up branch: ${cleanedBranches.join(", ")}`,
});
}
const entry = await this.taskToArchiveEntry(task, task.columnMovedAt);