diff --git a/docs/swarm/ui.md b/docs/swarm/ui.md index 26d77b006..63a761f91 100644 --- a/docs/swarm/ui.md +++ b/docs/swarm/ui.md @@ -11,21 +11,22 @@ The signed-in user's avatar sits at the right end of the header on every page. It opens a menu with the user's name and links to authelia's settings and sign-out pages; the hive dashboard and the per-agent page have the same menu. -| 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 | -| `/hives` | the hive directory, each hive with its last reported status | -| `/agents` | every agent: 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 | -| `/alerts` | the alerts the swarm's Grafana holds now: the firing ones, with a button for the pending, no-data and error ones and a link to Grafana's own alert list; read through the controller with a Viewer service-account token | -| `/jobs` | the controller's job graph — where agent creation and credential mints show progress | -| `/schedules` | the scheduled prompts: add, edit, pause, resume and remove | -| `/messages` | the swarm-wide message feed: every message between agents, and to them from the operator, reminders and compaction, with a history window and a filter on sender or recipient; a folded **broadcast** card above the feed sends one message to several agents at once | -| `/notifications` | the notification router's flows: a switch for each built-in, every flow drawn as a graph, and an editor for custom flows | -| `/issues` | a cross-repo issue report | -| `/review` | the review classifier: its recent runs, a try-out on a real PR, and its settings | -| `/builds` | the swarm builder's recent builds of agent config PRs, with what nix printed when one failed | +| 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 | +| `/hives` | the hive directory, each hive with its last reported status | +| `/agents` | every agent: 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 | +| `/alerts` | the alerts the swarm's Grafana holds now: the firing ones, with a button for the pending, no-data and error ones and a link to Grafana's own alert list; read through the controller with a Viewer service-account token | +| `/jobs` | the controller's job graph — where agent creation and credential mints show progress | +| `/schedules` | the scheduled prompts: add, edit, pause, resume and remove | +| `/broadcast` | send one message to several agents at once, picked from a grid of their icons | +| `/messages` | the swarm-wide message feed: every message between agents, and to them from the operator, reminders and compaction, with a history window and a filter on sender or recipient | +| `/notifications` | the notification router's flows: a switch for each built-in, every flow drawn as a graph, and an editor for custom flows | +| `/issues` | a cross-repo issue report | +| `/review` | the review classifier: its recent runs, a try-out on a real PR, and its settings | +| `/builds` | the swarm builder's recent builds of agent config PRs, with what nix printed when one failed | Everything it shows comes from [`swarm-controller`](../../swarm-controller/README.md). Pages that refresh on a timer share one polling rule: the page sends no new @@ -477,21 +478,18 @@ its newest 100 builds, so a link to an older one shows a note instead. ### Broadcasting a message -The messages page (`/messages`) has a **broadcast** card above the message list. It -starts folded; select its header to open it. The card holds a composer that sends one message -to several agents at once, and the messages show up in the list below as they -go. Folding it again keeps what you typed and ticked. Pick the +The **broadcast** page sends one message to several agents at once. Pick the agents from a grid of their icons. **running** shows the agents that report themselves running and **all** shows every agent; the browser keeps the choice. **select all** ticks every agent the filter shows, and **clear** unticks them. -The composer skips an agent you ticked and then hid with the filter. Type the +The page skips an agent you ticked and then hid with the filter. Type the message and press **send to N agents**. The text goes exactly as typed, as an inbox message from your authelia username, the same as the box under an agent's terminal. One broadcast may name at most 64 agents, and the button stays off until you untick the extra ones. A broadcast to many agents can take a few seconds to answer, and the button reads **sending…** meanwhile. -The composer then lists what happened to each agent. An agent that wasn't +The page then lists what happened to each agent. An agent that wasn't listening shows as not sent, with the reason, and the others still got the message. **select the N that failed** ticks just those, switching to **all** if the filter hid any, so you can send the same message again. When every agent got the message the box clears; otherwise the diff --git a/frontend/packages/swarm-ui/src/App.tsx b/frontend/packages/swarm-ui/src/App.tsx index 1c6661691..af15f7244 100644 --- a/frontend/packages/swarm-ui/src/App.tsx +++ b/frontend/packages/swarm-ui/src/App.tsx @@ -7,6 +7,7 @@ import { AgentsPage } from "./pages/agents/AgentsPage.js"; import { AgentTerminalPage } from "./pages/agents/AgentTerminalPage.js"; import { AlertsPage } from "./pages/AlertsPage.js"; import { BuildsPage } from "./pages/builds/BuildsPage.js"; +import { BroadcastPage } from "./pages/broadcast/BroadcastPage.js"; import { MessagesPage } from "./pages/messages/MessagesPage.js"; import { NEW_FLOW_PATH } from "./pages/notifications/FlowDraft.js"; import { FlowEditorPage } from "./pages/notifications/FlowEditorPage.js"; @@ -45,6 +46,7 @@ export function App() { + diff --git a/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastComposer.css b/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastPage.css similarity index 97% rename from frontend/packages/swarm-ui/src/pages/broadcast/BroadcastComposer.css rename to frontend/packages/swarm-ui/src/pages/broadcast/BroadcastPage.css index 63b979873..a0cb7ab30 100644 --- a/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastComposer.css +++ b/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastPage.css @@ -1,4 +1,4 @@ -/* : the agent picker over the message box, then the per-agent +/* : the agent picker over the message box, then the per-agent result. One column; the grid wraps to however many icons fit. */ .ui-broadcast { display: flex; diff --git a/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastComposer.tsx b/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastPage.tsx similarity index 95% rename from frontend/packages/swarm-ui/src/pages/broadcast/BroadcastComposer.tsx rename to frontend/packages/swarm-ui/src/pages/broadcast/BroadcastPage.tsx index 082a035d7..1f39e37e0 100644 --- a/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastComposer.tsx +++ b/frontend/packages/swarm-ui/src/pages/broadcast/BroadcastPage.tsx @@ -1,5 +1,4 @@ -// — one message to several agents at once, in a panel on -// the messages page above the stream that shows the messages arriving. Pick agents from a +// — one message to several agents at once. Pick agents from a // grid of their icons (every agent, or just the ones running), type the // message, send. The controller does the fan-out: `POST /api/agents/broadcast` // answers one outcome per agent, so one that is down does not stop the rest and @@ -17,6 +16,7 @@ import { ApiErrorPanel } from "@hive/shared/api-error-panel.js"; import { readApiError, type ProblemDetails } from "@hive/shared/api-error.js"; import { AgentIcon } from "../../agent/AgentIcon.js"; import { Button } from "../../ui/button/Button.js"; +import { Panel } from "../../ui/panel/Panel.js"; import { RefreshIntervalPicker, type RefreshIntervalMs, @@ -38,7 +38,7 @@ import { type BroadcastAgent, type BroadcastResult, } from "./broadcast-types.js"; -import "./BroadcastComposer.css"; +import "./BroadcastPage.css"; const DEFAULT_INTERVAL_MS: RefreshIntervalMs = 30_000; const FILTER_KEY = "swarm-ui:broadcast:filter"; @@ -57,7 +57,7 @@ function storedFilter(): AgentFilter { } } -export function BroadcastComposer() { +export function BroadcastPage() { const [intervalMs, setIntervalMs] = useState(DEFAULT_INTERVAL_MS); const { data: agents, error: loadError } = usePolled(intervalMs, (signal) => @@ -126,7 +126,17 @@ export function BroadcastComposer() { } return ( - <> + + } + > {loadError && ( )} @@ -169,11 +179,6 @@ export function BroadcastComposer() { {targets.length} selected - {agents !== null && shown.length === 0 ? ( @@ -248,7 +253,7 @@ export function BroadcastComposer() { )} - + ); } diff --git a/frontend/packages/swarm-ui/src/pages/broadcast/broadcast-types.ts b/frontend/packages/swarm-ui/src/pages/broadcast/broadcast-types.ts index 6634ba37c..99b083b7d 100644 --- a/frontend/packages/swarm-ui/src/pages/broadcast/broadcast-types.ts +++ b/frontend/packages/swarm-ui/src/pages/broadcast/broadcast-types.ts @@ -1,6 +1,6 @@ -// What the broadcast composer decides without a DOM: which agents the filter +// What the broadcast page decides without a DOM: which agents the filter // shows, which of the ticked ones a send really goes to, and how the -// controller's per-agent answer is read. Kept out of `BroadcastComposer.tsx` so it +// controller's per-agent answer is read. Kept out of `BroadcastPage.tsx` so it // is plain functions of its arguments and can be tested. /** The part of an `/api/agents/status` row the page reads. */ diff --git a/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.css b/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.css index bcb6fe8ac..6fe1d7583 100644 --- a/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.css +++ b/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.css @@ -1,12 +1,6 @@ /* : the filter bar over the terminal-style message list. */ @import "@hive/shared/terminal.css"; -/* The broadcast card, folded by default, over the messages card. */ -.ui-messages-page { - display: flex; - flex-direction: column; - gap: 1em; -} .ui-messages-bar { display: flex; flex-wrap: wrap; diff --git a/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.tsx b/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.tsx index e8322c029..561282282 100644 --- a/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.tsx +++ b/frontend/packages/swarm-ui/src/pages/messages/MessagesPage.tsx @@ -1,8 +1,6 @@ // — `/messages`: every message between agents, and from the // operator, reminders and compaction to an agent, as the swarm's controller -// streams them (`GET /api/messages/stream`), across all hives. Above the -// list, a folded **broadcast** card holds the composer that sends one message -// to several agents. +// streams them (`GET /api/messages/stream`), across all hives. // // The stream sends the chosen window of history first, then the live tail. A // message an agent drained with an in-turn `recv` is missing, because it starts @@ -13,8 +11,6 @@ import { memo } from "preact/compat"; import { useLayoutEffect, useRef, useState } from "preact/hooks"; import { Badge, type BadgeTone } from "@hive/shared/badge.js"; import { Row } from "@hive/shared/term-row.js"; -import { BroadcastComposer } from "../broadcast/BroadcastComposer.js"; -import { Disclosure } from "../../ui/disclosure/Disclosure.js"; import { Panel } from "../../ui/panel/Panel.js"; import { SelectField } from "../../ui/select-field/SelectField.js"; import { TextField } from "../../ui/text-field/TextField.js"; @@ -54,11 +50,6 @@ const MessageRow = memo(function MessageRow({ m }: { m: ArrivedMessage }) { export function MessagesPage() { const [sinceMinutes, setSinceMinutes] = useState(DEFAULT_WINDOW_MINUTES); const [query, setQuery] = useState(""); - const [composing, setComposing] = useState(false); - // The composer is built on the first open and kept after, so what was typed - // and ticked stays through a fold, and a page where it is never opened does - // not poll the agent list. - const [composerBuilt, setComposerBuilt] = useState(false); const { messages, connection, reconnect } = useMessageStream(sinceMinutes); const shown = filterMessages(messages, query); @@ -83,86 +74,72 @@ export function MessagesPage() { }, [newestId, shown.length, stickToBottom]); return ( -
- { - setComposing(open); - if (open) setComposerBuilt(true); - }} - > - {composerBuilt ? : null} - - + + + {connection === "closed" ? ( - {connection === "closed" ? ( - - ) : null} - - } - > -
- setSinceMinutes(Number(v))} - options={WINDOWS.map((w) => ({ - value: String(w.minutes), - label: w.label, - }))} - /> - - - {query.trim() === "" - ? `${messages.length} messages` - : `${shown.length} of ${messages.length} messages`} - + ) : null} + + } + > +
+ setSinceMinutes(Number(v))} + options={WINDOWS.map((w) => ({ + value: String(w.minutes), + label: w.label, + }))} + /> + + + {query.trim() === "" + ? `${messages.length} messages` + : `${shown.length} of ${messages.length} messages`} + +
+
+
+ {shown.length === 0 ? ( +
+ + {connection === "open" + ? messages.length === 0 + ? "(connected — no messages yet)" + : "(no message matches the filter)" + : CONNECTION_LABEL[connection]} + +
+ ) : ( + shown.map((m) => ) + )}
-
-
- {shown.length === 0 ? ( -
- - {connection === "open" - ? messages.length === 0 - ? "(connected — no messages yet)" - : "(no message matches the filter)" - : CONNECTION_LABEL[connection]} - -
- ) : ( - shown.map((m) => ) - )} -
-
-

- Shows what the agents sent each other. A message an agent drained with - an in-turn recv is missing. The history is at most 100 - recent messages per agent. -

- -
+
+

+ Shows what the agents sent each other. A message an agent drained with + an in-turn recv is missing. The history is at most 100 + recent messages per agent. +

+
); } diff --git a/frontend/packages/swarm-ui/src/shell/Shell.tsx b/frontend/packages/swarm-ui/src/shell/Shell.tsx index 560bc1977..160766479 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.tsx +++ b/frontend/packages/swarm-ui/src/shell/Shell.tsx @@ -54,6 +54,7 @@ const NAV_ITEMS: { href: string; label: string; accent: string }[] = [ { href: "/alerts", label: "alerts", accent: "var(--red)" }, { href: "/jobs", label: "jobs", accent: "var(--pink)" }, { href: "/schedules", label: "schedules", accent: "var(--cyan)" }, + { href: "/broadcast", label: "broadcast", accent: "var(--blue)" }, { href: "/messages", label: "messages", accent: "var(--purple)" }, { href: "/notifications", label: "notifications", accent: "var(--yellow)" }, { href: "/issues", label: "issues", accent: "var(--yellow)" }, diff --git a/frontend/packages/swarm-ui/test/broadcast-types.test.mjs b/frontend/packages/swarm-ui/test/broadcast-types.test.mjs index fd96e1519..c2a93cca0 100644 --- a/frontend/packages/swarm-ui/test/broadcast-types.test.mjs +++ b/frontend/packages/swarm-ui/test/broadcast-types.test.mjs @@ -1,4 +1,4 @@ -// The broadcast composer's selection and answer rules. Run by `npm test`, which +// The broadcast page's selection and answer rules. Run by `npm test`, which // Node runs with its built-in test runner and type stripping, so the `.ts` // module is imported as it is. import assert from "node:assert/strict";