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. |
WalkthroughUnifies replication UI to render read replicas and destinations together, introduces ReadReplicaRow, adds polling and per-replica status handling, adds optimistic cache updates in replica modals, small UI/text tweaks (dynamic destination loading text, icon/layout changes), and increases status polling interval to 10s. Changes
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In @apps/studio/components/interfaces/Database/Replication/Destinations.tsx:
- Line 141: Rename the misspelled variable fixedStatues to fixedStatuses and
update all references to it (e.g., where it’s used around the component —
previously referenced on line ~149) so the identifier matches the corrected
name; ensure any exports, imports, or usages within the same file (such as in
rendering or logic) are updated to fixedStatuses to avoid undefined-variable
errors.
- Line 231: The table rendering condition currently checks only hasDestinations,
causing the empty-state to show when unifiedReplication is true but only read
replicas exist; update the ternary condition in Destinations.tsx to render the
table when there are destinations OR when unifiedReplication is enabled and
there are read replicas (e.g., change "hasDestinations" to "hasDestinations ||
(unifiedReplication && (readReplicas?.length > 0))" or use an existing
hasReadReplicas boolean) so replicas are shown under the unified replication
flag.
In @apps/studio/components/interfaces/Database/Replication/PipelineStatus.tsx:
- Around line 128-132: The conditional checking pipelineStatus?.name uses
lowercase literals ('unknown','failed') while PipelineStatusName values are
uppercase (e.g., FAILED); update the check in the JSX so it matches the enum
strings consistently — either compare against PipelineStatusName.FAILED and
PipelineStatusName.UNKNOWN (preferred) or normalize the value with
.toLowerCase() and compare to lowercase literals; ensure you reference
pipelineStatus?.name and pipelineLogsUrl/InlineLink unchanged so the log link
renders when the pipeline is FAILED or UNKNOWN.
In
@apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx:
- Around line 91-102: The switch in statusLabel is missing an explicit case for
REPLICA_STATUS.RESTORING, so replicas with RESTORING fall through to the default
'Unhealthy'; update the switch (the statusLabel logic) to add a case for
REPLICA_STATUS.RESTORING that returns a proper label like 'Restoring' (also
verify consistency with isInTransition which includes RESTORING near line 67).
🧹 Nitpick comments (5)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsx (1)
32-52: Extract duplicated mapping logic.Both
setQueriesDatacalls contain identical mapping logic to update the replica status. This violates the DRY principle mentioned in the coding guidelines.♻️ Proposed refactor to eliminate duplication
+ const updateReplicaStatus = (old: Database[]) => { + return old.map((x) => { + if (x.identifier === selectedReplica?.identifier) { + return { ...x, status: REPLICA_STATUS.RESTARTING } + } else { + return x + } + }) + } + // [Joshen] Temporarily optimistic rendering until API supports immediate status update - queryClient.setQueriesData({ queryKey: replicaKeys.list(ref) }, (old: Database[]) => { - const updatedReplicas = old.map((x) => { - if (x.identifier === selectedReplica?.identifier) { - return { ...x, status: REPLICA_STATUS.RESTARTING } - } else { - return x - } - }) - return updatedReplicas - }) + queryClient.setQueriesData({ queryKey: replicaKeys.list(ref) }, updateReplicaStatus) - queryClient.setQueriesData({ queryKey: replicaKeys.statuses(ref) }, (old: Database[]) => { - const updatedReplicas = old.map((x) => { - if (x.identifier === selectedReplica?.identifier) { - return { ...x, status: REPLICA_STATUS.RESTARTING } - } else { - return x - } - }) - return updatedReplicas - }) + queryClient.setQueriesData({ queryKey: replicaKeys.statuses(ref) }, updateReplicaStatus)apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx (1)
28-28: Remove redundant optional chaining.The
onSuccessprop is now required (non-optional), but line 48 still uses optional chaining (onSuccess?.()). While this is safe at runtime, it creates unnecessary confusion.♻️ Proposed fix for consistency
Since
onSuccessis now required, update line 48 to use direct invocation:- onSuccess?.() + onSuccess()apps/studio/components/interfaces/Database/Replication/PipelineStatus.tsx (1)
110-122: Consider extracting Badge variant logic to avoid nested ternaries.Per coding guidelines, nested ternaries in JSX should be avoided. Extract the variant determination to a variable or helper.
🔧 Suggested refactor
+ const badgeVariant = + type === 'failure' + ? 'destructive' + : type === 'warning' + ? 'warning' + : type === 'success' + ? 'success' + : 'default' + {isSuccess && ( <Tooltip> <TooltipTrigger asChild> <div className="flex items-center gap-x-2"> - <Badge - variant={ - type === 'failure' - ? 'destructive' - : type === 'warning' - ? 'warning' - : type === 'success' - ? 'success' - : 'default' - } - > + <Badge variant={badgeVariant}> {label} </Badge>Alternatively, include the variant in
getStatusConfig()return value directly to co-locate the logic with the status determination.apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx (1)
81-81: Unused destructured variablesetRequestStatus.
setRequestStatusis destructured fromusePipelineRequestStatus()but never used in this component.🧹 Remove unused variable
- const { getRequestStatus, updatePipelineStatus, setRequestStatus } = usePipelineRequestStatus() + const { getRequestStatus, updatePipelineStatus } = usePipelineRequestStatus()apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (1)
30-36: Interface name conflicts with component name.The interface
ReadReplicaRowhas the same name as the component, which can cause confusion and potential TypeScript issues. Consider renaming toReadReplicaRowProps.🔧 Suggested fix
-interface ReadReplicaRow { +interface ReadReplicaRowProps { replica: Database replicaStatus?: DatabaseStatus onUpdateReplica: () => void } -export const ReadReplicaRow = ({ replica, replicaStatus, onUpdateReplica }: ReadReplicaRow) => { +export const ReadReplicaRow = ({ replica, replicaStatus, onUpdateReplica }: ReadReplicaRowProps) => {
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/PipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/studio/components/interfaces/Database/Replication/Replication.constants.tsapps/studio/components/interfaces/Database/Replication/RowMenu.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsxapps/studio/data/read-replicas/replica-remove-mutation.ts
💤 Files with no reviewable changes (1)
- apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.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/DestinationForm/index.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/RowMenu.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/data/read-replicas/replica-remove-mutation.tsapps/studio/components/interfaces/Database/Replication/Replication.constants.tsapps/studio/components/interfaces/Database/Replication/PipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.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/DestinationForm/index.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/RowMenu.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/components/interfaces/Database/Replication/PipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx
🧠 Learnings (13)
📚 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} : Show loading states on submit buttons using the loading prop
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.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/DestinationForm/index.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/RowMenu.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/data/read-replicas/replica-remove-mutation.tsapps/studio/components/interfaces/Database/Replication/Replication.constants.tsapps/studio/components/interfaces/Database/Replication/PipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx
📚 Learning: 2026-01-02T05:58:55.226Z
Learnt from: meGauravJain
Repo: supabase/supabase PR: 41658
File: apps/studio/components/interfaces/Connect/content/prisma/content.tsx:70-85
Timestamp: 2026-01-02T05:58:55.226Z
Learning: In Prisma configuration or related connection setup code, prefer the environment variable name DIRECT_URL for direct/non-pooled database connections instead of DATABASE_URL_UNPOOLED, per Prisma documentation. Update code that reads database connection strings to use DIRECT_URL where applicable, and document why this is preferred (explicit, documented behavior). Ensure your environment provides DIRECT_URL when using direct connections and fallback handling if needed.
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/studio/components/interfaces/Database/Replication/RowMenu.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/data/read-replicas/replica-remove-mutation.tsapps/studio/components/interfaces/Database/Replication/Replication.constants.tsapps/studio/components/interfaces/Database/Replication/PipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/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} : Contain tables within a card
Applied to files:
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.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/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsxapps/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/pages/**/*.{ts,tsx} : Add table actions to primary and secondary actions of PageLayout if table is main content of a page without search or filters
Applied to files:
apps/studio/components/interfaces/Database/Replication/RowMenu.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.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} : Add table actions to the right of ScaffoldSectionTitle if table is main content of a page section without search or filters
Applied to files:
apps/studio/components/interfaces/Database/Replication/RowMenu.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} : Place table actions above on right hand side if table has associated actions
Applied to files:
apps/studio/components/interfaces/Database/Replication/RowMenu.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/DestinationRow.tsxapps/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 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/DestinationRow.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 generic ui table components for most tables
Applied to files:
apps/studio/components/interfaces/Database/Replication/DestinationRow.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} : Import primitive UI components from packages/ui package for use across apps, not from individual component files
Applied to files:
apps/studio/components/interfaces/Database/Replication/PipelineStatus.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 : Use consistent loading/error/success pattern: handle loading state first with early returns, then error state, then empty state, then render success state
Applied to files:
apps/studio/components/interfaces/Database/Replication/PipelineStatus.tsx
🧬 Code graph analysis (5)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsx (1)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts (1)
REPLICA_STATUS(20-26)
apps/studio/components/interfaces/Database/Replication/Destinations.tsx (4)
apps/studio/data/read-replicas/replicas-status-query.ts (1)
useReadReplicasStatusesQuery(44-57)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts (1)
REPLICA_STATUS(20-26)apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (1)
ReadReplicaRow(36-189)apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx (1)
DestinationRow(51-270)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx (1)
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/index.tsx (1)
ReadReplicaForm(32-135)
apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx (1)
apps/studio/data/storage/analytics-buckets-query.ts (1)
AnalyticsBucket(12-12)
apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (3)
apps/studio/data/read-replicas/replicas-status-query.ts (1)
DatabaseStatus(16-16)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts (1)
REPLICA_STATUS(20-26)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsx (1)
RestartReplicaConfirmationModal(18-93)
⏰ 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 (10)
apps/studio/data/read-replicas/replica-remove-mutation.ts (1)
46-46: Status invalidation properly supports replica removal polling.Adding
replicaKeys.statuses(projectRef)invalidation ensures status polling reflects replica removals, aligning with the long-polling requirements.apps/studio/components/interfaces/Database/Replication/RowMenu.tsx (1)
184-184: LGTM! Visual styling refinement.The removal of the red stroke styling from the Trash icon aligns with the broader UI modernization efforts in this PR.
apps/studio/components/interfaces/Database/Replication/Replication.constants.ts (1)
1-1: LGTM! Polling frequency adjustment.The increase from 5 to 10 seconds is well-documented and aligns with the updated status polling behavior introduced across the replication UI in this PR.
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsx (1)
71-71: LGTM! Appropriate variant for restart action.The
variant="warning"is suitable for a restart operation that will cause temporary downtime.apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx (1)
652-652: LGTM! Improved loading message clarity.The dynamic loading message correctly reflects whether the form is updating or creating a destination, improving user feedback during the operation.
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx (1)
29-29: LGTM!The new
onSuccessCreateReadReplicacallback is properly typed as optional and correctly forwarded toReadReplicaForm. The naming follows theonprefix convention for prop callbacks.Also applies to: 37-37, 74-74
apps/studio/components/interfaces/Database/Replication/Destinations.tsx (2)
176-185: LGTM on the filter clear action.Clean implementation of the clear filter button with proper conditional rendering.
154-155: The length comparison appears correct.
statusesis fetched from the/databases-statusesendpoint (not a replicas-specific endpoint), and the code at line 254 searches for status entries by matchingidentifieragainst replicas—suggestingstatusesincludes entries for all databases, including the primary. The comparisonstatuses.length !== databases.lengthtriggers a refetch when the arrays have different lengths, which correctly detects when replicas have been added or removed.Likely an incorrect or invalid review comment.
apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx (1)
149-233: LGTM on the table row restructure.The new
TableRow/TableCellstructure aligns well with the unified table layout. Loading states, icons, and action controls are properly implemented.apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (1)
105-188: LGTM on the component structure and modal integration.The table row layout is consistent with
DestinationRow, loading states are properly handled, and the confirmation modals correctly triggeronUpdateReplicato refresh polling after actions.
🎭 Playwright Test ResultsDetails
Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In @apps/studio/components/interfaces/Database/Replication/Destinations.tsx:
- Line 143: Rename the typo'd variable fixedStatues to fixedStatuses and update
all references to that identifier in this file (e.g., where fixedStatues is used
later around the statuses mapping/usage) so the code compiles and reads
correctly; ensure any import/exports, destructuring, or JSX props that reference
fixedStatues are also renamed to fixedStatuses to keep consistency.
- Around line 299-311: The "No results" row is incorrectly gated by
hasDestinations, preventing the empty-filter message when only replicas exist;
update the conditional in the table render (the block using isLoading,
filteredDestinations, filteredReplicas, hasDestinations) to remove the
hasDestinations requirement so the message shows whenever !isLoading &&
filteredDestinations.length === 0 && filteredReplicas.length === 0 (or
alternatively replace hasDestinations with (hasDestinations ||
unifiedReplication) if you want to explicitly include unified replication mode);
adjust the condition around the TableRow/TableCell rendering in Destinations.tsx
accordingly.
In
@apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx:
- Around line 93-104: The statusLabel switch in ReadReplicaRow.tsx is missing a
case for REPLICA_STATUS.RESTORING, so RESTORING currently falls through to the
default 'Unhealthy'; update the switch in the statusLabel function to add an
explicit case for REPLICA_STATUS.RESTORING (e.g., return 'Restoring') to match
its inclusion in isInTransition and ensure consistent user-facing labels.
In
@apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx:
- Around line 29-40: The optimistic update passed to queryClient.setQueriesData
(for replicaKeys.list(projectRef)) assumes the cached data `old` is defined and
uses `.map()`, which can throw; add a guard to return `old` or an empty array
when `old` is falsy before mapping. Inside the map, simplify the return by
removing the unnecessary else: if x.identifier === selectedReplica?.identifier
return a copy with status set to REPLICA_STATUS.GOING_DOWN, otherwise just
return x. Ensure you reference the existing symbols: queryClient.setQueriesData,
replicaKeys.list, old, selectedReplica, and REPLICA_STATUS.GOING_DOWN.
🧹 Nitpick comments (1)
apps/studio/components/interfaces/Database/Replication/Destinations.tsx (1)
176-176: Update filter placeholder to reflect replica filtering.The filter placeholder says "Filter destinations" but now filters both destinations and replicas when
unifiedReplicationis enabled. Consider updating to "Filter" or "Filter destinations and replicas" for accuracy.📝 Suggested improvement
- placeholder="Filter destinations" + placeholder={unifiedReplication ? "Filter destinations and replicas" : "Filter destinations"}Or simply:
- placeholder="Filter destinations" + placeholder="Filter"
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.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/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.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/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx
🧠 Learnings (3)
📚 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} : Contain tables within a card
Applied to files:
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.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/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx
📚 Learning: 2026-01-02T05:58:55.226Z
Learnt from: meGauravJain
Repo: supabase/supabase PR: 41658
File: apps/studio/components/interfaces/Connect/content/prisma/content.tsx:70-85
Timestamp: 2026-01-02T05:58:55.226Z
Learning: In Prisma configuration or related connection setup code, prefer the environment variable name DIRECT_URL for direct/non-pooled database connections instead of DATABASE_URL_UNPOOLED, per Prisma documentation. Update code that reads database connection strings to use DIRECT_URL where applicable, and document why this is preferred (explicit, documented behavior). Ensure your environment provides DIRECT_URL when using direct connections and fallback handling if needed.
Applied to files:
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx
🧬 Code graph analysis (2)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx (1)
apps/studio/data/read-replicas/replica-remove-mutation.ts (2)
removeReadReplica(14-25)useReadReplicaRemoveMutation(29-61)
apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (3)
apps/studio/data/read-replicas/replicas-status-query.ts (1)
DatabaseStatus(16-16)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts (1)
REPLICA_STATUS(20-26)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsx (1)
RestartReplicaConfirmationModal(18-93)
⏰ 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 (2)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx (2)
1-1: LGTM!The new imports are necessary for the optimistic cache update functionality and are used appropriately.
Also applies to: 4-4, 10-10
24-24: LGTM!Correct usage of the React Query hook for accessing the query client.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apps/studio/components/interfaces/Database/Replication/Destinations.tsx (2)
139-168: Consider extracting polling logic into a custom hook.This effect handles multiple responsibilities: checking transition states, refetching databases, and controlling polling intervals. Per coding guidelines, complex logic that could be reusable should be extracted into custom hooks.
♻️ Potential custom hook extraction
Consider extracting this into a custom hook like
useReplicaStatusPolling:const useReplicaStatusPolling = ({ statuses, databases, isSuccessReplicasStatuses, refetchDatabases, }) => { const [statusRefetchInterval, setStatusRefetchInterval] = useState<number | false>(5000) useEffect(() => { // ... existing polling logic }, [databases.length, isSuccessReplicasStatuses, refetchDatabases, statuses]) return { statusRefetchInterval, setStatusRefetchInterval } }This would improve reusability if similar polling logic is needed elsewhere and make the component more focused on rendering.
299-311: Extract complex condition to descriptive variable.The condition on line 302 combines multiple checks. Per coding guidelines, complex conditions should be assigned to descriptive variables for better readability.
♻️ Suggested refactor
+ const shouldShowNoResults = + !isLoading && + filteredDestinations.length === 0 && + filteredReplicas.length === 0 && + ((unifiedReplication && hasReplicas) || hasDestinations) + - {!isLoading && - filteredDestinations.length === 0 && - filteredReplicas.length === 0 && - ((unifiedReplication && hasReplicas) || hasDestinations) && ( + {shouldShowNoResults && ( <TableRow> <TableCell colSpan={5}> <p>No results found</p> <p className="text-foreground-light"> Your search for "{filterString}" did not return any results </p> </TableCell> </TableRow> )}apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (2)
76-107: Consider extracting status label logic to a utility function.The status label computation is comprehensive but spans 30+ lines. Per coding guidelines for extracting complex logic, this could be moved to a shared utility function for better reusability and testability.
♻️ Potential utility function
Consider creating a utility function in a separate file:
// replica-status.utils.ts export const getReplicaStatusLabel = ( status: string, initStatus?: ReplicaInitializationStatus ): string => { if ( initStatus === ReplicaInitializationStatus.InProgress || status === REPLICA_STATUS.COMING_UP || status === REPLICA_STATUS.UNKNOWN || status === REPLICA_STATUS.INIT_READ_REPLICA ) { return 'Coming up' } if ( initStatus === ReplicaInitializationStatus.Failed || status === REPLICA_STATUS.INIT_READ_REPLICA_FAILED ) { return 'Failed' } switch (status) { case REPLICA_STATUS.GOING_DOWN: return 'Going down' case REPLICA_STATUS.RESTARTING: return 'Restarting' case REPLICA_STATUS.RESIZING: return 'Resizing' case REPLICA_STATUS.RESTORING: return 'Restoring' case REPLICA_STATUS.ACTIVE_HEALTHY: return 'Healthy' default: return 'Unhealthy' } }Then use it in the component:
const statusLabel = useMemo( () => getReplicaStatusLabel(status, initStatus), [status, initStatus] )This improves testability and could be reused if status labels are needed elsewhere.
140-148: Simplify lag cell rendering condition.The condition
isErrorLag || status !== REPLICA_STATUS.ACTIVE_HEALTHYcould be assigned to a descriptive variable per coding guidelines for better readability.♻️ Suggested refactor
+ const shouldShowLagPlaceholder = + isErrorLag || status !== REPLICA_STATUS.ACTIVE_HEALTHY + <TableCell> - {isErrorLag || status !== REPLICA_STATUS.ACTIVE_HEALTHY ? ( + {shouldShowLagPlaceholder ? ( <Minus size={18} className="text-foreground-lighter" /> ) : isLoadingLag ? ( <ShimmeringLoader /> ) : ( <p>{lagDuration}s</p> )} </TableCell>
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.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/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.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/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx
🧠 Learnings (3)
📚 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} : Contain tables within a card
Applied to files:
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.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/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx
📚 Learning: 2026-01-02T05:58:55.226Z
Learnt from: meGauravJain
Repo: supabase/supabase PR: 41658
File: apps/studio/components/interfaces/Connect/content/prisma/content.tsx:70-85
Timestamp: 2026-01-02T05:58:55.226Z
Learning: In Prisma configuration or related connection setup code, prefer the environment variable name DIRECT_URL for direct/non-pooled database connections instead of DATABASE_URL_UNPOOLED, per Prisma documentation. Update code that reads database connection strings to use DIRECT_URL where applicable, and document why this is preferred (explicit, documented behavior). Ensure your environment provides DIRECT_URL when using direct connections and fallback handling if needed.
Applied to files:
apps/studio/components/interfaces/Database/Replication/Destinations.tsxapps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsxapps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx
🧬 Code graph analysis (2)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx (2)
apps/studio/data/read-replicas/replica-remove-mutation.ts (1)
removeReadReplica(14-25)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts (1)
REPLICA_STATUS(20-26)
apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (4)
apps/studio/data/read-replicas/replicas-status-query.ts (1)
DatabaseStatus(16-16)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts (1)
REPLICA_STATUS(20-26)packages/ui/src/components/shadcn/ui/badge.tsx (1)
Badge(43-43)apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal.tsx (1)
RestartReplicaConfirmationModal(18-93)
⏰ 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). (4)
- GitHub Check: typecheck
- GitHub Check: format
- GitHub Check: test
- GitHub Check: test (1)
🔇 Additional comments (9)
apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx (3)
1-10: LGTM on imports and setup.The new imports and
queryClientinitialization are correctly placed and follow existing patterns in the codebase.
44-58: LGTM on mutation flow and guard clauses.The success callback flow (toast → optimistic update → callbacks) is well-structured. Guard clauses in
onConfirmRemoveuse early returns appropriately per coding guidelines.
29-42: The optimistic update logic is sound.REPLICA_STATUS.GOING_DOWNis properly defined in the constants and safely used throughout the codebase.apps/studio/components/interfaces/Database/Replication/Destinations.tsx (3)
53-53: Verify polling interval matches PR requirements.The status refetch interval is initialized to
5000(5 seconds), but the PR summary mentions "increases status polling interval to 10s". Lines 266 and 347 also use5000. Please confirm whether 5 seconds is the intended interval or if this should be updated to 10000 milliseconds.
182-191: LGTM: Clean implementation of clear button.The clear button in the filter input follows good patterns with conditional rendering and proper button props. Nice touch for UX.
237-315: LGTM: Unified table rendering with proper Card wrapper.The table rendering correctly:
- Uses Card wrapper as per coding guidelines and learnings
- Handles both replicas and destinations in unified view
- Properly conditionalizes rendering based on feature flag and data availability
- Addresses past review feedback on rendering conditions
apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaRow.tsx (3)
44-55: LGTM: Proper conditional query usage.The lag query is correctly enabled only when the replica status is
ACTIVE_HEALTHY, preventing unnecessary API calls. This is a good optimization pattern.
109-178: LGTM: Well-structured table row with proper actions.The table row rendering is clean and follows good patterns:
- Proper use of UI components (TableCell, Badge, DropdownMenu)
- Conditional rendering with appropriate loading and error states
- Badge variant correctly maps to status semantics (success for Healthy, destructive for Failed, default otherwise)
- Action dropdown with clear options
180-191: LGTM: Modal integration follows correct pattern.Both confirmation modals are properly wired:
- Conditionally rendered based on local state
- Correct use of
selectedReplicaprop (passingreplicawhen modal should show,undefinedotherwise)onSuccesscallback correctly invokesonUpdateReplicato resume pollingonCancelproperly resets the show state
Braintrust eval report
|
Context
Part of unifying read replicas into database/replication page, changes in this PR include
To test
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Style
✏️ Tip: You can customize this high-level summary in your review settings.