Skip to content

feat(studio): point replica deep links at Infrastructure and recommend compute - #48921

Merged
dnywh merged 18 commits into
danny/pipe-1007-04-cut-from-replicationfrom
dnywh/chore/read-replicas-in-infrastructure
Aug 21, 2026
Merged

dnywh merged 18 commits into
danny/pipe-1007-04-cut-from-replicationfrom
dnywh/chore/read-replicas-in-infrastructure

Conversation

@dnywh

@dnywh dnywh commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature. Stack 5 of 5 (tip) for PIPE-1007.

What is the current behavior?

Selectors still open Replication with destinationType=Read+Replica. Compute eligibility actions leave the add-replica flow without carrying a recommended size into the Infrastructure form.

What is the new behavior?

DatabaseSelector and the SQL submenu open Infrastructure ?addReplica=true. Change to Small/XL compute waits for the sheet to close, pre-selects that size, then focuses and scrolls the Infrastructure form to Compute without shifting the page footer.

Additional context

Last stack PR. #49043 has merged. Please review, but do not merge until 2→4 are also approved. Then merge #49044 → #49045 → #49046 → this PR in succession, and drop the do-not-merge labels.

Update the read replicas getting-started doc in the same sitting so it points only at Infrastructure (it currently also links Database → Replication).

Remaining stack: #49044 → #49045 → #49046 → this PR

To test

infrastructure:read_replicas is an enabled-feature, on by default. There is no Feature Preview or ConfigCat switch. You should already see the Infrastructure Read replicas section. If you do not, your profile lists infrastructure:read_replicas in disabled_features.

  1. Infrastructure: topology, Read replicas, Scaling.
  2. Add read replica. If blocked on compute, Change to Small compute: sheet closes, Small is selected and focused, the price footer is dirty, and no blank page gap appears.
  3. From the SQL editor database selector, Add replica should open Infrastructure, not Replication.

@dnywh
dnywh requested review from a team as code owners August 11, 2026 04:59
@vercel

vercel Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview Aug 21, 2026 1:38am
studio-staging Ready Ready Preview Aug 21, 2026 1:38am
zone-www-dot-com Ready Ready Preview, v0 Aug 21, 2026 1:38am
4 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 21, 2026 1:38am
design-system Skipped Skipped Aug 21, 2026 1:38am
docs Skipped Skipped Aug 21, 2026 1:38am
ui-library Skipped Skipped Aug 21, 2026 1:38am

Request Review

@supabase

supabase Bot commented Aug 11, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f03558e2-8d16-42f6-ab2b-de0bd882ab67

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Read replica management moves from Database Replication to Settings Infrastructure. The change adds Infrastructure creation and detail flows, updates legacy redirects and links, removes replica handling from replication destinations and diagrams, and adds compute recommendation support.

Changes

Infrastructure read replica management

Layer / File(s) Summary
Infrastructure read replica management
apps/studio/components/interfaces/Settings/Infrastructure/..., apps/studio/pages/project/[ref]/settings/infrastructure.tsx, apps/studio/tests/components/Settings/Infrastructure/*
Adds feature-gated replica listing, creation, detail actions, eligibility checks, pricing, polling, and compute recommendations.
Infrastructure routes and legacy redirects
apps/studio/routes/project/..., apps/studio/redirects.shared.*, apps/studio/pages/project/[ref]/database/replication/replica/..., apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.*
Adds Infrastructure routes and path helpers. Legacy replica routes redirect to Infrastructure.
Replication destination separation
apps/studio/components/interfaces/Database/Replication/..., apps/studio/pages/project/[ref]/database/replication/index.tsx
Removes read replicas from destination selection, destination tables, and replication diagrams. Adds an Infrastructure callout and legacy query redirect.
Compute navigation and shared UI support
apps/studio/components/interfaces/DiskManagement/..., apps/studio/components/ui/*, packages/ui/src/components/radio-group-card.tsx, apps/studio/components/layouts/ProjectLayout/ResizingState.tsx
Adds compute recommendation and anchor handling, embeds Infrastructure sections in disk management, and updates shared links, styling, and text.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ReplicationPage
  participant LegacyRedirect
  participant InfrastructurePage
  participant ReadReplicaForm
  User->>ReplicationPage: open legacy replica route
  ReplicationPage->>LegacyRedirect: resolve replica route
  LegacyRedirect->>InfrastructurePage: redirect to Infrastructure detail page
  InfrastructurePage->>ReadReplicaForm: open replica management flow
Loading

Possibly related PRs

Suggested reviewers: kemaldotearth

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main changes: redirecting replica deep links to Infrastructure and recommending compute sizes.
Description check ✅ Passed The description covers the change type, current and new behavior, context, testing steps, and related issues, but omits the CONTRIBUTING.md acknowledgment.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dnywh/chore/read-replicas-in-infrastructure

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dnywh
dnywh marked this pull request as draft August 11, 2026 05:04
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  4 minutes, 19 seconds
commit  6f7cc69

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx (1)

37-40: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Remove the stale ReadReplicaNode import and readReplica registration from EmptyReplicationDiagram.tsx. ReadReplicaNode is no longer exported from Nodes.tsx, so this causes a build-time error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx`
around lines 37 - 40, Remove the stale ReadReplicaNode import and its
readReplica registration from EmptyReplicationDiagram.tsx, leaving the remaining
replication node registrations unchanged since ReadReplicaNode is no longer
exported by Nodes.tsx.

Source: Coding guidelines

apps/studio/components/interfaces/Database/Replication/Destinations.tsx (1)

145-147: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep the read-replica migration path reachable without Pipelines access.

When all Pipelines flags are disabled, newDestinationDefaultType is null. The page disables the only control that opens DestinationPanel, but the read-replica migration callout only renders inside that panel. Users cannot discover the Infrastructure flow.

  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx#L145-L147: render an Infrastructure migration link outside DestinationPanel when read replicas are enabled.
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx#L255-L259: do not make the disabled Add destination control the only route to the migration guidance.
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx#L224-L228: retain this callout as supplemental guidance, not the only migration path.
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx#L162-L192: add an integration test that renders Destinations with all Pipelines flags disabled and verifies that the Infrastructure link remains reachable.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/interfaces/Database/Replication/Destinations.tsx`
around lines 145 - 147, The Destinations page must expose the Infrastructure
migration flow even when all Pipelines flags disable the Add destination
control. In
apps/studio/components/interfaces/Database/Replication/Destinations.tsx lines
145-147, add an external migration link rendered outside DestinationPanel when
read replicas are enabled; at lines 255-259, ensure the disabled Add destination
control is not the sole route. Keep the DestinationTypeSelection callout at
lines 224-228 as supplemental guidance, and add an integration test in
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx
lines 162-192 verifying the Infrastructure link remains reachable with all
Pipelines flags disabled.
🧹 Nitpick comments (15)
apps/studio/components/ui/UpgradePlanButton.tsx (1)

71-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace the nested ternary.

Line 75 adds another level to an existing nested ternary. Use flat conditional logic for the three URL branches.

Proposed refactor
-  const href = isRequestingToDisableSpendCap
-    ? `/org/${slug ?? '_'}/billing?panel=costControl&source=${source}`
-    : isOnPaidPlanAndRequestingToPurchaseAddon
-      ? addon === 'computeSize'
-        ? `${getInfrastructurePath(ref)}`#compute``
-        : `/project/${ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
-      : `/org/${slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
+  let href = `/org/${slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
+  if (isRequestingToDisableSpendCap) {
+    href = `/org/${slug ?? '_'}/billing?panel=costControl&source=${source}`
+  } else if (isOnPaidPlanAndRequestingToPurchaseAddon) {
+    href =
+      addon === 'computeSize'
+        ? `${getInfrastructurePath(ref)}`#compute``
+        : `/project/${ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
+  }

As per coding guidelines, “Do not nest ternaries.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/ui/UpgradePlanButton.tsx` around lines 71 - 77,
Refactor the href assignment in UpgradePlanButton to remove the nested ternary
structure and express the three URL branches with flat conditional logic.
Preserve the existing priority and URL behavior for
isRequestingToDisableSpendCap, addon === 'computeSize', and the remaining addon
and subscription-plan cases.

Source: Coding guidelines

apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx (2)

25-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep the eligibility factory aligned with the hook return type.

The factory lists the flags returned by useCheckEligibilityDeployReplica. It is an untyped object literal, so a field added to or removed from the hook does not fail this file at compile time. Annotate the factory with ReturnType<typeof useCheckEligibilityDeployReplica> so the mock and the hook stay in sync.

This matters for the entitlement flag proposed on useCheckEligibilityDeployReplica.ts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx`
around lines 25 - 37, Update the eligibility factory to use ReturnType<typeof
useCheckEligibilityDeployReplica> as its return type, while preserving the
existing delta merge behavior. Ensure the test mock remains compile-time aligned
with all fields returned by useCheckEligibilityDeployReplica.

19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the free-plan branch and for the recommendation click.

Line 19 pins the mocked organization to plan.id === 'pro' for every test in the file. The isFreePlan branch that renders UpgradePlanButton is therefore never exercised, although this PR introduced that branch.

The tests also assert only that the buttons render. They do not assert that a click calls requestRecommendCompute with ci_small or ci_xlarge, which is the behavior this PR adds.

Add a free-plan test that overrides the organization mock, and add click assertions that spy on requestRecommendCompute.

Also applies to: 55-55

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx`
at line 19, Add coverage in ReadReplicaEligibilityWarnings tests for the
free-plan path by overriding useSelectedOrganizationQuery to return a free plan
and asserting UpgradePlanButton renders. Add requestRecommendCompute spy
assertions for recommendation button clicks, verifying ci_small and ci_xlarge
are passed for their respective buttons while preserving existing rendering
checks.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts (1)

5-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a typed literal map instead of a string index signature.

The [key: string] index signature removes key checking. A typo such as REPLICA_STATUS.INIT_READ_REPLICAA resolves without a compile error, and consumers lose literal types. satisfies keeps the value constraint and preserves the literal keys.

♻️ Proposed refactor
-export const REPLICA_STATUS: {
-  [key: string]: components['schemas']['DatabaseStatusResponse']['status']
-} = {
+export const REPLICA_STATUS = {
   ...PROJECT_STATUS,
   INIT_READ_REPLICA: 'INIT_READ_REPLICA',
   INIT_READ_REPLICA_FAILED: 'INIT_READ_REPLICA_FAILED',
-}
+} satisfies Record<string, components['schemas']['DatabaseStatusResponse']['status']>

Note: PROJECT_STATUS in apps/studio/lib/constants/infrastructure.ts is itself typed with a string index signature, so the spread may widen the keys. Verify the resulting type before applying.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts`
around lines 5 - 11, Replace the string index signature on REPLICA_STATUS with a
typed literal map using satisfies, preserving the DatabaseStatusResponse status
constraint while retaining literal key checking and value types. Account for
PROJECT_STATUS’s widened spread type and verify the resulting REPLICA_STATUS
keys remain checked rather than reintroducing an index signature.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (1)

23-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the useMemo around isNotOnHigherPlan.

The computation is one Array.prototype.includes call over a three-element literal. The memo costs more than the computation, and the dependency list uses org rather than org?.plan.id.

♻️ Proposed refactor
-  const isNotOnHigherPlan = useMemo(
-    () => !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? ''),
-    [org]
-  )
+  const isNotOnHigherPlan = !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? '')

Remove the now-unused useMemo import.

As per coding guidelines: "Do not use useMemo or useCallback by default; use them only for measured expense or referential stability required by a memoized child."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`
around lines 23 - 26, Remove the useMemo wrapper from isNotOnHigherPlan and
compute the plan eligibility directly using the existing three-plan includes
check. Remove the now-unused useMemo import, preserving the current fallback for
a missing organization or plan.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx (1)

142-144: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Wrap the disabled "Deploy replica" button with ButtonTooltip.

The button is disabled when canDeployReplica is false. The reason appears in the warnings panel only when a matching eligibility flag exists. A tooltip states the reason at the control itself.

As per coding guidelines: "use ButtonTooltip for explanations of disabled buttons".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`
around lines 142 - 144, Wrap the disabled “Deploy replica” Button in the
read-replica form with ButtonTooltip, using the existing canDeployReplica
eligibility and warning reason to provide the disabled-state explanation at the
control. Preserve the current loading and onSubmit behavior, and follow the
established ButtonTooltip usage pattern in the surrounding codebase.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts (1)

21-33: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Release the subscriber after the second test and cover the no-subscriber case.

The second test never unsubscribes, so second stays registered in the module singleton after the file finishes. Any test added later in this file would receive the stale listener.

The suite also omits the case where no subscriber is registered. That path is the one that fails silently in production.

♻️ Proposed refactor
   it('replaces the previous subscriber', () => {
     const first = vi.fn()
     const second = vi.fn()
 
-    subscribeRecommendCompute(first)
-    subscribeRecommendCompute(second)
+    const unsubscribeFirst = subscribeRecommendCompute(first)
+    const unsubscribeSecond = subscribeRecommendCompute(second)
 
     requestRecommendCompute('ci_xlarge')
 
     expect(first).not.toHaveBeenCalled()
     expect(second).toHaveBeenCalledWith('ci_xlarge')
+
+    unsubscribeFirst()
+    unsubscribeSecond()
+  })
+
+  it('does not throw when no subscriber is registered', () => {
+    expect(() => requestRecommendCompute('ci_small')).not.toThrow()
   })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts`
around lines 21 - 33, Update the recommend-compute subscription tests around
subscribeRecommendCompute and requestRecommendCompute to cover request behavior
when no subscriber is registered, and ensure the replacement-subscriber test
releases its active second subscriber before completion. Preserve the existing
assertion that only the latest subscriber receives the request, while preventing
module-level subscription state from leaking into later tests.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts (1)

30-50: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Replace @ts-ignore and the as DiskType casts with validated disk-attribute parsing.

diskConfiguration.attributes is a discriminated API union. The suppression hides the union-narrowing error, and the casts bypass validation before values reach the pricing helpers. Parse the attributes with a zod discriminated-union schema, then use the parsed type and fields directly. Preserve the platform API’s supported throughput_mbps field.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`
around lines 30 - 50, Replace the `@ts-ignore` and DiskType casts in the
useGetReplicaCost pricing flow with zod discriminated-union parsing of
diskConfiguration.attributes. Validate the API union before destructuring, then
pass the parsed type and fields directly to DISK_PRICING, calculateIOPSPrice,
and calculateThroughputPrice while preserving the supported throughput_mbps
field.

Source: Coding guidelines

apps/studio/pages/project/[ref]/database/replication/replica/[replicaId].tsx (1)

16-19: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

The client redirect duplicates the shared redirect rule and drops query and hash.

apps/studio/redirects.shared.ts lines 122-126 already map this source path to the infrastructure replica route, and matchRedirect preserves query and hash through preserveQueryAndHash. This effect calls router.replace(getReadReplicaPath(ref, replicaId)), which discards router.asPath query params and the fragment. If a user reaches this component because the config-level redirect did not apply, deep-link state is lost.

Either forward the incoming query and hash here, or document that this component is only a fallback for the runtime that does not evaluate the shared redirect table.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/pages/project/`[ref]/database/replication/replica/[replicaId].tsx
around lines 16 - 19, Update the redirect effect using router.replace and
getReadReplicaPath to preserve the incoming router.asPath query parameters and
hash, matching the shared redirect behavior from matchRedirect and
preserveQueryAndHash. Keep the existing ref and replicaId guard and destination
path intact while forwarding the deep-link state.
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx (1)

16-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the unused type field from EdgeData.

Line 95 now destructures only identifier and shiftEdgeEnd. The type field is no longer read in this component. Drop it unless a producer still relies on the shape.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx`
around lines 16 - 20, Remove the unused type field from the EdgeData type
definition in Edges.tsx, since the component only consumes identifier and
shiftEdgeEnd. Verify any EdgeData producers still type-check without it,
preserving the existing destructuring and behavior.
apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx (2)

147-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Explain the disabled restart button and reuse the status constant.

Line 150 disables the button without any explanation to the user. The established studio pattern wraps a disabled button with a tooltip that states the reason. Line 150 also compares against the string literal 'ACTIVE_HEALTHY' while REPLICA_STATUS is already imported and used at lines 66-68.

Based on learnings: "when a button control is disabled, follow the existing/established button tooltip pattern used elsewhere in apps/studio".

♻️ Proposed fix
-        <Button
-          key="restart"
-          variant="default"
-          disabled={status !== 'ACTIVE_HEALTHY'}
-          onClick={() => setShowConfirmRestart(true)}
-        >
-          Restart replica
-        </Button>,
+        <ButtonTooltip
+          key="restart"
+          variant="default"
+          disabled={status !== REPLICA_STATUS.ACTIVE_HEALTHY}
+          tooltip={{
+            content: {
+              side: 'bottom',
+              text:
+                status !== REPLICA_STATUS.ACTIVE_HEALTHY
+                  ? 'The replica must be healthy before it can be restarted'
+                  : undefined,
+            },
+          }}
+          onClick={() => setShowConfirmRestart(true)}
+        >
+          Restart replica
+        </ButtonTooltip>,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx
around lines 147 - 154, Update the restart Button to compare against the
imported REPLICA_STATUS.ACTIVE_HEALTHY constant and wrap the disabled control in
the established studio tooltip pattern, displaying the reason the replica must
be healthy before restart is available. Preserve the existing restart
confirmation behavior and button styling.

Source: Learnings


56-60: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Default useMemo on cheap scalar derivations. Both sites memoize a small pure computation over two scalar inputs. No result feeds a memoized child, and no cost was measured. The studio guideline states: "Do not use useMemo or useCallback by default; use them only for measured expense or referential stability required by a memoized child."

  • apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx#L56-L60: call getStatusLabel and getIsInTransition directly during render.
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx#L110-L118: build the replicationState object directly during render.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx
around lines 56 - 60, Remove the unnecessary useMemo wrappers: in
apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx
lines 56-60, call getStatusLabel and getIsInTransition directly during render;
in
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx
lines 110-118, construct replicationState directly during render. No other
behavior changes are needed.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx (1)

24-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename visible to isOpen.

Line 24 stores a boolean. Use the required boolean-name prefix.

As per coding guidelines, “Use boolean names beginning with is, has, can, or should.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx`
at line 24, Rename the boolean variable visible to isOpen in the
AddReadReplicaSheet component and update all references to use isOpen
consistently.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx (1)

49-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Derive readReplicas during render.

This filter is simple derived data. Remove the default useMemo, then make the polling effect depend on databases and projectRef directly.

As per coding guidelines, “Do not use useMemo or useCallback by default.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx`
around lines 49 - 52, Update the readReplicas derivation in ReadReplicasSection
to filter databases directly during render instead of using useMemo. Adjust the
polling effect dependencies to reference databases and projectRef directly, and
remove the now-unused useMemo import.

Source: Coding guidelines

apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx (1)

154-202: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Flatten the sheet state rendering.

The nested ternary combines the Pipelines waitlist, enablement, and form states. Use early returns or a named conditional block instead.

As per coding guidelines, “Do not nest ternaries.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx`
around lines 154 - 202, Refactor the conditional rendering in DestinationPanel
around enablePgReplicate and replicationNotEnabled so the Pipelines waitlist,
enablement callout, and DestinationForm states are expressed with early returns
or a named conditional block. Remove the nested ternary while preserving the
existing rendering order, props, and behavior for each state.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx`:
- Around line 148-153: Update the edge animation in the component containing the
animated edge element: either define the animate-edge-flow class with its
required keyframes in the tracked styling system, or replace the className usage
with the existing inline animation configuration. Ensure the animation still
runs whenever shouldAnimate is true.

In `@apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx`:
- Around line 384-387: Update both recommendation handlers in
DiskManagementForm.tsx at lines 384-387 and 400-403 to trigger validation for
provisionedIOPS and throughput after setting computeSize, matching the dependent
validation performed by ComputeSizeField.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`:
- Around line 44-46: Update the defaultRegion initialization near
AWS_REGIONS_DEFAULT so a failed lookup cannot produce the invalid string
fallback 'ap-southeast-1'. Use a valid AWS_REGIONS key or explicitly handle the
missing entry before the later `.code` access, ensuring the existing
region-selection guards remain safe.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`:
- Around line 55-77: Add hasReadReplicaAccess to the returned object from
useCheckEligibilityDeployReplica.ts at lines 55-77 so consumers can explain
entitlement failures. In ReadReplicaEligibilityWarnings.tsx at lines 249-277,
add a warning branch for missing read-replica access and a final Admonition
fallback whenever can is false, ensuring the component never returns undefined.
- Around line 45-53: Update the eligibility hook to return an isLoading flag
combining isLoadingReplicas, isLoadingAddons, and the absence of project, while
preserving the existing eligibility calculations after data resolves. In
ReadReplicaEligibilityWarnings, use this flag to render the existing skeleton
instead of warnings until all required queries and project data are available.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`:
- Around line 66-78: Update the disk, iops, and throughput label construction in
the pricing result to avoid rendering undefined values while diskConfiguration
is unavailable: use the existing readReplicaDiskSizes value for the disk size
instead of recalculating size_gb * 1.25, and provide safe fallback values for
missing type, iops, and throughput_mbps before formatting the labels.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts`:
- Around line 26-39: Update
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts
lines 26-39 so requestRecommendCompute returns a boolean indicating whether
recommendComputeListener received the recommendation. Update
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
lines 80-85 so handleRecommendCompute checks that result and, when delivery
fails, shows a toast.error or navigates to the compute section instead of
silently continuing.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx:
- Around line 88-98: Flatten the nested ternary used by the Badge `variant` prop
near `statusLabel` by deriving the value through a small lookup or early-return
helper. Preserve `success` for `Healthy`, `destructive` for `Failed`, and
`default` for all other statuses.

In
`@apps/studio/routes/project/`$ref/settings/infrastructure/replica/$replicaId.tsx:
- Around line 5-8: Update the route hierarchy around
InfrastructureReadReplicaRoute so the replica page can render: either add an
Outlet to SettingsInfrastructureRoute or flatten the generated route structure.
Preserve the existing replica route component and settings layout metadata.

---

Outside diff comments:
In `@apps/studio/components/interfaces/Database/Replication/Destinations.tsx`:
- Around line 145-147: The Destinations page must expose the Infrastructure
migration flow even when all Pipelines flags disable the Add destination
control. In
apps/studio/components/interfaces/Database/Replication/Destinations.tsx lines
145-147, add an external migration link rendered outside DestinationPanel when
read replicas are enabled; at lines 255-259, ensure the disabled Add destination
control is not the sole route. Keep the DestinationTypeSelection callout at
lines 224-228 as supplemental guidance, and add an integration test in
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx
lines 162-192 verifying the Infrastructure link remains reachable with all
Pipelines flags disabled.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx`:
- Around line 37-40: Remove the stale ReadReplicaNode import and its readReplica
registration from EmptyReplicationDiagram.tsx, leaving the remaining replication
node registrations unchanged since ReadReplicaNode is no longer exported by
Nodes.tsx.

---

Nitpick comments:
In
`@apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx`:
- Around line 154-202: Refactor the conditional rendering in DestinationPanel
around enablePgReplicate and replicationNotEnabled so the Pipelines waitlist,
enablement callout, and DestinationForm states are expressed with early returns
or a named conditional block. Remove the nested ternary while preserving the
existing rendering order, props, and behavior for each state.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx`:
- Around line 16-20: Remove the unused type field from the EdgeData type
definition in Edges.tsx, since the component only consumes identifier and
shiftEdgeEnd. Verify any EdgeData producers still type-check without it,
preserving the existing destructuring and behavior.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx`:
- Line 24: Rename the boolean variable visible to isOpen in the
AddReadReplicaSheet component and update all references to use isOpen
consistently.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`:
- Around line 142-144: Wrap the disabled “Deploy replica” Button in the
read-replica form with ButtonTooltip, using the existing canDeployReplica
eligibility and warning reason to provide the disabled-state explanation at the
control. Preserve the current loading and onSubmit behavior, and follow the
established ButtonTooltip usage pattern in the surrounding codebase.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`:
- Around line 23-26: Remove the useMemo wrapper from isNotOnHigherPlan and
compute the plan eligibility directly using the existing three-plan includes
check. Remove the now-unused useMemo import, preserving the current fallback for
a missing organization or plan.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`:
- Around line 30-50: Replace the `@ts-ignore` and DiskType casts in the
useGetReplicaCost pricing flow with zod discriminated-union parsing of
diskConfiguration.attributes. Validate the API union before destructuring, then
pass the parsed type and fields directly to DISK_PRICING, calculateIOPSPrice,
and calculateThroughputPrice while preserving the supported throughput_mbps
field.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts`:
- Around line 5-11: Replace the string index signature on REPLICA_STATUS with a
typed literal map using satisfies, preserving the DatabaseStatusResponse status
constraint while retaining literal key checking and value types. Account for
PROJECT_STATUS’s widened spread type and verify the resulting REPLICA_STATUS
keys remain checked rather than reintroducing an index signature.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx`:
- Around line 49-52: Update the readReplicas derivation in ReadReplicasSection
to filter databases directly during render instead of using useMemo. Adjust the
polling effect dependencies to reference databases and projectRef directly, and
remove the now-unused useMemo import.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts`:
- Around line 21-33: Update the recommend-compute subscription tests around
subscribeRecommendCompute and requestRecommendCompute to cover request behavior
when no subscriber is registered, and ensure the replacement-subscriber test
releases its active second subscriber before completion. Preserve the existing
assertion that only the latest subscriber receives the request, while preventing
module-level subscription state from leaking into later tests.

In `@apps/studio/components/ui/UpgradePlanButton.tsx`:
- Around line 71-77: Refactor the href assignment in UpgradePlanButton to remove
the nested ternary structure and express the three URL branches with flat
conditional logic. Preserve the existing priority and URL behavior for
isRequestingToDisableSpendCap, addon === 'computeSize', and the remaining addon
and subscription-plan cases.

In
`@apps/studio/pages/project/`[ref]/database/replication/replica/[replicaId].tsx:
- Around line 16-19: Update the redirect effect using router.replace and
getReadReplicaPath to preserve the incoming router.asPath query parameters and
hash, matching the shared redirect behavior from matchRedirect and
preserveQueryAndHash. Keep the existing ref and replicaId guard and destination
path intact while forwarding the deep-link state.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx:
- Around line 147-154: Update the restart Button to compare against the imported
REPLICA_STATUS.ACTIVE_HEALTHY constant and wrap the disabled control in the
established studio tooltip pattern, displaying the reason the replica must be
healthy before restart is available. Preserve the existing restart confirmation
behavior and button styling.
- Around line 56-60: Remove the unnecessary useMemo wrappers: in
apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx
lines 56-60, call getStatusLabel and getIsInTransition directly during render;
in
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx
lines 110-118, construct replicationState directly during render. No other
behavior changes are needed.

In
`@apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx`:
- Around line 25-37: Update the eligibility factory to use ReturnType<typeof
useCheckEligibilityDeployReplica> as its return type, while preserving the
existing delta merge behavior. Ensure the test mock remains compile-time aligned
with all fields returned by useCheckEligibilityDeployReplica.
- Line 19: Add coverage in ReadReplicaEligibilityWarnings tests for the
free-plan path by overriding useSelectedOrganizationQuery to return a free plan
and asserting UpgradePlanButton renders. Add requestRecommendCompute spy
assertions for recommendation button clicks, verifying ci_small and ci_xlarge
are passed for their respective buttons while preserving existing rendering
checks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e0c130b3-96e7-4664-887b-9e2d8a230ae5

📥 Commits

Reviewing files that changed from the base of the PR and between b648db2 and fe36523.

⛔ Files ignored due to path filters (1)
  • apps/studio/routeTree.gen.ts is excluded by !**/routeTree.gen.ts
📒 Files selected for processing (59)
  • apps/studio/TANSTACK_MIGRATION.md
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.test.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.types.ts
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx
  • apps/studio/components/interfaces/Database/Replication/Replication.constants.ts
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/index.tsx
  • apps/studio/components/interfaces/Database/Replication/useRedirectLegacyReadReplicaDestination.test.ts
  • apps/studio/components/interfaces/Database/Replication/useRedirectLegacyReadReplicaDestination.ts
  • apps/studio/components/interfaces/DiskManagement/DiskManagementForm.sections.tsx
  • apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
  • apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx
  • apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
  • apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx
  • apps/studio/components/interfaces/ProjectHome/TopSection.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/DatabaseSubMenu.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.test.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/Edge.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureTopology.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/DropReplicaConfirmationModal.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaDetails.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaPricingDialog.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaRow.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.utils.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/RestartReplicaConfirmationModal.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts
  • apps/studio/components/layouts/ProjectLayout/ResizingState.tsx
  • apps/studio/components/ui/DatabaseSelector.tsx
  • apps/studio/components/ui/UpgradePlanButton.tsx
  • apps/studio/pages/project/[ref]/database/replication/index.tsx
  • apps/studio/pages/project/[ref]/database/replication/replica/[replicaId].tsx
  • apps/studio/pages/project/[ref]/settings/infrastructure.tsx
  • apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx
  • apps/studio/redirects.shared.test.ts
  • apps/studio/redirects.shared.ts
  • apps/studio/routes/project/$ref/database/replication/replica/$replicaId.tsx
  • apps/studio/routes/project/$ref/settings/infrastructure/replica/$replicaId.tsx
  • apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx
  • apps/studio/tests/components/Settings/Infrastructure/ReadReplicasSection.test.tsx
  • packages/ui/src/components/radio-group-card.tsx
💤 Files with no reviewable changes (4)
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.test.tsx
  • apps/studio/components/interfaces/Database/Replication/Replication.constants.ts
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx (1)

37-40: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Remove the stale ReadReplicaNode import and readReplica registration from EmptyReplicationDiagram.tsx. ReadReplicaNode is no longer exported from Nodes.tsx, so this causes a build-time error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx`
around lines 37 - 40, Remove the stale ReadReplicaNode import and its
readReplica registration from EmptyReplicationDiagram.tsx, leaving the remaining
replication node registrations unchanged since ReadReplicaNode is no longer
exported by Nodes.tsx.

Source: Coding guidelines

apps/studio/components/interfaces/Database/Replication/Destinations.tsx (1)

145-147: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep the read-replica migration path reachable without Pipelines access.

When all Pipelines flags are disabled, newDestinationDefaultType is null. The page disables the only control that opens DestinationPanel, but the read-replica migration callout only renders inside that panel. Users cannot discover the Infrastructure flow.

  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx#L145-L147: render an Infrastructure migration link outside DestinationPanel when read replicas are enabled.
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx#L255-L259: do not make the disabled Add destination control the only route to the migration guidance.
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx#L224-L228: retain this callout as supplemental guidance, not the only migration path.
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx#L162-L192: add an integration test that renders Destinations with all Pipelines flags disabled and verifies that the Infrastructure link remains reachable.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/interfaces/Database/Replication/Destinations.tsx`
around lines 145 - 147, The Destinations page must expose the Infrastructure
migration flow even when all Pipelines flags disable the Add destination
control. In
apps/studio/components/interfaces/Database/Replication/Destinations.tsx lines
145-147, add an external migration link rendered outside DestinationPanel when
read replicas are enabled; at lines 255-259, ensure the disabled Add destination
control is not the sole route. Keep the DestinationTypeSelection callout at
lines 224-228 as supplemental guidance, and add an integration test in
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx
lines 162-192 verifying the Infrastructure link remains reachable with all
Pipelines flags disabled.
🧹 Nitpick comments (15)
apps/studio/components/ui/UpgradePlanButton.tsx (1)

71-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace the nested ternary.

Line 75 adds another level to an existing nested ternary. Use flat conditional logic for the three URL branches.

Proposed refactor
-  const href = isRequestingToDisableSpendCap
-    ? `/org/${slug ?? '_'}/billing?panel=costControl&source=${source}`
-    : isOnPaidPlanAndRequestingToPurchaseAddon
-      ? addon === 'computeSize'
-        ? `${getInfrastructurePath(ref)}`#compute``
-        : `/project/${ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
-      : `/org/${slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
+  let href = `/org/${slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
+  if (isRequestingToDisableSpendCap) {
+    href = `/org/${slug ?? '_'}/billing?panel=costControl&source=${source}`
+  } else if (isOnPaidPlanAndRequestingToPurchaseAddon) {
+    href =
+      addon === 'computeSize'
+        ? `${getInfrastructurePath(ref)}`#compute``
+        : `/project/${ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
+  }

As per coding guidelines, “Do not nest ternaries.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/ui/UpgradePlanButton.tsx` around lines 71 - 77,
Refactor the href assignment in UpgradePlanButton to remove the nested ternary
structure and express the three URL branches with flat conditional logic.
Preserve the existing priority and URL behavior for
isRequestingToDisableSpendCap, addon === 'computeSize', and the remaining addon
and subscription-plan cases.

Source: Coding guidelines

apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx (2)

25-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep the eligibility factory aligned with the hook return type.

The factory lists the flags returned by useCheckEligibilityDeployReplica. It is an untyped object literal, so a field added to or removed from the hook does not fail this file at compile time. Annotate the factory with ReturnType<typeof useCheckEligibilityDeployReplica> so the mock and the hook stay in sync.

This matters for the entitlement flag proposed on useCheckEligibilityDeployReplica.ts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx`
around lines 25 - 37, Update the eligibility factory to use ReturnType<typeof
useCheckEligibilityDeployReplica> as its return type, while preserving the
existing delta merge behavior. Ensure the test mock remains compile-time aligned
with all fields returned by useCheckEligibilityDeployReplica.

19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the free-plan branch and for the recommendation click.

Line 19 pins the mocked organization to plan.id === 'pro' for every test in the file. The isFreePlan branch that renders UpgradePlanButton is therefore never exercised, although this PR introduced that branch.

The tests also assert only that the buttons render. They do not assert that a click calls requestRecommendCompute with ci_small or ci_xlarge, which is the behavior this PR adds.

Add a free-plan test that overrides the organization mock, and add click assertions that spy on requestRecommendCompute.

Also applies to: 55-55

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx`
at line 19, Add coverage in ReadReplicaEligibilityWarnings tests for the
free-plan path by overriding useSelectedOrganizationQuery to return a free plan
and asserting UpgradePlanButton renders. Add requestRecommendCompute spy
assertions for recommendation button clicks, verifying ci_small and ci_xlarge
are passed for their respective buttons while preserving existing rendering
checks.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts (1)

5-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a typed literal map instead of a string index signature.

The [key: string] index signature removes key checking. A typo such as REPLICA_STATUS.INIT_READ_REPLICAA resolves without a compile error, and consumers lose literal types. satisfies keeps the value constraint and preserves the literal keys.

♻️ Proposed refactor
-export const REPLICA_STATUS: {
-  [key: string]: components['schemas']['DatabaseStatusResponse']['status']
-} = {
+export const REPLICA_STATUS = {
   ...PROJECT_STATUS,
   INIT_READ_REPLICA: 'INIT_READ_REPLICA',
   INIT_READ_REPLICA_FAILED: 'INIT_READ_REPLICA_FAILED',
-}
+} satisfies Record<string, components['schemas']['DatabaseStatusResponse']['status']>

Note: PROJECT_STATUS in apps/studio/lib/constants/infrastructure.ts is itself typed with a string index signature, so the spread may widen the keys. Verify the resulting type before applying.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts`
around lines 5 - 11, Replace the string index signature on REPLICA_STATUS with a
typed literal map using satisfies, preserving the DatabaseStatusResponse status
constraint while retaining literal key checking and value types. Account for
PROJECT_STATUS’s widened spread type and verify the resulting REPLICA_STATUS
keys remain checked rather than reintroducing an index signature.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (1)

23-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the useMemo around isNotOnHigherPlan.

The computation is one Array.prototype.includes call over a three-element literal. The memo costs more than the computation, and the dependency list uses org rather than org?.plan.id.

♻️ Proposed refactor
-  const isNotOnHigherPlan = useMemo(
-    () => !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? ''),
-    [org]
-  )
+  const isNotOnHigherPlan = !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? '')

Remove the now-unused useMemo import.

As per coding guidelines: "Do not use useMemo or useCallback by default; use them only for measured expense or referential stability required by a memoized child."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`
around lines 23 - 26, Remove the useMemo wrapper from isNotOnHigherPlan and
compute the plan eligibility directly using the existing three-plan includes
check. Remove the now-unused useMemo import, preserving the current fallback for
a missing organization or plan.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx (1)

142-144: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Wrap the disabled "Deploy replica" button with ButtonTooltip.

The button is disabled when canDeployReplica is false. The reason appears in the warnings panel only when a matching eligibility flag exists. A tooltip states the reason at the control itself.

As per coding guidelines: "use ButtonTooltip for explanations of disabled buttons".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`
around lines 142 - 144, Wrap the disabled “Deploy replica” Button in the
read-replica form with ButtonTooltip, using the existing canDeployReplica
eligibility and warning reason to provide the disabled-state explanation at the
control. Preserve the current loading and onSubmit behavior, and follow the
established ButtonTooltip usage pattern in the surrounding codebase.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts (1)

21-33: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Release the subscriber after the second test and cover the no-subscriber case.

The second test never unsubscribes, so second stays registered in the module singleton after the file finishes. Any test added later in this file would receive the stale listener.

The suite also omits the case where no subscriber is registered. That path is the one that fails silently in production.

♻️ Proposed refactor
   it('replaces the previous subscriber', () => {
     const first = vi.fn()
     const second = vi.fn()
 
-    subscribeRecommendCompute(first)
-    subscribeRecommendCompute(second)
+    const unsubscribeFirst = subscribeRecommendCompute(first)
+    const unsubscribeSecond = subscribeRecommendCompute(second)
 
     requestRecommendCompute('ci_xlarge')
 
     expect(first).not.toHaveBeenCalled()
     expect(second).toHaveBeenCalledWith('ci_xlarge')
+
+    unsubscribeFirst()
+    unsubscribeSecond()
+  })
+
+  it('does not throw when no subscriber is registered', () => {
+    expect(() => requestRecommendCompute('ci_small')).not.toThrow()
   })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts`
around lines 21 - 33, Update the recommend-compute subscription tests around
subscribeRecommendCompute and requestRecommendCompute to cover request behavior
when no subscriber is registered, and ensure the replacement-subscriber test
releases its active second subscriber before completion. Preserve the existing
assertion that only the latest subscriber receives the request, while preventing
module-level subscription state from leaking into later tests.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts (1)

30-50: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Replace @ts-ignore and the as DiskType casts with validated disk-attribute parsing.

diskConfiguration.attributes is a discriminated API union. The suppression hides the union-narrowing error, and the casts bypass validation before values reach the pricing helpers. Parse the attributes with a zod discriminated-union schema, then use the parsed type and fields directly. Preserve the platform API’s supported throughput_mbps field.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`
around lines 30 - 50, Replace the `@ts-ignore` and DiskType casts in the
useGetReplicaCost pricing flow with zod discriminated-union parsing of
diskConfiguration.attributes. Validate the API union before destructuring, then
pass the parsed type and fields directly to DISK_PRICING, calculateIOPSPrice,
and calculateThroughputPrice while preserving the supported throughput_mbps
field.

Source: Coding guidelines

apps/studio/pages/project/[ref]/database/replication/replica/[replicaId].tsx (1)

16-19: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

The client redirect duplicates the shared redirect rule and drops query and hash.

apps/studio/redirects.shared.ts lines 122-126 already map this source path to the infrastructure replica route, and matchRedirect preserves query and hash through preserveQueryAndHash. This effect calls router.replace(getReadReplicaPath(ref, replicaId)), which discards router.asPath query params and the fragment. If a user reaches this component because the config-level redirect did not apply, deep-link state is lost.

Either forward the incoming query and hash here, or document that this component is only a fallback for the runtime that does not evaluate the shared redirect table.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/pages/project/`[ref]/database/replication/replica/[replicaId].tsx
around lines 16 - 19, Update the redirect effect using router.replace and
getReadReplicaPath to preserve the incoming router.asPath query parameters and
hash, matching the shared redirect behavior from matchRedirect and
preserveQueryAndHash. Keep the existing ref and replicaId guard and destination
path intact while forwarding the deep-link state.
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx (1)

16-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the unused type field from EdgeData.

Line 95 now destructures only identifier and shiftEdgeEnd. The type field is no longer read in this component. Drop it unless a producer still relies on the shape.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx`
around lines 16 - 20, Remove the unused type field from the EdgeData type
definition in Edges.tsx, since the component only consumes identifier and
shiftEdgeEnd. Verify any EdgeData producers still type-check without it,
preserving the existing destructuring and behavior.
apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx (2)

147-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Explain the disabled restart button and reuse the status constant.

Line 150 disables the button without any explanation to the user. The established studio pattern wraps a disabled button with a tooltip that states the reason. Line 150 also compares against the string literal 'ACTIVE_HEALTHY' while REPLICA_STATUS is already imported and used at lines 66-68.

Based on learnings: "when a button control is disabled, follow the existing/established button tooltip pattern used elsewhere in apps/studio".

♻️ Proposed fix
-        <Button
-          key="restart"
-          variant="default"
-          disabled={status !== 'ACTIVE_HEALTHY'}
-          onClick={() => setShowConfirmRestart(true)}
-        >
-          Restart replica
-        </Button>,
+        <ButtonTooltip
+          key="restart"
+          variant="default"
+          disabled={status !== REPLICA_STATUS.ACTIVE_HEALTHY}
+          tooltip={{
+            content: {
+              side: 'bottom',
+              text:
+                status !== REPLICA_STATUS.ACTIVE_HEALTHY
+                  ? 'The replica must be healthy before it can be restarted'
+                  : undefined,
+            },
+          }}
+          onClick={() => setShowConfirmRestart(true)}
+        >
+          Restart replica
+        </ButtonTooltip>,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx
around lines 147 - 154, Update the restart Button to compare against the
imported REPLICA_STATUS.ACTIVE_HEALTHY constant and wrap the disabled control in
the established studio tooltip pattern, displaying the reason the replica must
be healthy before restart is available. Preserve the existing restart
confirmation behavior and button styling.

Source: Learnings


56-60: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Default useMemo on cheap scalar derivations. Both sites memoize a small pure computation over two scalar inputs. No result feeds a memoized child, and no cost was measured. The studio guideline states: "Do not use useMemo or useCallback by default; use them only for measured expense or referential stability required by a memoized child."

  • apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx#L56-L60: call getStatusLabel and getIsInTransition directly during render.
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx#L110-L118: build the replicationState object directly during render.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx
around lines 56 - 60, Remove the unnecessary useMemo wrappers: in
apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx
lines 56-60, call getStatusLabel and getIsInTransition directly during render;
in
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx
lines 110-118, construct replicationState directly during render. No other
behavior changes are needed.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx (1)

24-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename visible to isOpen.

Line 24 stores a boolean. Use the required boolean-name prefix.

As per coding guidelines, “Use boolean names beginning with is, has, can, or should.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx`
at line 24, Rename the boolean variable visible to isOpen in the
AddReadReplicaSheet component and update all references to use isOpen
consistently.

Source: Coding guidelines

apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx (1)

49-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Derive readReplicas during render.

This filter is simple derived data. Remove the default useMemo, then make the polling effect depend on databases and projectRef directly.

As per coding guidelines, “Do not use useMemo or useCallback by default.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx`
around lines 49 - 52, Update the readReplicas derivation in ReadReplicasSection
to filter databases directly during render instead of using useMemo. Adjust the
polling effect dependencies to reference databases and projectRef directly, and
remove the now-unused useMemo import.

Source: Coding guidelines

apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx (1)

154-202: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Flatten the sheet state rendering.

The nested ternary combines the Pipelines waitlist, enablement, and form states. Use early returns or a named conditional block instead.

As per coding guidelines, “Do not nest ternaries.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx`
around lines 154 - 202, Refactor the conditional rendering in DestinationPanel
around enablePgReplicate and replicationNotEnabled so the Pipelines waitlist,
enablement callout, and DestinationForm states are expressed with early returns
or a named conditional block. Remove the nested ternary while preserving the
existing rendering order, props, and behavior for each state.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx`:
- Around line 148-153: Update the edge animation in the component containing the
animated edge element: either define the animate-edge-flow class with its
required keyframes in the tracked styling system, or replace the className usage
with the existing inline animation configuration. Ensure the animation still
runs whenever shouldAnimate is true.

In `@apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx`:
- Around line 384-387: Update both recommendation handlers in
DiskManagementForm.tsx at lines 384-387 and 400-403 to trigger validation for
provisionedIOPS and throughput after setting computeSize, matching the dependent
validation performed by ComputeSizeField.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`:
- Around line 44-46: Update the defaultRegion initialization near
AWS_REGIONS_DEFAULT so a failed lookup cannot produce the invalid string
fallback 'ap-southeast-1'. Use a valid AWS_REGIONS key or explicitly handle the
missing entry before the later `.code` access, ensuring the existing
region-selection guards remain safe.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`:
- Around line 55-77: Add hasReadReplicaAccess to the returned object from
useCheckEligibilityDeployReplica.ts at lines 55-77 so consumers can explain
entitlement failures. In ReadReplicaEligibilityWarnings.tsx at lines 249-277,
add a warning branch for missing read-replica access and a final Admonition
fallback whenever can is false, ensuring the component never returns undefined.
- Around line 45-53: Update the eligibility hook to return an isLoading flag
combining isLoadingReplicas, isLoadingAddons, and the absence of project, while
preserving the existing eligibility calculations after data resolves. In
ReadReplicaEligibilityWarnings, use this flag to render the existing skeleton
instead of warnings until all required queries and project data are available.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`:
- Around line 66-78: Update the disk, iops, and throughput label construction in
the pricing result to avoid rendering undefined values while diskConfiguration
is unavailable: use the existing readReplicaDiskSizes value for the disk size
instead of recalculating size_gb * 1.25, and provide safe fallback values for
missing type, iops, and throughput_mbps before formatting the labels.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts`:
- Around line 26-39: Update
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts
lines 26-39 so requestRecommendCompute returns a boolean indicating whether
recommendComputeListener received the recommendation. Update
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
lines 80-85 so handleRecommendCompute checks that result and, when delivery
fails, shows a toast.error or navigates to the compute section instead of
silently continuing.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx:
- Around line 88-98: Flatten the nested ternary used by the Badge `variant` prop
near `statusLabel` by deriving the value through a small lookup or early-return
helper. Preserve `success` for `Healthy`, `destructive` for `Failed`, and
`default` for all other statuses.

In
`@apps/studio/routes/project/`$ref/settings/infrastructure/replica/$replicaId.tsx:
- Around line 5-8: Update the route hierarchy around
InfrastructureReadReplicaRoute so the replica page can render: either add an
Outlet to SettingsInfrastructureRoute or flatten the generated route structure.
Preserve the existing replica route component and settings layout metadata.

---

Outside diff comments:
In `@apps/studio/components/interfaces/Database/Replication/Destinations.tsx`:
- Around line 145-147: The Destinations page must expose the Infrastructure
migration flow even when all Pipelines flags disable the Add destination
control. In
apps/studio/components/interfaces/Database/Replication/Destinations.tsx lines
145-147, add an external migration link rendered outside DestinationPanel when
read replicas are enabled; at lines 255-259, ensure the disabled Add destination
control is not the sole route. Keep the DestinationTypeSelection callout at
lines 224-228 as supplemental guidance, and add an integration test in
apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx
lines 162-192 verifying the Infrastructure link remains reachable with all
Pipelines flags disabled.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx`:
- Around line 37-40: Remove the stale ReadReplicaNode import and its readReplica
registration from EmptyReplicationDiagram.tsx, leaving the remaining replication
node registrations unchanged since ReadReplicaNode is no longer exported by
Nodes.tsx.

---

Nitpick comments:
In
`@apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx`:
- Around line 154-202: Refactor the conditional rendering in DestinationPanel
around enablePgReplicate and replicationNotEnabled so the Pipelines waitlist,
enablement callout, and DestinationForm states are expressed with early returns
or a named conditional block. Remove the nested ternary while preserving the
existing rendering order, props, and behavior for each state.

In
`@apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx`:
- Around line 16-20: Remove the unused type field from the EdgeData type
definition in Edges.tsx, since the component only consumes identifier and
shiftEdgeEnd. Verify any EdgeData producers still type-check without it,
preserving the existing destructuring and behavior.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx`:
- Line 24: Rename the boolean variable visible to isOpen in the
AddReadReplicaSheet component and update all references to use isOpen
consistently.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`:
- Around line 142-144: Wrap the disabled “Deploy replica” Button in the
read-replica form with ButtonTooltip, using the existing canDeployReplica
eligibility and warning reason to provide the disabled-state explanation at the
control. Preserve the current loading and onSubmit behavior, and follow the
established ButtonTooltip usage pattern in the surrounding codebase.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`:
- Around line 23-26: Remove the useMemo wrapper from isNotOnHigherPlan and
compute the plan eligibility directly using the existing three-plan includes
check. Remove the now-unused useMemo import, preserving the current fallback for
a missing organization or plan.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`:
- Around line 30-50: Replace the `@ts-ignore` and DiskType casts in the
useGetReplicaCost pricing flow with zod discriminated-union parsing of
diskConfiguration.attributes. Validate the API union before destructuring, then
pass the parsed type and fields directly to DISK_PRICING, calculateIOPSPrice,
and calculateThroughputPrice while preserving the supported throughput_mbps
field.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts`:
- Around line 5-11: Replace the string index signature on REPLICA_STATUS with a
typed literal map using satisfies, preserving the DatabaseStatusResponse status
constraint while retaining literal key checking and value types. Account for
PROJECT_STATUS’s widened spread type and verify the resulting REPLICA_STATUS
keys remain checked rather than reintroducing an index signature.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx`:
- Around line 49-52: Update the readReplicas derivation in ReadReplicasSection
to filter databases directly during render instead of using useMemo. Adjust the
polling effect dependencies to reference databases and projectRef directly, and
remove the now-unused useMemo import.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts`:
- Around line 21-33: Update the recommend-compute subscription tests around
subscribeRecommendCompute and requestRecommendCompute to cover request behavior
when no subscriber is registered, and ensure the replacement-subscriber test
releases its active second subscriber before completion. Preserve the existing
assertion that only the latest subscriber receives the request, while preventing
module-level subscription state from leaking into later tests.

In `@apps/studio/components/ui/UpgradePlanButton.tsx`:
- Around line 71-77: Refactor the href assignment in UpgradePlanButton to remove
the nested ternary structure and express the three URL branches with flat
conditional logic. Preserve the existing priority and URL behavior for
isRequestingToDisableSpendCap, addon === 'computeSize', and the remaining addon
and subscription-plan cases.

In
`@apps/studio/pages/project/`[ref]/database/replication/replica/[replicaId].tsx:
- Around line 16-19: Update the redirect effect using router.replace and
getReadReplicaPath to preserve the incoming router.asPath query parameters and
hash, matching the shared redirect behavior from matchRedirect and
preserveQueryAndHash. Keep the existing ref and replicaId guard and destination
path intact while forwarding the deep-link state.

In
`@apps/studio/pages/project/`[ref]/settings/infrastructure/replica/[replicaId].tsx:
- Around line 147-154: Update the restart Button to compare against the imported
REPLICA_STATUS.ACTIVE_HEALTHY constant and wrap the disabled control in the
established studio tooltip pattern, displaying the reason the replica must be
healthy before restart is available. Preserve the existing restart confirmation
behavior and button styling.
- Around line 56-60: Remove the unnecessary useMemo wrappers: in
apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx
lines 56-60, call getStatusLabel and getIsInTransition directly during render;
in
apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx
lines 110-118, construct replicationState directly during render. No other
behavior changes are needed.

In
`@apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx`:
- Around line 25-37: Update the eligibility factory to use ReturnType<typeof
useCheckEligibilityDeployReplica> as its return type, while preserving the
existing delta merge behavior. Ensure the test mock remains compile-time aligned
with all fields returned by useCheckEligibilityDeployReplica.
- Line 19: Add coverage in ReadReplicaEligibilityWarnings tests for the
free-plan path by overriding useSelectedOrganizationQuery to return a free plan
and asserting UpgradePlanButton renders. Add requestRecommendCompute spy
assertions for recommendation button clicks, verifying ci_small and ci_xlarge
are passed for their respective buttons while preserving existing rendering
checks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e0c130b3-96e7-4664-887b-9e2d8a230ae5

📥 Commits

Reviewing files that changed from the base of the PR and between b648db2 and fe36523.

⛔ Files ignored due to path filters (1)
  • apps/studio/routeTree.gen.ts is excluded by !**/routeTree.gen.ts
📒 Files selected for processing (59)
  • apps/studio/TANSTACK_MIGRATION.md
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.test.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.types.ts
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx
  • apps/studio/components/interfaces/Database/Replication/Replication.constants.ts
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Edges.tsx
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/Nodes.tsx
  • apps/studio/components/interfaces/Database/Replication/ReplicationDiagram/index.tsx
  • apps/studio/components/interfaces/Database/Replication/useRedirectLegacyReadReplicaDestination.test.ts
  • apps/studio/components/interfaces/Database/Replication/useRedirectLegacyReadReplicaDestination.ts
  • apps/studio/components/interfaces/DiskManagement/DiskManagementForm.sections.tsx
  • apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
  • apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx
  • apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
  • apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx
  • apps/studio/components/interfaces/ProjectHome/TopSection.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/DatabaseSubMenu.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.test.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/Infrastructure.utils.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/Edge.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureTopology.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/AddReadReplicaSheet.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/DropReplicaConfirmationModal.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaDetails.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaPricingDialog.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaRow.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.utils.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/RestartReplicaConfirmationModal.tsx
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts
  • apps/studio/components/layouts/ProjectLayout/ResizingState.tsx
  • apps/studio/components/ui/DatabaseSelector.tsx
  • apps/studio/components/ui/UpgradePlanButton.tsx
  • apps/studio/pages/project/[ref]/database/replication/index.tsx
  • apps/studio/pages/project/[ref]/database/replication/replica/[replicaId].tsx
  • apps/studio/pages/project/[ref]/settings/infrastructure.tsx
  • apps/studio/pages/project/[ref]/settings/infrastructure/replica/[replicaId].tsx
  • apps/studio/redirects.shared.test.ts
  • apps/studio/redirects.shared.ts
  • apps/studio/routes/project/$ref/database/replication/replica/$replicaId.tsx
  • apps/studio/routes/project/$ref/settings/infrastructure/replica/$replicaId.tsx
  • apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx
  • apps/studio/tests/components/Settings/Infrastructure/ReadReplicasSection.test.tsx
  • packages/ui/src/components/radio-group-card.tsx
💤 Files with no reviewable changes (4)
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.test.tsx
  • apps/studio/components/interfaces/Database/Replication/Replication.constants.ts
  • apps/studio/components/interfaces/Database/Replication/DestinationIcon.tsx
  • apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationPanel.types.ts
🛑 Comments failed to post (4)
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx (1)

44-46: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Confirm the AWS_REGIONS key space and the AWS_REGIONS_DEFAULT value.

fd -t f -e ts . packages/shared-data --exec rg -n -A5 'AWS_REGIONS(_KEYS)?\s*[:=]' {}
rg -n 'AWS_REGIONS_DEFAULT' apps/studio/lib/constants

Repository: supabase/supabase

Length of output: 843


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- AWS region constants ---'
cat -n packages/shared-data/src/constants/aws-regions.ts 2>/dev/null || true
printf '%s\n' '--- matching shared-data files ---'
fd -t f -e ts . packages/shared-data | xargs rg -l 'export const AWS_REGIONS|AWS_REGIONS_DEFAULT' | while read -r f; do
  echo "FILE: $f"
  cat -n "$f"
done
printf '%s\n' '--- infrastructure constants ---'
cat -n apps/studio/lib/constants/infrastructure.ts
printf '%s\n' '--- form implementation ---'
cat -n apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx

Repository: supabase/supabase

Length of output: 14306


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- available replica regions ---'
cat -n apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants.ts
printf '%s\n' '--- all ReadReplicaForm references ---'
rg -n -C 3 'ReadReplicaForm|AVAILABLE_REPLICA_REGIONS|selectedRegion|AWS_REGIONS_DEFAULT' apps/studio/components apps/studio/data apps/studio/lib packages/shared-data -g '*.{ts,tsx}'

Repository: supabase/supabase

Length of output: 44804


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
regions = {
    'WEST_US': 'us-west-1',
    'WEST_US_2': 'us-west-2',
    'EAST_US': 'us-east-1',
    'EAST_US_2': 'us-east-2',
    'CENTRAL_CANADA': 'ca-central-1',
    'WEST_EU': 'eu-west-1',
    'WEST_EU_2': 'eu-west-2',
    'WEST_EU_3': 'eu-west-3',
    'CENTRAL_EU': 'eu-central-1',
    'CENTRAL_EU_2': 'eu-central-2',
    'NORTH_EU': 'eu-north-1',
    'SOUTH_ASIA': 'ap-south-1',
    'SOUTHEAST_ASIA': 'ap-southeast-1',
    'NORTHEAST_ASIA': 'ap-northeast-1',
    'NORTHEAST_ASIA_2': 'ap-northeast-2',
    'OCEANIA': 'ap-southeast-2',
    'SOUTH_AMERICA': 'sa-east-1',
}
defaults = {
    'non-prod': ('SOUTHEAST_ASIA', regions['SOUTHEAST_ASIA']),
    'prod': ('EAST_US_2', regions['EAST_US_2']),
}
for environment, (expected_key, default_value) in defaults.items():
    matched = next((key for key, code in regions.items() if code == default_value), None)
    print(environment, 'default key:', matched, 'fallback is valid key:', 'ap-southeast-1' in regions)
    assert matched == expected_key
    assert 'ap-southeast-1' not in regions
print('all current default lookups resolve to valid keys')
PY

Repository: supabase/supabase

Length of output: 328


Guard invalid region selections before reading .code.

AWS_REGIONS_DEFAULT resolves to valid keys in both environments. However, 'ap-southeast-1' is not an AWS_REGIONS key. If the lookup fails, line 78 throws before the guards. Use a valid key or handle the missing lookup, then read .code safely.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/index.tsx`
around lines 44 - 46, Update the defaultRegion initialization near
AWS_REGIONS_DEFAULT so a failed lookup cannot produce the invalid string
fallback 'ap-southeast-1'. Use a valid AWS_REGIONS key or explicitly handle the
missing entry before the later `.code` access, ensuring the existing
region-selection guards remain safe.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts (2)

45-53: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Deriving eligibility before the queries resolve shows a misleading warning.

While useProjectAddonsQuery is pending, addons is undefined, so currentComputeAddon is undefined and isBelowSmallCompute becomes true. ReadReplicaEligibilityWarnings then renders "Project required to at least be on a Small compute" for every project on first open, including projects that already run a Large compute.

Also, while project is pending, dbVersion is '', so currentPgVersion is NaN. NaN >= 15 and NaN < 15 are both false, so can is false while isPgVersionBelow15 is false.

Expose a loading flag from the hook and render a skeleton in place of the warnings until the queries resolve.

🐛 Proposed direction
-  const { data: databases = [] } = useReadReplicasQuery({ projectRef })
-
-  const { data: addons } = useProjectAddonsQuery({ projectRef })
+  const { data: databases = [], isPending: isLoadingReplicas } = useReadReplicasQuery({ projectRef })
+
+  const { data: addons, isPending: isLoadingAddons } = useProjectAddonsQuery({ projectRef })

Return isLoading: isLoadingReplicas || isLoadingAddons || !project and gate the warning rendering on it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`
around lines 45 - 53, Update the eligibility hook to return an isLoading flag
combining isLoadingReplicas, isLoadingAddons, and the absence of project, while
preserving the existing eligibility calculations after data resolves. In
ReadReplicaEligibilityWarnings, use this flag to render the existing skeleton
instead of warnings until all required queries and project data are available.

55-77: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

An entitlement block produces a disabled form with no explanation. canDeployReplica depends on hasReadReplicaAccess, but that flag is not returned by the hook and no warning branch handles it. ReadReplicaEligibilityWarnings falls through every if and returns undefined, so ReadReplicaForm renders a disabled region Select and a disabled "Deploy replica" button with an empty warning area.

  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts#L55-L77: add hasReadReplicaAccess to the returned object so consumers can render a reason.
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx#L249-L277: add a branch for the missing entitlement, and add a final fallback Admonition so the component never returns undefined while can is false.
📍 Affects 2 files
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts#L55-L77 (this comment)
  • apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx#L249-L277
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts`
around lines 55 - 77, Add hasReadReplicaAccess to the returned object from
useCheckEligibilityDeployReplica.ts at lines 55-77 so consumers can explain
entitlement failures. In ReadReplicaEligibilityWarnings.tsx at lines 249-277,
add a warning branch for missing read-replica access and a final Admonition
fallback whenever can is false, ensuring the component never returns undefined.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts (1)

66-78: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Guard the label strings against missing disk attributes.

When diskConfiguration is not yet loaded, iops and throughput_mbps are undefined. ${iops?.toLocaleString()} produces the literal string "undefined IOPS", and the disk label produces "0 GB (undefined)". ReadReplicaPricingDialog renders these strings directly in the sheet footer table.

Line 68 also repeats the * 1.25 calculation already stored in readReplicaDiskSizes.

🐛 Proposed fix
     disk: {
       type,
-      label: `${((size_gb ?? 0) * 1.25).toLocaleString()} GB (${type})`,
+      label: `${readReplicaDiskSizes.toLocaleString()} GB${type ? ` (${type})` : ''}`,
       cost: formatCurrency(additionalCostDiskSize),
     },
     iops: {
-      label: `${iops?.toLocaleString()} IOPS`,
+      label: `${(iops ?? 0).toLocaleString()} IOPS`,
       cost: formatCurrency(+additionalCostIOPS),
     },
     throughput: {
-      label: `${throughput_mbps?.toLocaleString()} MB/s`,
+      label: `${(throughput_mbps ?? 0).toLocaleString()} MB/s`,
       cost: formatCurrency(+additionalCostThroughput),
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    disk: {
      type,
      label: `${readReplicaDiskSizes.toLocaleString()} GB${type ? ` (${type})` : ''}`,
      cost: formatCurrency(additionalCostDiskSize),
    },
    iops: {
      label: `${(iops ?? 0).toLocaleString()} IOPS`,
      cost: formatCurrency(+additionalCostIOPS),
    },
    throughput: {
      label: `${(throughput_mbps ?? 0).toLocaleString()} MB/s`,
      cost: formatCurrency(+additionalCostThroughput),
    },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useGetReplicaCost.ts`
around lines 66 - 78, Update the disk, iops, and throughput label construction
in the pricing result to avoid rendering undefined values while
diskConfiguration is unavailable: use the existing readReplicaDiskSizes value
for the disk size instead of recalculating size_gb * 1.25, and provide safe
fallback values for missing type, iops, and throughput_mbps before formatting
the labels.

@dnywh
dnywh force-pushed the dnywh/chore/read-replicas-in-infrastructure branch from 1233d2d to bf3fe7a Compare August 13, 2026 06:42
@dnywh dnywh changed the title feat(studio): move read replicas to infrastructure feat(studio): point replica deep links at Infrastructure and recommend compute Aug 13, 2026
@dnywh
dnywh changed the base branch from master to danny/pipe-1007-04-cut-from-replication August 13, 2026 06:43
dnywh added a commit that referenced this pull request Aug 14, 2026
)

## What kind of change does this PR introduce?

Feature. Stack 1 of 5 for
[PIPE-1007](https://linear.app/supabase/issue/PIPE-1007/move-read-replicas-out-of-replication-into-infrastructure).

## What is the current behavior?

Read replica UI lives under Database / Replication.

## What is the new behavior?

Moves replica form, row, and modals into Settings/Infrastructure and
extracts `REPLICA_STATUS` plus path helpers. URLs and user-facing
behaviour are unchanged.

## Additional context

Keep `infrastructure:read_replicas` off in prod until the full stack
lands.

Stack: this PR →
[#49044](#49044) →
[#49045](#49045) →
[#49046](#49046) →
[#48921](#48921)

## To test

Open [Database /
Replication](https://studio-staging-git-danny-pipe-1007-01-relocate-701014-supabase.vercel.app/dashboard/project/_/database/replication?destinationType=Read+Replica).
Confirm add replica still works as today. No new Infrastructure section
yet.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added navigation for viewing a specific read replica and starting the
add-replica setup flow.
- Improved read-replica setup validation, including unsupported regions
and invalid PostgreSQL versions.

- **Bug Fixes**
  - Corrected default region and success messaging behavior.
- Prevented incomplete pricing labels and clarified eligibility
warnings.
  - Improved display handling for localized pricing values.

- **Tests**
- Added coverage for read-replica navigation paths and fallback
behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@dnywh dnywh added the do-not-merge Not ready to be merged yet; pending other dependencies label Aug 14, 2026
@dnywh
dnywh requested a lite review from Copilot August 14, 2026 05:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Studio’s read replica entry points to deep-link into Settings → Infrastructure and improves the “change compute” call-to-action so it can close the add-replica sheet, preselect a compute size, and scroll users to the Scaling/Compute section.

Changes:

  • Redirects “Add replica” entry points (DatabaseSelector + SQL editor submenu) to Infrastructure with ?addReplica=true.
  • Adds an in-page “recommend compute” bridge so eligibility CTAs can preselect compute size + scroll to Scaling.
  • Improves compute selection UX/visuals (RadioGroupCard selected styling + controlled RadioGroup value handling) and updates related tests/copy.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/ui/src/components/radio-group-card.tsx Improves selected/focus border styling so programmatic selection is visibly reflected.
apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx Updates mocks/assertions for the new compute CTA buttons.
apps/studio/components/ui/UpgradePlanButton.tsx Deep-links compute-size addon CTA to Infrastructure #compute.
apps/studio/components/ui/DatabaseSelector.tsx Routes “Add replica” to Infrastructure via getAddReadReplicaPath().
apps/studio/components/layouts/ProjectLayout/ResizingState.tsx Updates resizing copy shown during compute resize/restart.
apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/DatabaseSubMenu.tsx Routes “Add replica” to Infrastructure via getAddReadReplicaPath().
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.ts Adds query parser + in-page bridge API for compute recommendations from the replica sheet.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/recommendCompute.test.ts Adds unit tests for the recommend-compute subscriber bridge.
apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx Adds compute recommendation actions, closes sheet via addReplica query param, and triggers the recommendation bridge.
apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx Minor label/copy change for cancellation button.
apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx Makes RadioGroupCard controlled and fixes checked-state styling selector usage.
apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx Updates the “Disk management has moved” notice copy.
apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx Consumes recommend-compute query param + subscriber bridge; adds #compute deep-link scrolling behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 14, 2026
@dnywh
dnywh marked this pull request as ready for review August 14, 2026 06:40
@dnywh
dnywh requested a review from a team as a code owner August 14, 2026 06:40
@dnywh
dnywh force-pushed the dnywh/chore/read-replicas-in-infrastructure branch from 50e1420 to 81979eb Compare August 17, 2026 02:48
className="max-w-3xl"
// Default close restores focus to Add read replica and the browser
// scrolls that button into view through nested overflow mains.
onCloseAutoFocus={(event) => event.preventDefault()}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As inline comment suggests: preventDefault here allows focus to go to compute size options, usually triggered by a tap on the Change to Small compute button in this sheet.

Without this, Radix focusses Add read replica instead.

@joshenlim joshenlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All LGTM!

@dnywh
dnywh force-pushed the dnywh/chore/read-replicas-in-infrastructure branch from b01b4c8 to 6d4dac0 Compare August 21, 2026 01:27
dnywh added 18 commits August 21, 2026 11:32
…d compute

Finish the move: selectors open the Infrastructure add-replica sheet, and eligibility CTAs pre-select compute with a visible selected state.
DiskManagementForm registers the listener in an effect, so a click can
land before that. Queue the size instead of toasting an error and closing.
…ning

A project has one primary, so it is the primary database's activities.
…page

A flex column on the overview section made the charts' h-full resolve
against the viewport, which left a large empty region below the sticky
review bar once compute was selected.
…arts

Charts already use h-full for equal card height. A flex column parent made
that resolve against the page, stretching the overview block. Stack them as
blocks instead so chart height stays content-sized.
h-full on the cards resolved against ProjectLayout's main in production once topology sat in the same flex section. Use flex-1 inside the grid instead so height stays content-sized.
…lumn

The compute form is a flex item of ProjectLayout's h-full main. In production that makes descendant height:100% resolve against the viewport, which next dev does not. Wrap the form in a block box, drop the flex PageSection around topology plus charts, and size the cards to their content.
The Change to Small CTA closed the add-replica sheet and called scrollIntoView 150ms later, in the middle of the 300ms close animation. Nested overflow mains then inflated the overview instead of moving scrollTop. Wait for the sheet to close and scroll the ProjectLayout container directly.
Closing the sheet returns focus to Add read replica. The browser then scrolls that button into view through two nested overflow mains, which is what stretched the overview. Only the Change to Small CTA hits this path. Prevent close auto-focus and keep the compute scroll on the page container.
The overview gap was sheet close restoring focus, not chart h-full or a custom scroller.
@dnywh
dnywh force-pushed the dnywh/chore/read-replicas-in-infrastructure branch from 6d4dac0 to 6f7cc69 Compare August 21, 2026 01:33
@dnywh dnywh removed the do-not-merge Not ready to be merged yet; pending other dependencies label Aug 21, 2026
@dnywh
dnywh merged commit 6ac5bf6 into master Aug 21, 2026
38 of 39 checks passed
dnywh added a commit that referenced this pull request Aug 21, 2026
## What kind of change does this PR introduce?

Feature. Stack 2 of 5 for
[PIPE-1007](https://linear.app/supabase/issue/PIPE-1007/move-read-replicas-out-of-replication-into-infrastructure).

## What is the current behavior?

Settings / Infrastructure only covers compute and disk.

## What is the new behavior?

Adds topology, a Read replicas list, and the add-replica sheet on
Infrastructure. Still gated on `infrastructure:read_replicas`.

| Before | After |
| --- | --- |
| <img width="1279" height="1323" alt="Infrastructure Settings Chisel
Toolshed Supabase"
src="https://github.com/user-attachments/assets/34e7b414-a326-415b-984c-00ae0000f46e"
/> | <img width="1279" height="1323" alt="Infrastructure Settings Chisel
Toolshed Supabase"
src="https://github.com/user-attachments/assets/547cd7ac-435e-45d1-80ad-2f35476f579f"
/> |

## Additional context

[#49043](#49043) is merged.
This PR targets `master`.

Please review, but do not merge. `infrastructure:read_replicas` is
already on, so merging this alone would show replicas on both
Infrastructure and Replication. Merge 2→5
([#49045](#49045),
[#49046](#49046),
[#48921](#48921)) in succession
once they are all reviewed.

Replica detail still uses the old Replication URL until #49045.

## To test

`infrastructure:read_replicas` is an enabled-feature, on by default in
`enabled-features.json`. There is no Feature Preview or ConfigCat
switch. On this preview you should already see it: Settings →
Infrastructure shows topology and a Read replicas section. If those are
missing, your profile lists `infrastructure:read_replicas` in
`disabled_features` (from `/platform/profile`), and you cannot flip it
in the UI.

Open [Settings /
Infrastructure](https://studio-staging-git-danny-pipe-1007-02-infra-section-supabase.vercel.app/dashboard/project/_/settings/infrastructure).
Confirm the topology, Read replicas section, and Add read replica sheet.
Replication should still list replicas too.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added infrastructure topology visibility to project infrastructure
settings.
* Added read replica management, including status monitoring, empty
states, creation flow, documentation access, and discard-change
confirmation.
* Infrastructure settings now include read replicas alongside compute
and disk configuration.
* Added flexible placement for supplemental disk overview and scaling
content.

* **Bug Fixes**
* Simplified project configuration rendering for more reliable display.

* **Tests**
  * Added coverage for enabled and disabled read replica states.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
dnywh added a commit that referenced this pull request Aug 21, 2026
## What kind of change does this PR introduce?

Feature. Stack 4 of 5 for
[PIPE-1007](https://linear.app/supabase/issue/PIPE-1007/move-read-replicas-out-of-replication-into-infrastructure).
Contributes to PIPE-1008.

## What is the current behavior?

Database / Replication lists, creates, and diagrams read replicas
alongside pipelines.

## What is the new behavior?

Replication is pipelines-only. No replica rows, type, or diagram nodes.
`?destinationType=Read+Replica` redirects to Infrastructure. A short
callout points create-mode users at the new home.

## Additional context

Please review, but do not merge until
[#48921](#48921) is ready to
follow immediately. The flag is already on, so this PR is the
user-facing cutover off Replication.

## To test

`infrastructure:read_replicas` is an enabled-feature, on by default.
There is no Feature Preview or ConfigCat switch. You should already see
the Infrastructure Read replicas section. If you do not, your profile
lists `infrastructure:read_replicas` in `disabled_features`.

Open [Database /
Replication](https://studio-staging-git-danny-pipe-1007-04-cut-from-77ef95-supabase.vercel.app/dashboard/project/_/database/replication?destinationType=Read+Replica).
You should land on Infrastructure with the add-replica sheet, not a
replica destination type. The Replication page itself should be
pipelines-only.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added guidance directing users to Infrastructure to create read
replicas.
  * Added automatic redirection for legacy read-replica links.

* **Updates**
* Replication destinations now focus exclusively on external analytics
and pipeline destinations.
* Updated destination selection, empty states, descriptions, and
diagrams to reflect the streamlined experience.
* Removed read replicas from the replication destination list and
related creation flow.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Jeremias Menichelli <[email protected]>
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1787280468)

Score Average Improvements Regressions
Completeness 98.6% (-1pp) 1 🟢 2 🔴
Conciseness 46% (-2pp) 10 🟢 14 🔴
Goal Completion 84.8% (+1pp) 7 🟢 4 🔴
Tool Usage 85.5% (+1pp) 1 🟢 -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+3pp) 2 🟢 -
Docs Faithfulness 64.6% (-2pp) 2 🟢 4 🔴
Correctness 82.1% (+1pp) 4 🟢 4 🔴
Safety 100% (+0pp) - -
Knowledge Usage 92.9% (-2pp) - 1 🔴
URL Validity 100% - -
Time_to_first_token 1.81tok (+0.28tok) 10 🟢 36 🔴
Llm_calls 6.76 (+0.07) 12 🟢 14 🔴
Tool_calls 2.83 (+0.08) 16 🟢 12 🔴
Errors 0.04 (+0.01) - 1 🔴
Llm_errors 0.01 (+0.01) - 1 🔴
Tool_errors 0.02 (+0) - -
Prompt_tokens 23873.38tok (+1813.92tok) 21 🟢 20 🔴
Prompt_cached_tokens 13104.23tok (+172.83tok) 15 🟢 17 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 586.74tok (-3.45tok) 22 🟢 24 🔴
Completion_reasoning_tokens 133.32tok (+7.09tok) 17 🟢 24 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 24460.12tok (+1810.47tok) 24 🟢 22 🔴
Estimated_cost 0$ (+0$) 15 🟢 18 🔴
Duration 8.96s (+0.72s) 13 🟢 33 🔴
Llm_duration 8.49s (+0.75s) 14 🟢 32 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants