swarm-ui: the state row offers reconnect when its stream closes, and says no report yet
This commit is contained in:
parent
705160c0fd
commit
10b8422d93
2 changed files with 34 additions and 21 deletions
|
|
@ -52,9 +52,10 @@ The preview carries only the connection badge and **expand**, so it stays clear
|
||||||
of the text. What the agent is doing shows in the details table above it, in
|
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**
|
the **state** row: the turn state (idle, thinking or compacting), a **paused**
|
||||||
badge for a paused agent, and the tokens in its context and billed. The row
|
badge for a paused agent, and the tokens in its context and billed. The row
|
||||||
reads "waiting for the agent's report…" until the first report arrives, since
|
reads "no report yet" until the first report arrives, and for an agent that's
|
||||||
the agent sends one when its state changes and once a minute. The terminal's
|
offline. The agent sends a report when its state changes and once a minute. If
|
||||||
own tab keeps these badges, with the model, beside the connection badge.
|
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 connection badge.
|
||||||
|
|
||||||
On a terminal's own page (`/agents/<name>/terminal`, or a subagent's) the
|
On a terminal's own page (`/agents/<name>/terminal`, or a subagent's) the
|
||||||
header has an **N running subagents** badge. It opens a list of the agent's
|
header has an **N running subagents** badge. It opens a list of the agent's
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@
|
||||||
// terminal preview below the table carries no badges of its own (the full
|
// 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.
|
// 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, so the row reads "waiting" until the first report lands.
|
// 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
|
||||||
|
// the stream, a **reconnect** badge opens it again, as the terminal's does.
|
||||||
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
import {
|
import {
|
||||||
StateBadges,
|
StateBadges,
|
||||||
termPaths,
|
termPaths,
|
||||||
|
|
@ -13,25 +16,34 @@ import { useSwarmAgentStateStream } from "../terminal/useSwarmAgentStateStream.j
|
||||||
import "./AgentStateRow.css";
|
import "./AgentStateRow.css";
|
||||||
|
|
||||||
export function AgentStateRow({ agent }: { agent: string }) {
|
export function AgentStateRow({ agent }: { agent: string }) {
|
||||||
const { header } = useSwarmAgentStateStream(termPaths(agent).state);
|
const { header, connection, reconnect } = useSwarmAgentStateStream(
|
||||||
if (!header) {
|
termPaths(agent).state,
|
||||||
return (
|
);
|
||||||
<span
|
|
||||||
class="ui-agent-state-waiting"
|
|
||||||
title="the agent reports its state when it changes, and once a minute"
|
|
||||||
>
|
|
||||||
waiting for the agent's report…
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div class="ui-agent-state-row">
|
<div class="ui-agent-state-row">
|
||||||
<StateBadges
|
{header ? (
|
||||||
header={header}
|
<StateBadges
|
||||||
ctx={tokenTotal(header.ctx_usage)}
|
header={header}
|
||||||
cost={tokenTotal(header.cost_usage)}
|
ctx={tokenTotal(header.ctx_usage)}
|
||||||
withModel={false}
|
cost={tokenTotal(header.cost_usage)}
|
||||||
/>
|
withModel={false}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
class="ui-agent-state-waiting"
|
||||||
|
title="the agent reports its state when it changes, and once a minute"
|
||||||
|
>
|
||||||
|
no report yet
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{connection === "closed" && (
|
||||||
|
<Badge
|
||||||
|
variant="quiet"
|
||||||
|
value="reconnect"
|
||||||
|
title={`follow ${agent}'s state again`}
|
||||||
|
onClick={reconnect}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue