Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: select a pane's name badge in a terminal group to open the agent's details

This commit is contained in:
iris 2026-11-22 17:20:03 +01:00 • committed by mara
commit 8e2844ec92
2 changed files with 73 additions and 19 deletions

View file

@ -0,0 +1,60 @@
// <GroupPaneName> — 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<typeof LiveAgentIcon>[0]["connection"];
}) {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLSpanElement>(null);
return (
<>
<span
ref={ref}
class="ui-agent-group-grip"
role="button"
tabIndex={0}
aria-expanded={open}
aria-label={`${paneKey}, ${agent}'s details`}
title={`${open ? "close" : "open"} ${agent}'s details; drag ${paneKey} onto another pane to move it`}
draggable
onClick={() => setOpen((o) => !o)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
setOpen((o) => !o);
}
}}
onDragStart={(e) => startAgentDrag(e, paneKey)}
onDragEnd={endAgentDrag}
>
<Badge
icon={<LiveAgentIcon name={agent} connection={connection} />}
value={paneKey}
/>
</span>
<AgentDetailPopover
agent={agent}
open={open}
onClose={() => setOpen(false)}
anchorRef={ref}
/>
</>
);
}

View file

@ -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) => (
<>
<span
class="ui-agent-group-grip"
draggable
title={`drag ${key} onto another pane to move it`}
onDragStart={(e) => startAgentDrag(e, key)}
onDragEnd={endAgentDrag}
>
<Badge
icon={<LiveAgentIcon name={agent} connection={connection} />}
value={key}
/>
</span>
<GroupPaneName
paneKey={key}
agent={agent}
connection={connection}
/>
<SubagentsMenu
key={agent}
agentName={agent}