swarm ui: the terminal's status badges overhaul
The connection is a light on the agent's icon instead of a "live" badge, the model and the effort are one badge, the context badge has an icon, subagents and a new bash tasks badge are an icon and a count, and an agent's tab shows a drag grip on hover. It also removes two things the overhaul replaces: the cost badge, and the "split" badge with its menu in group panes (splitting is by dragging a tab, or from the subagents list).
This commit is contained in:
parent
e9e71a09ac
commit
3a846c8c45
1 changed files with 430 additions and 199 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
|
||||
import { ChipIcon, GaugeIcon } from "@hive/shared/icons.js";
|
||||
import { BadgePopover } from "../../ui/badge-popover/BadgePopover.js";
|
||||
import { AgentInference } from "../detail/AgentInference.js";
|
||||
import { effortTitle, modelTitle } from "./badge-titles.js";
|
||||
import { inferenceTitle } from "./badge-titles.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||
import {
|
||||
useSwarmAgentStateStream,
|
||||
|
|
@ -42,24 +43,25 @@ function fmtTokens(n: number): string {
|
|||
return String(n);
|
||||
}
|
||||
|
||||
// Turn state, agent state, model, ctx and cost, as the badges beside the
|
||||
// connection one. Siblings only, no wrapper: they sit in the caller's row.
|
||||
// Turn state, agent state, the model with its effort, and the context size, as
|
||||
// the badges beside the connection one. Siblings only, no wrapper: they sit in
|
||||
// the caller's row. The model and the effort are one badge, "opus (high)", and
|
||||
// there is no cost badge: the cost is a metric in Grafana.
|
||||
export function StateBadges({
|
||||
header,
|
||||
ctx,
|
||||
cost,
|
||||
withModel = true,
|
||||
agent,
|
||||
}: {
|
||||
header: NonNullable<ReturnType<typeof useSwarmAgentStateStream>["header"]>;
|
||||
ctx: number | null;
|
||||
cost: number | null;
|
||||
// Off where the model is shown beside them, as in the details table.
|
||||
withModel?: boolean;
|
||||
// The agent whose settings the model and effort badges open in a popover
|
||||
// when clicked. Omitted: the badges only display.
|
||||
// The agent whose settings the model badge opens in a popover when clicked.
|
||||
// Omitted: the badge only displays.
|
||||
agent?: string;
|
||||
}) {
|
||||
const model = `${header.model} (${header.effort})`;
|
||||
return (
|
||||
<>
|
||||
<Badge
|
||||
|
|
@ -85,32 +87,25 @@ export function StateBadges({
|
|||
{withModel &&
|
||||
(agent === undefined ? (
|
||||
<Badge
|
||||
label="model"
|
||||
value={header.model}
|
||||
title={modelTitle(header.resolved_model, false)}
|
||||
icon={<ChipIcon />}
|
||||
value={model}
|
||||
title={inferenceTitle(
|
||||
header.resolved_model,
|
||||
header.effort_source,
|
||||
false,
|
||||
)}
|
||||
ariaLabel={`model ${model}`}
|
||||
/>
|
||||
) : (
|
||||
<BadgePopover
|
||||
label="model"
|
||||
value={header.model}
|
||||
title={modelTitle(header.resolved_model, true)}
|
||||
popoverLabel={`${agent} inference settings`}
|
||||
>
|
||||
<AgentInference agent={agent} />
|
||||
</BadgePopover>
|
||||
))}
|
||||
{withModel &&
|
||||
(agent === undefined ? (
|
||||
<Badge
|
||||
label="effort"
|
||||
value={header.effort}
|
||||
title={effortTitle(header.effort_source, false)}
|
||||
/>
|
||||
) : (
|
||||
<BadgePopover
|
||||
label="effort"
|
||||
value={header.effort}
|
||||
title={effortTitle(header.effort_source, true)}
|
||||
icon={<ChipIcon />}
|
||||
value={model}
|
||||
title={inferenceTitle(
|
||||
header.resolved_model,
|
||||
header.effort_source,
|
||||
true,
|
||||
)}
|
||||
ariaLabel={`model ${model}`}
|
||||
popoverLabel={`${agent} inference settings`}
|
||||
>
|
||||
<AgentInference agent={agent} />
|
||||
|
|
@ -118,16 +113,10 @@ export function StateBadges({
|
|||
))}
|
||||
{ctx !== null && (
|
||||
<Badge
|
||||
label="ctx"
|
||||
icon={<GaugeIcon />}
|
||||
value={fmtTokens(ctx)}
|
||||
title="tokens used in the current context window"
|
||||
/>
|
||||
)}
|
||||
{cost !== null && (
|
||||
<Badge
|
||||
label="cost"
|
||||
value={fmtTokens(cost)}
|
||||
title="cumulative tokens billed across the last turn"
|
||||
ariaLabel={`context ${fmtTokens(ctx)} tokens`}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
|
|
|||
Loading…
Reference in a new issue