Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): drive compute card cores/memory from infra_compute_size (#45334)

Ali Waseem6fe0ad442b66
diff --git a/apps/studio/components/ui/ComputeBadgeWrapper.tsx b/apps/studio/components/ui/ComputeBadgeWrapper.tsx
index b999890eea4..1fc12e68081 100644
--- a/apps/studio/components/ui/ComputeBadgeWrapper.tsx
+++ b/apps/studio/components/ui/ComputeBadgeWrapper.tsx
@@ -4,14 +4,12 @@ import { Button, cn, HoverCard, HoverCardContent, HoverCardTrigger, Separator }
import { ComputeBadge } from 'ui-patterns/ComputeBadge'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
-import { getAddons } from '@/components/interfaces/Billing/Subscription/Subscription.utils'
+import { getAvailableComputeOptions } from '@/components/interfaces/DiskManagement/DiskManagement.utils'
import { ProjectDetail } from '@/data/projects/project-detail-query'
import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
-import { ProjectAddonVariantMeta } from '@/data/subscriptions/types'
import { ResourceWarning } from '@/data/usage/resource-warnings-query'
import { getCloudProviderArchitecture } from '@/lib/cloudprovider-utils'
-import { INSTANCE_MICRO_SPECS } from '@/lib/constants'
import { useTrack } from '@/lib/telemetry/track'
export const ChevronsUpAnimated = () => (
@@ -76,23 +74,14 @@ export const ComputeBadgeWrapper = ({
{ projectRef },
{ enabled: open }
)
- const selectedAddons = addons?.selected_addons ?? []
- const { computeInstance } = getAddons(selectedAddons)
- const computeInstanceMeta = computeInstance?.variant?.meta
-
- const meta = (
- computeInstanceMeta === undefined && computeSize === 'micro'
- ? INSTANCE_MICRO_SPECS
- : computeInstanceMeta
- ) as ProjectAddonVariantMeta
-
- const availableCompute = addons?.available_addons.find(
- (addon) => addon.name === 'Compute Instance'
- )?.variants
-
- const highestComputeAvailable = availableCompute?.[availableCompute.length - 1].identifier
+ // Derive cores/memory from the same source as the badge (infra_compute_size) by looking up
+ // the matching variant in available_addons. Sourcing from selected_addons can drift out of
+ // sync with infra_compute_size and produce a card that contradicts its own badge.
+ const computeOptions = getAvailableComputeOptions(addons?.available_addons ?? [], cloudProvider)
+ const meta = computeOptions.find((variant) => variant.identifier === `ci_${computeSize}`)?.meta
+ const highestComputeAvailable = computeOptions[computeOptions.length - 1]?.identifier
const isHighestCompute = computeSize === highestComputeAvailable?.replace('ci_', '')
const { data, isPending: isLoadingSubscriptions } = useOrgSubscriptionQuery(
@@ -161,7 +150,12 @@ export const ComputeBadgeWrapper = ({
) : (
<>
<div className="flex flex-col gap-1">
- {meta !== undefined ? (
+ {computeSize === 'nano' ? (
+ <>
+ <Row label="CPU" stat="Shared" />
+ <Row label="Memory" stat="Up to 0.5 GB" />
+ </>
+ ) : meta !== undefined ? (
<>
<Row
label="CPU"
@@ -169,13 +163,7 @@ export const ComputeBadgeWrapper = ({
/>
<Row label="Memory" stat={`${meta.memory_gb ?? '-'} GB`} />
</>
- ) : (
- <>
- {/* meta is only undefined for nano sized compute */}
- <Row label="CPU" stat="Shared" />
- <Row label="Memory" stat="Up to 0.5 GB" />
- </>
- )}
+ ) : null}
</div>
</>
)}