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

@ -22,6 +22,7 @@ import {
useDeniedDomains,
} from "../../agent/detail/useAllowedDomains.js";
import { Button } from "../../ui/button/Button.js";
import { useConfirm } from "../../ui/confirm-dialog/useConfirm.js";
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
import { Dialog } from "../../ui/dialog/Dialog.js";
import { Hint } from "../../ui/hint/Hint.js";
@ -46,6 +47,27 @@ function DomainSection({
}) {
const { entries, behind, error, busy, remove, refetch } = list;
const [adding, setAdding] = useState(false);
const [confirm, confirmDialog] = useConfirm();
async function removeEntry(e: Parameters<typeof remove>[0]) {
const verb = kind === "deny" ? "Stop denying" : "Stop allowing";
if (
!(await confirm({
label: `${verb.toLowerCase()} ${e.domain} swarm-wide`,
confirmLabel: "remove",
danger: true,
body: (
<p>
{verb} <code>{e.domain}</code> for <strong>every agent</strong> on
the swarm?
</p>
),
}))
) {
return;
}
void remove(e);
}
// A list already loaded stays under a failed refetch, so a change that
// worked is not hidden by a read that did not.
@ -94,7 +116,7 @@ function DomainSection({
<Button
disabled={busy}
ariaLabel={`remove ${e.domain}`}
onClick={() => void remove(e)}
onClick={() => void removeEntry(e)}
>
remove
</Button>
@ -121,6 +143,7 @@ function DomainSection({
/>
) : null}
</Dialog>
{confirmDialog}
</>
)}
</section>