Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: ask before actions that cannot be undone, with a danger button and a useConfirm hook

Button gains a danger variant and an autofocus prop; ConfirmDialog gains danger (red confirm, focus on cancel). Destroy, delete linked account, delete claude login, remove schedule and delete flow use it. New useConfirm hook asks from inside a handler (await confirm({...})) without a dialog's state at the call site. It now guards: removing a swarm-wide egress domain, removing a domain for every agent from an agent's popover, removing a stored API-key environment, firing a schedule now, moving an agent's internet to a looser mode, the /clear message, and reload over unsaved instructions (replacing window.confirm). The review try-out's button is now called push a branch for a PR, since it pushes a branch and does not open one, and asks first. loosensInternet is a tested helper.
This commit is contained in:
iris 2026-11-19 18:42:34 +01:00 • committed by mara
commit c3e24fe2c6

View file

@ -1,14 +1,13 @@
// <Button> — the shared clickable-action control (form submit today,
// any future toolbar/dialog action later). `variant` is `'primary'`
// (the one emphasised action on a page, e.g. a form's submit) or
// `'default'` (everything else) — two is enough for every real caller
// so far; a third reading gets added the day something needs it, not
// speculatively.
// `'default'` (everything else), or `'danger'` (the action that cannot be
// taken back: destroy, delete, a removal that cuts access).
import type { ComponentChildren } from "preact";
import { Spinner } from "../spinner/Spinner.js";
import "./Button.css";
export type ButtonVariant = "primary" | "default";
export type ButtonVariant = "primary" | "default" | "danger";
export function Button({
variant = "default",
@ -18,6 +17,7 @@ export function Button({
onClick,
describedBy,
ariaLabel,
autofocus = false,
children,
}: {
variant?: ButtonVariant;
@ -33,6 +33,9 @@ export function Button({
/** A name that says what the button acts on, where its visible text repeats
* across a list ("remove", "edit"). It should start with the visible text. */
ariaLabel?: string;
/** Takes the focus when the dialog around it opens, in place of its first
* control. A destructive confirm puts it on the safe button. */
autofocus?: boolean;
children: ComponentChildren;
}) {
return (
@ -44,6 +47,7 @@ export function Button({
onClick={onClick}
aria-describedby={describedBy}
aria-label={ariaLabel}
autofocus={autofocus || undefined}
>
<span class="ui-button-label">{children}</span>
{busy ? (