Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/agent/terminal/AgentTodos.tsx
iris ef4c9214f7 swarm-ui: fold an agent's long activity lists, and list subagents as rows
On a busy agent the activity section grew long: the todos and bash tasks
ran to dozens of rows, and the subagents were one wrapping line of badges.
Each list now shows its first five rows with a "show all N" button;
expanded, the rows scroll in a bounded box. The subagents are one row each
(name, model and effort, state and age), running first and the rest dimmed,
as in the menu on the terminal page, and a picked subagent stays in view
when the list is folded.
2026-11-23 18:19:53 +01:00

55 lines
2.1 KiB
TypeScript

// <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.
//
// Mount it keyed by agent name: the refresh timer is armed once per mount.
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { CappedRows } from "../../ui/capped-rows/CappedRows.js";
import { Hint } from "../../ui/hint/Hint.js";
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
import { todosLabel } from "./agent-todos.js";
import { useAgentTodos } from "./useAgentTodos.js";
import "./AgentTodos.css";
export function AgentTodos({ agentName }: { agentName: string }) {
const { todos, error } = useAgentTodos(agentName);
return (
<section class="ui-agent-todos" aria-label={`${agentName}'s open todos`}>
{error && (
<ApiErrorPanel
problem={error}
context={`failed to list ${agentName}'s todos`}
/>
)}
{todos === null ? (
error ? null : (
<Hint as="span">…</Hint>
)
) : todos.length === 0 ? (
<Hint as="span">{todosLabel(todos)}</Hint>
) : (
<>
<p class="ui-agent-todos-count">{todosLabel(todos)}</p>
<CappedRows rows={todos} noun="todos">
{(shown) => (
<ul class="ui-agent-todos-list">
{shown.map((t) => (
<li key={t.id} class="ui-agent-todos-item">
<span class="ui-agent-todos-subsystem">{t.subsystem}</span>
<span class="ui-agent-todos-summary" title={t.summary}>
{t.summary}
</span>
<span class="ui-agent-todos-age">
<RelativeTime epochMs={t.updated_unix * 1000} />
</span>
</li>
))}
</ul>
)}
</CappedRows>
</>
)}
</section>
);
}