Skip to content

Conversation

@cezudas
Copy link
Contributor

@cezudas cezudas commented Jan 20, 2026

Fixes OPS-3457.

@linear
Copy link

linear bot commented Jan 20, 2026

@sonarqubecloud
Copy link

@cezudas cezudas marked this pull request as ready for review January 20, 2026 12:10
Copilot AI review requested due to automatic review settings January 20, 2026 12:10
Copy link
Contributor

Copilot AI left a comment

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 fixes a race condition where users were being redirected away from the analytics route before user metadata finished loading. The fix introduces proper loading state handling by checking if metadata is still being fetched before making access control decisions.

Changes:

  • Modified useHasAnalyticsAccess hook to return both access state and loading status
  • Added loading spinner display in AnalyticsGuard while metadata is being fetched
  • Updated useUserMeta hook to expose pending state

Reviewed changes

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

File Description
packages/react-ui/src/app/common/hooks/analytics-hooks.ts Changed return type from boolean to object containing both access flag and pending state
packages/react-ui/src/app/common/hooks/user-hooks.ts Added isPending field to return value for tracking query state
packages/react-ui/src/app/routes/openops-analytics/analytics-guard.tsx Added loading state check and full-page spinner during metadata fetch
packages/react-ui/src/app/features/navigation/lib/menu-links-hook.ts Updated to destructure hasAnalyticsAccess from new object return type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 7 to 9
const { data: isAnalyticsEnabled } = flagsHooks.useFlag<boolean | undefined>(
FlagId.ANALYTICS_ENABLED,
);
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The feature flag loading state is not considered. If the flag is still loading, isAnalyticsEnabled will be undefined, causing isPending to be false while access decisions are made with incomplete data. Consider also checking the pending state from useFlag.

Copilot uses AI. Check for mistakes.
@cezudas cezudas merged commit 5a0d440 into main Jan 20, 2026
21 checks passed
@cezudas cezudas deleted the cezudas/OPS-3457 branch January 20, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants