Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
WalkthroughReplaces the DestinationPanel placeholder with a new ReadReplicaForm and adds supporting hooks and UI: eligibility checks, pricing calculation and dialog, eligibility warnings, deployment mutation, and minor UI prop/routing changes. (46 words) Changes
Sequence DiagramsequenceDiagram
autonumber
participant User
participant UI as ReadReplicaForm
participant Eligibility as useCheckEligibilityDeployReplica
participant Cost as useGetReplicaCost
participant Warnings as ReadReplicaEligibilityWarnings
participant Pricing as ReadReplicaPricingDialog
participant API as ReadReplicaSetupMutation
User->>UI: open form
UI->>Eligibility: fetch eligibility flags
Eligibility-->>UI: eligibility + reasons
UI->>Cost: fetch cost breakdown
Cost-->>UI: compute/disk/iops/throughput
alt not eligible
UI->>Warnings: render warnings/actions
Warnings-->>User: show blockers (invoices, provider, version, backups, spend cap, limits)
else eligible
UI-->>User: show region selector & summary
User->>Pricing: "Learn more"
Pricing-->>User: show detailed cost dialog
end
User->>UI: submit deploy
UI->>API: call setup mutation
API-->>UI: success / error
UI-->>User: toast + close on success
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (8)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (1)
23-26: UnnecessaryuseMemofor a simple computation.The
includescheck on a small static array is inexpensive.useMemoadds overhead without benefit here.🔎 Suggested simplification
- const isNotOnHigherPlan = useMemo( - () => !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? ''), - [org] - ) + const isNotOnHigherPlan = !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? '')apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.ts (3)
29-30: Avoid@ts-ignore; prefer runtime validation.Per coding guidelines, avoid type casting. Consider using a zod schema to validate
diskConfiguration.attributesat runtime, or update the API types if they're incorrect.
32-49: Multiple type casts weaken type safety.The
type as DiskTypecasts on lines 33, 35, and 44 assume the API returns a validDiskType. If the API returns an unexpected value, pricing calculations may silently use fallback values. Consider validatingtypeagainstDiskTypeenum values before use.🔎 Suggested validation approach
const diskType = Object.values(DiskType).includes(type) ? (type as DiskType) : undefined
51-56: Inconsistent number coercion style.Lines 54-55 use
Number()while lines 72 and 76 use unary+. Consider using a consistent approach throughout for readability.Also applies to: 70-77
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (1)
32-36: Consider using a<button>element for the dialog trigger.The
<p>element styled as a link may cause accessibility issues. Screen readers expect interactive elements to be buttons or links. TheDialogTriggertypically expects an interactive child.🔎 Suggested fix
<DialogTrigger> - <p className={cn(InlineLinkClassName, 'text-sm text-foreground-light cursor-pointer')}> + <button + type="button" + className={cn(InlineLinkClassName, 'text-sm text-foreground-light cursor-pointer')} + > Learn more - </p> + </button> </DialogTrigger>apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx (2)
37-39: Clarify the default region fallback logic.The destructuring pattern with
?? ['ap-southeast-1']works but is subtle. IfAWS_REGIONS_DEFAULTisn't found, the fallback assumes'ap-southeast-1'is a valid key inAWS_REGIONS.🔎 Consider a more explicit approach
- const [defaultRegion] = Object.entries(AWS_REGIONS).find( - ([_, name]) => name === AWS_REGIONS_DEFAULT - ) ?? ['ap-southeast-1'] + const defaultRegionEntry = Object.entries(AWS_REGIONS).find( + ([_, name]) => name === AWS_REGIONS_DEFAULT + ) + const defaultRegion = defaultRegionEntry?.[0] ?? 'ap-southeast-1'This makes the fallback behavior clearer and easier to verify.
33-135: Consider react-hook-form for consistency.Based on learnings, the codebase standard is to build forms with react-hook-form and zod for validation. While the current implementation works fine for this simple single-field form, using the standard form pattern would improve consistency and make future enhancements easier.
This is a minor suggestion—the current approach is reasonable given the form's simplicity.
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx (1)
154-203: Extract conditional content to improve readability.The WALG warning block contains nested ternaries and conditional rendering based on
refetchInterval. Per coding guidelines, nested ternaries in JSX should be avoided. Consider extracting the conditional content into variables.🔎 Proposed refactor
+ const isEnablingBackups = refetchInterval !== false + const backupTitle = isEnablingBackups + ? 'Physical backups are currently being enabled' + : 'Physical backups are required to deploy replicas' + + const backupDescription = isEnablingBackups ? ( + <> + <p> + This warning will go away once physical backups have been enabled - check back in a + few minutes! + </p> + <p>You may start deploying read replicas thereafter once this is completed.</p> + </> + ) : ( + <> + <p> + Physical backups are used under the hood to spin up read replicas for your project. + </p> + <p> + Enabling physical backups will take a few minutes, after which you will be able to + deploy read replicas. + </p> + </> + ) + if (isWalgNotEnabled) { return ( - <Admonition - type="warning" - title={ - refetchInterval === false - ? 'Physical backups are required to deploy replicas' - : 'Physical backups are currently being enabled' - } - > - {refetchInterval === false ? ( - <> - <p> - Physical backups are used under the hood to spin up read replicas for your project. - </p> - <p> - Enabling physical backups will take a few minutes, after which you will be able to - deploy read replicas. - </p> - </> - ) : ( - <> - <p> - This warning will go away once physical backups have been enabled - check back in a - few minutes! - </p> - <p>You may start deploying read replicas thereafter once this is completed.</p> - </> - )} - {refetchInterval === false && ( + <Admonition type="warning" title={backupTitle}> + {backupDescription} + {!isEnablingBackups && ( <div className="flex items-center gap-x-2 mt-2">
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx(2 hunks)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx(1 hunks)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx(1 hunks)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx(1 hunks)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts(1 hunks)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.ts(1 hunks)apps/studio/components/ui/RequestUpgradeToBillingOwners.tsx(3 hunks)apps/studio/components/ui/UpgradePlanButton.tsx(6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/studio/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/studio-best-practices.mdc)
apps/studio/**/*.{ts,tsx}: Assign complex conditions to descriptive variables instead of using multiple conditions in a single expression
Use consistent naming conventions for boolean variables:isprefix for state/identity,hasprefix for possession,canprefix for capability/permission,shouldprefix for conditional behavior
Derive boolean state from existing state instead of storing it separately
Use early returns for guard clauses instead of deeply nested conditionals
Extract complex logic into custom hooks when logic becomes reusable or complex
Return objects from custom hooks instead of arrays for better extensibility and clearer API
Use discriminated unions for complex state management instead of multiple independent state fields
Avoid type casting (e.g.,as any,as Type); instead validate values at runtime using zod schemas
Files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.tsapps/studio/components/ui/RequestUpgradeToBillingOwners.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.tsapps/studio/components/ui/UpgradePlanButton.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
apps/studio/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/studio-best-practices.mdc)
apps/studio/**/*.tsx: Components should ideally be under 200-300 lines; break down large components with multiple distinct UI sections, complex conditional rendering, or multiple unrelated useState hooks
Extract repeated JSX patterns into reusable components instead of copying similar JSX blocks
Use consistent loading/error/success pattern: handle loading state first with early returns, then error state, then empty state, then render success state
Keep state as local as possible and only lift up when needed
Group related state using objects or reducers instead of multiple useState calls, preferring react-hook-form for form state management
Name event handlers consistently: useonprefix for prop callbacks andhandleprefix for internal handlers
Avoid inline arrow functions for expensive operations; use useCallback to maintain stable function references
Use appropriate conditional rendering patterns: && for simple show/hide, ternary for binary choice, early returns or extracted components for multiple conditions
Avoid nested ternaries in JSX; use separate conditions or early returns instead
Use useMemo for expensive computations when the computation is genuinely expensive and the value is passed to memoized children
Define prop interfaces explicitly for React components with proper typing of props and callback handlers
Files:
apps/studio/components/ui/RequestUpgradeToBillingOwners.tsxapps/studio/components/ui/UpgradePlanButton.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
🧠 Learnings (11)
📚 Learning: 2025-12-12T05:20:17.409Z
Learnt from: joshenlim
Repo: supabase/supabase PR: 41258
File: apps/studio/pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx:9-9
Timestamp: 2025-12-12T05:20:17.409Z
Learning: In apps/studio/**/*.{ts,tsx}, use named imports for DefaultLayout: import { DefaultLayout } from 'components/layouts/DefaultLayout' instead of default import. This is the new practice being adopted across the studio app.
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.tsapps/studio/components/ui/RequestUpgradeToBillingOwners.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.tsapps/studio/components/ui/UpgradePlanButton.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
📚 Learning: 2025-12-11T16:46:18.701Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-best-practices.mdc:0-0
Timestamp: 2025-12-11T16:46:18.701Z
Learning: Applies to apps/studio/**/*.tsx : Define prop interfaces explicitly for React components with proper typing of props and callback handlers
Applied to files:
apps/studio/components/ui/RequestUpgradeToBillingOwners.tsxapps/studio/components/ui/UpgradePlanButton.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Do not introduce new UI components unless asked to; check packages/ui/index.tsx for available components before composing interfaces
Applied to files:
apps/studio/components/ui/RequestUpgradeToBillingOwners.tsxapps/studio/components/ui/UpgradePlanButton.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/**/*.{ts,tsx} : Use _Shadcn_ suffixed components (e.g., Input_Shadcn_, Button_Shadcn_) from the ui package where possible
Applied to files:
apps/studio/components/ui/RequestUpgradeToBillingOwners.tsxapps/studio/components/ui/UpgradePlanButton.tsx
📚 Learning: 2025-12-11T16:46:18.701Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-best-practices.mdc:0-0
Timestamp: 2025-12-11T16:46:18.701Z
Learning: Applies to apps/studio/**/*.{ts,tsx} : Extract complex logic into custom hooks when logic becomes reusable or complex
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/**/*.{ts,tsx} : Use typography classes from apps/studio/styles/typography.scss (e.g., 'heading-default') instead of hard-coding Tailwind classes for typography styles
Applied to files:
apps/studio/components/ui/UpgradePlanButton.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : When submit button is outside the form, add a formId variable outside the component, set it as id on form element and form prop on the button
Applied to files:
apps/studio/components/ui/UpgradePlanButton.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use Admonition component to alert users of important actions or restrictions
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Build forms with react-hook-form and zod for validation
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/interfaces/**/*.{ts,tsx} : Create a new component in apps/studio/components/interfaces for the contents of each new page
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use sheets when revealing complicated forms or information relating to an object where context switching to a new page would be disruptive
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx
🧬 Code graph analysis (5)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.ts (1)
apps/studio/lib/helpers.ts (1)
formatCurrency(329-337)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (2)
apps/studio/hooks/misc/useSelectedProject.ts (2)
useIsAwsK8sCloudProvider(26-31)useSelectedProjectQuery(5-17)apps/studio/hooks/misc/useSelectedOrganization.ts (1)
useSelectedOrganizationQuery(5-21)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx (8)
apps/studio/hooks/misc/useSelectedOrganization.ts (1)
useSelectedOrganizationQuery(5-21)apps/studio/hooks/misc/useSelectedProject.ts (1)
useSelectedProjectQuery(5-17)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (1)
useCheckEligibilityDeployReplica(14-83)apps/studio/data/projects/project-detail-query.ts (1)
useProjectDetailQuery(42-66)packages/ui-patterns/src/admonition.tsx (1)
Admonition(83-180)apps/studio/lib/constants/index.ts (1)
DOCS_URL(48-48)apps/studio/components/interfaces/Support/SupportLink.tsx (1)
SupportLink(7-28)apps/studio/components/ui/UpgradePlanButton.tsx (1)
UpgradePlanButton(34-117)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx (4)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.ts (1)
useGetReplicaCost(14-79)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (1)
useCheckEligibilityDeployReplica(14-83)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx (1)
ReadReplicaEligibilityWarnings(20-251)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (1)
ReadReplicaPricingDialog(24-114)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx (1)
ReadReplicaForm(33-136)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: typecheck
- GitHub Check: test
- GitHub Check: test (1)
🔇 Additional comments (8)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (2)
59-69: Well-structured eligibility check.The conjunction of conditions is clear and the returned object provides all necessary flags for UI consumption. This follows the coding guidelines for custom hooks returning objects.
55-57: Version parsing relies on a specific string format.If
dbVersiondoesn't follow thesupabase-postgres-X.Y.Zformat,currentPgVersionbecomesNaN. While the>= 15comparison safely returnsfalse, this is non-obvious. Consider adding a fallback or explicit check.#!/bin/bash # Check how dbVersion is typically formatted in the codebase rg -n "dbVersion" --type=ts -C2 | head -50apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (1)
46-105: Clean conditional rendering for AWS vs non-AWS providers.The ternary for binary choice pattern is appropriate here and the table structure is well-organized with proper semantic elements.
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx (2)
69-70: Consider passingonSuccessfor potential data refresh.
ReadReplicaFormaccepts an optionalonSuccesscallback (visible in the relevant code snippet at lines 32-135). While omitting it works, you may want to pass a callback to trigger data refetch or UI updates after replica deployment.
16-16: LGTM on the import and integration.The
ReadReplicaFormis properly imported and conditionally rendered based onselectedType.apps/studio/components/ui/RequestUpgradeToBillingOwners.tsx (1)
50-51: LGTM on theclassNameprop addition.The prop is correctly typed as optional, destructured from props, and applied to the
Button. This follows the coding guidelines for explicit prop interfaces with proper typing.Also applies to: 59-60, 159-159
apps/studio/components/ui/UpgradePlanButton.tsx (1)
26-26: LGTM! Clean styling and routing enhancements.The className prop is properly threaded through all rendering paths, and the computeSize routing logic correctly directs users to the compute-and-disk settings page. The implementation maintains consistency with existing patterns.
Also applies to: 42-42, 67-69, 87-87, 99-99, 113-113
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx (1)
20-251: Component structure is reasonable for its purpose.At 251 lines, this component approaches the upper guideline of 200-300 lines. However, the structure is appropriate given that it orchestrates multiple distinct eligibility checks with early returns. Each conditional block is a self-contained warning, making the logic clear despite the length.
If more eligibility conditions are added in the future, consider extracting a helper function to render common Admonition patterns with actions.
| const onSubmit = async () => { | ||
| const regionKey = AWS_REGIONS[selectedRegion as AWS_REGIONS_KEYS].code | ||
| if (!projectRef) return console.error('Project is required') | ||
| if (!regionKey) return toast.error('Unable to deploy replica: Unsupported region selected') | ||
|
|
||
| const primary = data?.find((db) => db.identifier === projectRef) | ||
| setUpReplica({ projectRef, region: regionKey as Region, size: primary?.size ?? 't4g.small' }) | ||
| } |
There was a problem hiding this comment.
Replace console.error with proper error handling.
Line 63 uses console.error which is inappropriate for user-facing errors. While this branch should be unreachable due to the guard conditions, it's better to provide user feedback.
🔎 Proposed fix
- if (!projectRef) return console.error('Project is required')
+ if (!projectRef) {
+ toast.error('Unable to deploy replica: Project reference not found')
+ return
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const onSubmit = async () => { | |
| const regionKey = AWS_REGIONS[selectedRegion as AWS_REGIONS_KEYS].code | |
| if (!projectRef) return console.error('Project is required') | |
| if (!regionKey) return toast.error('Unable to deploy replica: Unsupported region selected') | |
| const primary = data?.find((db) => db.identifier === projectRef) | |
| setUpReplica({ projectRef, region: regionKey as Region, size: primary?.size ?? 't4g.small' }) | |
| } | |
| const onSubmit = async () => { | |
| const regionKey = AWS_REGIONS[selectedRegion as AWS_REGIONS_KEYS].code | |
| if (!projectRef) { | |
| toast.error('Unable to deploy replica: Project reference not found') | |
| return | |
| } | |
| if (!regionKey) return toast.error('Unable to deploy replica: Unsupported region selected') | |
| const primary = data?.find((db) => db.identifier === projectRef) | |
| setUpReplica({ projectRef, region: regionKey as Region, size: primary?.size ?? 't4g.small' }) | |
| } |
🤖 Prompt for AI Agents
In
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx
around lines 61 to 68, the onSubmit branch currently calls
console.error('Project is required'); replace that with user-facing error
handling: call toast.error('Project is required') (so the user sees feedback)
and return early; optionally keep a console.error or sentry.captureMessage for
telemetry if you want dev visibility, but do not leave console.error as the only
notification.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx (1)
150-199: Consider extracting refetch interval check to descriptive variable.The condition
refetchInterval === falseis repeated three times. Per coding guidelines, extracting this to a descriptive boolean variable would improve readability.💡 Suggested refactor
Add at the beginning of the component (after line 37):
maxNumberOfReplicas, } = useCheckEligibilityDeployReplica() +const isWaitingToEnableBackups = refetchInterval === false + const { data: projectDetail, isSuccess: isProjectDetailSuccess } = useProjectDetailQuery(Then use throughout the block:
type="warning" title={ - refetchInterval === false + isWaitingToEnableBackups ? 'Physical backups are required to deploy replicas' : 'Physical backups are currently being enabled' } > - {refetchInterval === false ? ( + {isWaitingToEnableBackups ? ( <> <p> Physical backups are used under the hood to spin up read replicas for your project. ... - {refetchInterval === false && ( + {isWaitingToEnableBackups && ( <div className="flex items-center gap-x-2 mt-2">As per coding guidelines, use consistent naming conventions for boolean variables with
isprefix for state/identity checks.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx(1 hunks)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx
🧰 Additional context used
📓 Path-based instructions (2)
apps/studio/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/studio-best-practices.mdc)
apps/studio/**/*.{ts,tsx}: Assign complex conditions to descriptive variables instead of using multiple conditions in a single expression
Use consistent naming conventions for boolean variables:isprefix for state/identity,hasprefix for possession,canprefix for capability/permission,shouldprefix for conditional behavior
Derive boolean state from existing state instead of storing it separately
Use early returns for guard clauses instead of deeply nested conditionals
Extract complex logic into custom hooks when logic becomes reusable or complex
Return objects from custom hooks instead of arrays for better extensibility and clearer API
Use discriminated unions for complex state management instead of multiple independent state fields
Avoid type casting (e.g.,as any,as Type); instead validate values at runtime using zod schemas
Files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
apps/studio/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/studio-best-practices.mdc)
apps/studio/**/*.tsx: Components should ideally be under 200-300 lines; break down large components with multiple distinct UI sections, complex conditional rendering, or multiple unrelated useState hooks
Extract repeated JSX patterns into reusable components instead of copying similar JSX blocks
Use consistent loading/error/success pattern: handle loading state first with early returns, then error state, then empty state, then render success state
Keep state as local as possible and only lift up when needed
Group related state using objects or reducers instead of multiple useState calls, preferring react-hook-form for form state management
Name event handlers consistently: useonprefix for prop callbacks andhandleprefix for internal handlers
Avoid inline arrow functions for expensive operations; use useCallback to maintain stable function references
Use appropriate conditional rendering patterns: && for simple show/hide, ternary for binary choice, early returns or extracted components for multiple conditions
Avoid nested ternaries in JSX; use separate conditions or early returns instead
Use useMemo for expensive computations when the computation is genuinely expensive and the value is passed to memoized children
Define prop interfaces explicitly for React components with proper typing of props and callback handlers
Files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
🧠 Learnings (7)
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use Admonition component to alert users of important actions or restrictions
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : When doing a mutation, always use the mutate function with onSuccess and onError callbacks that include toast.success and toast.error
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use mutateAsync only if the mutation is part of multiple async actions, wrapping the call with try/catch block and adding toast.success and toast.error
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-11T16:46:03.692Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/e2e-testing.mdc:0-0
Timestamp: 2025-12-11T16:46:03.692Z
Learning: Applies to e2e/studio/**/*.{ts,spec.ts} : Dismiss toasts before interacting with UI elements as they can overlay buttons and block interactions
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/**/*.{ts,tsx} : Use _Shadcn_ suffixed components (e.g., Input_Shadcn_, Button_Shadcn_) from the ui package where possible
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : When submit button is outside the form, add a formId variable outside the component, set it as id on form element and form prop on the button
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
📚 Learning: 2025-12-12T05:20:17.409Z
Learnt from: joshenlim
Repo: supabase/supabase PR: 41258
File: apps/studio/pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx:9-9
Timestamp: 2025-12-12T05:20:17.409Z
Learning: In apps/studio/**/*.{ts,tsx}, use named imports for DefaultLayout: import { DefaultLayout } from 'components/layouts/DefaultLayout' instead of default import. This is the new practice being adopted across the studio app.
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
🧬 Code graph analysis (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx (8)
apps/studio/hooks/misc/useSelectedOrganization.ts (1)
useSelectedOrganizationQuery(5-21)apps/studio/hooks/misc/useSelectedProject.ts (1)
useSelectedProjectQuery(5-17)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (1)
useCheckEligibilityDeployReplica(14-83)apps/studio/data/projects/project-detail-query.ts (1)
useProjectDetailQuery(42-66)packages/ui-patterns/src/admonition.tsx (1)
Admonition(83-180)apps/studio/lib/constants/index.ts (1)
DOCS_URL(48-48)apps/studio/components/interfaces/Support/SupportLink.tsx (1)
SupportLink(7-28)apps/studio/components/ui/UpgradePlanButton.tsx (1)
UpgradePlanButton(34-117)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test
- GitHub Check: test (1)
- GitHub Check: typecheck
🎭 Playwright Test ResultsDetails
Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
charislam
left a comment
There was a problem hiding this comment.
Tested locally as described!
- Saw admonition for compute size too small
- Saw admonition for no physical backups
- Successfully created read replica
| <DialogTrigger> | ||
| <p className={cn(InlineLinkClassName, 'text-sm text-foreground-light cursor-pointer')}> |
There was a problem hiding this comment.
| <DialogTrigger> | |
| <p className={cn(InlineLinkClassName, 'text-sm text-foreground-light cursor-pointer')}> | |
| <DialogTrigger asChild> | |
| <button className={cn(InlineLinkClassName, 'text-sm text-foreground-light cursor-pointer')}> |
might have to tweak styling, but this will give better a11y semantics
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (1)
32-36: Consider addingcursor-pointerto button className.A past review comment suggested including
cursor-pointerfor better UX consistency. While buttons typically have pointer cursor by default, explicitly adding the class ensures consistent styling across the application.🔎 Suggested addition
- <button className={cn(InlineLinkClassName, 'text-sm text-foreground-light')}> + <button className={cn(InlineLinkClassName, 'text-sm text-foreground-light cursor-pointer')}>
🧹 Nitpick comments (2)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (2)
24-28: Consider handling loading and error states from queries.Per coding guidelines, components should handle loading state first with early returns, then error state. While the Dialog is user-triggered and data may already be loaded, adding guards would prevent showing incomplete data if queries are still loading or have failed.
🔎 Suggested pattern
export const ReadReplicaPricingDialog = () => { - const { data: project } = useSelectedProjectQuery() + const { data: project, isLoading: isProjectLoading } = useSelectedProjectQuery() const { compute, disk, iops, throughput } = useGetReplicaCost() const showNewDiskManagementUI = project?.cloud_provider === 'AWS' + + // Optionally guard against missing data + const hasRequiredData = project && compute && disk && iops && throughputThen conditionally disable or show loading state in the DialogContent if needed.
46-94: Optional: Consider extracting the AWS pricing table into a separate component.The AWS-specific pricing table (lines 46-94) could be extracted into a separate component like
AwsReplicaPricingTable. This would improve modularity and make the main component easier to scan, though the current size (~90 lines) is well within acceptable limits.Example structure
// Separate file or within same file const AwsReplicaPricingTable = ({ compute, disk, iops, throughput }: { compute: ReturnType<typeof useGetReplicaCost>['compute'] disk: ReturnType<typeof useGetReplicaCost>['disk'] iops: ReturnType<typeof useGetReplicaCost>['iops'] throughput: ReturnType<typeof useGetReplicaCost>['throughput'] }) => { return ( <> <p className="text-foreground-light text-sm mb-2">...</p> <Table>...</Table> </> ) }Then use:
<AwsReplicaPricingTable compute={compute} disk={disk} iops={iops} throughput={throughput} />
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/studio/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/studio-best-practices.mdc)
apps/studio/**/*.{ts,tsx}: Assign complex conditions to descriptive variables instead of using multiple conditions in a single expression
Use consistent naming conventions for boolean variables:isprefix for state/identity,hasprefix for possession,canprefix for capability/permission,shouldprefix for conditional behavior
Derive boolean state from existing state instead of storing it separately
Use early returns for guard clauses instead of deeply nested conditionals
Extract complex logic into custom hooks when logic becomes reusable or complex
Return objects from custom hooks instead of arrays for better extensibility and clearer API
Use discriminated unions for complex state management instead of multiple independent state fields
Avoid type casting (e.g.,as any,as Type); instead validate values at runtime using zod schemas
Files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
apps/studio/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/studio-best-practices.mdc)
apps/studio/**/*.tsx: Components should ideally be under 200-300 lines; break down large components with multiple distinct UI sections, complex conditional rendering, or multiple unrelated useState hooks
Extract repeated JSX patterns into reusable components instead of copying similar JSX blocks
Use consistent loading/error/success pattern: handle loading state first with early returns, then error state, then empty state, then render success state
Keep state as local as possible and only lift up when needed
Group related state using objects or reducers instead of multiple useState calls, preferring react-hook-form for form state management
Name event handlers consistently: useonprefix for prop callbacks andhandleprefix for internal handlers
Avoid inline arrow functions for expensive operations; use useCallback to maintain stable function references
Use appropriate conditional rendering patterns: && for simple show/hide, ternary for binary choice, early returns or extracted components for multiple conditions
Avoid nested ternaries in JSX; use separate conditions or early returns instead
Use useMemo for expensive computations when the computation is genuinely expensive and the value is passed to memoized children
Define prop interfaces explicitly for React components with proper typing of props and callback handlers
Files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
🧠 Learnings (2)
📚 Learning: 2025-12-11T17:04:40.037Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.037Z
Learning: Applies to apps/studio/components/**/*.{ts,tsx} : Use Calendar inside Popover_Shadcn_ with a trigger button for date picker form fields
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
📚 Learning: 2025-12-12T05:20:17.409Z
Learnt from: joshenlim
Repo: supabase/supabase PR: 41258
File: apps/studio/pages/project/[ref]/storage/vectors/buckets/[bucketId].tsx:9-9
Timestamp: 2025-12-12T05:20:17.409Z
Learning: In apps/studio/**/*.{ts,tsx}, use named imports for DefaultLayout: import { DefaultLayout } from 'components/layouts/DefaultLayout' instead of default import. This is the new practice being adopted across the studio app.
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx
🧬 Code graph analysis (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (6)
apps/studio/hooks/misc/useSelectedProject.ts (1)
useSelectedProjectQuery(5-17)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.ts (1)
useGetReplicaCost(14-79)packages/ui/src/components/shadcn/ui/dialog.tsx (8)
Dialog(223-223)DialogTrigger(232-232)DialogContent(225-225)DialogHeader(228-228)DialogTitle(231-231)DialogSectionSeparator(230-230)DialogSection(229-229)DialogFooter(227-227)blocks/vue/registry/default/lib/utils.ts (1)
cn(5-7)apps/studio/components/ui/InlineLink.tsx (1)
InlineLinkClassName(14-15)apps/studio/lib/constants/index.ts (1)
DOCS_URL(48-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (1)
- GitHub Check: test
- GitHub Check: typecheck
🔇 Additional comments (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaPricingDialog.tsx (1)
39-39: Verify the intent ofaria-describedby={undefined}.Explicitly setting
aria-describedbytoundefinedis uncommon. This may be intentional to suppress Dialog's default behavior when no description section exists, but please confirm this is the desired accessibility pattern.
Context
Related project: https://linear.app/supabase/project/unify-read-replicas-with-replication-page-f0feb52cf161/overview
Implements creation of read replicas from the replication UI page of the Database Section
It's the same thing as per what was on the project settings -> infrastructure page, also has all the relevant warnings.
To test
Note that the changes here only supports creating read replicas, but not showing replicas in the replication UI yet, so I reckon it might be better to test locally
Firstly - you'll want to change
unifiedReplicationtofalseinInfrastructureInfoso that you can verify that the replicas are getting deployed. I won't go too much into detail on how to ensure that you project is eligible to deploy read replicas as I'd also like to verify that all the necessary warnings / CTAs are in place to guide the users to land in an eligible state, so let me know if anything's missing 🙏Summary by CodeRabbit
New Features
UX / Warnings
UI Improvements
✏️ Tip: You can customize this high-level summary in your review settings.