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

@ -14,6 +14,7 @@ import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { readApiError, type ProblemDetails } from "@hive/shared/api-error.js";
import { Button } from "../../ui/button/Button.js";
import { ConfirmDialog } from "../../ui/confirm-dialog/ConfirmDialog.js";
import { useConfirm } from "../../ui/confirm-dialog/useConfirm.js";
import { FilterableView } from "../../ui/filterable-view/FilterableView.js";
import { Toolbar } from "../../ui/toolbar/Toolbar.js";
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
@ -89,6 +90,7 @@ function SchedulesBody() {
const [creating, setCreating] = useState(false);
const [pendingIds, setPendingIds] = useState<Set<string>>(new Set());
const [removeTarget, setRemoveTarget] = useState<Schedule | null>(null);
const [confirm, fireDialog] = useConfirm();
const [actionError, setActionError] = useState<ProblemDetails | null>(null);
function markPending(id: string, on: boolean) {
@ -120,7 +122,20 @@ function SchedulesBody() {
}
}
function fireNow(s: Schedule) {
async function fireNow(s: Schedule) {
const repeats = s.interval_seconds !== null;
const yes = await confirm({
label: "fire schedule now",
confirmLabel: "fire now",
body: (
<p>
Fire <strong>{s.name}</strong> now? It sends its message to{" "}
{s.agents.join(", ")} at once, and its start moves to this moment
{repeats ? ", so it repeats from now on" : ""}. That cannot be undone.
</p>
),
});
if (!yes) return;
return act(s.id, () =>
fetch(`/api/schedules/${encodeURIComponent(s.id)}`, {
method: "PATCH",
@ -232,10 +247,12 @@ function SchedulesBody() {
}
/>
) : null}
{fireDialog}
<ConfirmDialog
open={removeTarget !== null}
label="remove schedule"
confirmLabel="remove"
danger
onCancel={() => setRemoveTarget(null)}
onConfirm={confirmRemove}
>