Auto-clear completed todo trees

This commit is contained in:
jb
2026-08-26 18:07:46 -04:00
parent 91a019de29
commit fbe8baf18c
9 changed files with 283 additions and 17 deletions
+25 -1
View File
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
import { TaskState } from "../src/state.ts";
import { TASK_STATE_ENTRY_TYPE, TaskState } from "../src/state.ts";
import { TaskValidationError } from "../src/types.ts";
function names(state: TaskState): string[] {
@@ -362,6 +362,30 @@ test("loads the latest valid mutation snapshot from a session branch", () => {
assert.deepEqual(state.list().map((task) => task.name), ["First", "Second"]);
});
test("loads a persisted automatic clear after task tool snapshots", () => {
const completed = new TaskState();
completed.add([{ name: "Completed", status: "done" }]);
const branch = [
{
type: "message",
message: {
role: "toolResult",
toolName: "update_task",
details: { action: "update", snapshot: completed.snapshot(), affected: [] },
},
},
{
type: "custom",
customType: TASK_STATE_ENTRY_TYPE,
data: { tasks: [], nextId: 1 },
},
];
const state = new TaskState();
state.loadFromSession({ sessionManager: { getBranch: () => branch } } as never);
assert.deepEqual(state.snapshot(), { tasks: [], nextId: 1 });
});
test("rejects terminal controls and bidirectional overrides without changing state", () => {
const state = new TaskState();
state.add([{ name: "Safe", description: "Line one\nLine two" }]);