Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: the setup assistant shows when ruth is declared destroyed

This commit is contained in:
iris 2026-10-28 22:14:52 +01:00
commit 1ee481c0b1

View file

@ -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<boolean> {
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;
}