Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/pages/agents/SelectionBar.tsx
iris 56ed2e07da swarm ui: select several agents on the agents page and broadcast to them
Select mode picks agents from the list: the select button in the filter
card, a press on an agent's icon, or a long press on a card starts it. In
it a card toggles a tick instead of opening its details, and the card's own
controls stop answering. A bar at the foot of the list has select all shown,
clear, broadcast and done; Escape leaves the mode.

Broadcast opens a dialog with the picked agents and a message box, sending
through the existing broadcast endpoint; the composer's send and result
parts are now shared with the swarm page's broadcast card. A full send shows
a toast and ends select mode; a partial one keeps the result with a retry
for the agents that failed.
2026-11-22 18:58:50 +01:00

66 lines
1.9 KiB
TypeScript

// <SelectionBar> — the bar at the foot of the agents list in select mode: how
// many agents are picked, the ways to change the pick (all shown, none), the
// action to take on them (broadcast, the only one so far) and done, which leaves
// select mode. It sticks to the bottom of the viewport while the list scrolls
// under it, so the action is in reach however far down the picks are.
import { Button } from "../../ui/button/Button.js";
import { MAX_BROADCAST } from "../broadcast/broadcast-types.js";
import "./SelectionBar.css";
export function SelectionBar({
count,
shown,
onSelectAll,
onClear,
onBroadcast,
onDone,
}: {
/** Agents picked. */
count: number;
/** Agents the filter shows, so "select all" has something to pick. */
shown: number;
onSelectAll: () => void;
onClear: () => void;
onBroadcast: () => void;
onDone: () => void;
}) {
const overCap = count > MAX_BROADCAST;
return (
<div class="agents-selection-bar" role="toolbar" aria-label="selection">
<span class="agents-selection-count" role="status">
{count === 0 ? "none selected" : `${count} selected`}
</span>
<button
type="button"
class="agents-selection-link"
disabled={shown === 0}
onClick={onSelectAll}
>
select all shown
</button>
<button
type="button"
class="agents-selection-link"
disabled={count === 0}
onClick={onClear}
>
clear
</button>
<span class="agents-selection-actions">
{overCap ? (
<span class="agents-selection-cap" role="status">
at most {MAX_BROADCAST} at once
</span>
) : null}
<Button
variant="primary"
disabled={count === 0 || overCap}
onClick={onBroadcast}
>
broadcast…
</Button>
<Button onClick={onDone}>done</Button>
</span>
</div>
);
}