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:
parent
9909e63c2d
commit
ab329e5793
12 changed files with 480 additions and 375 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
164
frontend/packages/swarm-ui/src/agent/detail/AgentIdentity.tsx
Normal file
164
frontend/packages/swarm-ui/src/agent/detail/AgentIdentity.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue