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
20 changed files with 430 additions and 199 deletions
|
|
@ -101,7 +101,7 @@ when the data arrives. The placeholders stand still where motion is off.
|
||||||
An opened card has six sections, and each reads nothing until you open it.
|
An opened card has six sections, and each reads nothing until you open it.
|
||||||
**status** and **terminal** start open, the other four folded:
|
**status** and **terminal** start open, the other four folded:
|
||||||
|
|
||||||
- **status**: how fresh the agent's last report is (with its age), its turn state, context and cost, its hive, links to its
|
- **status**: how fresh the agent's last report is (with its age), its turn state and context, its hive, links to its
|
||||||
profile and its config repo on the swarm's forge (built from the forge entry
|
profile and its config repo on the swarm's forge (built from the forge entry
|
||||||
of `GET /api/links`; the row stays hidden when the swarm lists none, and an
|
of `GET /api/links`; the row stays hidden when the swarm lists none, and an
|
||||||
agent built from an archetype has no config repo, so it gets no config repo
|
agent built from an archetype has no config repo, so it gets no config repo
|
||||||
|
|
@ -136,22 +136,28 @@ Each subagent in the list shows the model and effort it runs, like
|
||||||
`opus · high`, beside its name; one on the default model shows only the effort.
|
`opus · high`, beside its name; one on the default model shows only the effort.
|
||||||
The `/agents/<name>/terminal` page's subagent list shows them too.
|
The `/agents/<name>/terminal` page's subagent list shows them too.
|
||||||
|
|
||||||
The preview carries only the connection badge and **expand**, so it stays clear
|
The preview carries only a small connection light and **expand**, so it stays
|
||||||
of the text. What the agent is doing shows in the details table above it, in
|
clear of the text. What the agent is doing shows in the details table above it,
|
||||||
the **state** row: the turn state (idle, thinking or compacting), a **paused**
|
in 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. The row
|
||||||
shows the latest report the controller holds, if it's under 150 seconds old, as
|
shows the latest report the controller holds, if it's under 150 seconds old, as
|
||||||
soon as you look. It reads "no report yet" when there is none: for an agent
|
soon as you look. It reads "no report yet" when there is none: for an agent
|
||||||
that's offline, and until the first report after the controller restarts. The
|
that's offline, and until the first report after the controller restarts. The
|
||||||
agent sends a report when its state changes and once a minute. If
|
agent sends a report when its state changes and once a minute. If
|
||||||
the browser gives up on the stream, a **reconnect** badge opens it again. The
|
the browser gives up on the stream, a **reconnect** badge opens it again. The
|
||||||
terminal's own tab keeps these badges, with the model and the effort, beside the
|
terminal's own tab keeps these badges, with the model, beside the agent's name;
|
||||||
connection badge; the turn-state badge says how long the agent has been in that
|
the turn-state badge says how long the agent has been in that state.
|
||||||
state. Clicking the model or the effort badge opens the agent's inference
|
|
||||||
settings in a popover, the same settings its card shows.
|
The connection is a **light** on the agent's icon in the name badge: green when
|
||||||
|
the stream is live, amber while it connects or reconnects, red when it closes.
|
||||||
|
In the card's preview, which has no name badge, the light stands alone. The
|
||||||
|
model and the effort are one badge, a chip icon and "opus (high)," and the
|
||||||
|
context is a dial icon and a size. Select the model badge to open the agent's
|
||||||
|
inference settings in a popover, the same settings its card shows. The terminal
|
||||||
|
shows no cost badge: the cost is a metric in Grafana.
|
||||||
|
|
||||||
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 a **subagents** badge, a branching icon and the number running. It opens a list of the agent's
|
||||||
subagents. Choosing one puts its terminal to the right of this one in a
|
subagents. Choosing one puts its terminal to the right of this one in a
|
||||||
[group](#groups-of-terminals); in a group, it splits that pane. A subagent
|
[group](#groups-of-terminals); in a group, it splits that pane. A subagent
|
||||||
already in the group shows a marker and does nothing when chosen, and **maximize**
|
already in the group shows a marker and does nothing when chosen, and **maximize**
|
||||||
|
|
@ -162,6 +168,11 @@ swarm doesn't report more than when the newest row came, so a subagent that
|
||||||
thinks quietly for longer drops out of the count. The list shows the others below,
|
thinks quietly for longer drops out of the count. The list shows the others below,
|
||||||
dimmed, as **not running**.
|
dimmed, as **not running**.
|
||||||
|
|
||||||
|
Beside it, an agent with background bash tasks has a **bash tasks** badge, a
|
||||||
|
prompt icon and the number running, which opens the same list of tasks the card's
|
||||||
|
"background tasks" section shows. An agent with no tasks has no badge, and a
|
||||||
|
subagent's terminal has none.
|
||||||
|
|
||||||
An agent's terminal opens with its last 100 rows from the past 24 hours, then
|
An agent's terminal opens with its last 100 rows from the past 24 hours, then
|
||||||
follows new ones; a reconnect picks up after the last row it showed. A subagent
|
follows new ones; a reconnect picks up after the last row it showed. A subagent
|
||||||
terminal does the same with that subagent's rows, and has no turn-state badges.
|
terminal does the same with that subagent's rows, and has no turn-state badges.
|
||||||
|
|
@ -193,8 +204,8 @@ A terminal's own tab takes the agent's icon as its browser-tab icon, so tabs of
|
||||||
different agents tell apart. A subagent's tab shows its agent's icon. An agent
|
different agents tell apart. A subagent's tab shows its agent's icon. An agent
|
||||||
with no icon keeps the hyperhive mark. Everywhere else the swarm UI shows an agent's icon (the cards, the pickers, the badges), an agent with none shows the default agent icon.
|
with no icon keeps the hyperhive mark. Everywhere else the swarm UI shows an agent's icon (the cards, the pickers, the badges), an agent with none shows the default agent icon.
|
||||||
|
|
||||||
The tab also has an agent badge, with the agent's icon and name, ahead of the
|
The tab also has an agent badge, with the agent's icon (carrying the connection
|
||||||
connection badge. It opens the agent's details in a popover under the badge:
|
light) and name, ahead of the state badges. It opens the agent's details in a popover under the badge:
|
||||||
the same status, state, wanted state and folded **status** and **settings** sections (inference, resource caps, internet, allowed domains, permissions and linked accounts) as the
|
the same status, state, wanted state and folded **status** and **settings** sections (inference, resource caps, internet, allowed domains, permissions and linked accounts) as the
|
||||||
opened card on `/agents`, without the terminal and subagents. The popover doesn't dim the
|
opened card on `/agents`, without the terminal and subagents. The popover doesn't dim the
|
||||||
page. Selecting outside it, or Escape, closes it. From the keyboard, opening a
|
page. Selecting outside it, or Escape, closes it. From the keyboard, opening a
|
||||||
|
|
@ -210,9 +221,9 @@ another agent's terminal tab from the header onto the left, right, top or
|
||||||
bottom half of a terminal: the half it would take lights up, and the drop makes
|
bottom half of a terminal: the half it would take lights up, and the drop makes
|
||||||
a group of the two, with its own header tab at `/agents/group/<id>`. In a group,
|
a group of the two, with its own header tab at `/agents/group/<id>`. In a group,
|
||||||
the same drag onto a pane splits that pane, as many times as you like, and
|
the same drag onto a pane splits that pane, as many times as you like, and
|
||||||
dragging a pane's header badge onto another pane moves it there. The **split**
|
dragging a pane's header badge onto another pane moves it there. A tab you can
|
||||||
button in a pane's header does the same for an agent whose terminal tab is open:
|
drag shows a grip at its left edge when the pointer is over it, and its tooltip
|
||||||
**right** or **below** puts it beside the pane. A pane can hold a subagent's
|
reads "drag onto a terminal to split it." A pane can hold a subagent's
|
||||||
terminal (its header reads `agent/subagent`), put there by the **subagents**
|
terminal (its header reads `agent/subagent`), put there by the **subagents**
|
||||||
badge in the pane's header. Two icon buttons sit in a pane's top right corner.
|
badge in the pane's header. Two icon buttons sit in a pane's top right corner.
|
||||||
**Maximize** (the arrows pointing to the corners) opens that pane's own terminal
|
**Maximize** (the arrows pointing to the corners) opens that pane's own terminal
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,11 @@ export interface BadgeProps {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
class?: string;
|
class?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
/**
|
||||||
|
* The accessible name, when the visible text is not enough of one: a badge that
|
||||||
|
* is an icon and a number, say.
|
||||||
|
*/
|
||||||
|
ariaLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Badge({
|
export function Badge({
|
||||||
|
|
@ -88,6 +93,7 @@ export function Badge({
|
||||||
disabled,
|
disabled,
|
||||||
class: extraClass,
|
class: extraClass,
|
||||||
title,
|
title,
|
||||||
|
ariaLabel,
|
||||||
}: BadgeProps) {
|
}: BadgeProps) {
|
||||||
// `disabled` alone still means "button, just not clickable right
|
// `disabled` alone still means "button, just not clickable right
|
||||||
// now" — see the prop's own doc above for why this can't just check
|
// now" — see the prop's own doc above for why this can't just check
|
||||||
|
|
@ -123,6 +129,7 @@ export function Badge({
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
aria-expanded={expanded}
|
aria-expanded={expanded}
|
||||||
|
aria-label={ariaLabel}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
{content}
|
{content}
|
||||||
|
|
@ -130,7 +137,7 @@ export function Badge({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<span class={classes} title={title}>
|
<span class={classes} title={title} aria-label={ariaLabel}>
|
||||||
{content}
|
{content}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
// when `SettingsMenu` was extracted into `@hive/shared`, undoing this
|
// when `SettingsMenu` was extracted into `@hive/shared`, undoing this
|
||||||
// fix — restoring the SVG here, in the shared component this time,
|
// fix — restoring the SVG here, in the shared component this time,
|
||||||
// fixes it for both pages at once instead of just one).
|
// fixes it for both pages at once instead of just one).
|
||||||
|
import type { ComponentChildren } from "preact";
|
||||||
|
|
||||||
export function GearIcon() {
|
export function GearIcon() {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
|
|
@ -167,3 +169,77 @@ export function SendIcon() {
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The shared recipe of the line icons below: a 24-unit box, round strokes in
|
||||||
|
// the text colour, so each reads as part of the same family.
|
||||||
|
function LineIcon({ children }: { children: ComponentChildren }) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
width="1.15em"
|
||||||
|
height="1.15em"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A chip with pins: the model an agent runs on. */
|
||||||
|
export function ChipIcon() {
|
||||||
|
return (
|
||||||
|
<LineIcon>
|
||||||
|
<rect x="6" y="6" width="12" height="12" rx="2" />
|
||||||
|
<rect x="10" y="10" width="4" height="4" />
|
||||||
|
<path d="M9 3v3M15 3v3M9 18v3M15 18v3M3 9h3M3 15h3M18 9h3M18 15h3" />
|
||||||
|
</LineIcon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A dial: how full the context window is. */
|
||||||
|
export function GaugeIcon() {
|
||||||
|
return (
|
||||||
|
<LineIcon>
|
||||||
|
<path d="M4 17a8 8 0 1 1 16 0" />
|
||||||
|
<path d="M12 17l4-5" />
|
||||||
|
<circle cx="12" cy="17" r="1" />
|
||||||
|
</LineIcon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One node branching into two: the subagents an agent started. */
|
||||||
|
export function SubagentsIcon() {
|
||||||
|
return (
|
||||||
|
<LineIcon>
|
||||||
|
<circle cx="12" cy="5" r="2" />
|
||||||
|
<circle cx="6" cy="19" r="2" />
|
||||||
|
<circle cx="18" cy="19" r="2" />
|
||||||
|
<path d="M12 7v4M12 11H6v6M12 11h6v6" />
|
||||||
|
</LineIcon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Six dots in two columns: the handle of something that can be dragged. */
|
||||||
|
export function GripIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
width="0.8em"
|
||||||
|
height="1.15em"
|
||||||
|
viewBox="0 0 10 16"
|
||||||
|
fill="currentColor"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<circle cx="2.5" cy="3" r="1.3" />
|
||||||
|
<circle cx="7.5" cy="3" r="1.3" />
|
||||||
|
<circle cx="2.5" cy="8" r="1.3" />
|
||||||
|
<circle cx="7.5" cy="8" r="1.3" />
|
||||||
|
<circle cx="2.5" cy="13" r="1.3" />
|
||||||
|
<circle cx="7.5" cy="13" r="1.3" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ export function AgentStateRow({ agent }: { agent: string }) {
|
||||||
<StateBadges
|
<StateBadges
|
||||||
header={header}
|
header={header}
|
||||||
ctx={tokenTotal(header.ctx_usage)}
|
ctx={tokenTotal(header.ctx_usage)}
|
||||||
cost={tokenTotal(header.cost_usage)}
|
|
||||||
withModel={false}
|
withModel={false}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
|
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 { BadgePopover } from "../../ui/badge-popover/BadgePopover.js";
|
||||||
import { AgentInference } from "../detail/AgentInference.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 { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||||
import {
|
import {
|
||||||
useSwarmAgentStateStream,
|
useSwarmAgentStateStream,
|
||||||
|
|
@ -42,24 +43,25 @@ function fmtTokens(n: number): string {
|
||||||
return String(n);
|
return String(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn state, agent state, model, ctx and cost, as the badges beside the
|
// Turn state, agent state, the model with its effort, and the context size, as
|
||||||
// connection one. Siblings only, no wrapper: they sit in the caller's row.
|
// 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({
|
export function StateBadges({
|
||||||
header,
|
header,
|
||||||
ctx,
|
ctx,
|
||||||
cost,
|
|
||||||
withModel = true,
|
withModel = true,
|
||||||
agent,
|
agent,
|
||||||
}: {
|
}: {
|
||||||
header: NonNullable<ReturnType<typeof useSwarmAgentStateStream>["header"]>;
|
header: NonNullable<ReturnType<typeof useSwarmAgentStateStream>["header"]>;
|
||||||
ctx: number | null;
|
ctx: number | null;
|
||||||
cost: number | null;
|
|
||||||
// Off where the model is shown beside them, as in the details table.
|
// Off where the model is shown beside them, as in the details table.
|
||||||
withModel?: boolean;
|
withModel?: boolean;
|
||||||
// The agent whose settings the model and effort badges open in a popover
|
// The agent whose settings the model badge opens in a popover when clicked.
|
||||||
// when clicked. Omitted: the badges only display.
|
// Omitted: the badge only displays.
|
||||||
agent?: string;
|
agent?: string;
|
||||||
}) {
|
}) {
|
||||||
|
const model = `${header.model} (${header.effort})`;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Badge
|
<Badge
|
||||||
|
|
@ -85,32 +87,25 @@ export function StateBadges({
|
||||||
{withModel &&
|
{withModel &&
|
||||||
(agent === undefined ? (
|
(agent === undefined ? (
|
||||||
<Badge
|
<Badge
|
||||||
label="model"
|
icon={<ChipIcon />}
|
||||||
value={header.model}
|
value={model}
|
||||||
title={modelTitle(header.resolved_model, false)}
|
title={inferenceTitle(
|
||||||
|
header.resolved_model,
|
||||||
|
header.effort_source,
|
||||||
|
false,
|
||||||
|
)}
|
||||||
|
ariaLabel={`model ${model}`}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<BadgePopover
|
<BadgePopover
|
||||||
label="model"
|
icon={<ChipIcon />}
|
||||||
value={header.model}
|
value={model}
|
||||||
title={modelTitle(header.resolved_model, true)}
|
title={inferenceTitle(
|
||||||
popoverLabel={`${agent} inference settings`}
|
header.resolved_model,
|
||||||
>
|
header.effort_source,
|
||||||
<AgentInference agent={agent} />
|
true,
|
||||||
</BadgePopover>
|
)}
|
||||||
))}
|
ariaLabel={`model ${model}`}
|
||||||
{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)}
|
|
||||||
popoverLabel={`${agent} inference settings`}
|
popoverLabel={`${agent} inference settings`}
|
||||||
>
|
>
|
||||||
<AgentInference agent={agent} />
|
<AgentInference agent={agent} />
|
||||||
|
|
@ -118,16 +113,10 @@ export function StateBadges({
|
||||||
))}
|
))}
|
||||||
{ctx !== null && (
|
{ctx !== null && (
|
||||||
<Badge
|
<Badge
|
||||||
label="ctx"
|
icon={<GaugeIcon />}
|
||||||
value={fmtTokens(ctx)}
|
value={fmtTokens(ctx)}
|
||||||
title="tokens used in the current context window"
|
title="tokens used in the current context window"
|
||||||
/>
|
ariaLabel={`context ${fmtTokens(ctx)} tokens`}
|
||||||
)}
|
|
||||||
{cost !== null && (
|
|
||||||
<Badge
|
|
||||||
label="cost"
|
|
||||||
value={fmtTokens(cost)}
|
|
||||||
title="cumulative tokens billed across the last turn"
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,19 @@
|
||||||
// The tooltips of the model and effort badges in an agent's terminal header.
|
// The tooltip of the model badge in an agent's terminal header, which names the
|
||||||
// Clickable ones, which open the agent's inference settings, say so; the plain
|
// model and the effort together. A clickable one, which opens the agent's
|
||||||
// ones, on a subagent's terminal and in the details table, only say where the
|
// inference settings, says so; the plain one, on a subagent's terminal and in
|
||||||
// value comes from.
|
// the details table, only says where the values come from.
|
||||||
|
|
||||||
const OPENS = "Click for the inference settings";
|
const OPENS = "Click for the inference settings";
|
||||||
|
|
||||||
/** The model badge's tooltip: what the alias resolved to, when known. */
|
/**
|
||||||
export function modelTitle(
|
* What the alias resolved to, when known, and where the effort comes from.
|
||||||
|
*/
|
||||||
|
export function inferenceTitle(
|
||||||
resolvedModel: string | null | undefined,
|
resolvedModel: string | null | undefined,
|
||||||
|
effortSource: string,
|
||||||
clickable: boolean,
|
clickable: boolean,
|
||||||
): string | undefined {
|
): string {
|
||||||
const resolved = resolvedModel ? `resolved to ${resolvedModel}` : undefined;
|
const resolved = resolvedModel ? `resolved to ${resolvedModel}; ` : "";
|
||||||
if (!clickable) return resolved;
|
const from = `${resolved}effort set by: ${effortSource}`;
|
||||||
return resolved ? `${resolved}. ${OPENS}` : OPENS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The effort badge's tooltip: where the effort comes from. */
|
|
||||||
export function effortTitle(source: string, clickable: boolean): string {
|
|
||||||
const from = `set by: ${source}`;
|
|
||||||
return clickable ? `${from}. ${OPENS}` : from;
|
return clickable ? `${from}. ${OPENS}` : from;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,13 +79,13 @@
|
||||||
this: with the base padding, "thinking"/"model sonnet" sat directly
|
this: with the base padding, "thinking"/"model sonnet" sat directly
|
||||||
on top of the terminal's first line whenever content started right
|
on top of the terminal's first line whenever content started right
|
||||||
at the top (a running preview scrolled to the newest rows almost
|
at the top (a running preview scrolled to the newest rows almost
|
||||||
always does). One badge row: the connection badge and the expand
|
always does). One badge row: the connection light and the expand
|
||||||
trigger, each keeping the 2.75em touch-target floor. */
|
trigger, each keeping the 2.75em touch-target floor. */
|
||||||
padding-block-start: 3.4em;
|
padding-block-start: 3.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The floating row over the terminal's top edge: the connection badge
|
/* The floating row over the terminal's top edge: the connection light
|
||||||
(and on the full tab turn_state/agent_state/model/ctx/cost) on the left, the
|
(and on the full tab turn_state/agent_state/model/ctx) on the left, the
|
||||||
expand trigger on the right. Positioned by `.terminal-wrap`'s own
|
expand trigger on the right. Positioned by `.terminal-wrap`'s own
|
||||||
`position: relative`, same anchor `@hive/shared/terminal.css`'s
|
`position: relative`, same anchor `@hive/shared/terminal.css`'s
|
||||||
`.tail-pill` uses, which anchors bottom-right and so never competes for
|
`.tail-pill` uses, which anchors bottom-right and so never competes for
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
// component the per-hive local terminal uses — "share components between hive and swarm level
|
// component the per-hive local terminal uses — "share components between hive and swarm level
|
||||||
// term as much as possible" (mara).
|
// term as much as possible" (mara).
|
||||||
//
|
//
|
||||||
// **Floating header badges** — turn state / model / ctx / cost parity
|
// **Floating header badges** — turn state / model / ctx parity
|
||||||
// with the per-agent page's own `StatusChips` — mara: "dont make it a
|
// with the per-agent page's own `StatusChips` — mara: "dont make it a
|
||||||
// header though - make it floating elements on top of the terminal", so
|
// header though - make it floating elements on top of the terminal", so
|
||||||
// this is a small `Badge` cluster pinned to the terminal box's own
|
// this is a small `Badge` cluster pinned to the terminal box's own
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
// has its own control surface (`WantedMenu` on `AgentsPage`), so nothing
|
// has its own control surface (`WantedMenu` on `AgentsPage`), so nothing
|
||||||
// here needs to be interactive. Sourced from `useSwarmAgentStateStream`,
|
// here needs to be interactive. Sourced from `useSwarmAgentStateStream`,
|
||||||
// not from `AgentRow` — the roster fetch `AgentsPage` already did has no
|
// not from `AgentRow` — the roster fetch `AgentsPage` already did has no
|
||||||
// notion of turn_state/model/ctx/cost, only `wanted`/`snapshot.running`.
|
// notion of turn_state/model/ctx, only `wanted`/`snapshot.running`.
|
||||||
// Only the full-tab mount (`fullHeight`) shows the state badges: the small
|
// Only the full-tab mount (`fullHeight`) shows the state badges: the small
|
||||||
// preview in an opened card stays free of them (mara: "the preview is small
|
// preview in an opened card stays free of them (mara: "the preview is small
|
||||||
// and should not be encroached further with badges on top, but for the full
|
// and should not be encroached further with badges on top, but for the full
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
// already IS the destination, so it has nothing further to expand to.
|
// already IS the destination, so it has nothing further to expand to.
|
||||||
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
||||||
import type { ComponentChildren } from "preact";
|
import type { ComponentChildren } from "preact";
|
||||||
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
import { ExpandIcon } from "@hive/shared/icons.js";
|
import { ExpandIcon } from "@hive/shared/icons.js";
|
||||||
import { Row } from "@hive/shared/term-row.js";
|
import { Row } from "@hive/shared/term-row.js";
|
||||||
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
||||||
|
|
@ -45,26 +45,13 @@ import {
|
||||||
import { useSwarmAgentStateStream } from "./useSwarmAgentStateStream.js";
|
import { useSwarmAgentStateStream } from "./useSwarmAgentStateStream.js";
|
||||||
import { termPaths } from "./term-paths.js";
|
import { termPaths } from "./term-paths.js";
|
||||||
import { StateBadges, tokenTotal } from "../state/StateBadges.js";
|
import { StateBadges, tokenTotal } from "../state/StateBadges.js";
|
||||||
|
import { CONNECTION_LABEL, ConnectionDot } from "./ConnectionDot.js";
|
||||||
import { AgentInputForm } from "./AgentInputForm.js";
|
import { AgentInputForm } from "./AgentInputForm.js";
|
||||||
import { CancelTurnBadge } from "./CancelTurnBadge.js";
|
import { CancelTurnBadge } from "./CancelTurnBadge.js";
|
||||||
import "./AgentTermPreview.css";
|
import "./AgentTermPreview.css";
|
||||||
|
|
||||||
const NEAR_BOTTOM_PX = 48;
|
const NEAR_BOTTOM_PX = 48;
|
||||||
|
|
||||||
const CONNECTION_LABEL: Record<ConnectionState, string> = {
|
|
||||||
connecting: "connecting…",
|
|
||||||
open: "live",
|
|
||||||
reconnecting: "reconnecting…",
|
|
||||||
closed: "disconnected",
|
|
||||||
};
|
|
||||||
|
|
||||||
const CONNECTION_TONE: Record<ConnectionState, BadgeTone> = {
|
|
||||||
connecting: "neutral",
|
|
||||||
open: "positive",
|
|
||||||
reconnecting: "warning",
|
|
||||||
closed: "negative",
|
|
||||||
};
|
|
||||||
|
|
||||||
export function AgentTermPreview({
|
export function AgentTermPreview({
|
||||||
agentName,
|
agentName,
|
||||||
subagent,
|
subagent,
|
||||||
|
|
@ -79,9 +66,10 @@ export function AgentTermPreview({
|
||||||
// The full-tab mount: fills the tab, has no expand trigger, and shows the
|
// The full-tab mount: fills the tab, has no expand trigger, and shows the
|
||||||
// agent's state badges beside the connection one.
|
// agent's state badges beside the connection one.
|
||||||
fullHeight?: boolean;
|
fullHeight?: boolean;
|
||||||
// A badge ahead of the connection badge, for the full-tab mount's
|
// The badges ahead of the state ones, for the full-tab mount's link back to
|
||||||
// link back to the agent's details.
|
// the agent's details. Given the connection, which it shows as a light on the
|
||||||
leading?: ComponentChildren;
|
// name badge. Without it the connection is a light of its own.
|
||||||
|
leading?: (connection: ConnectionState) => ComponentChildren;
|
||||||
// Icon-only badges in the top right corner, for the full-tab mount's own
|
// Icon-only badges in the top right corner, for the full-tab mount's own
|
||||||
// controls (a group pane's maximize and close).
|
// controls (a group pane's maximize and close).
|
||||||
trailing?: ComponentChildren;
|
trailing?: ComponentChildren;
|
||||||
|
|
@ -98,7 +86,6 @@ export function AgentTermPreview({
|
||||||
const [stickToBottom, setStickToBottom] = useState(true);
|
const [stickToBottom, setStickToBottom] = useState(true);
|
||||||
|
|
||||||
const ctx = header ? tokenTotal(header.ctx_usage) : null;
|
const ctx = header ? tokenTotal(header.ctx_usage) : null;
|
||||||
const cost = header ? tokenTotal(header.cost_usage) : null;
|
|
||||||
|
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
const el = logRef.current;
|
const el = logRef.current;
|
||||||
|
|
@ -130,11 +117,11 @@ export function AgentTermPreview({
|
||||||
it has no expand trigger. */}
|
it has no expand trigger. */}
|
||||||
<div class="ui-agent-term-preview-controls">
|
<div class="ui-agent-term-preview-controls">
|
||||||
<div class="ui-agent-term-preview-header-badges">
|
<div class="ui-agent-term-preview-header-badges">
|
||||||
{leading}
|
{leading ? (
|
||||||
<Badge
|
leading(connection)
|
||||||
tone={CONNECTION_TONE[connection]}
|
) : (
|
||||||
value={CONNECTION_LABEL[connection]}
|
<ConnectionDot connection={connection} />
|
||||||
/>
|
)}
|
||||||
{connection === "closed" && (
|
{connection === "closed" && (
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
|
|
@ -150,7 +137,6 @@ export function AgentTermPreview({
|
||||||
<StateBadges
|
<StateBadges
|
||||||
header={header}
|
header={header}
|
||||||
ctx={ctx}
|
ctx={ctx}
|
||||||
cost={cost}
|
|
||||||
agent={subagent === undefined ? agentName : undefined}
|
agent={subagent === undefined ? agentName : undefined}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,31 @@
|
||||||
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
|
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
|
||||||
import { Hint } from "../../ui/hint/Hint.js";
|
import { Hint } from "../../ui/hint/Hint.js";
|
||||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||||
import { isLive, runningTasksLabel, stateWord } from "./bash-tasks.js";
|
import type { ProblemDetails } from "@hive/shared/api-error.js";
|
||||||
|
import {
|
||||||
|
isLive,
|
||||||
|
runningTasksLabel,
|
||||||
|
stateWord,
|
||||||
|
type BashTask,
|
||||||
|
} from "./bash-tasks.js";
|
||||||
import { useBashTasks } from "./useBashTasks.js";
|
import { useBashTasks } from "./useBashTasks.js";
|
||||||
import "./BashTasks.css";
|
import "./BashTasks.css";
|
||||||
|
|
||||||
export function BashTasks({ agentName }: { agentName: string }) {
|
export function BashTasks({ agentName }: { agentName: string }) {
|
||||||
const { tasks, error } = useBashTasks(agentName);
|
const { tasks, error } = useBashTasks(agentName);
|
||||||
|
return <BashTasksList agentName={agentName} tasks={tasks} error={error} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The list for a fetch already made, so a badge and its popover share one poll. */
|
||||||
|
export function BashTasksList({
|
||||||
|
agentName,
|
||||||
|
tasks,
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
agentName: string;
|
||||||
|
tasks: BashTask[] | null;
|
||||||
|
error: ProblemDetails | null;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<section class="ui-bash-tasks" aria-label={`${agentName}'s bash tasks`}>
|
<section class="ui-bash-tasks" aria-label={`${agentName}'s bash tasks`}>
|
||||||
{error && (
|
{error && (
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// <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.
|
||||||
|
// 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";
|
||||||
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
|
import { TerminalIcon } from "@hive/shared/icons.js";
|
||||||
|
import { Panel } from "../../ui/panel/Panel.js";
|
||||||
|
import { Popover } from "../../ui/popover/Popover.js";
|
||||||
|
import { BashTasksList } from "./BashTasks.js";
|
||||||
|
import { isLive, runningTasksLabel } from "./bash-tasks.js";
|
||||||
|
import { useBashTasks } from "./useBashTasks.js";
|
||||||
|
|
||||||
|
export function BashTasksMenu({ agentName }: { agentName: string }) {
|
||||||
|
const { tasks, error } = useBashTasks(agentName);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const anchorRef = useRef<HTMLSpanElement>(null);
|
||||||
|
|
||||||
|
if (!error && (tasks === null || tasks.length === 0)) return null;
|
||||||
|
|
||||||
|
const running = (tasks ?? []).filter(isLive).length;
|
||||||
|
const label = runningTasksLabel(tasks ?? []);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<span ref={anchorRef}>
|
||||||
|
<Badge
|
||||||
|
icon={<TerminalIcon />}
|
||||||
|
value={running}
|
||||||
|
tone={running > 0 ? "positive" : "neutral"}
|
||||||
|
ariaLabel={label}
|
||||||
|
title={`${label}: ${open ? "close" : "open"} ${agentName}'s bash tasks`}
|
||||||
|
expanded={open}
|
||||||
|
onClick={() => setOpen((o) => !o)}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<Popover
|
||||||
|
open={open}
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
anchorRef={anchorRef}
|
||||||
|
label={`${agentName}'s bash tasks`}
|
||||||
|
>
|
||||||
|
<Panel
|
||||||
|
title={`${agentName}'s bash tasks`}
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
>
|
||||||
|
<BashTasksList agentName={agentName} tasks={tasks} error={error} />
|
||||||
|
</Panel>
|
||||||
|
</Popover>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
.ui-conn-dot {
|
||||||
|
display: inline-block;
|
||||||
|
width: 0.65em;
|
||||||
|
height: 0.65em;
|
||||||
|
flex: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--muted);
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg) 70%, transparent);
|
||||||
|
}
|
||||||
|
.ui-conn-dot-open {
|
||||||
|
background: var(--green);
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 2px color-mix(in srgb, var(--bg) 70%, transparent),
|
||||||
|
0 0 6px var(--green);
|
||||||
|
}
|
||||||
|
.ui-conn-dot-connecting,
|
||||||
|
.ui-conn-dot-reconnecting {
|
||||||
|
background: var(--amber);
|
||||||
|
}
|
||||||
|
.ui-conn-dot-closed {
|
||||||
|
background: var(--red);
|
||||||
|
}
|
||||||
|
/* On the corner of the icon: the light sits half over its bottom-right edge. */
|
||||||
|
.ui-live-icon {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
.ui-conn-dot-on-icon {
|
||||||
|
position: absolute;
|
||||||
|
right: -0.2em;
|
||||||
|
bottom: -0.2em;
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.ui-conn-dot-connecting,
|
||||||
|
.ui-conn-dot-reconnecting {
|
||||||
|
animation: ui-conn-dot-pulse 1.2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes ui-conn-dot-pulse {
|
||||||
|
50% {
|
||||||
|
opacity: 0.45;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Alone in a terminal's top corner, with room around it. */
|
||||||
|
.ui-agent-term-preview-controls .ui-conn-dot:not(.ui-conn-dot-on-icon) {
|
||||||
|
margin: 0.55em 0 0 0.55em;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// The connection of a terminal's stream as an indicator light: green when it is
|
||||||
|
// live, amber while it connects or reconnects, red when it is closed. It says
|
||||||
|
// what the "live" badge said, in less room. Beside an agent's name it sits on the
|
||||||
|
// corner of the name badge's icon (`LiveAgentIcon`); alone, it stands for the
|
||||||
|
// connection badge of a terminal that has no name badge.
|
||||||
|
import { AgentIcon } from "../AgentIcon.js";
|
||||||
|
import type { ConnectionState } from "./useSwarmTermStream.js";
|
||||||
|
import "./ConnectionDot.css";
|
||||||
|
|
||||||
|
export const CONNECTION_LABEL: Record<ConnectionState, string> = {
|
||||||
|
connecting: "connecting…",
|
||||||
|
open: "live",
|
||||||
|
reconnecting: "reconnecting…",
|
||||||
|
closed: "disconnected",
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ConnectionDot({
|
||||||
|
connection,
|
||||||
|
onIcon = false,
|
||||||
|
}: {
|
||||||
|
connection: ConnectionState;
|
||||||
|
/** Drawn on the corner of an icon rather than as a light of its own. */
|
||||||
|
onIcon?: boolean;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
class={
|
||||||
|
`ui-conn-dot ui-conn-dot-${connection}` +
|
||||||
|
(onIcon ? " ui-conn-dot-on-icon" : "")
|
||||||
|
}
|
||||||
|
role="img"
|
||||||
|
aria-label={CONNECTION_LABEL[connection]}
|
||||||
|
title={CONNECTION_LABEL[connection]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An agent's icon with the connection light on its corner. */
|
||||||
|
export function LiveAgentIcon({
|
||||||
|
name,
|
||||||
|
connection,
|
||||||
|
}: {
|
||||||
|
name: string;
|
||||||
|
connection: ConnectionState;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<span class="ui-live-icon">
|
||||||
|
<AgentIcon name={name} small />
|
||||||
|
<ConnectionDot connection={connection} onIcon />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// <SubagentsMenu> — "N running subagents" in the full-screen terminal page's
|
// <SubagentsMenu> — a branching icon and the number of running subagents in the
|
||||||
// header: a badge that opens a list of the agent's subagents, each a link to
|
// full-screen terminal page's header: a badge that opens a list of the agent's subagents, each a link to
|
||||||
// its own terminal page. On a subagent's page the current one is marked and the
|
// its own terminal page. On a subagent's page the current one is marked and the
|
||||||
// list starts with a way back to the agent's own terminal. The list is the
|
// list starts with a way back to the agent's own terminal. The list is the
|
||||||
// same `GET /api/agents/{name}/subagents` as the one under the preview, and
|
// same `GET /api/agents/{name}/subagents` as the one under the preview, and
|
||||||
|
|
@ -17,6 +17,7 @@ import { useRef, useState } from "preact/hooks";
|
||||||
import { Link } from "wouter-preact";
|
import { Link } from "wouter-preact";
|
||||||
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
|
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
|
||||||
import { Badge } from "@hive/shared/badge.js";
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
|
import { SubagentsIcon } from "@hive/shared/icons.js";
|
||||||
import { Panel } from "../../ui/panel/Panel.js";
|
import { Panel } from "../../ui/panel/Panel.js";
|
||||||
import { Popover } from "../../ui/popover/Popover.js";
|
import { Popover } from "../../ui/popover/Popover.js";
|
||||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||||
|
|
@ -121,9 +122,11 @@ export function SubagentsMenu({
|
||||||
<>
|
<>
|
||||||
<span ref={anchorRef}>
|
<span ref={anchorRef}>
|
||||||
<Badge
|
<Badge
|
||||||
value={runningLabel(running.length)}
|
icon={<SubagentsIcon />}
|
||||||
|
value={running.length}
|
||||||
tone={running.length > 0 ? "positive" : "neutral"}
|
tone={running.length > 0 ? "positive" : "neutral"}
|
||||||
title={`${open ? "close" : "open"} ${agentName}'s subagents`}
|
ariaLabel={runningLabel(running.length)}
|
||||||
|
title={`${runningLabel(running.length)}: ${open ? "close" : "open"} ${agentName}'s subagents`}
|
||||||
expanded={open}
|
expanded={open}
|
||||||
onClick={() => setOpen((o) => !o)}
|
onClick={() => setOpen((o) => !o)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,6 @@
|
||||||
.ui-agent-group-grip {
|
.ui-agent-group-grip {
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
.ui-agent-group-menu {
|
|
||||||
list-style: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
display: grid;
|
|
||||||
gap: 0.4em;
|
|
||||||
}
|
|
||||||
.ui-agent-group-menu li {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5em;
|
|
||||||
}
|
|
||||||
.ui-agent-group-menu-name {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
.ui-agent-group-menu-empty {
|
|
||||||
margin: 0;
|
|
||||||
max-width: 22em;
|
|
||||||
}
|
|
||||||
.ui-agent-group-missing {
|
.ui-agent-group-missing {
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ import { useEffect } from "preact/hooks";
|
||||||
import { useLocation, type RouteComponentProps } from "wouter-preact";
|
import { useLocation, type RouteComponentProps } from "wouter-preact";
|
||||||
import { Badge } from "@hive/shared/badge.js";
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
import { CloseIcon, ExpandIcon } from "@hive/shared/icons.js";
|
import { CloseIcon, ExpandIcon } from "@hive/shared/icons.js";
|
||||||
import { AgentIcon } from "../../agent/AgentIcon.js";
|
|
||||||
import { SubagentsMenu } from "../../agent/terminal/SubagentsMenu.js";
|
import { SubagentsMenu } from "../../agent/terminal/SubagentsMenu.js";
|
||||||
import { AgentTermPreview } from "../../agent/terminal/AgentTermPreview.js";
|
import { AgentTermPreview } from "../../agent/terminal/AgentTermPreview.js";
|
||||||
|
import { BashTasksMenu } from "../../agent/terminal/BashTasksMenu.js";
|
||||||
|
import { LiveAgentIcon } from "../../agent/terminal/ConnectionDot.js";
|
||||||
import { termPaths } from "../../agent/terminal/term-paths.js";
|
import { termPaths } from "../../agent/terminal/term-paths.js";
|
||||||
import {
|
import {
|
||||||
agentsIn,
|
agentsIn,
|
||||||
|
|
@ -27,54 +28,16 @@ import {
|
||||||
resizeAt,
|
resizeAt,
|
||||||
splitKey,
|
splitKey,
|
||||||
splitPane,
|
splitPane,
|
||||||
terminalAgentOf,
|
|
||||||
type Side,
|
|
||||||
} from "../../agent/terminal/split-layout.js";
|
} from "../../agent/terminal/split-layout.js";
|
||||||
import { endAgentDrag, startAgentDrag } from "../../agent/terminal/termDrag.js";
|
import { endAgentDrag, startAgentDrag } from "../../agent/terminal/termDrag.js";
|
||||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||||
import { useTermGroups } from "../../agent/terminal/useTermGroups.js";
|
import { useTermGroups } from "../../agent/terminal/useTermGroups.js";
|
||||||
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
||||||
import { BadgePopover } from "../../ui/badge-popover/BadgePopover.js";
|
|
||||||
import { Button } from "../../ui/button/Button.js";
|
import { Button } from "../../ui/button/Button.js";
|
||||||
import { PaneDropTarget } from "../../ui/pane-tree/PaneDropTarget.js";
|
import { PaneDropTarget } from "../../ui/pane-tree/PaneDropTarget.js";
|
||||||
import { PaneTree } from "../../ui/pane-tree/PaneTree.js";
|
import { PaneTree } from "../../ui/pane-tree/PaneTree.js";
|
||||||
import "./AgentGroupPage.css";
|
import "./AgentGroupPage.css";
|
||||||
|
|
||||||
// The split menu of a pane: the agents whose terminal tab is open and that are
|
|
||||||
// not in the group yet, each to be put beside this pane on the right or below.
|
|
||||||
function SplitMenu({
|
|
||||||
candidates,
|
|
||||||
onSplit,
|
|
||||||
}: {
|
|
||||||
candidates: string[];
|
|
||||||
onSplit: (agent: string, side: Side) => void;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<BadgePopover
|
|
||||||
value="split"
|
|
||||||
title="put another agent's terminal beside this one"
|
|
||||||
popoverLabel="split this pane"
|
|
||||||
>
|
|
||||||
{candidates.length === 0 ? (
|
|
||||||
<p class="ui-agent-group-menu-empty">
|
|
||||||
Open another agent's terminal tab first, then split it in here, or
|
|
||||||
drag its tab onto a pane.
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<ul class="ui-agent-group-menu">
|
|
||||||
{candidates.map((agent) => (
|
|
||||||
<li key={agent}>
|
|
||||||
<span class="ui-agent-group-menu-name">{agent}</span>
|
|
||||||
<Button onClick={() => onSplit(agent, "right")}>right</Button>
|
|
||||||
<Button onClick={() => onSplit(agent, "bottom")}>below</Button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</BadgePopover>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AgentGroupPage({
|
export function AgentGroupPage({
|
||||||
params,
|
params,
|
||||||
}: RouteComponentProps<{ id: string }>) {
|
}: RouteComponentProps<{ id: string }>) {
|
||||||
|
|
@ -82,7 +45,7 @@ export function AgentGroupPage({
|
||||||
const href = groupHref(id);
|
const href = groupHref(id);
|
||||||
const groups = useTermGroups();
|
const groups = useTermGroups();
|
||||||
const group = groups.find(id);
|
const group = groups.find(id);
|
||||||
const { tabs, open, close } = useDynamicTabs();
|
const { open, close } = useDynamicTabs();
|
||||||
const [, navigate] = useLocation();
|
const [, navigate] = useLocation();
|
||||||
|
|
||||||
const inGroup = group === undefined ? [] : agentsIn(group.root);
|
const inGroup = group === undefined ? [] : agentsIn(group.root);
|
||||||
|
|
@ -134,10 +97,6 @@ export function AgentGroupPage({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const candidates = tabs
|
|
||||||
.map((t) => terminalAgentOf(t.href))
|
|
||||||
.filter((a): a is string => a !== null && !inGroup.includes(a));
|
|
||||||
|
|
||||||
// `key` is the pane's key: its agent, or `agent/subagent` for a subagent's.
|
// `key` is the pane's key: its agent, or `agent/subagent` for a subagent's.
|
||||||
function renderPane(key: string) {
|
function renderPane(key: string) {
|
||||||
const { agent, subagent } = splitKey(key);
|
const { agent, subagent } = splitKey(key);
|
||||||
|
|
@ -152,7 +111,7 @@ export function AgentGroupPage({
|
||||||
agentName={agent}
|
agentName={agent}
|
||||||
subagent={subagent}
|
subagent={subagent}
|
||||||
fullHeight
|
fullHeight
|
||||||
leading={
|
leading={(connection) => (
|
||||||
<>
|
<>
|
||||||
<span
|
<span
|
||||||
class="ui-agent-group-grip"
|
class="ui-agent-group-grip"
|
||||||
|
|
@ -161,14 +120,11 @@ export function AgentGroupPage({
|
||||||
onDragStart={(e) => startAgentDrag(e, key)}
|
onDragStart={(e) => startAgentDrag(e, key)}
|
||||||
onDragEnd={endAgentDrag}
|
onDragEnd={endAgentDrag}
|
||||||
>
|
>
|
||||||
<Badge icon={<AgentIcon name={agent} small />} value={key} />
|
<Badge
|
||||||
|
icon={<LiveAgentIcon name={agent} connection={connection} />}
|
||||||
|
value={key}
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
<SplitMenu
|
|
||||||
candidates={candidates}
|
|
||||||
onSplit={(other, side) =>
|
|
||||||
groups.update(id, (r) => splitPane(r, key, other, side))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<SubagentsMenu
|
<SubagentsMenu
|
||||||
key={agent}
|
key={agent}
|
||||||
agentName={agent}
|
agentName={agent}
|
||||||
|
|
@ -184,8 +140,11 @@ export function AgentGroupPage({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{subagent === undefined && (
|
||||||
|
<BashTasksMenu key={agent} agentName={agent} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
trailing={
|
trailing={
|
||||||
<>
|
<>
|
||||||
<Badge
|
<Badge
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ import { useEffect, useRef, useState } from "preact/hooks";
|
||||||
import type { RouteComponentProps } from "wouter-preact";
|
import type { RouteComponentProps } from "wouter-preact";
|
||||||
import { Badge } from "@hive/shared/badge.js";
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
import { AgentDetailPopover } from "../../agent/detail/AgentDetailPopover.js";
|
import { AgentDetailPopover } from "../../agent/detail/AgentDetailPopover.js";
|
||||||
import { AgentIcon } from "../../agent/AgentIcon.js";
|
|
||||||
import { SubagentsMenu } from "../../agent/terminal/SubagentsMenu.js";
|
import { SubagentsMenu } from "../../agent/terminal/SubagentsMenu.js";
|
||||||
import { AgentTermPreview } from "../../agent/terminal/AgentTermPreview.js";
|
import { AgentTermPreview } from "../../agent/terminal/AgentTermPreview.js";
|
||||||
|
import { BashTasksMenu } from "../../agent/terminal/BashTasksMenu.js";
|
||||||
|
import { LiveAgentIcon } from "../../agent/terminal/ConnectionDot.js";
|
||||||
import { termPaths } from "../../agent/terminal/term-paths.js";
|
import { termPaths } from "../../agent/terminal/term-paths.js";
|
||||||
import { useAgentFavicon } from "../../agent/terminal/useAgentFavicon.js";
|
import { useAgentFavicon } from "../../agent/terminal/useAgentFavicon.js";
|
||||||
import {
|
import {
|
||||||
|
|
@ -70,11 +71,11 @@ export function AgentTerminalPage({
|
||||||
agentName={name}
|
agentName={name}
|
||||||
subagent={subagent}
|
subagent={subagent}
|
||||||
fullHeight
|
fullHeight
|
||||||
leading={
|
leading={(connection) => (
|
||||||
<>
|
<>
|
||||||
<span ref={badgeRef}>
|
<span ref={badgeRef}>
|
||||||
<Badge
|
<Badge
|
||||||
icon={<AgentIcon name={name} small />}
|
icon={<LiveAgentIcon name={name} connection={connection} />}
|
||||||
value={name}
|
value={name}
|
||||||
title={`${detailOpen ? "close" : "open"} ${name}'s details`}
|
title={`${detailOpen ? "close" : "open"} ${name}'s details`}
|
||||||
expanded={detailOpen}
|
expanded={detailOpen}
|
||||||
|
|
@ -93,8 +94,11 @@ export function AgentTerminalPage({
|
||||||
open({ href: groupHref(group.id), label: groupTitle(group) });
|
open({ href: groupHref(group.id), label: groupTitle(group) });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{subagent === undefined && (
|
||||||
|
<BashTasksMenu key={name} agentName={name} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,33 @@
|
||||||
.shell-tab-active {
|
.shell-tab-active {
|
||||||
border-color: var(--pink);
|
border-color: var(--pink);
|
||||||
}
|
}
|
||||||
|
/* A tab that can be dragged onto a terminal to split it shows a grip in a gutter
|
||||||
|
of its own on hover, so the drag is discoverable. The gutter is part of the
|
||||||
|
padding, so the tab does not change size when the grip appears. */
|
||||||
|
.shell-tab-draggable {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 1.3em;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
.shell-tab-grip {
|
||||||
|
position: absolute;
|
||||||
|
left: 0.35em;
|
||||||
|
top: 50%;
|
||||||
|
display: inline-flex;
|
||||||
|
color: var(--muted);
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.shell-tab-draggable:hover .shell-tab-grip {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.shell-tab-grip {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
.shell-tab-link {
|
.shell-tab-link {
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import { useHideDebug } from "./useHideDebug.js";
|
||||||
import { SettingsMenu } from "@hive/shared/settings-menu.js";
|
import { SettingsMenu } from "@hive/shared/settings-menu.js";
|
||||||
import { HideDebugSetting } from "@hive/shared/hide-debug-setting.js";
|
import { HideDebugSetting } from "@hive/shared/hide-debug-setting.js";
|
||||||
import { ShowThinkingSetting } from "@hive/shared/show-thinking-setting.js";
|
import { ShowThinkingSetting } from "@hive/shared/show-thinking-setting.js";
|
||||||
|
import { GripIcon } from "@hive/shared/icons.js";
|
||||||
import { ExpandDetailsSetting } from "@hive/shared/expand-details-setting.js";
|
import { ExpandDetailsSetting } from "@hive/shared/expand-details-setting.js";
|
||||||
import { useApplyThemeOverride } from "@hive/shared/theme-apply.js";
|
import { useApplyThemeOverride } from "@hive/shared/theme-apply.js";
|
||||||
import { useApplyMotionOverride } from "@hive/shared/motion-apply.js";
|
import { useApplyMotionOverride } from "@hive/shared/motion-apply.js";
|
||||||
|
|
@ -174,13 +175,25 @@ function DynamicTabLink({
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
class={"shell-tab" + (active ? " shell-tab-active" : "")}
|
class={
|
||||||
|
"shell-tab" +
|
||||||
|
(active ? " shell-tab-active" : "") +
|
||||||
|
(agent !== undefined ? " shell-tab-draggable" : "")
|
||||||
|
}
|
||||||
|
title={
|
||||||
|
agent === undefined ? undefined : "drag onto a terminal to split it"
|
||||||
|
}
|
||||||
draggable={agent !== undefined && !editing}
|
draggable={agent !== undefined && !editing}
|
||||||
onDragStart={
|
onDragStart={
|
||||||
agent === undefined ? undefined : (e) => startAgentDrag(e, agent)
|
agent === undefined ? undefined : (e) => startAgentDrag(e, agent)
|
||||||
}
|
}
|
||||||
onDragEnd={agent === undefined ? undefined : endAgentDrag}
|
onDragEnd={agent === undefined ? undefined : endAgentDrag}
|
||||||
>
|
>
|
||||||
|
{agent !== undefined && (
|
||||||
|
<span class="shell-tab-grip" aria-hidden="true">
|
||||||
|
<GripIcon />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
{editing && onRename !== undefined ? (
|
{editing && onRename !== undefined ? (
|
||||||
<input
|
<input
|
||||||
class="shell-tab-rename"
|
class="shell-tab-rename"
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ import "./BadgePopover.css";
|
||||||
export function BadgePopover({
|
export function BadgePopover({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
|
icon,
|
||||||
tone,
|
tone,
|
||||||
title,
|
title,
|
||||||
|
ariaLabel,
|
||||||
popoverLabel,
|
popoverLabel,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
|
|
@ -23,9 +25,13 @@ export function BadgePopover({
|
||||||
label?: ComponentChildren;
|
label?: ComponentChildren;
|
||||||
/** What the badge says, e.g. "7 granted". */
|
/** What the badge says, e.g. "7 granted". */
|
||||||
value: ComponentChildren;
|
value: ComponentChildren;
|
||||||
|
/** A glyph before the value. */
|
||||||
|
icon?: ComponentChildren;
|
||||||
tone?: BadgeTone;
|
tone?: BadgeTone;
|
||||||
/** Tooltip on the badge: what clicking it does. */
|
/** Tooltip on the badge: what clicking it does. */
|
||||||
title?: string;
|
title?: string;
|
||||||
|
/** The badge's accessible name, when its text is not enough of one. */
|
||||||
|
ariaLabel?: string;
|
||||||
/** `aria-label` of the floating box. */
|
/** `aria-label` of the floating box. */
|
||||||
popoverLabel: string;
|
popoverLabel: string;
|
||||||
children: ComponentChildren;
|
children: ComponentChildren;
|
||||||
|
|
@ -38,8 +44,10 @@ export function BadgePopover({
|
||||||
<Badge
|
<Badge
|
||||||
label={label}
|
label={label}
|
||||||
value={value}
|
value={value}
|
||||||
|
icon={icon}
|
||||||
tone={tone}
|
tone={tone}
|
||||||
title={title}
|
title={title}
|
||||||
|
ariaLabel={ariaLabel}
|
||||||
expanded={open}
|
expanded={open}
|
||||||
onClick={() => setOpen((o) => !o)}
|
onClick={() => setOpen((o) => !o)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,28 @@
|
||||||
// The model and effort badge tooltips. Run by `npm test`, which Node runs with
|
// The model badge's tooltip. Run by `npm test`, which Node runs with its
|
||||||
// its built-in test runner and type stripping.
|
// built-in test runner and type stripping.
|
||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { test } from "node:test";
|
import { test } from "node:test";
|
||||||
import { effortTitle, modelTitle } from "../src/agent/state/badge-titles.ts";
|
import { inferenceTitle } from "../src/agent/state/badge-titles.ts";
|
||||||
|
|
||||||
test("a plain model badge says what the alias resolved to, or nothing", () => {
|
test("the tooltip says what the alias resolved to and where the effort comes from", () => {
|
||||||
assert.equal(modelTitle("claude-x-1", false), "resolved to claude-x-1");
|
|
||||||
assert.equal(modelTitle(undefined, false), undefined);
|
|
||||||
assert.equal(modelTitle("", false), undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("a clickable model badge says it opens the settings", () => {
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
modelTitle("claude-x-1", true),
|
inferenceTitle("claude-x-1", "swarm", false),
|
||||||
"resolved to claude-x-1. Click for the inference settings",
|
"resolved to claude-x-1; effort set by: swarm",
|
||||||
);
|
);
|
||||||
assert.equal(modelTitle(undefined, true), "Click for the inference settings");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("the effort badge names its source and, when clickable, the click", () => {
|
test("an alias that did not resolve leaves that part out", () => {
|
||||||
assert.equal(effortTitle("swarm", false), "set by: swarm");
|
for (const resolved of [undefined, null, ""]) {
|
||||||
|
assert.equal(
|
||||||
|
inferenceTitle(resolved, "default", false),
|
||||||
|
"effort set by: default",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a clickable badge says it opens the settings", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
effortTitle("swarm", true),
|
inferenceTitle("claude-x-1", "swarm", true),
|
||||||
"set by: swarm. Click for the inference settings",
|
"resolved to claude-x-1; effort set by: swarm. Click for the inference settings",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue