Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: an open todos section on the agent card

This commit is contained in:
iris 2026-11-16 00:28:54 +01:00 • committed by mara
commit fa2a75d499

View file

@ -0,0 +1,36 @@
// An agent's open todos: their order and the count in words. Run by `npm test`.
import assert from "node:assert/strict";
import { test } from "node:test";
import { sortTodos, todosLabel } from "../src/agent/terminal/agent-todos.ts";
const todo = (id, updated_unix) => ({
id,
subsystem: "forge",
summary: `todo ${id}`,
updated_unix,
});
test("the newest todo comes first and a tie goes to the higher id", () => {
const ids = sortTodos([
todo(1, 100),
todo(2, 300),
todo(3, 300),
todo(4, 200),
]).map((t) => t.id);
assert.deepEqual(ids, [3, 2, 4, 1]);
});
test("sorting leaves the list it was given alone", () => {
const list = [todo(1, 100), todo(2, 200)];
sortTodos(list);
assert.deepEqual(
list.map((t) => t.id),
[1, 2],
);
});
test("the count reads in words", () => {
assert.equal(todosLabel([]), "no open todos");
assert.equal(todosLabel([todo(1, 1)]), "1 open todo");
assert.equal(todosLabel([todo(1, 1), todo(2, 2)]), "2 open todos");
});