Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
danielhanchen
00cc20baa1 studio/frontend: keep shutdown dialog open when server-stop fails
`AlertDialogAction` from Radix auto-closes the AlertDialog on click
(documented behavior). The shutdown handler then runs async, and on
error calls `toastError(...)` + `setStopping(false)` to reset the
button label for a retry, but the dialog has already vanished by
then. The user sees a flash + a toast and has to re-navigate through
the user-menu to try again.

Fix: call `event.preventDefault()` in the AlertDialogAction onClick
so the dialog stays open while the request is in flight. On success
the handler replaces document.body wholesale, so dialog open-ness
doesn't matter. On failure the dialog stays open with the reset
"Stop server" label, ready for retry.

Probe: scripts/r6_shutdown_dialog_probe.py — intercepts
/api/shutdown to return 500, asserts dialog still open + button
label resets to "Stop server".
2026-05-19 23:37:05 +00:00

View file

@ -72,7 +72,15 @@ export function ShutdownDialog({
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={handleStop}
onClick={(event) => {
// AlertDialogAction auto-closes the dialog by default.
// On the shutdown error path we toast + reset `stopping`
// to let the user retry, which only works if the dialog
// stays open. preventDefault keeps it open; on success
// the handler replaces document.body anyway.
event.preventDefault();
void handleStop();
}}
disabled={stopping}
variant="destructive"
>