Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: an agent's details are an identity card and sections by question

The details pane showed the agent's name, then status, message and wanted
rows with no card, then a folded status section repeating the state, and a
single settings section of eleven rows of different kinds.

The pane now opens with one identity card: icon and name, the wanted menu,
badges for freshness, turn state, context and a needed login, the whole
status message, and the hive, links and config PR. Below it the folded
sections answer one question each: terminal, activity (todos, subagents and
background tasks together), instructions, inference (which now holds the
claude login and API key), access, and accounts. The terminal page's popover
shows the card without the name and the four settings sections.
This commit is contained in:
iris 2026-11-22 23:34:11 +01:00 • committed by mara
commit ab329e5793
14 changed files with 480 additions and 375 deletions

View file

@ -104,16 +104,16 @@ create first, since the badge is the only way to destroy.
An agent created here or with `swarmctl agent create` starts `paused`; set it
`up` from its card. A card shows **login needed** when the agent's own
turn-state header says its claude has no session, and a **log in** button
that runs the claude login from a dialog: open the URL it shows, then paste
the code back. A failed login offers **try again** in the same dialog. When the
secret store has the login, the dialog closes and a
short toast in the top-right corner says so. The credentials go to the agent through the secret store
([`claude-login.md`](../../2-handbook/swarm/claude-login.md)). The agent's own web UI login still
works too. The settings section of an agent's details has a **claude login** row: when
the swarm stored the agent's login, or that none is, with a **log in** button
(**log in again** when the swarm holds one) that opens the same dialog, and a **delete
login** action that asks first.
turn-state header says its claude has no session, and a **log in** button that
runs the claude login from a dialog: open the URL it shows, then paste the code
back. A failed login offers **try again** in the same dialog. When the secret
store has the login, the dialog closes and a short toast in the top-right corner
says so. The credentials go to the agent through the secret store
([`claude-login.md`](../../2-handbook/swarm/claude-login.md)). The agent's own
web UI login still works too. The **inference** section of an agent's details
has a **claude login** row: when the swarm stored the agent's login, or that
none is, with a **log in** button (**log in again** when the swarm holds one)
that opens the same dialog, and a **delete login** action that asks first.
A card shows its freshness when the agent isn't **fresh**: **stale** with how long ago the hive last
reported it, **never reported**, or **not in swarm identity**. A fresh agent shows nothing, so the
@ -170,56 +170,72 @@ got the message, a toast says so and select mode ends. Otherwise the dialog
stays with the per-agent result, and **select the N that failed** picks just
those for another send. One broadcast takes at most 64 agents.
Below the agent's state, message and wanted menu, the details have six sections,
and each reads nothing until you open it. **status** and **terminal** start
open, the other four folded:
At the top of the details, one **identity card** says who the agent is and how
it's doing: its icon and name, the **wanted** menu (the one action there),
badges for how fresh its last report is (with its age), its turn state and
context, and **login needed** when its claude has no session, the whole status
message with how long ago it set it, and a line with its hive, links to its
profile and its config repo on the swarm's forge (built from the forge entry of
`GET /api/links`; hidden when the swarm lists none, and an agent built from an
archetype has no config repo link), its open config PR, and, for an agent built
from an archetype, the archetype with a **turn into custom** button.
Below it, the details have six folded sections, one for each question an
operator comes with, and each reads nothing until you open it. **terminal**
starts open, the other five folded:
- **status**: how fresh the agent's last report is (with its age), its turn state and context, its hive, links to its
profile and its config repo on the swarm's forge (built from the forge entry
of `GET /api/links`; the row stays hidden when the swarm lists none, and an
agent built from an archetype has no config repo, so it gets no config repo
link), and its open config PR.
- **terminal**: the live terminal with its message box, a pill floating over the
terminal's bottom edge whose right end holds the send button, a circle with an
arrow. Typing `/` opens a menu
filled from `GET /api/agents/<name>/commands`, which lists the swarm's own
commands and the skills the agent published. Sending exactly `/clear` isn't a
message: the box POSTs `/api/agents/<name>/new-session` instead of `/input` (see
the command paragraph below).
- **open todos**: the agent's open todos from `GET /api/agents/<name>/todos`, newest first, each with
its subsystem, one line of text and how long ago it changed. Read only; refetched every ten seconds.
- **subagents**: the agent's subagents and their terminal preview (next section).
- **background tasks**: the agent's bash tasks (see the section on them below).
- **settings**: inference, instructions, resource caps, internet, allowed
domains and permissions, then the agent's linked accounts and the menu that
links another. Internet, allowed domains and permissions show a badge; select
it to open the control that changes it (described below).
arrow. Typing `/` opens a menu filled from `GET /api/agents/<name>/commands`,
which lists the swarm's own commands and the skills the agent published.
Sending exactly `/clear` isn't a message: the box POSTs
`/api/agents/<name>/new-session` instead of `/input` (see the command
paragraph below).
- **activity**: what the agent is working on, in three lists one under another.
Its open todos from `GET /api/agents/<name>/todos`, newest first, each with
its subsystem, one line of text and how long ago it changed (read only,
refetched every ten seconds); its subagents and their terminal preview (next
section); and its bash tasks (see the section on them below).
- **instructions**: the agent's AGENTS.md, with an **edit** button.
- **inference**: how the agent thinks and what it costs: its model and effort
and the other inference settings, its resource caps, and the claude login and
API key (the login's state, **log in**, and **set API key**), since the key is
how the agent reaches claude.
- **access**: what the agent may reach: internet, allowed domains, repositories,
SSH and permissions. Internet, allowed domains, repositories, SSH and
permissions show a badge; select it to open the control that changes it
(described below).
- **accounts**: the agent's linked external accounts, and the menu that links
another.
The terminal page's details popover shows the identity card without the icon and
name (the popover's own header has the name), then the four settings sections.
### Agent and subagent terminals
An agent's detail pane on `/agents` shows, in its **terminal** section, a small live preview of its
terminal, and below it the agent's **subagents**: every subagent the swarm
queue holds terminal rows for from the last 24 hours. Picking one shows its
terminal in the same preview, and **expand** opens it in its own tab, as it
does for the agent. The list refreshes every 10 seconds, so a subagent the
agent spawns shows up once it writes output. A subagent that drops out of the
list closes its terminal, and a later subagent with the same name starts
unpicked.
Each subagent in the list shows the model and effort it runs, like
`opus · high`, beside its name; one on the default model shows only the effort.
The `/agents/<name>/terminal` page's subagent list shows them too.
An agent's detail pane on `/agents` shows, in its **terminal** section, a small
live preview of its terminal, and in its **activity** section the agent's
**subagents**: every subagent the swarm queue holds terminal rows for from the
last 24 hours. Picking one shows its terminal in the same preview, and
**expand** opens it in its own tab, as it does for the agent. The list refreshes
every 10 seconds, so a subagent the agent spawns shows up once it writes output.
A subagent that drops out of the list closes its terminal, and a later subagent
with the same name starts unpicked. Each subagent in the list shows the model
and effort it runs, like `opus · high`, beside its name; one on the default
model shows only the effort. The `/agents/<name>/terminal` page's subagent list
shows them too.
The preview carries only a small connection light and **expand**, so it stays
clear of the text. What the agent is doing shows in the details table above it,
in the **state** row: the turn state (idle, thinking or compacting), a **paused**
badge for a paused agent, and the tokens in its context. The row
shows the latest report the controller holds, if it's under 150 seconds old, as
soon as you look. It reads "no report yet" when there is none: for an agent
that's offline, and until the first report after the controller restarts. The
agent sends a report when its state changes and once a minute. If
the browser gives up on the stream, a **reconnect** badge opens it again. The
terminal's own tab keeps these badges, with the model, beside the agent's name;
the turn-state badge says how long the agent has been in that state.
clear of the text. What the agent is doing shows in the identity card above it,
in the state badges: the turn state (idle, thinking or compacting), a **paused**
badge for a paused agent, and the tokens in its context. The badges show the
latest report the controller holds, if it's under 150 seconds old, as soon as
you look. It reads "no report yet" when there is none: for an agent that's
offline, and until the first report after the controller restarts. The agent
sends a report when its state changes and once a minute. If the browser gives up
on the stream, a **reconnect** badge opens it again. The terminal's own tab
keeps these badges, with the model, beside the agent's name; the turn-state
badge says how long the agent has been in that state.
The terminal is a `role="log"` that takes the keyboard focus, so the arrow keys
scroll it, and it doesn't announce new rows, since many can arrive in a second.
@ -256,8 +272,8 @@ thinks quietly for longer drops out of the count. The list shows the others belo
dimmed, as **not running**.
Beside it, an agent with background bash tasks has a **bash tasks** badge, a
prompt icon and the number running, which opens the same list of tasks the card's
"background tasks" section shows. An agent with no tasks has no badge, and a
prompt icon and the number running, which opens the same list of tasks the
details' **activity** section shows. An agent with no tasks has no badge, and a
subagent's terminal has none.
An agent's terminal opens with its last 100 rows from the past 24 hours, then
@ -299,14 +315,15 @@ different agents tell apart. A subagent's tab shows its agent's icon. An agent
with no icon keeps the hyperhive mark. Everywhere else the swarm UI shows an agent's icon (the cards, the pickers, the badges), an agent with none shows the default agent icon.
The tab also has an agent badge, with the agent's icon (carrying the connection
light) and name, ahead of the state badges. It opens the agent's details in a popover under the badge:
the same status, state, wanted state and folded **status** and **settings** sections (inference, resource caps, internet, allowed domains, permissions and linked accounts) as the
details on `/agents`, without the terminal and subagents. The popover doesn't dim the
page. Selecting outside it, or Escape, closes it. From the keyboard, opening a
popover moves focus into it, and Escape puts focus back on the badge. The filter
popovers on table headers work the same way. You can stop or pause the
agent, or link an account, without leaving the terminal. A subagent's tab opens
its agent's details.
light) and name, ahead of the state badges. It opens the agent's details in a
popover under the badge: the same identity card and folded **instructions**,
**inference**, **access** and **accounts** sections as the details on `/agents`,
without the terminal and the activity. The popover doesn't dim the page.
Selecting outside it, or Escape, closes it. From the keyboard, opening a popover
moves focus into it, and Escape puts focus back on the badge. The filter
popovers on table headers work the same way. You can stop or pause the agent, or
link an account, without leaving the terminal. A subagent's tab opens its
agent's details.
#### Groups of terminals
@ -732,15 +749,16 @@ store identity, or no queue address, publishes no subagent terminals.
<details><summary>Where the background task list comes from</summary>
An agent's detail pane has a **background tasks** section, below the subagents, listing the
tasks the agent started through the bash MCP. Its bash MCP publishes one status per task
to the `bash-task-status` bucket, and swarm-controller serves the list as
`GET /api/agents/<name>/bash-tasks`: each task's id, command, state, the time the agent queued it and
the time it entered its state, and the exit status. The state is the published
one, or `stale` for a live task whose daemon stopped reporting. The section lists the running
tasks first, then the rest, each newest first. Before the age it says `started`,
`finished`, `exited N`, `timed out`, `killed` or `stopped reporting`. It refetches
every ten seconds and shows no output, which is a separate stream.
An agent's detail pane lists, in its **activity** section below the subagents,
the tasks the agent started through the bash MCP. Its bash MCP publishes one
status per task to the `bash-task-status` bucket, and swarm-controller serves
the list as `GET /api/agents/<name>/bash-tasks`: each task's id, command, state,
the time the agent queued it and the time it entered its state, and the exit
status. The state is the published one, or `stale` for a live task whose daemon
stopped reporting. The section lists the running tasks first, then the rest,
each newest first. Before the age it says `started`, `finished`, `exited N`,
`timed out`, `killed` or `stopped reporting`. It refetches every ten seconds and
shows no output, which is a separate stream.
</details>
@ -860,25 +878,37 @@ text stays.
### Inference settings
An agent's detail pane shows, in its **settings** section, its model and effort under **inference**, each
with where it comes from: the swarm, its agent.nix, its own pick, or the
default. Below them are the subagent model list the swarm sets, or "its own"
when it sets none, the subagent cap, which reads "no cap" when unset, and the
fresh-session threshold and the soft context limit, which each read "its own" when unset. **edit** opens a dialog with the fields, filled with what the swarm
stores; saving does a `PUT /api/agents/{agent}/inference` of
the whole value. A field you leave empty stays out of it, so the agent keeps
its own value for that field; an empty max subagents is no cap, and the two context limits share one slider with two handles on the model's context window, from 5 to 100 percent: a turn that finds the prompt cache cold starts a fresh session once the context passes the left (green) handle, and the agent compacts at the end of a turn once it passes the right (purple) one, and a turn can run past it. The handles can't cross. A handle the swarm hasn't set sits at the harness's own value (50 and 75), dimmed; **use its own** on its line puts it back there, which leaves that field out of the `PUT`. **clear the swarm's setting** sends the `DELETE`.
The model is a dropdown of the models the swarm already knows (`GET /api/models`: those in any agent's stored settings and those the agents report running on), with the agent's own as the empty choice; **other…** opens a box for any other model name, and a stored name the list lacks opens it too. The subagent models stay a typed list.
The card reads `GET /api/agents/{agent}/inference`; before the agent's first
report reaches the controller, it shows the swarm's stored values only.
An agent's detail pane shows, in its **inference** section, its model and
effort, each with where it comes from: the swarm, its agent.nix, its own pick,
or the default. Below them are the subagent model list the swarm sets, or "its
own" when it sets none, the subagent cap, which reads "no cap" when unset, and
the fresh-session threshold and the soft context limit, which each read "its
own" when unset. **edit** opens a dialog with the fields, filled with what the
swarm stores; saving does a `PUT /api/agents/{agent}/inference` of the whole
value. A field you leave empty stays out of it, so the agent keeps its own value
for that field; an empty max subagents is no cap, and the two context limits
share one slider with two handles on the model's context window, from 5 to 100
percent: a turn that finds the prompt cache cold starts a fresh session once the
context passes the left (green) handle, and the agent compacts at the end of a
turn once it passes the right (purple) one, and a turn can run past it. The
handles can't cross. A handle the swarm hasn't set sits at the harness's own
value (50 and 75), dimmed; **use its own** on its line puts it back there, which
leaves that field out of the `PUT`. **clear the swarm's setting** sends the
`DELETE`. The model is a dropdown of the models the swarm already knows (`GET
/api/models`: those in any agent's stored settings and those the agents report
running on), with the agent's own as the empty choice; **other…** opens a box
for any other model name, and a stored name the list lacks opens it too. The
subagent models stay a typed list. The card reads `GET
/api/agents/{agent}/inference`; before the agent's first report reaches the
controller, it shows the swarm's stored values only.
[inference](../swarm/inference.md) describes the settings themselves.
### Editing an agent's instructions
The **instructions** row of an agent's **settings** has an **edit** button. It
The **instructions** section of an agent's details has an **edit** button. It
opens `AGENTS.md`, the file the agent reads its instructions from, in a plain
text box. The text is the copy the agent last published, so the box still
opens for a stopped agent, but **save** needs the agent running.
text box. The text is the copy the agent last published, so the box still opens
for a stopped agent, but **save** needs the agent running.
Save sends the swarm a diff against the version you opened, and the agent
applies it to its own file with git. When the agent changed the file in the
@ -891,13 +921,13 @@ dialog keeps an unsaved edit for the next time you open it.
### Resource caps
An agent's detail pane shows, under **settings**, its CPU quota and memory max under **resource
caps**. A cap is the swarm's, so it follows the agent to whichever hive runs
it, and it replaces what the hive says for that field. A field the swarm
leaves out shows as the hive deciding it. **edit** opens a dialog with the two
fields, filled with what the swarm stores. A cpu quota is a percentage of one
core (`400%` is four cores). A memory max is a size such as `512M` or `8G`, a
percentage of the machine's memory, or `infinity`.
An agent's detail pane shows, in its **inference** section, its CPU quota and
memory max under **resource caps**. A cap is the swarm's, so it follows the
agent to whichever hive runs it, and it replaces what the hive says for that
field. A field the swarm leaves out shows as the hive deciding it. **edit**
opens a dialog with the two fields, filled with what the swarm stores. A cpu
quota is a percentage of one core (`400%` is four cores). A memory max is a size
such as `512M` or `8G`, a percentage of the machine's memory, or `infinity`.
Saving does a `PUT /api/agents/{agent}/limits` of the filled fields. A `PUT`
replaces the stored value whole, so an empty box clears that cap and the hive
@ -932,13 +962,13 @@ reason and a **retry** button.
### Permissions
An agent's detail pane shows, under **settings**, what the swarm grants it under **permissions**:
a badge reading the default set, none, or a count. A swarm
grant is the agent's whole set, so it follows the agent to whichever hive runs
it. Selecting the badge opens a box under it with one checkbox per permission the controller
knows (`GET /api/permissions`), ticked as the grant stands, or on the default
set when the swarm sets none. The box lists every permission at once, without a
scroll area.
An agent's detail pane shows, in its **access** section, what the swarm grants
it under **permissions**: a badge reading the default set, none, or a count. A
swarm grant is the agent's whole set, so it follows the agent to whichever hive
runs it. Selecting the badge opens a box under it with one checkbox per
permission the controller knows (`GET /api/permissions`), ticked as the grant
stands, or on the default set when the swarm sets none. The box lists every
permission at once, without a scroll area.
Each tick saves at once, as a `PUT /api/agents/{agent}/permissions` of the ticked boxes. A
`PUT` replaces the stored list whole, so an unticked box revokes that
@ -1003,13 +1033,13 @@ same grant from a shell.
### Allowed domains
An agent's detail pane lists, under **settings**, the destinations it may reach through its
hive's egress proxy under **allowed domains**, beyond the base list every
agent has: one badge per source with its count, **swarm-wide** (the entries for every
agent), **this agent** (the ones for it alone) and **automatic**. Selecting a badge
opens the names behind it. An entry matters
to a restricted agent. One with the unrestricted internet flag reaches any
name the proxy's private-range rules leave. **remove**, beside a name, drops one entry;
An agent's detail pane lists, in its **access** section, the destinations it may
reach through its hive's egress proxy under **allowed domains**, beyond the base
list every agent has: one badge per source with its count, **swarm-wide** (the
entries for every agent), **this agent** (the ones for it alone) and
**automatic**. Selecting a badge opens the names behind it. An entry matters to
a restricted agent. One with the unrestricted internet flag reaches any name the
proxy's private-range rules leave. **remove**, beside a name, drops one entry;
**add** opens a dialog with a domain box and a tick for every agent in the
swarm. The tick is off by default, so an entry is for this agent alone.
@ -1135,14 +1165,13 @@ the form above. The row shows whether the store holds a key and never the key. A
change reaches the agent at its next restart, and an agent with a key tries it
instead of waiting for a claude login.
An agent's detail pane lists its linked accounts at the end of its **settings** section, one row
per account: kind, name and host. Opening an agent makes one request,
An agent's detail pane lists its linked accounts in its **accounts** section,
one row per account: kind, name and host. Opening an agent makes one request,
`GET /api/hives/{hive}/agents/{agent}/linked-accounts`, which returns every
account of that agent as names and hosts and never a credential. When the card
fails to read the accounts, the inference settings, the resource caps or the
permissions, it
shows the reason as text. A list the card already loaded stays on screen
beneath the error.
permissions, it shows the reason as text. A list the card already loaded stays
on screen beneath the error.
| kind | one row per | name | host |
| --------- | ------------------------------------------- | ------------- | ------------------------ |

View file

@ -1,5 +1,4 @@
/* <AgentDetail> body — the panel or dialog around it supplies the title (the
agent's name), so it is not repeated in here. */
/* <AgentDetail> body: the identity card, then the folded sections. */
.ui-agent-detail-fields {
display: grid;
grid-template-columns: auto 1fr;
@ -25,3 +24,10 @@
flex-direction: column;
gap: 0.75em;
}
/* The activity section holds three lists, each with its own label. */
.ui-agent-detail-activity {
display: flex;
flex-direction: column;
gap: 1em;
}

View file

@ -1,26 +1,21 @@
// <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 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.
// <AgentDetail> — one agent's details: the identity card (who it is and how it
// is doing, `AgentIdentity`), then folded sections (`sections.ts`), one for
// each question an operator comes with: the terminal, what it is working on
// (activity), its instructions, how it thinks (inference, which holds the
// claude login and API key), what it may reach (access) and which accounts it
// is linked to. Each section builds when first opened. In the details popover
// on a terminal page (`AgentDetailPopover`) it is the identity card without
// the name, then the four settings sections, 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.
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { Badge } from "@hive/shared/badge.js";
import { ActionRow } from "../../ui/action-row/ActionRow.js";
import { Button } from "../../ui/button/Button.js";
import { ExternalLink } from "../../ui/external-link/ExternalLink.js";
import { Hint } from "../../ui/hint/Hint.js";
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
import type { AgentActions } from "../roster/AgentActions.js";
import { AgentApiKey } from "./AgentApiKey.js";
import { AgentClaudeLogin } from "./AgentClaudeLogin.js";
import { AgentInference } from "./AgentInference.js";
import { StatusMessage } from "./StatusMessage.js";
import { AgentInstructions } from "./AgentInstructions.js";
import { AgentLimits } from "./AgentLimits.js";
import { AgentSsh } from "./AgentSsh.js";
@ -31,11 +26,9 @@ import {
useGrant,
} from "./AgentPermissions.js";
import { AllowedDomains } from "./AllowedDomains.js";
import { AgentStateRow } from "./AgentStateRow.js";
import { AgentIdentity } from "./AgentIdentity.js";
import { AgentTermPreview } from "../terminal/AgentTermPreview.js";
import { canTurnIntoCustom, FRESHNESS, type AgentRow } from "../AgentTypes.js";
import { agentForgeLinks } from "./forge-links.js";
import { useForgeBase } from "./useForgeBase.js";
import type { AgentRow } from "../AgentTypes.js";
import { LinkAccountMenu } from "./LinkAccountMenu.js";
import { LinkedAccounts } from "./LinkedAccounts.js";
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
@ -48,162 +41,21 @@ import {
import { AgentTodos } from "../terminal/AgentTodos.js";
import { BashTasks } from "../terminal/BashTasks.js";
import { SubagentTerms } from "../terminal/SubagentTerms.js";
import { WantedMenu } from "../roster/WantedMenu.js";
import "./AgentDetail.css";
/** The state rows: status, message and wanted. */
function HeaderRows({
row,
actions,
function InferenceRows({
agent,
hive,
}: {
row: AgentRow;
actions: AgentActions;
agent: string;
hive: string | null;
}) {
const { tone, label } = FRESHNESS[row.freshness];
const declareError = actions.actionErrors.get(row.name);
return (
<>
<dt>status</dt>
<dd>
<Badge
tone={tone}
title={
row.freshness === "unknown"
? "reported by its hive but not registered in swarm-level identity — needs migration"
: undefined
}
value={
<>
{label}
{row.last_seen_unix !== null ? (
<>
{" "}
(<RelativeTime epochMs={row.last_seen_unix * 1000} />)
</>
) : null}
</>
}
/>
</dd>
<dt>message</dt>
<dd>
<StatusMessage snapshot={row.snapshot} />
</dd>
<dt>wanted</dt>
<dd>
{/* Full menu (destroy included) — mara: "destroy is already
available via wanted state", no separate button needed. */}
<WantedMenu
row={row}
pending={actions.pendingAgents.has(row.name)}
onSelectUp={actions.selectUp}
onSelectOffline={actions.selectOffline}
onSelectPaused={actions.selectPaused}
onDestroy={actions.requestDestroy}
/>
{/* A failed declaration shows here too: on a terminal page's
dialog there is no roster card to carry the "failed" badge. */}
{declareError ? (
<ApiErrorPanel
context="the declaration failed"
problem={declareError}
/>
) : null}
</dd>
</>
);
}
function OverviewRows({
row,
actions,
}: {
row: AgentRow;
actions: AgentActions;
}) {
const forge = useForgeBase();
const forgeLinks = forge
? agentForgeLinks(forge, row.name, !row.archetype)
: null;
return (
<>
<dt>state</dt>
<dd>
<AgentStateRow key={row.name} agent={row.name} />
</dd>
<dt>hive</dt>
<dd>{row.hive ?? "—"}</dd>
{forgeLinks ? (
<>
<dt>forge</dt>
<dd class="ui-agent-detail-links">
<ExternalLink href={forgeLinks.profile}>profile</ExternalLink>
{forgeLinks.configRepo ? (
<ExternalLink href={forgeLinks.configRepo}>
config repo
</ExternalLink>
) : null}
</dd>
</>
) : null}
<dt>config PR</dt>
<dd>
{row.config_pr ? (
<Badge
tone="warning"
value={
row.config_pr.html_url ? (
<ExternalLink href={row.config_pr.html_url}>
#{row.config_pr.pr_number}
</ExternalLink>
) : (
`#${row.config_pr.pr_number}`
)
}
/>
) : (
"—"
)}
</dd>
{row.archetype ? (
<>
<dt>archetype</dt>
<dd>
{row.archetype.source}/{row.archetype.name}
{canTurnIntoCustom(row) ? (
<>
{" "}
<Button
disabled={actions.pendingAgents.has(row.name)}
onClick={() => actions.requestCustom(row)}
>
turn into custom
</Button>
</>
) : null}
</dd>
</>
) : null}
</>
);
}
function SettingsRows({ agent, hive }: { agent: string; hive: string | null }) {
return (
<>
<dt>inference</dt>
<dd>
<AgentInference key={agent} agent={agent} />
</dd>
<dt>instructions</dt>
<dd>
<AgentInstructions key={agent} agent={agent} />
</dd>
<dt>resource caps</dt>
<dd>
<AgentLimits key={agent} agent={agent} />
</dd>
<GrantRows key={agent} agent={agent} />
<dt>claude login</dt>
<dd>
<AgentClaudeLogin key={agent} agent={agent} />
@ -258,22 +110,15 @@ function AccountsRows({
row: AgentRow;
actions: AgentActions;
}) {
return (
<>
<dt>accounts</dt>
<dd>
{row.hive ? (
<LinkedAccounts
key={`${row.hive}/${row.name}`}
hive={row.hive}
agent={row.name}
version={actions.linkVersion}
/>
) : (
"—"
)}
</dd>
</>
return row.hive ? (
<LinkedAccounts
key={`${row.hive}/${row.name}`}
hive={row.hive}
agent={row.name}
version={actions.linkVersion}
/>
) : (
<Hint as="span">no hive, so no accounts</Hint>
);
}
@ -306,31 +151,41 @@ function SectionBody({
actions: AgentActions;
}) {
switch (section) {
case "status":
return (
<dl class="ui-agent-detail-fields">
<OverviewRows row={row} actions={actions} />
</dl>
);
case "settings":
return (
<>
<dl class="ui-agent-detail-fields">
<SettingsRows agent={row.name} hive={row.hive} />
<AccountsRows row={row} actions={actions} />
</dl>
<LinkAccountAction row={row} actions={actions} />
</>
);
case "terminal":
// The agent's live terminal and its input box.
return <AgentTermPreview agentName={row.name} />;
case "todos":
return <AgentTodos key={row.name} agentName={row.name} />;
case "subagents":
return <SubagentTerms key={row.name} agentName={row.name} />;
case "tasks":
return <BashTasks key={row.name} agentName={row.name} />;
case "activity":
return (
<div class="ui-agent-detail-activity">
<AgentTodos key={row.name} agentName={row.name} />
<SubagentTerms key={row.name} agentName={row.name} />
<BashTasks key={row.name} agentName={row.name} />
</div>
);
case "instructions":
return <AgentInstructions key={row.name} agent={row.name} />;
case "inference":
return (
<>
<AgentInference key={row.name} agent={row.name} />
<dl class="ui-agent-detail-fields">
<InferenceRows agent={row.name} hive={row.hive} />
</dl>
</>
);
case "access":
return (
<dl class="ui-agent-detail-fields">
<GrantRows key={row.name} agent={row.name} />
</dl>
);
case "accounts":
return (
<>
<AccountsRows row={row} actions={actions} />
<LinkAccountAction row={row} actions={actions} />
</>
);
}
}
@ -338,17 +193,18 @@ export function AgentDetail({
row,
actions,
withTerminal = false,
showName = true,
}: {
row: AgentRow;
actions: AgentActions;
/** Add the live terminal, todos, subagents and background tasks sections. */
/** Add the live terminal and the activity (todos, subagents, background tasks) sections. */
withTerminal?: boolean;
/** Draw the icon and name in the identity card: off where a header names the agent. */
showName?: boolean;
}) {
return (
<div class="ui-agent-detail ui-agent-detail-sections">
<dl class="ui-agent-detail-fields">
<HeaderRows row={row} actions={actions} />
</dl>
<AgentIdentity row={row} actions={actions} showName={showName} />
{sectionsFor(withTerminal).map((section) => (
<LazyDisclosure
key={section}

View file

@ -80,7 +80,7 @@ export function AgentDetailPopover({
problem={error}
/>
) : row ? (
<AgentDetail row={row} actions={actions} />
<AgentDetail row={row} actions={actions} showName={false} />
) : row === null ? (
<p>{agent} is not in the swarm's agent list</p>
) : (

View file

@ -0,0 +1,49 @@
/* <AgentIdentity>: the card with the icon and name, the badges, the message and
the hive and links. The card's own look is `Card`'s (border, background). */
.ui-agent-identity-top {
display: flex;
align-items: flex-start;
gap: 0.9em;
}
.ui-agent-identity-main {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 0.5em;
}
.ui-agent-identity-line {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.5em 1em;
}
.ui-agent-identity-name {
margin: 0;
font-size: 1.25em;
}
/* The name takes the focus when the details open; it is not a control. */
.ui-agent-identity-name:focus {
outline: none;
}
.ui-agent-identity-wanted {
margin-left: auto;
}
.ui-agent-identity-badges {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.4em 0.6em;
}
.ui-agent-identity-message {
margin: 0;
overflow-wrap: anywhere;
}
.ui-agent-identity-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.3em 1em;
color: var(--muted);
font-size: 0.9em;
}

View file

@ -0,0 +1,164 @@
// <AgentIdentity> — the card at the top of an agent's details: who it is and
// how it is doing, in one place. The icon and name, the wanted menu (the one
// action), the badges (how fresh its report is, its turn state and context,
// whether it needs a login), the whole status message with its age, and the
// hive, forge links and config PR. The agent's state is said here once; the
// sections below it hold what the operator reads or changes.
//
// `showName` is off where a header already names the agent (the terminal
// page's popover), which leaves the icon and name out and the rest as is.
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { Badge } from "@hive/shared/badge.js";
import { Button } from "../../ui/button/Button.js";
import { Card } from "../../ui/card/Card.js";
import { ExternalLink } from "../../ui/external-link/ExternalLink.js";
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
import { AgentIcon } from "../AgentIcon.js";
import {
canTurnIntoCustom,
FRESHNESS,
showsLoginNeeded,
type AgentRow,
} from "../AgentTypes.js";
import type { AgentActions } from "../roster/AgentActions.js";
import { WantedMenu } from "../roster/WantedMenu.js";
import { AgentStateRow } from "./AgentStateRow.js";
import { agentForgeLinks } from "./forge-links.js";
import { StatusMessage } from "./StatusMessage.js";
import { useForgeBase } from "./useForgeBase.js";
import "./AgentIdentity.css";
export function AgentIdentity({
row,
actions,
showName = true,
}: {
row: AgentRow;
actions: AgentActions;
showName?: boolean;
}) {
const { tone, label } = FRESHNESS[row.freshness];
const declareError = actions.actionErrors.get(row.name);
const forge = useForgeBase();
const forgeLinks = forge
? agentForgeLinks(forge, row.name, !row.archetype)
: null;
return (
<Card class="ui-agent-identity">
<div class="ui-agent-identity-top">
{showName ? <AgentIcon name={row.name} /> : null}
<div class="ui-agent-identity-main">
<div class="ui-agent-identity-line">
{showName ? (
<h2
class="ui-agent-identity-name"
tabIndex={-1}
data-details-title
>
{row.name}
</h2>
) : null}
<span class="ui-agent-identity-wanted">
{/* Full menu (destroy included): the wanted state is the one
action an agent's details take. */}
<WantedMenu
row={row}
pending={actions.pendingAgents.has(row.name)}
onSelectUp={actions.selectUp}
onSelectOffline={actions.selectOffline}
onSelectPaused={actions.selectPaused}
onDestroy={actions.requestDestroy}
/>
</span>
</div>
<div class="ui-agent-identity-badges">
<Badge
tone={tone}
title={
row.freshness === "unknown"
? "reported by its hive but not registered in swarm-level identity — needs migration"
: undefined
}
value={
<>
{label}
{row.last_seen_unix !== null ? (
<>
{" "}
(<RelativeTime epochMs={row.last_seen_unix * 1000} />)
</>
) : null}
</>
}
/>
<AgentStateRow key={row.name} agent={row.name} />
{showsLoginNeeded(row) ? (
<Badge
tone="warning"
value="login needed"
title="the agent's claude has no session; its turns wait until it is logged in (log in under inference)"
/>
) : null}
</div>
<p class="ui-agent-identity-message">
<StatusMessage snapshot={row.snapshot} />
</p>
<div class="ui-agent-identity-meta">
<span>{row.hive ?? "no hive"}</span>
{forgeLinks ? (
<>
<ExternalLink href={forgeLinks.profile}>profile</ExternalLink>
{forgeLinks.configRepo ? (
<ExternalLink href={forgeLinks.configRepo}>
config repo
</ExternalLink>
) : null}
</>
) : null}
{row.config_pr ? (
<Badge
tone="warning"
value={
<>
config PR{" "}
{row.config_pr.html_url ? (
<ExternalLink href={row.config_pr.html_url}>
#{row.config_pr.pr_number}
</ExternalLink>
) : (
`#${row.config_pr.pr_number}`
)}
</>
}
/>
) : null}
{row.archetype ? (
<span>
archetype {row.archetype.source}/{row.archetype.name}
{canTurnIntoCustom(row) ? (
<>
{" "}
<Button
disabled={actions.pendingAgents.has(row.name)}
onClick={() => actions.requestCustom(row)}
>
turn into custom
</Button>
</>
) : null}
</span>
) : null}
</div>
</div>
</div>
{/* A failed declaration shows here too: on a terminal page's popover
there is no roster card to carry the "failed" badge. */}
{declareError ? (
<ApiErrorPanel
context="the declaration failed"
problem={declareError}
/>
) : null}
</Card>
);
}

View file

@ -1,7 +1,8 @@
// <AgentStateRow> — an agent's turn state, whether it is paused, and the
// tokens in its context, as the details table's "state" row. The
// terminal preview below the table carries no badges of its own (the full
// terminal tab does), so this is where the panel says what the agent is doing.
// tokens in its context, as the badges in the identity card at the top
// of the details. The terminal preview below it carries no badges of its own
// (the full terminal tab does), so this is where the panel says what the agent
// is doing.
// Follows the agent's state stream, which announces on a change and once a
// minute: the row reads "no report yet" until the first report lands, and for
// an agent that is offline and so never reports. When the browser gives up on

View file

@ -1,38 +1,43 @@
// The sections an agent card opens into, without a DOM: which there are, in
// 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.
// The sections an agent's details open into, without a DOM: which there are, in
// what order, and which start open. The identity card above them already shows
// the agent's state, message and wanted state, so the sections hold the rest,
// one for each question an operator comes with.
/** One folded block of an agent's details. */
export type DetailSection =
| "status"
| "terminal"
| "todos"
| "subagents"
| "tasks"
| "settings";
| "activity"
| "instructions"
| "inference"
| "access"
| "accounts";
/** What each section's header says. */
export const SECTION_TITLE: Record<DetailSection, string> = {
status: "status",
terminal: "terminal",
todos: "open todos",
subagents: "subagents",
tasks: "background tasks",
settings: "settings",
activity: "activity",
instructions: "instructions",
inference: "inference",
access: "access",
accounts: "accounts",
};
/**
* The sections a card shows, top to bottom. The terminal, todos, subagents and tasks are
* left out where the page is already beside a terminal (the terminal page's
* details popover).
* The sections the details show, top to bottom. The terminal and the activity
* (todos, subagents, background tasks) are left out where the page is already
* beside a terminal (the terminal page's details popover).
*/
export function sectionsFor(withTerminal: boolean): DetailSection[] {
return withTerminal
? ["status", "terminal", "todos", "subagents", "tasks", "settings"]
: ["status", "settings"];
const settings: DetailSection[] = [
"instructions",
"inference",
"access",
"accounts",
];
return withTerminal ? ["terminal", "activity", ...settings] : settings;
}
/** The status and the terminal are open when a card opens; the rest build on demand. */
/** The terminal is open when the details open; the rest build on demand. */
export function startsOpen(section: DetailSection): boolean {
return section === "status" || section === "terminal";
return section === "terminal";
}

View file

@ -1,4 +1,4 @@
// <AgentTodos> — an agent's open todos, in its card's "todos" section: what each
// <AgentTodos> — an agent's open todos, in the details' **activity** section: what each
// says, which subsystem raised it and since when. The list is
// `GET /api/agents/{name}/todos` (`useAgentTodos`), which swarm-controller reads
// from what the agent's harness published. Read-only.

View file

@ -1,5 +1,5 @@
// <BashTasks> — an agent's background bash tasks, in its card's "background
// tasks" section: the running ones first, each with its command, what state it
// <BashTasks> — an agent's background bash tasks, in the details'
// activity section: the running ones first, each with its command, what state it
// is in and since when. The list is `GET /api/agents/{name}/bash-tasks`
// (`useBashTasks`), which swarm-controller builds from the status each task's
// bash MCP publishes. Read-only; a task's output is not shown here.

View file

@ -1,6 +1,6 @@
// <BashTasksMenu> — the agent's background bash tasks as a badge in the terminal
// header: a prompt icon and the number running, and the list of tasks (the same
// one the agent card's "background tasks" section shows) in a popover under it.
// one the details' activity section shows) in a popover under it.
// Nothing shows for an agent with no tasks, and nothing before the first answer;
// a failed fetch shows its reason in the open list.
import { useRef, useState } from "preact/hooks";

View file

@ -1,4 +1,4 @@
/* <AgentDetailPane>: the back button, then the agent's icon and name. */
/* <AgentDetailPane>: the back button, then the agent's details. */
.agent-detail-pane {
display: flex;
flex-direction: column;
@ -18,16 +18,12 @@
.agent-detail-pane-back:focus-visible {
color: var(--fg);
}
/* The name of an agent the roster does not have, over its "no agent" note; it
takes the focus when the details open and is not a control. */
.agent-detail-pane-title {
display: flex;
align-items: center;
gap: 0.7em;
}
.agent-detail-pane-title h2 {
margin: 0;
font-size: 1.25em;
}
/* The name takes the focus when the details open; it is not a control. */
.agent-detail-pane-title h2:focus {
.agent-detail-pane-title:focus {
outline: none;
}

View file

@ -1,13 +1,11 @@
// <AgentDetailPane> — the selected agent's details, in the column beside the
// agents list (or alone on a narrow screen): a title row with the back button
// and the agent's icon and name, then `AgentDetail`'s state rows and folded
// sections, the same ones the terminal page's popover shows, plus the terminal
// preview.
// agents list (or alone on a narrow screen): the back button, then
// `AgentDetail`: the identity card with the agent's icon and name, and the
// folded sections.
//
// The agent comes from the roster the page already polls, so a state change made
// here or a refresh shows at once. A name the roster does not have (a stale link,
// an agent destroyed meanwhile) says so and still offers the way back.
import { AgentIcon } from "../../agent/AgentIcon.js";
import type { AgentActions } from "../../agent/roster/AgentActions.js";
import type { AgentRow } from "../../agent/AgentTypes.js";
import { AgentDetail } from "../../agent/detail/AgentDetail.js";
@ -34,16 +32,15 @@ export function AgentDetailPane({
<span aria-hidden="true">←</span> agents
</button>
</div>
<div class="agent-detail-pane-title">
{row ? <AgentIcon name={name} /> : null}
<h2 tabIndex={-1} data-details-title>
{name}
</h2>
</div>
{row ? (
<AgentDetail key={name} row={row} actions={actions} withTerminal />
) : (
<EmptyState>no agent named {name} in the swarm</EmptyState>
<>
<h2 class="agent-detail-pane-title" tabIndex={-1} data-details-title>
{name}
</h2>
<EmptyState>no agent named {name} in the swarm</EmptyState>
</>
)}
</div>
);

View file

@ -8,26 +8,28 @@ import {
startsOpen,
} from "../src/agent/detail/sections.ts";
test("a card holds status, terminal, open todos, subagents, background tasks, then settings", () => {
test("the details hold the terminal, the activity, then one section per question", () => {
assert.deepEqual(sectionsFor(true), [
"status",
"terminal",
"todos",
"subagents",
"tasks",
"settings",
"activity",
"instructions",
"inference",
"access",
"accounts",
]);
});
test("a page beside a terminal leaves the terminal, todos, subagents and tasks out", () => {
assert.deepEqual(sectionsFor(false), ["status", "settings"]);
test("a page beside a terminal leaves the terminal and the activity out", () => {
assert.deepEqual(sectionsFor(false), [
"instructions",
"inference",
"access",
"accounts",
]);
});
test("the status and the terminal start open", () => {
assert.deepEqual(sectionsFor(true).filter(startsOpen), [
"status",
"terminal",
]);
test("only the terminal starts open", () => {
assert.deepEqual(sectionsFor(true).filter(startsOpen), ["terminal"]);
});
test("every section has a header", () => {