diff --git a/docs/swarm/ui.md b/docs/swarm/ui.md index 270bb054..3aa7d3b9 100644 --- a/docs/swarm/ui.md +++ b/docs/swarm/ui.md @@ -22,7 +22,7 @@ shut. A dropdown inside a dialog opens above the dialog and the dialog doesn't c | route | what | | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `/` | the start page: the swarm's name over a digital-rain backdrop, plus a paperclip offering to set up an agent while no `ruth` exists (it opens the create form with `ruth` filled in); the swarm name in the header links here | +| `/` | the start page: the swarm's name over a digital-rain backdrop, plus a paperclip offering to set up an agent while no `ruth` exists, or her hive declares her destroyed (it opens the create form with `ruth` filled in); the swarm name in the header links here | | `/agents` | every agent, under a folded **hives** card with the hive directory and each hive's last reported status: status, config PR, wanted state, inference settings, resource caps, permissions; create agents (with their permissions, optionally from an [archetype](archetypes.md)), link forge, matrix and GitHub accounts | | `/agents//terminal` | one agent's live terminal | | `/agents//subagents//terminal` | one of that agent's subagents' live terminal | diff --git a/frontend/packages/swarm-ui/src/shell/ruth-missing.ts b/frontend/packages/swarm-ui/src/shell/ruth-missing.ts index b09ba5aa..c5c84a60 100644 --- a/frontend/packages/swarm-ui/src/shell/ruth-missing.ts +++ b/frontend/packages/swarm-ui/src/shell/ruth-missing.ts @@ -1,8 +1,10 @@ // Whether the swarm has no agent named `ruth`, from `GET /api/agents/status`. -// The start page's setup assistant shows only then. It is a nudge, so -// anything short of a clear "ruth is not in the roster" answers `false`: a -// failed request or an unreadable list must not tell the operator to set -// up an agent that may already exist. +// The start page's setup assistant shows only then: when the roster has no +// `ruth`, or has one its hive declares `destroyed` (the declaration stays in +// the roster for good, though the agent is gone). Offline and paused still +// count as an agent. It is a nudge, so anything short of a clear answer +// is `false`: a failed request or an unreadable list must not tell the +// operator to set up an agent that may already exist. type Fetch = (url: string) => Promise<{ ok: boolean; @@ -15,7 +17,10 @@ export async function ruthIsMissing(fetchImpl: Fetch): Promise { if (!r.ok) return false; const rows = await r.json(); if (!Array.isArray(rows)) return false; - return !rows.some((row) => (row as { name?: unknown }).name === "ruth"); + return !rows.some((row) => { + const { name, wanted } = row as { name?: unknown; wanted?: unknown }; + return name === "ruth" && wanted !== "destroyed"; + }); } catch { return false; } diff --git a/frontend/packages/swarm-ui/test/ruth-missing.test.mjs b/frontend/packages/swarm-ui/test/ruth-missing.test.mjs index 0af86895..d8edd77a 100644 --- a/frontend/packages/swarm-ui/test/ruth-missing.test.mjs +++ b/frontend/packages/swarm-ui/test/ruth-missing.test.mjs @@ -33,6 +33,20 @@ test("a roster with ruth means she is not missing", async () => { ); }); +test("a ruth declared destroyed is missing; a stopped or paused one is not", async () => { + assert.equal( + await ruthIsMissing(answering([{ name: "ruth", wanted: "destroyed" }])), + true, + ); + for (const wanted of ["up", "offline", "paused", null, undefined]) { + assert.equal( + await ruthIsMissing(answering([{ name: "ruth", wanted }])), + false, + String(wanted), + ); + } +}); + test("anything but a clear answer is not missing", async () => { assert.equal(await ruthIsMissing(answering([], false)), false); assert.equal(await ruthIsMissing(answering({ not: "a list" })), false);