Skip to content

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

[MUL-1475] fix(studio): show setup state on HA topology diagram during boot (#49786)

Alaister Younga14fc049374e
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.test.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.test.tsx
new file mode 100644
index 00000000000..fefde036516
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.test.tsx
@@ -0,0 +1,129 @@
+import { screen, within } from '@testing-library/react'
+import { platformComponents as components } from 'api-types'
+import { http, HttpResponse } from 'msw'
+import { describe, expect, test, vi } from 'vitest'
+
+import { HaInstanceConfiguration } from './HaInstanceConfiguration'
+import { API_URL } from '@/lib/constants'
+import type { ProfileContextType } from '@/lib/profile'
+import { customRender } from '@/tests/lib/custom-render'
+import { addAPIMock, mswServer, type APIErrorBody } from '@/tests/lib/msw'
+
+type ProjectDetailResponse = components['schemas']['ProjectDetailResponse']
+
+vi.mock('@/lib/constants', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('@/lib/constants')>()
+ return {
+ ...actual,
+ IS_PLATFORM: true,
+ }
+})
+
+const PROFILE_CONTEXT: ProfileContextType = {
+ profile: {
+ id: 1,
+ auth0_id: 'auth0|test',
+ gotrue_id: 'gotrue-test',
+ username: 'testuser',
+ primary_email: '[email protected]',
+ first_name: null,
+ last_name: null,
+ mobile: null,
+ is_alpha_user: false,
+ is_sso_user: false,
+ disabled_features: [],
+ free_project_limit: null,
+ },
+ error: null,
+ isLoading: false,
+ isError: false,
+ isSuccess: true,
+}
+
+const PROJECT: ProjectDetailResponse = {
+ cloud_provider: 'AWS_K8S',
+ connectionString: 'postgresql://postgres:[email protected]:5432/postgres',
+ db_host: 'db.default.supabase.co',
+ dbVersion: 'supabase-postgres-15.1.0',
+ high_availability: true,
+ id: 1,
+ infra_compute_size: 'large',
+ inserted_at: '2026-01-01T00:00:00.000Z',
+ integration_source: null,
+ is_branch_enabled: false,
+ is_physical_backups_enabled: false,
+ name: 'Production',
+ organization_id: 1,
+ ref: 'default',
+ region: 'us-east-1',
+ restUrl: 'https://default.supabase.co',
+ status: 'ACTIVE_HEALTHY',
+ subscription_id: 'subscription-1',
+ updated_at: '2026-01-01T00:00:00.000Z',
+}
+
+const mockProject = (status: ProjectDetailResponse['status']) => {
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref',
+ response: { ...PROJECT, status } satisfies ProjectDetailResponse,
+ })
+}
+
+// The /ha-admin passthrough paths are off-schema (see get-ha-admin.ts), so they
+// can't go through the OpenAPI-typed addAPIMock.
+const mockHaAdmin = ({ isHealthy }: { isHealthy: boolean }) => {
+ mswServer.use(
+ http.get(`${API_URL}/platform/projects/:ref/ha-admin/v1/gateways`, () =>
+ isHealthy
+ ? HttpResponse.json({ gateways: [] })
+ : HttpResponse.json<APIErrorBody>({ message: 'upstream unavailable' }, { status: 500 })
+ ),
+ http.get(`${API_URL}/platform/projects/:ref/ha-admin/v1/poolers`, () =>
+ isHealthy
+ ? HttpResponse.json({ poolers: [] })
+ : HttpResponse.json<APIErrorBody>({ message: 'upstream unavailable' }, { status: 500 })
+ )
+ )
+}
+
+describe('HaInstanceConfiguration', () => {
+ test('shows the setup state instead of an error while the project is coming up', async () => {
+ mockProject('COMING_UP')
+ mockHaAdmin({ isHealthy: false })
+
+ customRender(<HaInstanceConfiguration />, { profileContext: PROFILE_CONTEXT })
+
+ const statusRegion = await screen.findByRole('status')
+ expect(await within(statusRegion).findByText('Setting up project')).toBeInTheDocument()
+ expect(screen.queryByText('Failed to retrieve cluster topology')).not.toBeInTheDocument()
+ })
+
+ test('shows the setup state instead of the unavailable state while the project is coming up with an empty topology', async () => {
+ mockProject('COMING_UP')
+ mockHaAdmin({ isHealthy: true })
+
+ customRender(<HaInstanceConfiguration />, { profileContext: PROFILE_CONTEXT })
+
+ expect(await screen.findByText('Setting up project')).toBeInTheDocument()
+ expect(screen.queryByText('Cluster topology unavailable')).not.toBeInTheDocument()
+ })
+
+ test('surfaces topology errors once the project is running', async () => {
+ mockProject('ACTIVE_HEALTHY')
+ mockHaAdmin({ isHealthy: false })
+
+ customRender(<HaInstanceConfiguration />, { profileContext: PROFILE_CONTEXT })
+
+ expect(await screen.findByText('Failed to retrieve cluster topology')).toBeInTheDocument()
+ })
+
+ test('shows the unavailable state for an empty topology once the project is running', async () => {
+ mockProject('ACTIVE_HEALTHY')
+ mockHaAdmin({ isHealthy: true })
+
+ customRender(<HaInstanceConfiguration />, { profileContext: PROFILE_CONTEXT })
+
+ expect(await screen.findByText('Cluster topology unavailable')).toBeInTheDocument()
+ })
+})
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.tsx
index 0a5c0681998..8c31ccb71ea 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceConfiguration.tsx
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query'
import { useParams } from 'common'
import { Loader2 } from 'lucide-react'
import { useMemo } from 'react'
+import { EmptyStatePresentational } from 'ui-patterns/EmptyStatePresentational'
import { DiagramFlow } from './DiagramFlow'
import { addShardNodes, generateHaNodesAndEdges } from './HaInstanceConfiguration.utils'
@@ -12,6 +13,8 @@ import { AlertError } from '@/components/ui/AlertError'
import { HighAvailabilityDisabledEmptyState } from '@/components/ui/HighAvailability/HighAvailabilityDisabledEmptyState'
import { haClusterGatewaysQueryOptions } from '@/data/ha-admin/ha-cluster-gateways-query'
import { haClusterPoolersQueryOptions } from '@/data/ha-admin/ha-cluster-poolers-query'
+import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from '@/lib/constants'
const nodeTypes = {
HA_GATEWAY: MultigatewayNode,
@@ -32,6 +35,10 @@ const POOLER_STATUS_REFRESH_MS = 30_000
*/
export const HaInstanceConfiguration = () => {
const { ref: projectRef } = useParams()
+ const { data: project } = useSelectedProjectQuery()
+
+ const isProjectBuilding =
+ project?.status === PROJECT_STATUS.COMING_UP || project?.status === PROJECT_STATUS.UNKNOWN
// Gateways poll on the same interval as poolers so the gateway count and
// gateway→primary edge track cluster changes while the page stays open.
@@ -70,11 +77,40 @@ export const HaInstanceConfiguration = () => {
const isError = isErrorGateways || isErrorPoolers
const error = gatewaysError ?? poolersError
- if (isPending) {
+ // While the project is provisioning, the /ha-admin endpoints fail or return an
+ // empty topology as a matter of course — that's a project still booting, not an
+ // unhealthy cluster.
+ const isProvisioning = isProjectBuilding && (isError || (poolers ?? []).length === 0)
+
+ // The initial load and the provisioning placeholder share one persistent
+ // role="status" live region so screen readers announce the transition between
+ // them — a live region only announces updates to content it already contains.
+ if (isPending || isProvisioning) {
return (
- <div role="status" className="h-full w-full flex items-center justify-center">
- <span className="sr-only">Loading cluster topology...</span>
- <Loader2 aria-hidden="true" className="motion-safe:animate-spin text-foreground-light" />
+ <div role="status" className="h-full w-full flex items-center justify-center p-6">
+ {isPending ? (
+ <>
+ <span className="sr-only">Loading cluster topology...</span>
+ <Loader2
+ aria-hidden="true"
+ className="motion-safe:animate-spin text-foreground-light"
+ />
+ </>
+ ) : (
+ <EmptyStatePresentational
+ icon={
+ <Loader2
+ size={24}
+ strokeWidth={1.5}
+ aria-hidden="true"
+ className="motion-safe:animate-spin text-foreground-muted"
+ />
+ }
+ title="Setting up project"
+ description="Cluster topology will be available once your project is ready. This may take a few minutes."
+ className="max-w-md"
+ />
+ )}
</div>
)
}