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.
This commit is contained in:
parent
7bdaea7954
commit
56ed2e07da
1 changed files with 793 additions and 88 deletions
66
frontend/packages/swarm-ui/src/pages/agents/SelectionBar.tsx
Normal file
66
frontend/packages/swarm-ui/src/pages/agents/SelectionBar.tsx
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// <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>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue