feat: preserve Herdr task counts

This commit is contained in:
lesetong
2026-07-23 00:01:01 +08:00
parent 281f3c1615
commit fe05b278a4
5 changed files with 28 additions and 16 deletions
+4 -1
View File
@@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import test from "node:test";
import { visibleWidth } from "@earendil-works/pi-tui";
import { currentTaskLabel } from "../src/herdr.ts";
import { currentTaskLabel, currentTaskTokens } from "../src/herdr.ts";
import { TaskState } from "../src/state.ts";
import {
renderProgressHeader,
@@ -106,6 +106,7 @@ test("selects the most specific in-progress task and compresses parallel leaves"
{ name: "Parallel", description: "Parallel", status: "in-progress" },
]);
assert.equal(currentTaskLabel(state.list()), "#2 Child +1");
assert.deepEqual(currentTaskTokens(state.list()), { task: "#2 Child", task_count: "+1" });
});
test("uses blocked tasks only when nothing is in progress", () => {
@@ -115,8 +116,10 @@ test("uses blocked tasks only when nothing is in progress", () => {
{ name: "Blocked two", description: "Two", status: "blocked" },
]);
assert.equal(currentTaskLabel(state.list()), "#1 Blocked one +1");
assert.deepEqual(currentTaskTokens(state.list()), { task: "#1 Blocked one", task_count: "+1" });
state.update([{ id: 1, status: "done" }, { id: 2, status: "done" }]);
assert.equal(currentTaskLabel(state.list()), null);
assert.deepEqual(currentTaskTokens(state.list()), { task: null, task_count: null });
});
test("hides an empty widget and renders a populated one", () => {