Repository navigation
feat(etl): Implement batch rollback - #41552
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. |
WalkthroughAdds dialog-driven single and batch restart flows and an error-details dialog; removes legacy retry/reset components; updates rollback mutation to accept multi-table targets and restart pipelines on success; expands API/types with rollback and marketplace eligibility schemas; assorted UI/type tweaks. Changes
Sequence DiagramsequenceDiagram
autonumber
participant User
participant UI as Browser/UI
participant Mutation as useRollbackTablesMutation
participant API as Backend API
participant Restart as RestartPipelineHelper
participant Cache as Query Cache
User->>UI: Open restart dialog & confirm
UI->>UI: validate projectRef, compute target (single/all/errored)
UI->>Mutation: trigger rollback(projectRef, pipelineId, target)
Mutation->>API: POST /platform/replication/{ref}/pipelines/{id}/rollback-tables
API-->>Mutation: 200 OK (rollback success)
Mutation->>Restart: restartPipeline(projectRef, pipelineId)
Restart->>API: POST /platform/replication/{ref}/pipelines/{id}/restart
API-->>Restart: 200 OK (restart success)
Mutation->>Cache: invalidate replication-related queries
Mutation-->>UI: show toast, call onRestartComplete, close dialog
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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 |
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › table-editor.spec.ts › table editor › add enums and show enums on table Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsx (1)
77-114: Unreachable code after first return statement.There are two
returnstatements in this component. The code from lines 77-114 (the Tooltip-based implementation) will never execute because the function already returns at line 75. This appears to be leftover code from a refactor.🔎 Proposed fix: Remove the unreachable code
</Dialog> ) - - return ( - <Tooltip delayDuration={0}> - <TooltipTrigger asChild> - <Button - size="tiny" - type="default" - className="w-min" - icon={<AlertCircle size={14} />} - aria-label="Show error details" - > - Show Error - </Button> - </TooltipTrigger> - <TooltipContent - side="bottom" - align="start" - className="w-[500px] max-w-[90vw] max-h-[400px] p-0 overflow-hidden" - > - <div className="flex flex-col gap-y-3 p-4 max-h-[400px] overflow-y-auto"> - {/* Error message */} - <div> - <div className="text-xs font-medium mb-2">Error</div> - <div className="bg-surface-100 rounded p-2 max-h-[250px] overflow-y-auto"> - <pre className="text-xs font-mono whitespace-pre-wrap break-words">{reason}</pre> - </div> - </div> - - {/* Solution if available */} - {solution && ( - <div> - <div className="text-xs font-medium mb-2">Solution</div> - <p className="text-xs">{solution}</p> - </div> - )} - </div> - </TooltipContent> - </Tooltip> - ) }
🧹 Nitpick comments (11)
apps/studio/data/replication/rollback-tables-mutation.ts (1)
40-42: Consider adding validation fortargetparameter.The function validates
projectRef,pipelineId, androllbackType, but omits validation fortarget. For consistency and to fail fast on invalid input, consider adding:if (!projectRef) throw new Error('Project reference is required') if (!pipelineId) throw new Error('Pipeline ID is required') if (!rollbackType) throw new Error('Rollback type is required') + if (!target) throw new Error('Target is required')packages/api-types/types/platform.d.ts (2)
8844-8870: Consider documenting valid rollback_type and target combinations.The schema defines
rollback_typeas'individual' | 'full'andtargetas a discriminated union with three types. The semantic relationship between these fields isn't immediately clear from the types alone:
- Does
individualonly pair withsingle_table?- Does
fullpair withall_errored_tablesorall_tables?If certain combinations are invalid, consider adding JSDoc comments to clarify the valid pairings, or the backend should return appropriate validation errors for invalid combinations.
11283-11310: Missing 401/403 error responses compared to similar operations.This operation only defines
200and500responses, while the similarReplicationPipelinesController_rollbackTablesoperation (hunk 15) includes401,403, and429responses. If this endpoint requires authentication, consider adding these error responses for consistency and accurate client-side error handling.apps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsx (2)
51-62: Consider using lucide-react icon instead of inline SVG.The inline SVG duplicates what's available in lucide-react (e.g.,
XCircleorAlertCircle). Using the library icon would be more consistent with the rest of the codebase.🔎 Proposed refactor
+import { XCircle } from 'lucide-react' import { useParams } from 'common' // ... other imports // Then in the JSX: - <div className="min-w-4 mt-0.5"> - <svg - xmlns="http://www.w3.org/2000/svg" - className="h-4 w-4 text-destructive-600" - viewBox="0 0 20 20" - fill="currentColor" - > - <path - fillRule="evenodd" - d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" - clipRule="evenodd" - /> - </svg> - </div> + <XCircle size={16} className="text-destructive-600 mt-0.5 shrink-0" />
7-11: UnusedtableIdprop.The
tableIdprop is declared in the interface and destructured but never used within the component. If it's no longer needed after removingResetTableButton, consider removing it from the interface.apps/studio/components/interfaces/Database/Replication/TableActionsMenu.tsx (2)
16-19: Avoid loose typing with[key: string]: any.Per coding guidelines, avoid type casting and validate values at runtime using zod schemas. The
tableStateprop uses an index signature that accepts any value. Consider defining a more specific type or discriminated union for the expected state shapes.🔎 Proposed improvement
interface TableActionsMenuProps { tableId: number tableName: string - tableState: { - name: string - [key: string]: any - } + tableState: { + name: string + reason?: string + solution?: string + retry_policy?: { policy: string } + } onRestartClick: () => void onShowErrorClick?: () => void disabled?: boolean }
25-27: UnusedtableIdprop.The
tableIdprop is destructured but never used in the component. If it's not needed, remove it from the interface and destructuring to keep the API minimal.apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (1)
66-79: Consider grouping related dialog state.Per coding guidelines, group related state using objects or reducers instead of multiple useState calls. The dialog-related state could be consolidated:
🔎 Proposed grouping
// Instead of multiple useState calls: const [dialogState, setDialogState] = useState<{ errorDialog: { open: boolean; table: { tableName: string; reason: string; solution?: string } | null } restartDialog: { open: boolean; table: { tableId: number; tableName: string } | null } batchRestartDialog: { open: boolean; mode: 'all' | 'errored' | null } }>({ errorDialog: { open: false, table: null }, restartDialog: { open: false, table: null }, batchRestartDialog: { open: false, mode: null }, })This consolidates the six dialog-related useState calls into one structured object.
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (1)
63-104: Dialog content duplicated with ResetTableButton.The dialog title, description, and bullet points are nearly identical to those in
ResetTableButton.tsx. Consider extracting a shared component or constant for the restart confirmation content to maintain consistency and reduce duplication.🔎 Example extraction
// RestartConfirmationContent.tsx or shared constants export const getRestartConfirmationContent = (tableName: string) => ({ title: `Restart replication for ${tableName}`, bullets: [ { bold: 'The table copy will be re-initialized.', detail: 'All data will be copied again from the source.' }, { bold: 'Existing downstream data will be deleted.', detail: 'Any replicated data for this table will be removed.' }, { bold: 'All other tables remain untouched.', detail: 'Only this table is affected.' }, { bold: 'The pipeline will restart automatically.', detail: 'This is required to apply this change.' }, ], })apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx (2)
24-31: Avoid loose typing with[key: string]: any.Similar to
TableActionsMenu, thestateobject in the tables array uses an index signature. Define a more specific type for consistency and type safety.🔎 Proposed improvement
tables: Array<{ table_id: number state: { name: string retry_policy?: { policy: string } - [key: string]: any } }>
22-23:totalTablesanderroredTablesCountcould be derived fromtables.These props can be computed from the
tablesarray, reducing the API surface and avoiding potential inconsistencies between the count props and the actual array.🔎 Proposed change
interface BatchRestartDialogProps { open: boolean onOpenChange: (open: boolean) => void projectRef?: string pipelineId: number mode: 'all' | 'errored' - totalTables: number - erroredTablesCount: number tables: Array<{...}> onRestartStart?: (tableIds: number[]) => void onRestartComplete?: (tableIds: number[]) => void } // Inside component: const totalTables = tables.length const erroredTablesCount = tables.filter( t => t.state.name === 'error' && t.state.retry_policy?.policy === 'manual_retry' ).length
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/RetryOptionsDropdown.tsxapps/studio/components/interfaces/Database/Replication/TableActionsMenu.tsxapps/studio/data/replication/rollback-tables-mutation.tsapps/studio/data/replication/use-table-reset.tspackages/api-types/types/api.d.tspackages/api-types/types/platform.d.ts
💤 Files with no reviewable changes (2)
- apps/studio/data/replication/use-table-reset.ts
- apps/studio/components/interfaces/Database/Replication/RetryOptionsDropdown.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsxapps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsxapps/studio/data/replication/rollback-tables-mutation.ts
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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsxapps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsx
🧠 Learnings (14)
📚 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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 search or filters above on left hand side if table has associated search or filters
Applied to files:
apps/studio/components/interfaces/Database/Replication/TableActionsMenu.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.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/TableActionsMenu.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsxapps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsxapps/studio/data/replication/rollback-tables-mutation.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/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/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.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/ResetTableButton.tsx
📚 Learning: 2025-12-19T10:16:24.570Z
Learnt from: joshenlim
Repo: supabase/supabase PR: 41486
File: apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx:47-56
Timestamp: 2025-12-19T10:16:24.570Z
Learning: The `useEnablePhysicalBackupsMutation` hook in `data/database/enable-physical-backups-mutation.ts` has a built-in default error handler that shows a toast.error when no custom onError callback is provided, so explicit onError callbacks are optional for this mutation.
Applied to files:
apps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/data/replication/rollback-tables-mutation.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 _Shadcn_ suffixed components (e.g., Input_Shadcn_, Button_Shadcn_) from the ui package where possible
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
📚 Learning: 2025-12-12T11:27:51.417Z
Learnt from: ignaciodob
Repo: supabase/supabase PR: 41291
File: packages/api-types/types/platform.d.ts:7128-7128
Timestamp: 2025-12-12T11:27:51.417Z
Learning: For changes tied to entitlements (e.g., adding a new entitlement like 'security.questionnaire'), do not merge until backend entitlements are confirmed live. Apply a do-not-merge label on such PRs and ensure UI changes that rely on new entitlements are not merged in isolation. In reviews, verify entitlement availability in backend before approving and, if needed, hold UI-only changes until entitlement is active.
Applied to files:
packages/api-types/types/api.d.tspackages/api-types/types/platform.d.ts
🧬 Code graph analysis (5)
apps/studio/components/interfaces/Database/Replication/ResetTableButton.tsx (1)
apps/studio/data/replication/rollback-tables-mutation.ts (1)
useRollbackTablesMutation(59-104)
apps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsx (2)
packages/ui/src/components/shadcn/ui/dialog.tsx (8)
Dialog(223-223)DialogContent(225-225)DialogHeader(228-228)DialogTitle(231-231)DialogSectionSeparator(230-230)DialogSection(229-229)DialogFooter(227-227)DialogClose(224-224)blocks/vue/registry/default/lib/utils.ts (1)
cn(5-7)
apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx (2)
apps/studio/data/replication/rollback-tables-mutation.ts (1)
useRollbackTablesMutation(59-104)packages/ui/src/components/shadcn/ui/alert-dialog.tsx (8)
AlertDialog(166-166)AlertDialogContent(169-169)AlertDialogHeader(172-172)AlertDialogTitle(173-173)AlertDialogDescription(170-170)AlertDialogFooter(171-171)AlertDialogCancel(168-168)AlertDialogAction(167-167)
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (2)
apps/studio/data/replication/rollback-tables-mutation.ts (1)
useRollbackTablesMutation(59-104)packages/ui/src/components/shadcn/ui/alert-dialog.tsx (8)
AlertDialog(166-166)AlertDialogContent(169-169)AlertDialogHeader(172-172)AlertDialogTitle(173-173)AlertDialogDescription(170-170)AlertDialogFooter(171-171)AlertDialogCancel(168-168)AlertDialogAction(167-167)
apps/studio/data/replication/rollback-tables-mutation.ts (1)
apps/studio/data/replication/restart-pipeline-helper.ts (1)
useRestartPipelineHelper(19-40)
🔇 Additional comments (13)
packages/api-types/types/api.d.ts (3)
286-293: Org projects pagination doc is clear and consistentThe added note about offset/limit-based pagination for
/v1/organizations/{slug}/projectsmatches the existing query parameters and helps consumers; no issues from a typings perspective.
309-313: v1/projects deprecation guidance reads correctlyThe expanded description nudging clients toward
/v1/organizations/{slug}/projectsfor better pagination/precision is accurate and non-breaking for thev1-list-all-projectsoperation type.
3279-3366:ProjectUpgradeEligibilityResponse.validation_errorsunion is well-structuredThe deprecation JSDoc on
objects_to_be_dropped,unsupported_extensions, anduser_defined_objects_in_internal_schemasplus the newvalidation_errorsdiscriminated union give strongly-typed, forward-compatible validation details; the union shape and enums look coherent and syntactically sound.apps/studio/data/replication/rollback-tables-mutation.ts (1)
11-14: Good use of discriminated union.The
RollbackTablesTargettype correctly uses a discriminated union pattern with thetypefield as discriminator, which aligns with coding guidelines and provides excellent type safety for handling different rollback scenarios.packages/api-types/types/platform.d.ts (3)
6971-6994: Verify backend entitlement availability before relying on these in UI.New entitlements are added (
security.soc2_report,security.private_link, and multiplerealtime.*keys). Based on learnings, ensure the backend entitlements are confirmed live before merging any UI changes that depend on these new keys.
23055-23111: New rollback-tables operation looks well-structured.The operation definition properly handles multiple error scenarios (401, 403, 429, 500) and aligns with the batch rollback feature requirements. The path parameters, request body, and response types are correctly wired up.
7897-7904: Verify if ProfileResponse fields were previously nullable before confirming this is a breaking change.The current type definitions show
first_name: string,last_name: string,mobile: string, andfree_project_limit: numberas non-nullable. However, frontend code uses defensive patterns (profile?.first_name ?? '') that suggest developers expect these fields to be potentially null.Without git history or changelog documentation, I cannot confirm whether these were previously declared as nullable in the type definitions. If they were always typed as non-nullable while the API sometimes returned null, the defensive coding is a workaround rather than evidence of a breaking change. If the type definitions were recently changed from nullable to non-nullable, this would be a breaking change that needs coordinated frontend updates.
Verify the before state of these field types and whether the backend API guarantees they are always populated for all user profiles (including legacy accounts).
apps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsx (1)
23-68: Clean implementation of the error details dialog.The component follows best practices with explicit prop typing, controlled dialog state, and clear separation of concerns. The conditional rendering for the optional
solutionis handled cleanly.apps/studio/components/interfaces/Database/Replication/ResetTableButton.tsx (1)
33-44: Mutation follows best practices.The mutation correctly uses
mutatewithonSuccessandonErrorcallbacks that includetoast.successandtoast.errorrespectively, following the coding guidelines for mutation handling.apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (2)
136-174: Good use ofuseMemofor derived data.The memoized computations for
tableStatuses,filteredTableStatuses,tablesWithLag, anderroredTablesare appropriate optimizations since these values are derived from potentially large arrays and passed to child components.
597-616: Guard pattern for conditional dialog rendering is correct.The pattern
{selectedTableForRestart && <RestartTableDialog ... />}ensures the dialog only mounts when there's a selected table, preventing potential null reference issues. Same pattern applied consistently to ErrorDetailsDialog and BatchRestartDialog.apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (1)
36-49: Mutation follows correct pattern with cleanup callbacks.Good handling of
onRestartCompletein both success and error paths ensures the parent component'srestartingTableIdsstate is properly cleaned up regardless of outcome.apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx (1)
64-78: Mutation follows best practices with proper toast notifications.The mutation correctly uses
onSuccessandonErrorcallbacks with appropriate toast messages. TheonRestartCompletecallback is called in both paths for consistent state cleanup.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx (1)
171-175: Avoid type casting; use runtime validation with zod or ensure type correctness by construction.The
as DiskAttributesData['attributes']cast violates the coding guideline. As per coding guidelines, type casting should be avoided in favor of runtime validation using zod schemas.🔎 Recommended approaches
Option 1: Runtime validation with zod (preferred for robustness)
// Define schema at the top of the file or in a shared location const DiskAttributesSchema = z.object({ type: z.string(), size_gb: z.number(), iops: z.number(), throughput_mbps: z.number(), }) // Then validate at usage: const branchDiskAttributes = DiskAttributesSchema.parse({ ...projectDiskAttributes, size_gb: Math.round(projectDiskAttributes.size_gb * 1.5), })Option 2: Type-safe construction without casting
// Ensure TypeScript infers the correct type by satisfying the constraint const branchDiskAttributes: DiskAttributesData['attributes'] = { ...projectDiskAttributes, size_gb: Math.round(projectDiskAttributes.size_gb * 1.5), }This will fail at compile-time if the shape doesn't match, rather than using a cast that bypasses type checking.
Based on coding guidelines.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsxapps/studio/pages/api/platform/organizations/[slug]/billing/subscription.ts
💤 Files with no reviewable changes (1)
- apps/studio/pages/api/platform/organizations/[slug]/billing/subscription.ts
🧰 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/BranchManagement/CreateBranchModal.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/BranchManagement/CreateBranchModal.tsx
🧠 Learnings (5)
📚 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/BranchManagement/CreateBranchModal.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} : Use discriminated unions for complex state management instead of multiple independent state fields
Applied to files:
apps/studio/components/interfaces/BranchManagement/CreateBranchModal.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/BranchManagement/CreateBranchModal.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/BranchManagement/CreateBranchModal.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/BranchManagement/CreateBranchModal.tsx
⏰ 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 (1)
apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx (1)
22-22: LGTM: Type import added correctly.The
DiskAttributesDatatype import is properly added alongside the existinguseDiskAttributesQueryimport.
There was a problem hiding this comment.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In
@apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx:
- Around line 394-408: Remove the dead JSX comment block that starts with "/*
{hasErroredTables && (" and ends with ")} */" in the ReplicationPipelineStatus
component; this block contains a Button using hasErroredTables,
setBatchRestartMode, setShowBatchRestartDialog, isAnyRestartInProgress and
AlertTriangle and is duplicated by the dropdown logic, so delete those commented
lines entirely (or replace with a one-line TODO referencing an issue number if
you want to preserve intent) to eliminate unused/commented-out code.
🧹 Nitpick comments (3)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsx (1)
59-65: Consider extracting badge logic to a variable.The nested ternary, while functional, goes against the guideline to avoid nested ternaries in JSX. Extracting this to a descriptive variable would improve readability.
🔎 Proposed refactor
+ const badgeContent = isRestarting + ? <Badge variant="default">Restarting</Badge> + : showDisabledState + ? <Badge variant="default">Not Available</Badge> + : statusConfig.badge + <TableCell className="align-top"> - {isRestarting ? ( - <Badge variant="default">Restarting</Badge> - ) : showDisabledState ? ( - <Badge variant="default">Not Available</Badge> - ) : ( - statusConfig.badge - )} + {badgeContent} </TableCell>As per coding guidelines, which recommend avoiding nested ternaries in JSX.
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (2)
69-596: Consider breaking down this large component.At 596 lines, this component significantly exceeds the 200-300 line guideline. It contains multiple distinct UI sections (header, lag metrics, table list, empty state, dialogs) and manages complex state with 8+ useState hooks.
Consider extracting sections into sub-components:
- Lag metrics section (lines 318-367)
- Table list with search/actions (lines 369-499)
- Empty state (lines 502-524)
This would improve maintainability and make the component easier to test and understand.
As per coding guidelines, which recommend breaking down components with multiple distinct UI sections and multiple unrelated useState hooks.
74-87: Consider grouping related dialog state.The multiple useState calls for dialog state (error dialog, restart dialog, batch dialog) could be consolidated using objects or a discriminated union pattern for better organization and type safety.
Example approach:
type DialogState = | { type: 'error'; tableName: string; reason: string; solution?: string } | { type: 'restart'; tableId: number; tableName: string } | { type: 'batch'; mode: 'all' | 'errored' } | { type: 'none' } const [dialog, setDialog] = useState<DialogState>({ type: 'none' })This reduces the number of state variables and makes the dialog state transitions more explicit.
As per coding guidelines, which recommend grouping related state using objects or discriminated unions instead of multiple independent useState calls.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.tsxapps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ResetTableButton.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsxapps/studio/data/replication/pipeline-replication-status-query.ts
💤 Files with no reviewable changes (1)
- apps/studio/components/interfaces/Database/Replication/ResetTableButton.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
- apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx
- apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx
- apps/studio/components/interfaces/Database/Replication/ErroredTableDetails.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/data/replication/pipeline-replication-status-query.tsapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.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/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.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/data/replication/pipeline-replication-status-query.tsapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/DestinationRow.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/data/replication/pipeline-replication-status-query.tsapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/**/*.{ts,tsx} : Contain tables within a card
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/**/*.{ts,tsx} : Place table actions above on right hand side if table has associated actions
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.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/ReplicationPipelineStatus/TableReplicationRow.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 search or filters above on left hand side if table has associated search or filters
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 FormItemLayout without form control for action fields with buttons for navigation or performable actions, wrapping buttons in a div with justify-end
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/DestinationRow.tsx
🧬 Code graph analysis (2)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (4)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsx (1)
TableReplicationRow(22-113)apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (1)
RestartTableDialog(26-105)apps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsx (1)
ErrorDetailsDialog(23-69)apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx (1)
BatchRestartDialog(30-162)
apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx (1)
packages/ui/index.tsx (3)
Tooltip(239-239)TooltipTrigger(240-240)TooltipContent(241-241)
⏰ 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: typecheck
- GitHub Check: test
🔇 Additional comments (4)
apps/studio/data/replication/pipeline-replication-status-query.ts (1)
3-3: LGTM!The new type export correctly extracts the table status type from the API schema. This provides proper typing for per-table replication status used throughout the new UI components.
Also applies to: 10-11
apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx (2)
180-189: LGTM!The warning indicator provides clear visual feedback for table-level replication errors. The conditional rendering, tooltip pattern, and pluralization logic are all correct.
192-192: LGTM!The simplified link label "View replication" is clearer and less redundant than the previous implementation.
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsx (1)
13-20: LGTM!The props interface is well-defined with proper typing. Boolean naming conventions (
is*,show*) and callback naming (on*) follow the coding guidelines.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (3)
74-87: Consider consolidating dialog state into a discriminated union.The multiple dialog-related state hooks (error dialog, restart dialog, batch restart dialog, and their associated data) could be grouped into a single state object using a discriminated union pattern. This would prevent impossible states (e.g., multiple dialogs open at once) and simplify state management.
As per coding guidelines, which recommend grouping related state using objects or reducers instead of multiple useState calls, and using discriminated unions for complex state management instead of multiple independent state fields.
Example implementation
type DialogState = | { type: 'none' } | { type: 'error-details'; tableName: string; reason: string; solution?: string } | { type: 'restart-single'; tableId: number; tableName: string } | { type: 'restart-batch'; mode: 'all' | 'errored' } const [dialogState, setDialogState] = useState<DialogState>({ type: 'none' }) const [restartingTableIds, setRestartingTableIds] = useState<Set<number>>(new Set())Then update handlers to use:
setDialogState({ type: 'restart-single', tableId: table.table_id, tableName: table.table_name })And conditionally render:
{dialogState.type === 'restart-single' && ( <RestartTableDialog open={true} onOpenChange={(open) => !open && setDialogState({ type: 'none' })} tableId={dialogState.tableId} tableName={dialogState.tableName} // ... /> )}
444-479: Extract inline arrow function handlers using useCallback.The inline arrow functions for
onSelectRestartandonSelectShowErrorare created on every render for each table row, which prevents proper memoization ofTableReplicationRowcomponents and could impact performance with many tables.As per coding guidelines, which recommend avoiding inline arrow functions for expensive operations and using useCallback to maintain stable function references.
Recommended refactor
Define stable handlers using useCallback:
const handleSelectRestart = useCallback((tableId: number, tableName: string) => { setSelectedTableForRestart({ tableId, tableName }) setShowRestartDialog(true) }, []) const handleSelectShowError = useCallback((tableName: string, reason: string, solution?: string) => { setSelectedTableError({ tableName, reason, solution }) setShowErrorDialog(true) }, [])Then simplify the map:
{filteredTableStatuses.map((table) => { const isRestarting = restartingTableIds.has(table.table_id) const isErrorState = table.state.name === 'error' const errorReason = isErrorState && 'reason' in table.state ? table.state.reason : undefined const errorSolution = isErrorState && 'solution' in table.state ? table.state.solution : undefined return ( <TableReplicationRow key={table.table_id} table={table} config={config} isRestarting={isRestarting} showDisabledState={showDisabledState} onSelectRestart={() => handleSelectRestart(table.table_id, table.table_name)} onSelectShowError={ isErrorState && errorReason ? () => handleSelectShowError(table.table_name, errorReason, errorSolution) : undefined } /> ) })}Also consider updating
TableReplicationRowto acceptonSelectShowErroras optional (onSelectShowError?:) and handle the undefined case internally, rather than passing an empty function.
69-581: Consider breaking down component for improved maintainability.The component is currently 581 lines, which exceeds the recommended 200-300 line guideline. It contains multiple distinct UI sections (header, lag metrics, table list, dialogs), complex conditional rendering, and 8 state hooks. While still functional, extracting sections into sub-components would improve maintainability and testability.
As per coding guidelines, which state: "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."
Potential extractions:
- Lag metrics section (lines 318-367) →
PipelineLagMetricsSection- Table list with search/actions (lines 369-484) →
PipelineTablesList- Empty state display (lines 487-509) →
PipelineEmptyState
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.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} : Contain tables within a card
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : Avoid nested ternaries in JSX; use separate conditions or early returns instead
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : Extract repeated JSX patterns into reusable components instead of copying similar JSX blocks
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : 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
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 appropriate conditional rendering patterns: && for simple show/hide, ternary for binary choice, early returns or extracted components for multiple conditions
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : Avoid inline arrow functions for expensive operations; use useCallback to maintain stable function references
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 FormItemLayout without form control for action fields with buttons for navigation or performable actions, wrapping buttons in a div with justify-end
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 search or filters above on left hand side if table has associated search or filters
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.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/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
🧬 Code graph analysis (1)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (4)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsx (1)
TableReplicationRow(22-113)apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (1)
RestartTableDialog(26-105)apps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsx (1)
ErrorDetailsDialog(23-69)apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx (1)
BatchRestartDialog(30-162)
⏰ 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
joshenlim
left a comment
There was a problem hiding this comment.
Verified changes locally + staging preview
@iambriccardo guessing we'll need to ensure that the BE changes have been deployed before the changes here go through? will let you merge whenever ready 🙂 🙏
There was a problem hiding this comment.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In
@apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx:
- Around line 33-34: The code converts _pipelineId to pipelineId with
Number(_pipelineId) but doesn't validate it before use; update the component to
validate pipelineId (from useParams) before calling the mutation in handleReset:
parse/convert _pipelineId defensively (e.g., use Number and Number.isFinite or
parseInt + isNaN), check projectRef and pipelineId are present and valid, and
return early (or disable the UI action) with an error/log if validation fails;
reference the useParams extraction (projectRef, _pipelineId), the derived
pipelineId, and the handleReset function so the mutation is only invoked with a
valid numeric pipelineId.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (1)
69-577: Break down this large component into smaller pieces.At 577 lines, this component significantly exceeds the 200-300 line guideline. It contains multiple distinct UI sections (pipeline header, lag metrics, table list, dialogs) that could be extracted into focused sub-components for improved maintainability and testability.
As per coding guidelines: "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."
Potential extractions:
- PipelineHeader: Header controls, status, and action buttons (lines ~247-295)
- LagMetricsSection: Replication lag display and per-table lag (lines ~318-367)
- TableListSection: Search, batch actions, and table rendering (lines ~369-484)
- EmptyTableState: Empty state messaging (lines ~487-509)
🧹 Nitpick comments (4)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (4)
73-87: Consider consolidating related dialog state.Eight separate
useStatecalls manage overlapping dialog concerns. Grouping related state (error dialog + selected error, restart dialog + selected table, batch restart dialog + mode) into objects would clarify relationships and reduce complexity.As per coding guidelines: "Group related state using objects or reducers instead of multiple useState calls."
🔎 Example consolidation
- const [showErrorDialog, setShowErrorDialog] = useState(false) - const [selectedTableError, setSelectedTableError] = useState<{ - tableName: string - reason: string - solution?: string - } | null>(null) - const [showRestartDialog, setShowRestartDialog] = useState(false) - const [selectedTableForRestart, setSelectedTableForRestart] = useState<{ - tableId: number - tableName: string - } | null>(null) - const [showBatchRestartDialog, setShowBatchRestartDialog] = useState(false) - const [batchRestartMode, setBatchRestartMode] = useState<'all' | 'errored' | null>(null) + const [errorDialog, setErrorDialog] = useState<{ + open: boolean + table: { tableName: string; reason: string; solution?: string } | null + }>({ open: false, table: null }) + const [restartDialog, setRestartDialog] = useState<{ + open: boolean + table: { tableId: number; tableName: string } | null + }>({ open: false, table: null }) + const [batchRestartDialog, setBatchRestartDialog] = useState<{ + open: boolean + mode: 'all' | 'errored' | null + }>({ open: false, mode: null }) const [restartingTableIds, setRestartingTableIds] = useState<Set<number>>(new Set())
200-218: Consider extracting nested ternaries to a helper.While these nested ternaries are in the component body rather than JSX, extracting the status-to-label and status-to-icon mapping into a helper function would improve readability and align with the guideline to avoid nested ternaries.
As per coding guidelines: "Avoid nested ternaries in JSX; use separate conditions or early returns instead."
🔎 Example extraction
+const getPipelineActionConfig = (statusName: string) => { + switch (statusName) { + case 'stopped': + return { label: 'Start', icon: <Play /> } + case 'started': + return { label: 'Stop', icon: <Pause /> } + case 'failed': + return { label: 'Restart', icon: <RotateCcw /> } + default: + return { label: statusName, icon: <Ban /> } + } +} - const label = - statusName === 'stopped' - ? 'Start' - : statusName === 'started' - ? 'Stop' - : statusName === 'failed' - ? 'Restart' - : statusName - - const icon = - statusName === 'stopped' ? ( - <Play /> - ) : statusName === 'started' ? ( - <Pause /> - ) : statusName === 'failed' ? ( - <RotateCcw /> - ) : ( - <Ban /> - ) + const { label, icon } = getPipelineActionConfig(statusName)
444-479: Extract inline arrow functions from the map iteration.The
onSelectRestartandonSelectShowErrorhandlers (lines 458-476) create new function instances on each render. For a list that re-renders frequently (every 2s viarefetchInterval), extracting these to stable handlers or usinguseCallbackwould prevent unnecessary child re-renders.As per coding guidelines: "Avoid inline arrow functions for expensive operations; use useCallback to maintain stable function references."
🔎 Example extraction
+ const handleSelectRestart = useCallback((tableId: number, tableName: string) => { + setSelectedTableForRestart({ tableId, tableName }) + setShowRestartDialog(true) + }, []) + + const handleSelectShowError = useCallback((tableName: string, reason: string, solution?: string) => { + setSelectedTableError({ tableName, reason, solution }) + setShowErrorDialog(true) + }, []) {filteredTableStatuses.map((table) => { const isRestarting = restartingTableIds.has(table.table_id) const isErrorState = table.state.name === 'error' const errorReason = isErrorState && 'reason' in table.state ? table.state.reason : undefined const errorSolution = isErrorState && 'solution' in table.state ? table.state.solution : undefined return ( <TableReplicationRow key={table.table_id} table={table} config={config} isRestarting={isRestarting} showDisabledState={showDisabledState} - onSelectRestart={() => { - setSelectedTableForRestart({ - tableId: table.table_id, - tableName: table.table_name, - }) - setShowRestartDialog(true) - }} + onSelectRestart={() => handleSelectRestart(table.table_id, table.table_name)} - onSelectShowError={ - isErrorState && errorReason - ? () => { - setSelectedTableError({ - tableName: table.table_name, - reason: errorReason, - solution: errorSolution, - }) - setShowErrorDialog(true) - } - : () => {} - } + onSelectShowError={ + isErrorState && errorReason + ? () => handleSelectShowError(table.table_name, errorReason, errorSolution) + : () => {} + } /> ) })}
523-574: Consider extracting dialog callback handlers.The
onRestartStartandonRestartCompletecallbacks (lines 530-539, 563-571) contain non-trivial Set manipulation logic. Extracting these to named handlers would improve readability and make the dialog props less cluttered.🔎 Example extraction
+ const handleTableRestartStart = useCallback((tableId: number) => { + setRestartingTableIds((prev) => new Set(prev).add(tableId)) + }, []) + + const handleTableRestartComplete = useCallback((tableId: number) => { + setRestartingTableIds((prev) => { + const next = new Set(prev) + next.delete(tableId) + return next + }) + }, []) + + const handleBatchRestartStart = useCallback((tableIds: number[]) => { + setRestartingTableIds((prev) => new Set([...prev, ...tableIds])) + }, []) + + const handleBatchRestartComplete = useCallback((tableIds: number[]) => { + setRestartingTableIds((prev) => { + const next = new Set(prev) + tableIds.forEach((id) => next.delete(id)) + return next + }) + }, []) {selectedTableForRestart && ( <RestartTableDialog open={showRestartDialog} onOpenChange={setShowRestartDialog} tableId={selectedTableForRestart.tableId} tableName={selectedTableForRestart.tableName} - onRestartStart={() => { - setRestartingTableIds((prev) => new Set(prev).add(selectedTableForRestart.tableId)) - }} + onRestartStart={() => handleTableRestartStart(selectedTableForRestart.tableId)} - onRestartComplete={() => { - setRestartingTableIds((prev) => { - const next = new Set(prev) - next.delete(selectedTableForRestart.tableId) - return next - }) - }} + onRestartComplete={() => handleTableRestartComplete(selectedTableForRestart.tableId)} /> )} {batchRestartMode && ( <BatchRestartDialog open={showBatchRestartDialog} onOpenChange={setShowBatchRestartDialog} mode={batchRestartMode} totalTables={tableStatuses.length} erroredTablesCount={erroredTables.length} tables={tableStatuses} - onRestartStart={(tableIds) => { - setRestartingTableIds((prev) => new Set([...prev, ...tableIds])) - }} + onRestartStart={handleBatchRestartStart} - onRestartComplete={(tableIds) => { - setRestartingTableIds((prev) => { - const next = new Set(prev) - tableIds.forEach((id) => next.delete(id)) - return next - }) - }} + onRestartComplete={handleBatchRestartComplete} /> )}
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsxapps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsxapps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx
💤 Files with no reviewable changes (1)
- apps/studio/components/interfaces/Database/Replication/ErrorDetailsButton.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
🧠 Learnings (14)
📚 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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/RestartTableDialog.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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/RestartTableDialog.tsxapps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : Avoid nested ternaries in JSX; use separate conditions or early returns instead
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : Extract repeated JSX patterns into reusable components instead of copying similar JSX blocks
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : 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
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 appropriate conditional rendering patterns: && for simple show/hide, ternary for binary choice, early returns or extracted components for multiple conditions
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 : Avoid inline arrow functions for expensive operations; use useCallback to maintain stable function references
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 FormItemLayout without form control for action fields with buttons for navigation or performable actions, wrapping buttons in a div with justify-end
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.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 search or filters above on left hand side if table has associated search or filters
Applied to files:
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
🧬 Code graph analysis (2)
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (1)
apps/studio/data/replication/rollback-tables-mutation.ts (1)
useRollbackTablesMutation(59-104)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (4)
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/TableReplicationRow.tsx (1)
TableReplicationRow(22-113)apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (1)
RestartTableDialog(25-105)apps/studio/components/interfaces/Database/Replication/ErrorDetailsDialog.tsx (1)
ErrorDetailsDialog(23-69)apps/studio/components/interfaces/Database/Replication/BatchRestartDialog.tsx (1)
BatchRestartDialog(29-162)
⏰ 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 (3)
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (2)
36-49: LGTM!The mutation hook setup properly handles both success and error cases with appropriate user feedback, callback invocations, and dialog cleanup.
63-104: LGTM!The AlertDialog structure is well-formed with clear user messaging, proper disabled states during mutation, and semantic HTML. The warning variant appropriately signals the destructive nature of the restart action.
apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx (1)
144-179: LGTM!The memoized derived state is well-structured: table sorting, search filtering, and error/lag table extraction all benefit from memoization with correct dependencies. Simple boolean derivations (lines 181-182) appropriately avoid over-memoization.
All good, we are ready to merge! |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.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/RestartTableDialog.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/RestartTableDialog.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} : Contain tables within a card
Applied to files:
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.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/RestartTableDialog.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/RestartTableDialog.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/RestartTableDialog.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/RestartTableDialog.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/RestartTableDialog.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/RestartTableDialog.tsx
⏰ 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 (1)
- GitHub Check: test
🔇 Additional comments (2)
apps/studio/components/interfaces/Database/Replication/RestartTableDialog.tsx (2)
36-49: LGTM: Mutation callbacks are properly structured.The success and error handlers appropriately show toast notifications, invoke the optional
onRestartCompletecallback, and close the dialog. The toast messages are clear and informative, with the success message mentioning automatic pipeline restart and the error message including diagnostic information.
64-105: LGTM: Well-structured dialog with excellent UX.The AlertDialog implementation provides clear, comprehensive information about the restart operation's impact. The bullet-point format effectively communicates the consequences (re-initialization, data deletion, scope limitation, automatic restart), and the button states properly reflect loading status. The warning variant on the action button appropriately signals the destructive nature of the operation.
| const { ref: projectRef, pipelineId: _pipelineId } = useParams() | ||
| const pipelineId = Number(_pipelineId) |
There was a problem hiding this comment.
Incomplete validation: pipelineId can be NaN when passed to mutation.
Line 53 validates that _pipelineId exists as a string, but doesn't verify the converted pipelineId (line 34) is a valid number. If _pipelineId contains a non-numeric value (e.g., "abc"), Number(_pipelineId) produces NaN, which passes the line 53 check but results in an invalid value sent to the API at line 58.
Per coding guidelines, avoid type casting without runtime validation using zod schemas or equivalent checks.
🔎 Proposed fix
const handleReset = () => {
if (!projectRef) return toast.error('Project ref is required')
- if (!_pipelineId) return toast.error('Pipeline ID is required')
+ if (!pipelineId || isNaN(pipelineId)) return toast.error('Valid pipeline ID is required')
onRestartStart?.()
rollbackTables({Also applies to: 53-53, 58-58
Braintrust eval report
|
This PR implements a new overhauled UX around table restarts. The rationale for implementing this is that many customers have a lot of tables that they want to replicate and we want to give them the possibility to batch restart a series of tables in case they fail. We also want to give them the option to individually restart a table that is not in failing state.
The PR uses the new
rollback-tablesendpoint and implements a new more sophisticated UI for allow all kinds of restarts.Screenshots
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Removed
✏️ Tip: You can customize this high-level summary in your review settings.