Repository navigation
Conversation
Migrate ResetTemplateDialog to the async AlertDialogAction pattern so the reset confirmation returns the mutation promise, keeps the dialog open while pending, and closes only on success. Failures now surface inline via a destructive Admonition in AlertDialogBody instead of a toast, and the asChild + preventDefault workaround is removed. Resolves DEPR-573.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
📝 WalkthroughWalkthroughResetTemplateDialog now uses mutateAsync with try/catch to surface reset failures inline, clears error state on close, and updates tests to cover the failure path and the mocked async mutation flow. ChangesReset failure surfacing
Estimated code review effort: 2 (Simple) | ~12 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/studio/components/interfaces/Auth/EmailTemplates/ResetTemplateDialog.tsx (1)
37-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winInline
Admonitionbypasses the establishedErrorMatcherarchitecture.Studio's error-handling convention routes caught errors through
ErrorMatcher(which readserror.errorTypeoff the typed error class for an O(1) troubleshooting lookup), rather than extractingerror.messageinto local string state. Here,setError(error.message ?? ...)discards the typed error object, and the raw string is rendered via a bespokeAdmonitioninstead ofErrorMatcher.Consider storing the caught error object (not just its message) and rendering via
ErrorMatcherfor consistency with the rest of Studio, e.g.:<ErrorMatcher title="Unable to reset email template" error={error} supportFormParams={{ projectRef }} />This is advisory — if there's no meaningful troubleshooting content for this failure mode, the current inline message is a reasonable simplification.
As per coding guidelines, "Errors flow:
handleError()→ throws typed subclass → React Query catches →ErrorMatcherreadserrorType→ renders troubleshooting," and the rules flag when "PR passeserror.messageinstead of the fullerrorobject" to the matcher.Also applies to: 62-65, 90-98
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/interfaces/Auth/EmailTemplates/ResetTemplateDialog.tsx` at line 37, The ResetTemplateDialog error path is bypassing Studio’s standard ErrorMatcher flow by storing only error.message in local state and rendering a custom Admonition. Update the error handling in ResetTemplateDialog to keep the caught error object intact (instead of converting it to a string) and pass that error into ErrorMatcher so it can use error.errorType consistently with the existing troubleshooting architecture. Ensure the render path that currently uses the local error state is replaced with ErrorMatcher, using the dialog’s existing title/context and supportFormParams where appropriate.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@apps/studio/components/interfaces/Auth/EmailTemplates/ResetTemplateDialog.tsx`:
- Line 37: The ResetTemplateDialog error path is bypassing Studio’s standard
ErrorMatcher flow by storing only error.message in local state and rendering a
custom Admonition. Update the error handling in ResetTemplateDialog to keep the
caught error object intact (instead of converting it to a string) and pass that
error into ErrorMatcher so it can use error.errorType consistently with the
existing troubleshooting architecture. Ensure the render path that currently
uses the local error state is replaced with ErrorMatcher, using the dialog’s
existing title/context and supportFormParams where appropriate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 773f22e7-90cb-4c01-8fb1-8e2cd7dfe37e
📒 Files selected for processing (2)
apps/studio/components/interfaces/Auth/EmailTemplates/ResetTemplateDialog.tsxapps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.test.tsx
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › queue-table-operations.spec.ts › Queue Table Operations › pending changes persist when switching between tables Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
Narrow the caught reset error with an instanceof Error check instead of typing it as any, to satisfy the no-explicit-any lint ratchet.
There was a problem hiding this comment.
Pull request overview
This PR updates the Studio Auth email template “Reset template” confirmation flow to use the newer async-capable AlertDialogAction API, keeping the dialog open during the reset mutation and surfacing failures inline instead of via a toast-only error path.
Changes:
- Migrated
ResetTemplateDialogto usemutateAsyncwith asyncAlertDialogActionhandling (loading/close-on-success/stay-open-on-error). - Added inline error rendering via
AlertDialogBody+ destructiveAdmonition, with error state cleared on dialog close. - Updated
TemplateEditortests to mockmutateAsyncand added a failure-path assertion (dialog remains open, inline error shown, no toast error).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.test.tsx | Updates reset mutation mocking to mutateAsync and adds a failure-path test for inline error behavior. |
| apps/studio/components/interfaces/Auth/EmailTemplates/ResetTemplateDialog.tsx | Refactors the reset confirmation dialog to the async AlertDialogAction pattern and displays reset errors inline. |
| try { | ||
| await resetAuthTemplate({ projectRef, template: templateType }) | ||
| } catch (error) { | ||
| setError( | ||
| error instanceof Error | ||
| ? error.message | ||
| : 'An unknown error occurred while resetting the template' | ||
| ) | ||
| throw error | ||
| } |
There was a problem hiding this comment.
we could stick to using mutate - these could be handled in onError handler
There was a problem hiding this comment.
ohhh it must depend on async here for the async loading
Braintrust eval report
|
What kind of change does this PR introduce?
Bug fix / refactor. Resolves DEPR-573.
What is the current behavior?
ResetTemplateDialog(added in #45572) confirms the Auth email template reset using the oldAlertDialogworkaround: anAlertDialogActionwithasChild+event.preventDefault()and a manual loadingButton, driven bymutateplus inline callbacks. Reset failures are only reported via a toast from the mutation's defaultonError, so the error disappears from the dialog context.This predates #45960, which added first-class async handling to
AlertDialogAction(promise-returning handlers, controlledloading, andAlertDialogBodyfor inline feedback). #45960 explicitly flaggedResetTemplateDialogas needing this follow-up migration.What is the new behavior?
ResetTemplateDialognow uses the asyncAlertDialogActionpattern:mutateAsyncand returns the reset promise, so the dialog stays open with a loading state while the mutation is pending and closes only after it succeeds.AdmonitioninsideAlertDialogBody, and the mutation's toast-only error path is suppressed (onError: () => {}). The inline error clears when the dialog closes.Cancelis disabled while the reset is in flight.asChild+preventDefault()workaround and the manual loadingButtonare removed;loading={isResetting}is retained for parent-controlled loading.This matches the established usage in
DisablePipelinesDialog/JitDbAccessDeleteDialogand the design-systemalert-dialog-async-errorexample.To test
*/templates/*/reset, click Reset, and confirm the dialog stays open with an inline destructive admonition and no toast.Summary by CodeRabbit