feat(cancel-button): improve UX with loading spinner and success state#774
feat(cancel-button): improve UX with loading spinner and success state#774
Conversation
- Add loading spinner (Loader2 with animate-spin) during mutation - Show brief success indicator with auto-dismiss after 2 seconds - Replace window.confirm() with shadcn AlertDialog - Update dialog text: 'This will terminate the worker container?' - Improve error display to show full error message - Prevent double-cancellation by disabling button during success
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Good UX improvement overall — replacing window.confirm() with AlertDialog and adding loading/success states are solid changes. Two issues worth addressing: dead code in the dialog that can never execute, and a pattern deviation from existing AlertDialog usage.
Code Issues
Should Fix
-
web/src/components/runs/cancel-run-button.tsx:100-108 — The spinner and disabled states inside
AlertDialogContentare dead code. Radix UI'sAlertDialogActionauto-closes the dialog on click. SinceonClickcallscancelMutation.mutate()and then the dialog immediately closes,cancelMutation.isPendingwill never betruewhile the dialog is visible. The<Loader2>spinner (line 107), anddisabled={cancelMutation.isPending}onAlertDialogCancel(line 100) andAlertDialogAction(line 102) will never have any visible effect. This is misleading — it looks like the dialog stays open during the mutation, but it doesn't. Either remove the dead code from the dialog, or switchAlertDialogActionto a regular<Button>and manage dialog close manually inonSuccessif the intent is to show in-dialog progress. -
web/src/components/runs/cancel-run-button.tsx:99 — Uses a raw
<div>instead ofAlertDialogFooter. Every other AlertDialog in the codebase (credentials-table.tsx,projects-table.tsx,agent-configs-table.tsx) usesAlertDialogFooter, which provides responsive layout (flex-col-reverseon mobile,sm:flex-row sm:justify-end). Should useAlertDialogFooterfor consistency and better mobile behavior.
- Remove dead `disabled={cancelMutation.isPending}` props from AlertDialogCancel
and AlertDialogAction — Radix UI auto-closes the dialog on action click, so
isPending is never true while the dialog is visible
- Remove the unreachable Loader2 spinner inside AlertDialogAction for the same reason
- Replace raw `<div>` footer with `AlertDialogFooter` for consistent responsive
layout matching credentials-table, projects-table, and agent-configs-table
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Clean implementation that correctly replaces window.confirm() with shadcn/ui AlertDialog and adds loading/success/error states. Follows existing codebase patterns (matches projects-table, credentials-table, agent-configs-table AlertDialog usage). No blocking issues.
Minor Observations
Should consider
- Race condition on success visibility (line 34):
onSuccesssetsshowSuccess(true)and invalidates queries simultaneously. If the query re-fetch resolves quickly (status changes from'running'to something else), the component returnsnullbefore the 2-second success indicator is visible to the user. Consider delaying theinvalidateQueriescalls to fire after the 2-second success display (e.g., inside the timeout callback) if the success indicator is important for user feedback. This is a UX polish point, not a bug. - Minor style inconsistency (line 109): The destructive button uses
text-destructive-foregroundwhileprojects-table.tsxandcredentials-table.tsxusetext-white. Both work, buttext-destructive-foregroundis arguably more correct (semantic token). Just noting the inconsistency —agent-configs-table.tsxalready uses the same approach as this PR.
Summary
Enhanced the cancel run button in the dashboard with improved UX feedback and better confirmation flow.
Changes Made
window.confirm()with shadcn/ui AlertDialog for consistent UXAcceptance Criteria Met
Testing
Files Modified
Card: https://trello.com/c/5serjXgw/305-as-a-user-i-want-improved-cancel-button-ux-in-the-dashboard-so-that-i-get-clear-feedback-when-stopping-a-run