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
3 changed files with 430 additions and 199 deletions
|
|
@ -11,25 +11,6 @@
|
|||
.ui-agent-group-grip {
|
||||
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 {
|
||||
padding: 2em;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ import { useEffect } from "preact/hooks";
|
|||
import { useLocation, type RouteComponentProps } from "wouter-preact";
|
||||
import { Badge } from "@hive/shared/badge.js";
|
||||
import { CloseIcon, ExpandIcon } from "@hive/shared/icons.js";
|
||||
import { AgentIcon } from "../../agent/AgentIcon.js";
|
||||
import { SubagentsMenu } from "../../agent/terminal/SubagentsMenu.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 {
|
||||
agentsIn,
|
||||
|
|
@ -27,54 +28,16 @@ import {
|
|||
resizeAt,
|
||||
splitKey,
|
||||
splitPane,
|
||||
terminalAgentOf,
|
||||
type Side,
|
||||
} from "../../agent/terminal/split-layout.js";
|
||||
import { endAgentDrag, startAgentDrag } from "../../agent/terminal/termDrag.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { useTermGroups } from "../../agent/terminal/useTermGroups.js";
|
||||
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
||||
import { BadgePopover } from "../../ui/badge-popover/BadgePopover.js";
|
||||
import { Button } from "../../ui/button/Button.js";
|
||||
import { PaneDropTarget } from "../../ui/pane-tree/PaneDropTarget.js";
|
||||
import { PaneTree } from "../../ui/pane-tree/PaneTree.js";
|
||||
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({
|
||||
params,
|
||||
}: RouteComponentProps<{ id: string }>) {
|
||||
|
|
@ -82,7 +45,7 @@ export function AgentGroupPage({
|
|||
const href = groupHref(id);
|
||||
const groups = useTermGroups();
|
||||
const group = groups.find(id);
|
||||
const { tabs, open, close } = useDynamicTabs();
|
||||
const { open, close } = useDynamicTabs();
|
||||
const [, navigate] = useLocation();
|
||||
|
||||
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.
|
||||
function renderPane(key: string) {
|
||||
const { agent, subagent } = splitKey(key);
|
||||
|
|
@ -152,7 +111,7 @@ export function AgentGroupPage({
|
|||
agentName={agent}
|
||||
subagent={subagent}
|
||||
fullHeight
|
||||
leading={
|
||||
leading={(connection) => (
|
||||
<>
|
||||
<span
|
||||
class="ui-agent-group-grip"
|
||||
|
|
@ -161,14 +120,11 @@ export function AgentGroupPage({
|
|||
onDragStart={(e) => startAgentDrag(e, key)}
|
||||
onDragEnd={endAgentDrag}
|
||||
>
|
||||
<Badge icon={<AgentIcon name={agent} small />} value={key} />
|
||||
<Badge
|
||||
icon={<LiveAgentIcon name={agent} connection={connection} />}
|
||||
value={key}
|
||||
/>
|
||||
</span>
|
||||
<SplitMenu
|
||||
candidates={candidates}
|
||||
onSplit={(other, side) =>
|
||||
groups.update(id, (r) => splitPane(r, key, other, side))
|
||||
}
|
||||
/>
|
||||
<SubagentsMenu
|
||||
key={agent}
|
||||
agentName={agent}
|
||||
|
|
@ -184,8 +140,11 @@ export function AgentGroupPage({
|
|||
)
|
||||
}
|
||||
/>
|
||||
{subagent === undefined && (
|
||||
<BashTasksMenu key={agent} agentName={agent} />
|
||||
)}
|
||||
</>
|
||||
}
|
||||
)}
|
||||
trailing={
|
||||
<>
|
||||
<Badge
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ import { useEffect, useRef, useState } from "preact/hooks";
|
|||
import type { RouteComponentProps } from "wouter-preact";
|
||||
import { Badge } from "@hive/shared/badge.js";
|
||||
import { AgentDetailPopover } from "../../agent/detail/AgentDetailPopover.js";
|
||||
import { AgentIcon } from "../../agent/AgentIcon.js";
|
||||
import { SubagentsMenu } from "../../agent/terminal/SubagentsMenu.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 { useAgentFavicon } from "../../agent/terminal/useAgentFavicon.js";
|
||||
import {
|
||||
|
|
@ -70,11 +71,11 @@ export function AgentTerminalPage({
|
|||
agentName={name}
|
||||
subagent={subagent}
|
||||
fullHeight
|
||||
leading={
|
||||
leading={(connection) => (
|
||||
<>
|
||||
<span ref={badgeRef}>
|
||||
<Badge
|
||||
icon={<AgentIcon name={name} small />}
|
||||
icon={<LiveAgentIcon name={name} connection={connection} />}
|
||||
value={name}
|
||||
title={`${detailOpen ? "close" : "open"} ${name}'s details`}
|
||||
expanded={detailOpen}
|
||||
|
|
@ -93,8 +94,11 @@ export function AgentTerminalPage({
|
|||
open({ href: groupHref(group.id), label: groupTitle(group) });
|
||||
}}
|
||||
/>
|
||||
{subagent === undefined && (
|
||||
<BashTasksMenu key={name} agentName={name} />
|
||||
)}
|
||||
</>
|
||||
}
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue