From 7e1b3cdcdc36dff5014cde9ae4a6bf48feb6c4ff Mon Sep 17 00:00:00 2001
From: Jordi Enric <37541088+jordienr@users.noreply.github.com>
Date: Wed, 11 Feb 2026 17:21:57 +0100
Subject: [PATCH] O11y Overview: wait for flags loaded before redirect DEPR-372
(#42689)
https://linear.app/supabase/issue/DEPR-372/observability-overview-redirects-to-custom-reports-on-refresh
## Summary by CodeRabbit
* **Bug Fixes**
* Prevented premature redirect on the observability page by waiting for
feature flags to finish loading before running redirect logic.
* Added an early loading guard to display a logo loader until feature
flags and page data are ready, reducing UI flicker.
* Consistently render the empty-state and report creation UI when the
overview is not shown, simplifying display logic.
---
.../project/[ref]/observability/index.tsx | 70 +++++++++----------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/apps/studio/pages/project/[ref]/observability/index.tsx b/apps/studio/pages/project/[ref]/observability/index.tsx
index 087c2791fb1..24e081daa5d 100644
--- a/apps/studio/pages/project/[ref]/observability/index.tsx
+++ b/apps/studio/pages/project/[ref]/observability/index.tsx
@@ -1,25 +1,25 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useRouter } from 'next/router'
-import { useEffect, useState } from 'react'
-
-import { useParams, useFlag } from 'common'
-import { CreateReportModal } from 'components/interfaces/Reports/CreateReportModal'
+import { useFeatureFlags, useFlag, useParams } from 'common'
import { ObservabilityOverview } from 'components/interfaces/Observability/ObservabilityOverview'
+import { CreateReportModal } from 'components/interfaces/Reports/CreateReportModal'
import DefaultLayout from 'components/layouts/DefaultLayout'
import ObservabilityLayout from 'components/layouts/ObservabilityLayout/ObservabilityLayout'
import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
import { useContentQuery } from 'data/content/content-query'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useProfile } from 'lib/profile'
+import { useRouter } from 'next/router'
+import { parseAsBoolean, useQueryState } from 'nuqs'
+import { useEffect, useState } from 'react'
import type { NextPageWithLayout } from 'types'
import { LogoLoader } from 'ui'
-import { parseAsBoolean, useQueryState } from 'nuqs'
export const UserReportPage: NextPageWithLayout = () => {
const router = useRouter()
const { ref } = useParams()
const { profile } = useProfile()
+ const { hasLoaded: flagsLoaded } = useFeatureFlags()
const showOverview = useFlag('observabilityOverview')
const [showCreateReportModal, setShowCreateReportModal] = useQueryState(
'newReport',
@@ -37,6 +37,7 @@ export const UserReportPage: NextPageWithLayout = () => {
useEffect(() => {
if (!isSuccess) return
+ if (!flagsLoaded) return // Wait for flags to load before checking redirect
if (showOverview) return // Don't redirect if overview is enabled
const reports = data.content
@@ -44,7 +45,7 @@ export const UserReportPage: NextPageWithLayout = () => {
.sort((a, b) => a.name.localeCompare(b.name))
if (reports.length >= 1) router.push(`/project/${ref}/observability/${reports[0].id}`)
if (reports.length === 0) router.push(`/project/${ref}/observability/api-overview`)
- }, [isSuccess, data, router, ref, showOverview])
+ }, [isSuccess, data, router, ref, showOverview, flagsLoaded])
const { can: canCreateReport } = useAsyncCheckPermissions(
PermissionAction.CREATE,
@@ -55,6 +56,11 @@ export const UserReportPage: NextPageWithLayout = () => {
}
)
+ // Wait for flags to load before rendering to avoid flashing wrong page
+ if (!flagsLoaded || isLoading) {
+ return
- Create custom reports for your projects. -
-- Get a high level overview of your network traffic, user actions, and infrastructure - health. -
-Create custom reports for your projects.
++ Get a high level overview of your network traffic, user actions, and infrastructure + health. +
+