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 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 `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 turn-state header says its claude has no session, and a **log in** button that
that runs the claude login from a dialog: open the URL it shows, then paste runs the claude login from a dialog: open the URL it shows, then paste the code
the code back. A failed login offers **try again** in the same dialog. When the back. A failed login offers **try again** in the same dialog. When the secret
secret store has the login, the dialog closes and a store has the login, the dialog closes and a short toast in the top-right corner
short toast in the top-right corner says so. The credentials go to the agent through the secret store 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 ([`claude-login.md`](../../2-handbook/swarm/claude-login.md)). The agent's own
works too. The settings section of an agent's details has a **claude login** row: when web UI login still works too. The **inference** section of an agent's details
the swarm stored the agent's login, or that none is, with a **log in** button has a **claude login** row: when the swarm stored the agent's login, or that
(**log in again** when the swarm holds one) that opens the same dialog, and a **delete none is, with a **log in** button (**log in again** when the swarm holds one)
login** action that asks first. 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 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 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 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. 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, At the top of the details, one **identity card** says who the agent is and how
and each reads nothing until you open it. **status** and **terminal** start it's doing: its icon and name, the **wanted** menu (the one action there),
open, the other four folded: 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**: 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 terminal's bottom edge whose right end holds the send button, a circle with an
arrow. Typing `/` opens a menu arrow. Typing `/` opens a menu filled from `GET /api/agents/<name>/commands`,
filled from `GET /api/agents/<name>/commands`, which lists the swarm's own which lists the swarm's own commands and the skills the agent published.
commands and the skills the agent published. Sending exactly `/clear` isn't a Sending exactly `/clear` isn't a message: the box POSTs
message: the box POSTs `/api/agents/<name>/new-session` instead of `/input` (see `/api/agents/<name>/new-session` instead of `/input` (see the command
the command paragraph below). paragraph below).
- **open todos**: the agent's open todos from `GET /api/agents/<name>/todos`, newest first, each with - **activity**: what the agent is working on, in three lists one under another.
its subsystem, one line of text and how long ago it changed. Read only; refetched every ten seconds. Its open todos from `GET /api/agents/<name>/todos`, newest first, each with
- **subagents**: the agent's subagents and their terminal preview (next section). its subsystem, one line of text and how long ago it changed (read only,
- **background tasks**: the agent's bash tasks (see the section on them below). refetched every ten seconds); its subagents and their terminal preview (next
- **settings**: inference, instructions, resource caps, internet, allowed section); and its bash tasks (see the section on them below).
domains and permissions, then the agent's linked accounts and the menu that - **instructions**: the agent's AGENTS.md, with an **edit** button.
links another. Internet, allowed domains and permissions show a badge; select - **inference**: how the agent thinks and what it costs: its model and effort
it to open the control that changes it (described below). 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 ### Agent and subagent terminals
An agent's detail pane on `/agents` shows, in its **terminal** section, a small live preview of its An agent's detail pane on `/agents` shows, in its **terminal** section, a small
terminal, and below it the agent's **subagents**: every subagent the swarm live preview of its terminal, and in its **activity** section the agent's
queue holds terminal rows for from the last 24 hours. Picking one shows its **subagents**: every subagent the swarm queue holds terminal rows for from the
terminal in the same preview, and **expand** opens it in its own tab, as it last 24 hours. Picking one shows its terminal in the same preview, and
does for the agent. The list refreshes every 10 seconds, so a subagent the **expand** opens it in its own tab, as it does for the agent. The list refreshes
agent spawns shows up once it writes output. A subagent that drops out of the every 10 seconds, so a subagent the agent spawns shows up once it writes output.
list closes its terminal, and a later subagent with the same name starts A subagent that drops out of the list closes its terminal, and a later subagent
unpicked. with the same name starts unpicked. Each subagent in the list shows the model
Each subagent in the list shows the model and effort it runs, like and effort it runs, like `opus · high`, beside its name; one on the default
`opus · high`, beside its name; one on the default model shows only the effort. model shows only the effort. The `/agents/<name>/terminal` page's subagent list
The `/agents/<name>/terminal` page's subagent list shows them too. shows them too.
The preview carries only a small connection light and **expand**, so it stays 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, clear of the text. What the agent is doing shows in the identity card above it,
in the **state** row: the turn state (idle, thinking or compacting), a **paused** 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 row badge for a paused agent, and the tokens in its context. The badges show the
shows the latest report the controller holds, if it's under 150 seconds old, as latest report the controller holds, if it's under 150 seconds old, as soon as
soon as you look. It reads "no report yet" when there is none: for an agent you look. It reads "no report yet" when there is none: for an agent that's
that's offline, and until the first report after the controller restarts. The offline, and until the first report after the controller restarts. The agent
agent sends a report when its state changes and once a minute. If sends a report when its state changes and once a minute. If the browser gives up
the browser gives up on the stream, a **reconnect** badge opens it again. The on the stream, a **reconnect** badge opens it again. The terminal's own tab
terminal's own tab keeps these badges, with the model, beside the agent's name; keeps these badges, with the model, beside the agent's name; the turn-state
the turn-state badge says how long the agent has been in that 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 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. 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**. dimmed, as **not running**.
Beside it, an agent with background bash tasks has a **bash tasks** badge, a 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 prompt icon and the number running, which opens the same list of tasks the
"background tasks" section shows. An agent with no tasks has no badge, and a details' **activity** section shows. An agent with no tasks has no badge, and a
subagent's terminal has none. subagent's terminal has none.
An agent's terminal opens with its last 100 rows from the past 24 hours, then 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. 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 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: light) and name, ahead of the state badges. It opens the agent's details in a
the same status, state, wanted state and folded **status** and **settings** sections (inference, resource caps, internet, allowed domains, permissions and linked accounts) as the popover under the badge: the same identity card and folded **instructions**,
details on `/agents`, without the terminal and subagents. The popover doesn't dim the **inference**, **access** and **accounts** sections as the details on `/agents`,
page. Selecting outside it, or Escape, closes it. From the keyboard, opening a without the terminal and the activity. The popover doesn't dim the page.
popover moves focus into it, and Escape puts focus back on the badge. The filter Selecting outside it, or Escape, closes it. From the keyboard, opening a popover
popovers on table headers work the same way. You can stop or pause the moves focus into it, and Escape puts focus back on the badge. The filter
agent, or link an account, without leaving the terminal. A subagent's tab opens popovers on table headers work the same way. You can stop or pause the agent, or
its agent's details. link an account, without leaving the terminal. A subagent's tab opens its
agent's details.
#### Groups of terminals #### 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> <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 An agent's detail pane lists, in its **activity** section below the subagents,
tasks the agent started through the bash MCP. Its bash MCP publishes one status per task the tasks the agent started through the bash MCP. Its bash MCP publishes one
to the `bash-task-status` bucket, and swarm-controller serves the list as status per task to the `bash-task-status` bucket, and swarm-controller serves
`GET /api/agents/<name>/bash-tasks`: each task's id, command, state, the time the agent queued it and the list as `GET /api/agents/<name>/bash-tasks`: each task's id, command, state,
the time it entered its state, and the exit status. The state is the published the time the agent queued it and the time it entered its state, and the exit
one, or `stale` for a live task whose daemon stopped reporting. The section lists the running status. The state is the published one, or `stale` for a live task whose daemon
tasks first, then the rest, each newest first. Before the age it says `started`, stopped reporting. The section lists the running tasks first, then the rest,
`finished`, `exited N`, `timed out`, `killed` or `stopped reporting`. It refetches each newest first. Before the age it says `started`, `finished`, `exited N`,
every ten seconds and shows no output, which is a separate stream. `timed out`, `killed` or `stopped reporting`. It refetches every ten seconds and
shows no output, which is a separate stream.
</details> </details>
@ -860,25 +878,37 @@ text stays.
### Inference settings ### Inference settings
An agent's detail pane shows, in its **settings** section, its model and effort under **inference**, each An agent's detail pane shows, in its **inference** section, its model and
with where it comes from: the swarm, its agent.nix, its own pick, or the effort, each with where it comes from: the swarm, its agent.nix, its own pick,
default. Below them are the subagent model list the swarm sets, or "its own" or the default. Below them are the subagent model list the swarm sets, or "its
when it sets none, the subagent cap, which reads "no cap" when unset, and the own" when it sets none, the subagent cap, which reads "no cap" when unset, and
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 the fresh-session threshold and the soft context limit, which each read "its
stores; saving does a `PUT /api/agents/{agent}/inference` of own" when unset. **edit** opens a dialog with the fields, filled with what the
the whole value. A field you leave empty stays out of it, so the agent keeps swarm stores; saving does a `PUT /api/agents/{agent}/inference` of the whole
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`. value. A field you leave empty stays out of it, so the agent keeps its own value
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. for that field; an empty max subagents is no cap, and the two context limits
The card reads `GET /api/agents/{agent}/inference`; before the agent's first share one slider with two handles on the model's context window, from 5 to 100
report reaches the controller, it shows the swarm's stored values only. 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. [inference](../swarm/inference.md) describes the settings themselves.
### Editing an agent's instructions ### 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 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 text box. The text is the copy the agent last published, so the box still opens
opens for a stopped agent, but **save** needs the agent running. for a stopped agent, but **save** needs the agent running.
Save sends the swarm a diff against the version you opened, and the agent 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 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 ### Resource caps
An agent's detail pane shows, under **settings**, its CPU quota and memory max under **resource An agent's detail pane shows, in its **inference** section, its CPU quota and
caps**. A cap is the swarm's, so it follows the agent to whichever hive runs memory max under **resource caps**. A cap is the swarm's, so it follows the
it, and it replaces what the hive says for that field. A field the swarm agent to whichever hive runs it, and it replaces what the hive says for that
leaves out shows as the hive deciding it. **edit** opens a dialog with the two field. A field the swarm leaves out shows as the hive deciding it. **edit**
fields, filled with what the swarm stores. A cpu quota is a percentage of one opens a dialog with the two fields, filled with what the swarm stores. A cpu
core (`400%` is four cores). A memory max is a size such as `512M` or `8G`, a quota is a percentage of one core (`400%` is four cores). A memory max is a size
percentage of the machine's memory, or `infinity`. 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` 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 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 ### Permissions
An agent's detail pane shows, under **settings**, what the swarm grants it under **permissions**: An agent's detail pane shows, in its **access** section, what the swarm grants
a badge reading the default set, none, or a count. A swarm it under **permissions**: a badge reading the default set, none, or a count. A
grant is the agent's whole set, so it follows the agent to whichever hive runs swarm grant is the agent's whole set, so it follows the agent to whichever hive
it. Selecting the badge opens a box under it with one checkbox per permission the controller runs it. Selecting the badge opens a box under it with one checkbox per
knows (`GET /api/permissions`), ticked as the grant stands, or on the default permission the controller knows (`GET /api/permissions`), ticked as the grant
set when the swarm sets none. The box lists every permission at once, without a stands, or on the default set when the swarm sets none. The box lists every
scroll area. permission at once, without a scroll area.
Each tick saves at once, as a `PUT /api/agents/{agent}/permissions` of the ticked boxes. A 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 `PUT` replaces the stored list whole, so an unticked box revokes that
@ -1003,13 +1033,13 @@ same grant from a shell.
### Allowed domains ### Allowed domains
An agent's detail pane lists, under **settings**, the destinations it may reach through its An agent's detail pane lists, in its **access** section, the destinations it may
hive's egress proxy under **allowed domains**, beyond the base list every reach through its hive's egress proxy under **allowed domains**, beyond the base
agent has: one badge per source with its count, **swarm-wide** (the entries for every list every agent has: one badge per source with its count, **swarm-wide** (the
agent), **this agent** (the ones for it alone) and **automatic**. Selecting a badge entries for every agent), **this agent** (the ones for it alone) and
opens the names behind it. An entry matters **automatic**. Selecting a badge opens the names behind it. An entry matters to
to a restricted agent. One with the unrestricted internet flag reaches any a restricted agent. One with the unrestricted internet flag reaches any name the
name the proxy's private-range rules leave. **remove**, beside a name, drops one entry; 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 **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. 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 change reaches the agent at its next restart, and an agent with a key tries it
instead of waiting for a claude login. 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 An agent's detail pane lists its linked accounts in its **accounts** section,
per account: kind, name and host. Opening an agent makes one request, 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 `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 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 fails to read the accounts, the inference settings, the resource caps or the
permissions, it permissions, it shows the reason as text. A list the card already loaded stays
shows the reason as text. A list the card already loaded stays on screen on screen beneath the error.
beneath the error.
| kind | one row per | name | host | | kind | one row per | name | host |
| --------- | ------------------------------------------- | ------------- | ------------------------ | | --------- | ------------------------------------------- | ------------- | ------------------------ |

View file

@ -1,5 +1,4 @@
/* <AgentDetail> body — the panel or dialog around it supplies the title (the /* <AgentDetail> body: the identity card, then the folded sections. */
agent's name), so it is not repeated in here. */
.ui-agent-detail-fields { .ui-agent-detail-fields {
display: grid; display: grid;
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;
@ -25,3 +24,10 @@
flex-direction: column; flex-direction: column;
gap: 0.75em; 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 // <AgentDetail> — one agent's details: the identity card (who it is and how it
// PR, inference settings, resource caps and linked accounts, plus the actions on // is doing, `AgentIdentity`), then folded sections (`sections.ts`), one for
// them. Two layouts. In the details beside the list on `/agents` // each question an operator comes with: the terminal, what it is working on
// (`withTerminal`) it is the state rows, then folded sections (`sections.ts`): // (activity), its instructions, how it thinks (inference, which holds the
// status, terminal, open todos, subagents, background tasks and settings, each // claude login and API key), what it may reach (access) and which accounts it
// built when first opened. In the details popover on a terminal page // is linked to. Each section builds when first opened. In the details popover
// (`AgentDetailPopover`) it is the state rows, then the status and the settings // on a terminal page (`AgentDetailPopover`) it is the identity card without
// only, since the page is already beside a terminal. // 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 // 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. // 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 { 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 { Hint } from "../../ui/hint/Hint.js";
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
import type { AgentActions } from "../roster/AgentActions.js"; import type { AgentActions } from "../roster/AgentActions.js";
import { AgentApiKey } from "./AgentApiKey.js"; import { AgentApiKey } from "./AgentApiKey.js";
import { AgentClaudeLogin } from "./AgentClaudeLogin.js"; import { AgentClaudeLogin } from "./AgentClaudeLogin.js";
import { AgentInference } from "./AgentInference.js"; import { AgentInference } from "./AgentInference.js";
import { StatusMessage } from "./StatusMessage.js";
import { AgentInstructions } from "./AgentInstructions.js"; import { AgentInstructions } from "./AgentInstructions.js";
import { AgentLimits } from "./AgentLimits.js"; import { AgentLimits } from "./AgentLimits.js";
import { AgentSsh } from "./AgentSsh.js"; import { AgentSsh } from "./AgentSsh.js";
@ -31,11 +26,9 @@ import {
useGrant, useGrant,
} from "./AgentPermissions.js"; } from "./AgentPermissions.js";
import { AllowedDomains } from "./AllowedDomains.js"; import { AllowedDomains } from "./AllowedDomains.js";
import { AgentStateRow } from "./AgentStateRow.js"; import { AgentIdentity } from "./AgentIdentity.js";
import { AgentTermPreview } from "../terminal/AgentTermPreview.js"; import { AgentTermPreview } from "../terminal/AgentTermPreview.js";
import { canTurnIntoCustom, FRESHNESS, type AgentRow } from "../AgentTypes.js"; import type { AgentRow } from "../AgentTypes.js";
import { agentForgeLinks } from "./forge-links.js";
import { useForgeBase } from "./useForgeBase.js";
import { LinkAccountMenu } from "./LinkAccountMenu.js"; import { LinkAccountMenu } from "./LinkAccountMenu.js";
import { LinkedAccounts } from "./LinkedAccounts.js"; import { LinkedAccounts } from "./LinkedAccounts.js";
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js"; import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
@ -48,162 +41,21 @@ import {
import { AgentTodos } from "../terminal/AgentTodos.js"; import { AgentTodos } from "../terminal/AgentTodos.js";
import { BashTasks } from "../terminal/BashTasks.js"; import { BashTasks } from "../terminal/BashTasks.js";
import { SubagentTerms } from "../terminal/SubagentTerms.js"; import { SubagentTerms } from "../terminal/SubagentTerms.js";
import { WantedMenu } from "../roster/WantedMenu.js";
import "./AgentDetail.css"; import "./AgentDetail.css";
/** The state rows: status, message and wanted. */ function InferenceRows({
function HeaderRows({ agent,
row, hive,
actions,
}: { }: {
row: AgentRow; agent: string;
actions: AgentActions; hive: string | null;
}) { }) {
const { tone, label } = FRESHNESS[row.freshness];
const declareError = actions.actionErrors.get(row.name);
return ( 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> <dt>resource caps</dt>
<dd> <dd>
<AgentLimits key={agent} agent={agent} /> <AgentLimits key={agent} agent={agent} />
</dd> </dd>
<GrantRows key={agent} agent={agent} />
<dt>claude login</dt> <dt>claude login</dt>
<dd> <dd>
<AgentClaudeLogin key={agent} agent={agent} /> <AgentClaudeLogin key={agent} agent={agent} />
@ -258,22 +110,15 @@ function AccountsRows({
row: AgentRow; row: AgentRow;
actions: AgentActions; actions: AgentActions;
}) { }) {
return ( return row.hive ? (
<> <LinkedAccounts
<dt>accounts</dt> key={`${row.hive}/${row.name}`}
<dd> hive={row.hive}
{row.hive ? ( agent={row.name}
<LinkedAccounts version={actions.linkVersion}
key={`${row.hive}/${row.name}`} />
hive={row.hive} ) : (
agent={row.name} <Hint as="span">no hive, so no accounts</Hint>
version={actions.linkVersion}
/>
) : (
"—"
)}
</dd>
</>
); );
} }
@ -306,31 +151,41 @@ function SectionBody({
actions: AgentActions; actions: AgentActions;
}) { }) {
switch (section) { 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": case "terminal":
// The agent's live terminal and its input box. // The agent's live terminal and its input box.
return <AgentTermPreview agentName={row.name} />; return <AgentTermPreview agentName={row.name} />;
case "todos": case "activity":
return <AgentTodos key={row.name} agentName={row.name} />; return (
case "subagents": <div class="ui-agent-detail-activity">
return <SubagentTerms key={row.name} agentName={row.name} />; <AgentTodos key={row.name} agentName={row.name} />
case "tasks": <SubagentTerms key={row.name} agentName={row.name} />
return <BashTasks 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, row,
actions, actions,
withTerminal = false, withTerminal = false,
showName = true,
}: { }: {
row: AgentRow; row: AgentRow;
actions: AgentActions; 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; withTerminal?: boolean;
/** Draw the icon and name in the identity card: off where a header names the agent. */
showName?: boolean;
}) { }) {
return ( return (
<div class="ui-agent-detail ui-agent-detail-sections"> <div class="ui-agent-detail ui-agent-detail-sections">
<dl class="ui-agent-detail-fields"> <AgentIdentity row={row} actions={actions} showName={showName} />
<HeaderRows row={row} actions={actions} />
</dl>
{sectionsFor(withTerminal).map((section) => ( {sectionsFor(withTerminal).map((section) => (
<LazyDisclosure <LazyDisclosure
key={section} key={section}

View file

@ -80,7 +80,7 @@ export function AgentDetailPopover({
problem={error} problem={error}
/> />
) : row ? ( ) : row ? (
<AgentDetail row={row} actions={actions} /> <AgentDetail row={row} actions={actions} showName={false} />
) : row === null ? ( ) : row === null ? (
<p>{agent} is not in the swarm's agent list</p> <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 // <AgentStateRow> — an agent's turn state, whether it is paused, and the
// tokens in its context, as the details table's "state" row. The // tokens in its context, as the badges in the identity card at the top
// terminal preview below the table carries no badges of its own (the full // of the details. The terminal preview below it carries no badges of its own
// terminal tab does), so this is where the panel says what the agent is doing. // (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 // 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 // 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 // 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 // The sections an agent's details open into, without a DOM: which there are, in
// what order, and which start open. The card's header already shows the // what order, and which start open. The identity card above them already shows
// agent's state, message and wanted state, so the sections hold the rest. // 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. */ /** One folded block of an agent's details. */
export type DetailSection = export type DetailSection =
| "status"
| "terminal" | "terminal"
| "todos" | "activity"
| "subagents" | "instructions"
| "tasks" | "inference"
| "settings"; | "access"
| "accounts";
/** What each section's header says. */ /** What each section's header says. */
export const SECTION_TITLE: Record<DetailSection, string> = { export const SECTION_TITLE: Record<DetailSection, string> = {
status: "status",
terminal: "terminal", terminal: "terminal",
todos: "open todos", activity: "activity",
subagents: "subagents", instructions: "instructions",
tasks: "background tasks", inference: "inference",
settings: "settings", access: "access",
accounts: "accounts",
}; };
/** /**
* The sections a card shows, top to bottom. The terminal, todos, subagents and tasks are * The sections the details show, top to bottom. The terminal and the activity
* left out where the page is already beside a terminal (the terminal page's * (todos, subagents, background tasks) are left out where the page is already
* details popover). * beside a terminal (the terminal page's details popover).
*/ */
export function sectionsFor(withTerminal: boolean): DetailSection[] { export function sectionsFor(withTerminal: boolean): DetailSection[] {
return withTerminal const settings: DetailSection[] = [
? ["status", "terminal", "todos", "subagents", "tasks", "settings"] "instructions",
: ["status", "settings"]; "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 { 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 // says, which subsystem raised it and since when. The list is
// `GET /api/agents/{name}/todos` (`useAgentTodos`), which swarm-controller reads // `GET /api/agents/{name}/todos` (`useAgentTodos`), which swarm-controller reads
// from what the agent's harness published. Read-only. // 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 // <BashTasks> — an agent's background bash tasks, in the details'
// tasks" section: the running ones first, each with its command, what state it // 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` // 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 // (`useBashTasks`), which swarm-controller builds from the status each task's
// bash MCP publishes. Read-only; a task's output is not shown here. // 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 // <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 // 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; // Nothing shows for an agent with no tasks, and nothing before the first answer;
// a failed fetch shows its reason in the open list. // a failed fetch shows its reason in the open list.
import { useRef, useState } from "preact/hooks"; 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 { .agent-detail-pane {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -18,16 +18,12 @@
.agent-detail-pane-back:focus-visible { .agent-detail-pane-back:focus-visible {
color: var(--fg); 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 { .agent-detail-pane-title {
display: flex;
align-items: center;
gap: 0.7em;
}
.agent-detail-pane-title h2 {
margin: 0; margin: 0;
font-size: 1.25em; font-size: 1.25em;
} }
/* The name takes the focus when the details open; it is not a control. */ .agent-detail-pane-title:focus {
.agent-detail-pane-title h2:focus {
outline: none; outline: none;
} }

View file

@ -1,13 +1,11 @@
// <AgentDetailPane> — the selected agent's details, in the column beside the // <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 // agents list (or alone on a narrow screen): the back button, then
// and the agent's icon and name, then `AgentDetail`'s state rows and folded // `AgentDetail`: the identity card with the agent's icon and name, and the
// sections, the same ones the terminal page's popover shows, plus the terminal // folded sections.
// preview.
// //
// The agent comes from the roster the page already polls, so a state change made // 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, // 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. // 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 { AgentActions } from "../../agent/roster/AgentActions.js";
import type { AgentRow } from "../../agent/AgentTypes.js"; import type { AgentRow } from "../../agent/AgentTypes.js";
import { AgentDetail } from "../../agent/detail/AgentDetail.js"; import { AgentDetail } from "../../agent/detail/AgentDetail.js";
@ -34,16 +32,15 @@ export function AgentDetailPane({
<span aria-hidden="true">←</span> agents <span aria-hidden="true">←</span> agents
</button> </button>
</div> </div>
<div class="agent-detail-pane-title">
{row ? <AgentIcon name={name} /> : null}
<h2 tabIndex={-1} data-details-title>
{name}
</h2>
</div>
{row ? ( {row ? (
<AgentDetail key={name} row={row} actions={actions} withTerminal /> <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> </div>
); );

View file

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