From 8e2844ec924e12acf4788f956f5f2de4a7f7937d Mon Sep 17 00:00:00 2001 From: iris Date: Sun, 22 Nov 2026 17:20:03 +0100 Subject: [PATCH] swarm-ui: select a pane's name badge in a terminal group to open the agent's details --- docs/4-implementation/web-ui/swarm-ui.md | 12 ++-- .../src/agent/terminal/GroupPaneName.tsx | 60 +++++++++++++++++++ .../src/pages/agents/AgentGroupPage.tsx | 20 ++----- 3 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 frontend/packages/swarm-ui/src/agent/terminal/GroupPaneName.tsx diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md index 99bbf168d..da1e3325c 100644 --- a/docs/4-implementation/web-ui/swarm-ui.md +++ b/docs/4-implementation/web-ui/swarm-ui.md @@ -287,11 +287,13 @@ 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 a group of the two, with its own header tab at `/agents/group/`. In a group, 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. A tab you can -drag shows a grip at its left edge when the pointer is over it, and its tooltip -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** -badge in the pane's header. Two icon buttons sit in a pane's top right corner. +dragging a pane's header badge onto another pane moves it there. Selecting that +badge opens the agent's details in a popover, as the name badge of its own +terminal does. A tab you can drag shows a grip at its left edge when the pointer +is over it, and its tooltip 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** 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 in its tab, or goes to the tab when one is open already. **Close** (the cross) takes the pane out of the group, and a group left with one pane goes, landing on that diff --git a/frontend/packages/swarm-ui/src/agent/terminal/GroupPaneName.tsx b/frontend/packages/swarm-ui/src/agent/terminal/GroupPaneName.tsx new file mode 100644 index 000000000..b0067b9e5 --- /dev/null +++ b/frontend/packages/swarm-ui/src/agent/terminal/GroupPaneName.tsx @@ -0,0 +1,60 @@ +// — the name badge of a pane in a group of terminals. Dragging +// it moves the pane onto another pane's edge, and selecting it opens the +// agent's details in a popover under it, as the name badge of an agent's own +// terminal does. The two share one element: a click that follows no drag is the +// select, and it works from the keyboard too. It's a draggable `span`, not a +// button inside one, because Firefox starts no drag from a button. +import { useRef, useState } from "preact/hooks"; +import { Badge } from "@hive/shared/badge.js"; +import { AgentDetailPopover } from "../detail/AgentDetailPopover.js"; +import { LiveAgentIcon } from "./ConnectionDot.js"; +import { endAgentDrag, startAgentDrag } from "./termDrag.js"; + +export function GroupPaneName({ + paneKey, + agent, + connection, +}: { + /** The pane's key: its agent, or `agent/subagent` for a subagent's. */ + paneKey: string; + /** The agent whose details open; a subagent has none of its own. */ + agent: string; + connection: Parameters[0]["connection"]; +}) { + const [open, setOpen] = useState(false); + const ref = useRef(null); + return ( + <> + setOpen((o) => !o)} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + setOpen((o) => !o); + } + }} + onDragStart={(e) => startAgentDrag(e, paneKey)} + onDragEnd={endAgentDrag} + > + } + value={paneKey} + /> + + setOpen(false)} + anchorRef={ref} + /> + + ); +} diff --git a/frontend/packages/swarm-ui/src/pages/agents/AgentGroupPage.tsx b/frontend/packages/swarm-ui/src/pages/agents/AgentGroupPage.tsx index b75c9ae78..55e73c527 100644 --- a/frontend/packages/swarm-ui/src/pages/agents/AgentGroupPage.tsx +++ b/frontend/packages/swarm-ui/src/pages/agents/AgentGroupPage.tsx @@ -16,7 +16,7 @@ import { CloseIcon, ExpandIcon } from "@hive/shared/icons.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 { GroupPaneName } from "../../agent/terminal/GroupPaneName.js"; import { termPaths } from "../../agent/terminal/term-paths.js"; import { agentsIn, @@ -29,7 +29,6 @@ import { splitKey, splitPane, } 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"; @@ -113,18 +112,11 @@ export function AgentGroupPage({ fullHeight leading={(connection) => ( <> - startAgentDrag(e, key)} - onDragEnd={endAgentDrag} - > - } - value={key} - /> - +