Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: an open todos section on the agent card

This commit is contained in:
iris 2026-11-16 00:28:54 +01:00 • committed by mara
commit fa2a75d499

View file

@ -0,0 +1,50 @@
// <AgentTodos> — an agent's open todos, in its card's "todos" 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 { 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>
<ul class="ui-agent-todos-list">
{todos.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>
</>
)}
</section>
);
}