// — 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 details' activity 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(null); if (!error && (tasks === null || tasks.length === 0)) return null; const running = (tasks ?? []).filter(isLive).length; const label = runningTasksLabel(tasks ?? []); return ( <> } value={running} tone={running > 0 ? "positive" : "neutral"} ariaLabel={label} title={`${label}: ${open ? "close" : "open"} ${agentName}'s bash tasks`} expanded={open} onClick={() => setOpen((o) => !o)} /> setOpen(false)} anchorRef={anchorRef} label={`${agentName}'s bash tasks`} > setOpen(false)} > ); }