The details pane showed the agent's name, then status, message and wanted rows with no card, then a folded status section repeating the state, and a single settings section of eleven rows of different kinds. The pane now opens with one identity card: icon and name, the wanted menu, badges for freshness, turn state, context and a needed login, the whole status message, and the hive, links and config PR. Below it the folded sections answer one question each: terminal, activity (todos, subagents and background tasks together), instructions, inference (which now holds the claude login and API key), access, and accounts. The terminal page's popover shows the card without the name and the four settings sections.
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
// <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 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<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>
|
|
</>
|
|
);
|
|
}
|