Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: restructure the agent card into status, terminal, subagents and settings, with badge controls for internet, permissions and allowed domains

This commit is contained in:
iris 2026-11-03 23:47:44 +01:00 • committed by mara
commit 5e23734667
2 changed files with 437 additions and 302 deletions

View file

@ -4,6 +4,7 @@ import assert from "node:assert/strict";
import { test } from "node:test";
import {
allowedSummary,
entryGroups,
entriesFor,
entryBody,
} from "../src/agent/detail/allowed-domains.ts";
@ -62,3 +63,25 @@ test("a derived entry is counted as automatic, not as the operator's own", () =>
assert.equal(allowedSummary([derived]), "1 automatic");
assert.deepEqual(entriesFor([derived], "atlas"), [derived]);
});
test("entries are grouped by source, empty sources left out", () => {
const derived = { domain: "auto.io", agent: "atlas", derived: true };
const groups = entryGroups([
{ domain: "a.io" },
{ domain: "b.io", agent: "atlas" },
derived,
]);
assert.deepEqual(
groups.map((g) => [g.source, g.entries.length]),
[
["swarm-wide", 1],
["own", 1],
["automatic", 1],
],
);
assert.deepEqual(
entryGroups([{ domain: "a.io" }]).map((g) => g.source),
["swarm-wide"],
);
assert.deepEqual(entryGroups([]), []);
});

View file

@ -8,21 +8,24 @@ import {
startsOpen,
} from "../src/agent/detail/sections.ts";
test("a card holds overview, settings and accounts, then the terminal", () => {
test("a card holds status, terminal, subagents, then settings", () => {
assert.deepEqual(sectionsFor(true), [
"overview",
"settings",
"accounts",
"status",
"terminal",
"subagents",
"settings",
]);
});
test("a page beside a terminal leaves the terminal out", () => {
assert.deepEqual(sectionsFor(false), ["overview", "settings", "accounts"]);
test("a page beside a terminal leaves the terminal and subagents out", () => {
assert.deepEqual(sectionsFor(false), ["status", "settings"]);
});
test("only the overview starts open", () => {
assert.deepEqual(sectionsFor(true).filter(startsOpen), ["overview"]);
test("the status and the terminal start open", () => {
assert.deepEqual(sectionsFor(true).filter(startsOpen), [
"status",
"terminal",
]);
});
test("every section has a header", () => {