swarm ui: the messages cards move to the swarm page and the messages tab goes
The broadcast, schedules and message log cards now sit on the swarm page, after the notification router; the message log opens its stream on its first open instead of when the page loads, and its connection badge moves into its filter bar. The messages tab is removed from the header, and the old /messages address redirects to /swarm next to /schedules, which now does too. MessagesPage becomes MessageCards, and comments, tests and the swarm UI docs say the swarm page where they said the messages tab.
This commit is contained in:
parent
94969b552e
commit
797e6e3137
11 changed files with 120 additions and 116 deletions
|
|
@ -14,7 +14,6 @@ import { useGuardedLocation } from "./shell/useGuardedLocation.js";
|
|||
import { AgentsPage } from "./pages/agents/AgentsPage.js";
|
||||
import { AgentGroupPage } from "./pages/agents/AgentGroupPage.js";
|
||||
import { AgentTerminalPage } from "./pages/agents/AgentTerminalPage.js";
|
||||
import { MessagesPage } from "./pages/messages/MessagesPage.js";
|
||||
import { NEW_FLOW_PATH } from "./pages/notifications/FlowDraft.js";
|
||||
import { FlowEditorPage } from "./pages/notifications/FlowEditorPage.js";
|
||||
import { SwarmPage } from "./pages/swarm/SwarmPage.js";
|
||||
|
|
@ -63,7 +62,6 @@ export function App() {
|
|||
component={AgentTerminalPage}
|
||||
/>
|
||||
<Route path="/jobs" component={JobsPage} />
|
||||
<Route path="/messages" component={MessagesPage} />
|
||||
<Route path="/swarm" component={SwarmPage} />
|
||||
<Route path={NEW_FLOW_PATH}>
|
||||
<FlowEditorPage params={{ flowId: "" }} isNew />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// `GET /api/agents/{name}/term/stream`, or for a subagent
|
||||
// `GET /api/agents/{name}/subagents/{subagent}/term/stream`, via
|
||||
// `useSwarmTermStream`, and renders each row through the `@hive/shared` `Row`
|
||||
// component, the same one `MessagesPage` uses.
|
||||
// component, the same one `MessageCards` uses.
|
||||
//
|
||||
// **Floating controls** — one row pinned over the terminal's top edge, so the
|
||||
// terminal keeps the whole box. On the left, the `leading` slot (the page's
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// <BroadcastComposer> — 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
|
||||
// the swarm page above the stream that shows the messages arriving. 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
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
/* <MessagesPage>: the filter bar over the terminal-style message list. */
|
||||
/* <MessageCards>: the filter bar over the terminal-style message list. */
|
||||
@import "@hive/shared/terminal.css";
|
||||
|
||||
/* The broadcast and schedules cards, folded by default, over the message log. */
|
||||
.ui-messages-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
}
|
||||
.ui-messages-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
// <MessagesPage> — `/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, and a folded **schedules** card holds the scheduled prompts.
|
||||
// The list itself is the folded **message log** card.
|
||||
// <MessageCards> — the cards of the swarm page that hold the swarm's 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. A folded **broadcast** card
|
||||
// holds the composer that sends one message to several agents, and a folded
|
||||
// **schedules** card holds the scheduled prompts. The list itself is the folded
|
||||
// **message log** card, which opens the stream on its first open.
|
||||
//
|
||||
// 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
|
||||
// no turn; the page says so under the list. Each message is a row of the same
|
||||
// no turn; the card says so under the list. Each message is a row of the same
|
||||
// terminal list an agent's own terminal uses, one summary line with the time,
|
||||
// the two parties and the start of the body, and the whole body under it.
|
||||
import { memo } from "preact/compat";
|
||||
|
|
@ -17,6 +18,7 @@ import { Row } from "@hive/shared/term-row.js";
|
|||
import { BroadcastComposer } from "../broadcast/BroadcastComposer.js";
|
||||
import { SchedulesCard } from "../schedules/SchedulesPage.js";
|
||||
import { Disclosure } from "../../ui/disclosure/Disclosure.js";
|
||||
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
|
||||
import { Hint } from "../../ui/hint/Hint.js";
|
||||
import { SelectField } from "../../ui/select-field/SelectField.js";
|
||||
import { TextField } from "../../ui/text-field/TextField.js";
|
||||
|
|
@ -28,7 +30,7 @@ import {
|
|||
WINDOWS,
|
||||
} from "./messages.js";
|
||||
import { useMessageStream, type ConnectionState } from "./useMessageStream.js";
|
||||
import "./MessagesPage.css";
|
||||
import "./MessageCards.css";
|
||||
|
||||
const NEAR_BOTTOM_PX = 48;
|
||||
|
||||
|
|
@ -53,16 +55,11 @@ const MessageRow = memo(function MessageRow({ m }: { m: ArrivedMessage }) {
|
|||
return <Row row={messageRow(m, String(m.id))} />;
|
||||
});
|
||||
|
||||
export function MessagesPage() {
|
||||
// The body of the message log card: the filter bar over the list. It opens the
|
||||
// stream when it is built, which is the card's first open.
|
||||
function MessageLog() {
|
||||
const [sinceMinutes, setSinceMinutes] = useState(DEFAULT_WINDOW_MINUTES);
|
||||
const [query, setQuery] = useState("");
|
||||
const [composing, setComposing] = useState(false);
|
||||
// The log starts folded, as the cards above it do.
|
||||
const [logOpen, setLogOpen] = 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);
|
||||
|
||||
|
|
@ -84,10 +81,80 @@ export function MessagesPage() {
|
|||
useLayoutEffect(() => {
|
||||
const el = logRef.current;
|
||||
if (el && stickToBottom) el.scrollTop = el.scrollHeight - el.clientHeight;
|
||||
}, [newestId, shown.length, stickToBottom, logOpen]);
|
||||
}, [newestId, shown.length, stickToBottom]);
|
||||
|
||||
return (
|
||||
<div class="ui-messages-page">
|
||||
<>
|
||||
<div class="ui-messages-bar">
|
||||
<Badge
|
||||
tone={CONNECTION_TONE[connection]}
|
||||
value={CONNECTION_LABEL[connection]}
|
||||
/>
|
||||
{connection === "closed" ? (
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value="reconnect"
|
||||
title="open the message stream again"
|
||||
onClick={reconnect}
|
||||
/>
|
||||
) : null}
|
||||
<SelectField
|
||||
id="messages-window"
|
||||
label="history"
|
||||
value={String(sinceMinutes)}
|
||||
onChange={(v) => setSinceMinutes(Number(v))}
|
||||
options={WINDOWS.map((w) => ({
|
||||
value: String(w.minutes),
|
||||
label: w.label,
|
||||
}))}
|
||||
/>
|
||||
<TextField
|
||||
id="messages-filter"
|
||||
label="agent"
|
||||
value={query}
|
||||
placeholder="sender or recipient"
|
||||
onInput={setQuery}
|
||||
/>
|
||||
<Hint as="span" class="ui-messages-count">
|
||||
{query.trim() === ""
|
||||
? `${messages.length} messages`
|
||||
: `${shown.length} of ${messages.length} messages`}
|
||||
</Hint>
|
||||
</div>
|
||||
<div class="terminal-wrap ui-messages-wrap">
|
||||
<div class="live terminal" ref={logRef} onScroll={handleScroll}>
|
||||
{shown.length === 0 ? (
|
||||
<div class="row note">
|
||||
<span class="row-content">
|
||||
{connection === "open"
|
||||
? messages.length === 0
|
||||
? "(connected — no messages yet)"
|
||||
: "(no message matches the filter)"
|
||||
: CONNECTION_LABEL[connection]}
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
shown.map((m) => <MessageRow key={m.id} m={m} />)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Hint class="ui-messages-note">
|
||||
Shows what the agents sent each other. A message an agent drained with
|
||||
an in-turn <code>recv</code> is missing. The history is at most 100
|
||||
recent messages per agent.
|
||||
</Hint>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function MessageCards() {
|
||||
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);
|
||||
return (
|
||||
<>
|
||||
<Disclosure
|
||||
title="broadcast"
|
||||
icon="📣"
|
||||
|
|
@ -101,73 +168,13 @@ export function MessagesPage() {
|
|||
{composerBuilt ? <BroadcastComposer /> : null}
|
||||
</Disclosure>
|
||||
<SchedulesCard />
|
||||
<Disclosure
|
||||
<LazyDisclosure
|
||||
title="message log"
|
||||
icon="💬"
|
||||
hint={
|
||||
<Badge
|
||||
tone={CONNECTION_TONE[connection]}
|
||||
value={CONNECTION_LABEL[connection]}
|
||||
/>
|
||||
}
|
||||
open={logOpen}
|
||||
onToggle={setLogOpen}
|
||||
hint="what the agents sent each other"
|
||||
>
|
||||
<div class="ui-messages-bar">
|
||||
{connection === "closed" ? (
|
||||
<Badge
|
||||
variant="quiet"
|
||||
value="reconnect"
|
||||
title="open the message stream again"
|
||||
onClick={reconnect}
|
||||
/>
|
||||
) : null}
|
||||
<SelectField
|
||||
id="messages-window"
|
||||
label="history"
|
||||
value={String(sinceMinutes)}
|
||||
onChange={(v) => setSinceMinutes(Number(v))}
|
||||
options={WINDOWS.map((w) => ({
|
||||
value: String(w.minutes),
|
||||
label: w.label,
|
||||
}))}
|
||||
/>
|
||||
<TextField
|
||||
id="messages-filter"
|
||||
label="agent"
|
||||
value={query}
|
||||
placeholder="sender or recipient"
|
||||
onInput={setQuery}
|
||||
/>
|
||||
<Hint as="span" class="ui-messages-count">
|
||||
{query.trim() === ""
|
||||
? `${messages.length} messages`
|
||||
: `${shown.length} of ${messages.length} messages`}
|
||||
</Hint>
|
||||
</div>
|
||||
<div class="terminal-wrap ui-messages-wrap">
|
||||
<div class="live terminal" ref={logRef} onScroll={handleScroll}>
|
||||
{shown.length === 0 ? (
|
||||
<div class="row note">
|
||||
<span class="row-content">
|
||||
{connection === "open"
|
||||
? messages.length === 0
|
||||
? "(connected — no messages yet)"
|
||||
: "(no message matches the filter)"
|
||||
: CONNECTION_LABEL[connection]}
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
shown.map((m) => <MessageRow key={m.id} m={m} />)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Hint class="ui-messages-note">
|
||||
Shows what the agents sent each other. A message an agent drained with
|
||||
an in-turn <code>recv</code> is missing. The history is at most 100
|
||||
recent messages per agent.
|
||||
</Hint>
|
||||
</Disclosure>
|
||||
</div>
|
||||
<MessageLog />
|
||||
</LazyDisclosure>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// The messages page's logic, kept out of the component so `npm test` can run
|
||||
// The message log's logic, kept out of the component so `npm test` can run
|
||||
// it: the stream URL, which messages a filter keeps, and how one message
|
||||
// becomes a terminal row.
|
||||
import type { TermRow } from "@hive/shared/term-msg.js";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// <SchedulesCard> — the swarm's scheduled prompts, one card per schedule, folded on the messages tab.
|
||||
// <SchedulesCard> — the swarm's scheduled prompts, one card per schedule, folded on the swarm page.
|
||||
// Backed by swarm-controller's `GET/POST /api/schedules` and
|
||||
// `PATCH/DELETE /api/schedules/{id}`; the controller is the only writer of
|
||||
// the schedule store and computes each schedule's `next_fire_unix`, so
|
||||
|
|
@ -267,7 +267,7 @@ function SchedulesBody() {
|
|||
);
|
||||
}
|
||||
|
||||
// A folded card on the messages tab: the scheduled prompts, read and polled
|
||||
// A folded card on the swarm page: the scheduled prompts, read and polled
|
||||
// only once it is opened.
|
||||
export function SchedulesCard() {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
// <SwarmPage> — what belongs to the swarm as a whole rather than to one agent:
|
||||
// the hive roster, the swarm-wide egress allow list and the notification router.
|
||||
// Each is a card that starts folded and reads nothing until it is opened.
|
||||
// the hive roster, the swarm-wide egress allow list, the notification router and
|
||||
// the messages: the broadcast composer, the schedules and the message log. Each
|
||||
// is a card that starts folded and reads nothing until it is opened.
|
||||
//
|
||||
// The notification router is marked beta: its card says so beside the title and
|
||||
// carries a warning banner inside.
|
||||
import { Badge } from "@hive/shared/badge.js";
|
||||
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
|
||||
import { MessageCards } from "../messages/MessageCards.js";
|
||||
import { NotificationRouter } from "../notifications/NotificationsPage.js";
|
||||
import { EgressCard } from "./EgressCard.js";
|
||||
import { HivesCard } from "./HivesCard.js";
|
||||
|
|
@ -33,6 +35,7 @@ export function SwarmPage() {
|
|||
</p>
|
||||
<NotificationRouter />
|
||||
</LazyDisclosure>
|
||||
<MessageCards />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ const NAV_ITEMS: { href: string; label: string; accent: string }[] = [
|
|||
{ href: "/swarm", label: "swarm", accent: "var(--yellow)" },
|
||||
{ href: "/reports", label: "reports", accent: "var(--red)" },
|
||||
{ href: "/jobs", label: "jobs", accent: "var(--pink)" },
|
||||
{ href: "/messages", label: "messages", accent: "var(--purple)" },
|
||||
{ href: "/components", label: "components", accent: "var(--blue)" },
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ export const MOVED_ROUTES: Readonly<Record<string, string>> = {
|
|||
"/issues": "/reports",
|
||||
"/builds": "/jobs",
|
||||
"/review": "/jobs",
|
||||
"/schedules": "/messages",
|
||||
"/schedules": "/swarm",
|
||||
"/messages": "/swarm",
|
||||
"/notifications": "/swarm",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ test("an old address goes to the tab that holds its page, query kept", () => {
|
|||
assert.equal(movedHref("/alerts", ""), "/reports");
|
||||
assert.equal(movedHref("/issues", ""), "/reports");
|
||||
assert.equal(movedHref("/review", ""), "/jobs");
|
||||
assert.equal(movedHref("/schedules", ""), "/messages");
|
||||
assert.equal(movedHref("/schedules", ""), "/swarm");
|
||||
assert.equal(movedHref("/messages", ""), "/swarm");
|
||||
assert.equal(
|
||||
movedHref("/builds", "run=atlas-abc-1"),
|
||||
"/jobs?run=atlas-abc-1",
|
||||
|
|
|
|||
Loading…
Reference in a new issue