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
2 changed files with 200 additions and 12 deletions

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");
});

View file

@ -8,17 +8,18 @@ import {
startsOpen,
} from "../src/agent/detail/sections.ts";
test("a card holds status, terminal, subagents, background tasks, then settings", () => {
test("a card holds status, terminal, open todos, subagents, background tasks, then settings", () => {
assert.deepEqual(sectionsFor(true), [
"status",
"terminal",
"todos",
"subagents",
"tasks",
"settings",
]);
});
test("a page beside a terminal leaves the terminal, subagents and tasks out", () => {
test("a page beside a terminal leaves the terminal, todos, subagents and tasks out", () => {
assert.deepEqual(sectionsFor(false), ["status", "settings"]);
});