From 00cc20baa156e51cdabd5741f3c9306987cb4f08 Mon Sep 17 00:00:00 2001 From: danielhanchen Date: Tue, 19 May 2026 23:37:05 +0000 Subject: [PATCH] studio/frontend: keep shutdown dialog open when server-stop fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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". --- studio/frontend/src/components/shutdown-dialog.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/studio/frontend/src/components/shutdown-dialog.tsx b/studio/frontend/src/components/shutdown-dialog.tsx index dfeafb33eb..d572f2e31d 100644 --- a/studio/frontend/src/components/shutdown-dialog.tsx +++ b/studio/frontend/src/components/shutdown-dialog.tsx @@ -72,7 +72,15 @@ export function ShutdownDialog({ Cancel { + // 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" >