Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: agents page opens an agent's details beside the list

Selecting an agent card opens its details in a column on the right of the
agents list, at /agents/<name>, instead of unfolding the card in place. The
list is full width until an agent is selected, then narrows and the details
slide in. A narrow screen shows the details alone, with a back button. A
card's message is cut to one line.

The shell treats /agents/<name> as the agents page, so the nav tab stays lit
and the page is not rebuilt on each selection.
This commit is contained in:
iris 2026-11-22 18:42:20 +01:00
commit 7bdaea7954
33 changed files with 494 additions and 154 deletions

View file

@ -54,7 +54,8 @@ export function App() {
<MovedTo from={from} />
</Route>
))}
<Route path="/agents" component={AgentsPage} />
{/* `/agents/:name` is the same page with that agent selected. */}
<Route path="/agents/:name?" component={AgentsPage} />
<Route path="/agents/group/:id" component={AgentGroupPage} />
<Route path="/agents/:name/terminal" component={AgentTerminalPage} />
<Route

View file

@ -18,7 +18,7 @@
gap: 0.4em 1em;
}
/* The folded sections of an opened card sit one under another, each with the
/* The folded sections of an agent's details sit one under another, each with the
shared disclosure look; the fields keep the grid above. */
.ui-agent-detail-sections {
display: flex;

View file

@ -1,11 +1,11 @@
// <AgentDetail> — one agent's details: its status, wanted state, hive, config
// PR, inference settings, resource caps and linked accounts, plus the actions on
// them. Two layouts. In an opened card on `/agents` (`inCard`) the card header
// already shows status, message and wanted state, so the body is folded
// sections (`sections.ts`): status, terminal, open todos, subagents, background
// tasks and settings, each built when first opened. In the details popover on a
// terminal page (`AgentDetailPopover`) it is the status and the settings only,
// since the page is already beside a terminal.
// them. Two layouts. In the details beside the list on `/agents`
// (`withTerminal`) it is the state rows, then folded sections (`sections.ts`):
// status, terminal, open todos, subagents, background tasks and settings, each
// built when first opened. In the details popover on a terminal page
// (`AgentDetailPopover`) it is the state rows, then the status and the settings
// only, since the page is already beside a terminal.
//
// Takes the agent's *live* row and the shared `AgentActions`, so a state
// change or a link made here shows wherever else the same row is drawn.
@ -51,7 +51,7 @@ import { SubagentTerms } from "../terminal/SubagentTerms.js";
import { WantedMenu } from "../roster/WantedMenu.js";
import "./AgentDetail.css";
/** The rows the card header already shows: status, message and wanted. */
/** The state rows: status, message and wanted. */
function HeaderRows({
row,
actions,
@ -295,7 +295,7 @@ function LinkAccountAction({
);
}
/** The body of one folded section of an opened card. */
/** The body of one folded section of an agent's details. */
function SectionBody({
section,
row,
@ -338,25 +338,17 @@ export function AgentDetail({
row,
actions,
withTerminal = false,
inCard = false,
}: {
row: AgentRow;
actions: AgentActions;
/** Add the live terminal, todos, subagents and background tasks sections. */
withTerminal?: boolean;
/**
* An opened card, whose header already shows the state rows. Without it
* (the terminal page's popover) those rows go above the same sections.
*/
inCard?: boolean;
}) {
return (
<div class="ui-agent-detail ui-agent-detail-sections">
{inCard ? null : (
<dl class="ui-agent-detail-fields">
<HeaderRows row={row} actions={actions} />
</dl>
)}
<dl class="ui-agent-detail-fields">
<HeaderRows row={row} actions={actions} />
</dl>
{sectionsFor(withTerminal).map((section) => (
<LazyDisclosure
key={section}

View file

@ -1,4 +1,4 @@
// <AgentDetailPopover> — an agent's details from `/agents`, as in an opened card, in a popover
// <AgentDetailPopover> — an agent's details from `/agents`, as in the details beside the list, in a popover
// under its anchor, for a page that is already showing the agent's terminal
// and should not be left, or dimmed, to read or change its details. It carries
// the same body (`AgentDetail`) and the same actions (`useAgentActions`) as the

View file

@ -1,4 +1,4 @@
// <AgentInference> — one agent's inference settings in an opened agent card: the
// <AgentInference> — one agent's inference settings in an agent's details: the
// model and effort it runs on now, with where each came from, and an editor
// for the value the swarm sets.
//

View file

@ -1,5 +1,5 @@
// <AgentInstructions> — an editor for an agent's AGENTS.md, in a dialog opened
// from the agent's opened card.
// from the agent's details.
//
// It loads the copy the agent's harness last published
// (`GET /api/agents/{name}/agents-md`, so a stopped agent shows the text it

View file

@ -1,4 +1,4 @@
// <AgentLimits> — one agent's resource caps in an opened agent card: the CPU and
// <AgentLimits> — one agent's resource caps in an agent's details: the CPU and
// memory caps the swarm sets for it, and an editor for them.
//
// Reads `GET /api/agents/{name}/limits`, which answers the stored caps as

View file

@ -1,5 +1,5 @@
// <AgentPermissions>, <AgentInternet> and <AgentRepos> — one agent's grant in an
// opened agent card: the permissions it holds, how far its traffic may leave
// an agent's details: the permissions it holds, how far its traffic may leave
// the host, and how many repositories its forge account may create. Each is a badge that opens a control under it, which saves as soon as it
// changes.
//

View file

@ -1,4 +1,4 @@
// <AgentSsh> — one agent's SSH access in an opened agent card: a badge that
// <AgentSsh> — one agent's SSH access in an agent's details: a badge that
// opens a warning and the switch, then three folded sections: "how it works"
// (the explainer), "on the target" (the text a machine needs to trust the
// agent's certificates) and "connections" (the agent's named connections, in

View file

@ -1,4 +1,4 @@
// The allowed-domains editor of an opened agent card: which entries it
// The allowed-domains editor of an agent's details: which entries it
// shows and the bodies it sends. Kept out of the component so `npm test` can
// run it.

View file

@ -1,4 +1,4 @@
// An opened agent card's permissions editor: what it starts on and how a granted
// The agent details' permissions editor: what it starts on and how a granted
// set reads. Kept out of the component so `npm test` can run it.
/**

View file

@ -2,7 +2,7 @@
// what order, and which start open. The card's header already shows the
// agent's state, message and wanted state, so the sections hold the rest.
/** One folded block of an opened agent card. */
/** One folded block of an agent's details. */
export type DetailSection =
| "status"
| "terminal"

View file

@ -1,4 +1,4 @@
// The named SSH connections of an opened agent card: the routes, the body a
// The named SSH connections of an agent's details: the routes, the body a
// save sends and what the add form says about a name that is already there.
// Kept out of the component so `npm test` can run it. The controller checks
// every field (the name, user and host rules, the ports it refuses, the limit of

View file

@ -1,4 +1,4 @@
// An opened agent card's SSH row: what the badge says, the body of the PUT that
// The agent details' SSH row: what the badge says, the body of the PUT that
// flips the switch, and the text an operator puts on a target machine. Kept out
// of the component so `npm test` can run it.

View file

@ -25,10 +25,13 @@
align-items: center;
gap: 0.4em;
}
/* One line, cut with an ellipsis: the whole message is in the card's tooltip
and in the details beside the list. */
.ui-agent-card-message {
color: var(--muted);
white-space: normal;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* Icon (`AgentIcon`) beside the name/message. */
.ui-agent-card-row {
@ -44,38 +47,18 @@
min-width: 0;
}
/* The header is what opens the card: it reads as a control without a box. */
/* The header is what opens the agent's details: it reads as a control without
a box. */
.ui-agent-card-row[role="button"] {
cursor: pointer;
}
/* The opened body, set off from the header by a rule. */
.ui-agent-card-detail {
margin-block-start: 0.75em;
padding-block-start: 0.75em;
border-block-start: 1px solid var(--border);
/* The card's own row takes the clicks, so the card shows the hover and the
keyboard focus the way a `Card` with a click handler does. */
.ui-card:has(> .ui-agent-card-row[role="button"]:hover) {
border-color: var(--purple);
}
/* The same chevron as a folded card's (`ui/disclosure/`): right while shut,
down while open, so the header reads as something that unfolds. */
.ui-agent-card-chevron {
align-self: center;
width: 0.55em;
height: 0.55em;
flex: none;
border-right: 2px solid var(--muted);
border-bottom: 2px solid var(--muted);
transform: rotate(-45deg);
transition: transform 0.15s ease;
}
/* The placeholder card keeps the chevron's box without its arrow. */
.ui-agent-card-chevron-blank {
border-color: transparent;
}
.ui-agent-card-row[aria-expanded="true"] .ui-agent-card-chevron {
transform: rotate(45deg);
}
@media (prefers-reduced-motion: reduce) {
.ui-agent-card-chevron {
transition: none;
}
.ui-card:has(> .ui-agent-card-row[role="button"]:focus-visible) {
border-color: var(--purple);
outline: 2px solid var(--purple);
outline-offset: 2px;
}

View file

@ -1,10 +1,9 @@
// <AgentCard> — one card per roster agent (mara: "main view: name,
// status, message, wanted" / "message as second line" / "more like
// card per agent"). The header is those four things; selecting it opens the
// card in place into the agent's details (mara: "one column of expandable
// cards"), so there is no second panel to select into. The header already
// shows the agent's status, message and wanted state, so the opened body is the
// rest: `AgentDetail`'s folded sections (`inCard`).
// card per agent"). The header is those four things, with the message cut to one
// line. Selecting the card opens the agent's details beside the list (`onOpen`,
// which the page turns into `/agents/<name>`); the card of the open agent is
// marked `selected`.
//
// The terminal badge beside the wanted menu opens the agent's terminal tab, the
// most common action, without opening the card.
@ -21,8 +20,8 @@ import { Card } from "../../ui/card/Card.js";
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
import { AgentIcon } from "../AgentIcon.js";
import { ClaudeLoginDialog } from "../claude-login/ClaudeLoginDialog.js";
import { AgentDetail } from "../detail/AgentDetail.js";
import { StatusMessage } from "../detail/StatusMessage.js";
import { statusText } from "../detail/status-fields.js";
import { termPaths } from "../terminal/term-paths.js";
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
import {
@ -40,29 +39,34 @@ import "./AgentCard.css";
export function AgentCard({
row,
actions,
selected = false,
onOpen,
}: {
row: AgentRow;
actions: AgentActions;
/** This agent's details are open beside the list. */
selected?: boolean;
/** Called when the card is chosen, to open the agent's details. */
onOpen: () => void;
}) {
const [loggingIn, setLoggingIn] = useState(false);
const [open, setOpen] = useState(false);
const error = actions.actionErrors.get(row.name);
const toggle = () => setOpen((was) => !was);
const { open: openTab } = useDynamicTabs();
const term = termPaths(row.name);
return (
<Card>
<Card selected={selected}>
<AgentCardLayout
rowProps={{
role: "button",
tabIndex: 0,
"aria-expanded": open,
onClick: toggle,
"data-agent": row.name,
"aria-current": selected ? "true" : undefined,
onClick: onOpen,
onKeyDown: (e) => {
if (e.target !== e.currentTarget) return;
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
toggle();
onOpen();
}
},
}}
@ -157,7 +161,7 @@ export function AgentCard({
</span>
}
message={<StatusMessage snapshot={row.snapshot} />}
chevron={<span class="ui-agent-card-chevron" aria-hidden="true" />}
messageTitle={statusText(row.snapshot)}
/>
{error ? (
<ApiErrorPanel
@ -165,11 +169,6 @@ export function AgentCard({
problem={error}
/>
) : null}
{open ? (
<div class="ui-agent-card-detail">
<AgentDetail row={row} actions={actions} withTerminal inCard />
</div>
) : null}
</Card>
);
}

View file

@ -1,6 +1,6 @@
// <AgentCardLayout> — the arrangement of an agent card's header, with a slot
// for each part: the icon, the name, the status (freshness and login badges),
// the trailing controls, the message line and the chevron. `AgentCard` fills
// the trailing controls and the message line. `AgentCard` fills
// the slots with the real sub components; `AgentCardSkeleton` fills the same
// slots with placeholder shapes, so the card that replaces it lands in the same
// place.
@ -13,7 +13,7 @@ export function AgentCardLayout({
status,
trailing,
message,
chevron,
messageTitle,
rowProps,
}: {
icon: ComponentChildren;
@ -21,9 +21,10 @@ export function AgentCardLayout({
status: ComponentChildren;
trailing: ComponentChildren;
message: ComponentChildren;
chevron?: ComponentChildren;
/** The whole message as a tooltip, for the line that cuts it short. */
messageTitle?: string;
/** Attributes of the header row, for the card that opens on a click. */
rowProps?: HTMLAttributes<HTMLDivElement>;
rowProps?: HTMLAttributes<HTMLDivElement> & { "data-agent"?: string };
}) {
return (
<div class="ui-agent-card-row" {...rowProps}>
@ -34,9 +35,10 @@ export function AgentCardLayout({
{status}
{trailing}
</div>
<div class="ui-agent-card-message">{message}</div>
<div class="ui-agent-card-message" title={messageTitle}>
{message}
</div>
</div>
{chevron}
</div>
);
}

View file

@ -22,14 +22,6 @@ export function AgentCardSkeleton() {
</span>
}
message={<Skeleton width="55%" />}
// The real chevron's box with no arrow, so the trailing controls end at
// the same x.
chevron={
<span
class="ui-agent-card-chevron ui-agent-card-chevron-blank"
aria-hidden="true"
/>
}
/>
</Card>
);

View file

@ -1,6 +1,6 @@
/* <AgentTermPreview> — a *preview*, not the full terminal: a much
shorter cap than @hive/shared/terminal.css's own 32em default so it
reads as "peek at what's happening" inside an opened agent card rather
reads as "peek at what's happening" inside an agent's details rather
than competing with the card's own fields for vertical space. */
@import "@hive/shared/terminal.css";

View file

@ -1,4 +1,4 @@
// <AgentTermPreview> — an agent's terminal: the preview in an opened card on
// <AgentTermPreview> — an agent's terminal: the preview in the details on
// `AgentsPage` and the full tab (`fullHeight`, `AgentTerminalPage`), with an
// `AgentInputForm` under an agent's own terminal (a subagent's has none: it
// takes no input of its own). Consumes swarm-controller's

Some files were not shown because too many files have changed in this diff Show more