On a busy agent the activity section grew long: the todos and bash tasks ran to dozens of rows, and the subagents were one wrapping line of badges. Each list now shows its first five rows with a "show all N" button; expanded, the rows scroll in a bounded box. The subagents are one row each (name, model and effort, state and age), running first and the rest dimmed, as in the menu on the terminal page, and a picked subagent stays in view when the list is folded.
34 lines
1 KiB
JavaScript
34 lines
1 KiB
JavaScript
// Which rows a folded list shows. Run by `npm test`, which Node runs with its
|
|
// built-in test runner and type stripping.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { CAP, capRows } from "../src/ui/capped-rows/cap-rows.ts";
|
|
|
|
const rows = (n) => Array.from({ length: n }, (_, i) => i);
|
|
|
|
test("a list no longer than the cap shows whole", () => {
|
|
assert.deepEqual(capRows(rows(CAP), false), {
|
|
shown: rows(CAP),
|
|
hidden: 0,
|
|
});
|
|
});
|
|
|
|
test("a longer list folds to the first rows and counts the rest", () => {
|
|
assert.deepEqual(capRows(rows(CAP + 3), false), {
|
|
shown: rows(CAP),
|
|
hidden: 3,
|
|
});
|
|
});
|
|
|
|
test("expanded, every row shows", () => {
|
|
assert.deepEqual(capRows(rows(CAP + 3), true), {
|
|
shown: rows(CAP + 3),
|
|
hidden: 0,
|
|
});
|
|
});
|
|
|
|
test("a kept row past the cap still shows, and is not counted as hidden", () => {
|
|
const out = capRows(rows(CAP + 3), false, (r) => r === CAP + 1);
|
|
assert.deepEqual(out.shown, [...rows(CAP), CAP + 1]);
|
|
assert.equal(out.hidden, 2);
|
|
});
|