Skip to content

OCPBUGS-84047: Fix perspective stuck issue with transition guard#16411

Open
TheRealJon wants to merge 1 commit intoopenshift:mainfrom
TheRealJon:OCPBUGS-84047
Open

OCPBUGS-84047: Fix perspective stuck issue with transition guard#16411
TheRealJon wants to merge 1 commit intoopenshift:mainfrom
TheRealJon:OCPBUGS-84047

Conversation

@TheRealJon
Copy link
Copy Markdown
Member

@TheRealJon TheRealJon commented May 7, 2026

Fixes perspective getting stuck when switching away from plugin-registered perspectives (e.g., Fleet Management). Plugins watch activePerspective changes and force back to their perspective, preventing user-initiated switches.

Analysis / Root cause

Plugin effects fire during perspective transitions and override the user's switch by calling setActivePerspective with the plugin's perspective.

Solution description

Add transition guard (isTransitioning ref) that blocks setPerspective calls during active transitions, preventing plugin interference.

Screenshots / screen recording:

Screen.Recording.2026-05-07.at.2.59.38.PM.mov

Test setup

  1. Launch a cluster with the changes from this PR using cluster bot
  2. Install ACM operator and create a multiclusterhub resource

Test cases

Test Case 1: Switching Away from Plugin Perspective (Primary Bug Fix)

Objective: Verify user can switch away from Fleet Management perspective

Steps:

  1. Navigate to Fleet Management perspective (ACM)
  2. Click on any ACM page (e.g., /multicloud/infrastructure/clusters/managed)
  3. Open perspective switcher dropdown
  4. Click "Administrator" or "Developer" perspective

Expected Result:

  • ✅ Console switches to selected perspective
  • ✅ Perspective stays on selected perspective (does NOT snap back to Fleet Management)
  • ✅ Page navigates to appropriate landing page for selected perspective

Failure Scenario (without fix):

  • ❌ Briefly switches then snaps back to Fleet Management
  • ❌ Gets stuck on Fleet Management perspective

Test Case 2: Switching TO Plugin Perspective

Objective: Verify switching TO Fleet Management still works

Steps:

  1. Start on Administrator or Developer perspective
  2. Open perspective switcher dropdown
  3. Click "Fleet Management" (ACM) perspective

Expected Result:

  • ✅ Console switches to Fleet Management
  • ✅ Displays Fleet Management landing page
  • ✅ No errors in console

--- ## Test Case 3: Rapid Perspective Switching

Objective: Verify transition guard handles rapid clicks

Steps:

  1. Start on Fleet Management perspective
  2. Quickly switch: Fleet Management → Admin → Developer → Fleet Management → Admin
  3. Try clicking another perspective while navigation is in progress

Expected Result:

  • ✅ Each switch completes successfully
  • ✅ Final perspective matches last click
  • ✅ No perspective fighting or flickering
  • ✅ No console errors

Test Case 4: Query Param Preservation

Objective: Verify query params (except ?perspective=) are preserved during switches

Steps:

  1. Navigate to Developer perspective
  2. Go to Topology page: /topology/ns/default?view=graph
  3. Open perspective switcher
  4. Switch to Administrator perspective

Expected Result:

  • ✅ URL params like ?view=graph should be stripped (navigates to clean admin page)
  • ✅ Check browser console - no errors about lost query params

Note: The navigation goes to perspective landing page (/ or /dashboards), so query params from previous page aren't expected to transfer. The fix ensures we don't carry over ?perspective= which caused loops.


Test Case 5: Hash Fragment Preservation

Objective: Verify URL hash is handled correctly

Steps:

  1. Navigate to a page with hash: /some/page#section
  2. Switch perspectives

Expected Result:

  • ✅ Navigation completes without errors
  • ✅ No hash-related loops or issues

Test Case 6: Initial Load with ACM Installed

Objective: Verify ACM default on first visit

Steps:

  1. Clear browser local storage (or use incognito)
  2. Navigate to console for first time with ACM installed
  3. Observe which perspective loads

Expected Result:

  • ✅ If no previous perspective preference exists, defaults to Fleet Management (ACM)
  • ✅ User can then switch to other perspectives normally

Test Case 7: Built-in Perspective Switching (Regression Test)

Objective: Verify switching between Admin/Dev still works normally

Steps:

  1. Switch from Administrator to Developer
  2. Switch from Developer to Administrator
  3. Repeat several times

Expected Result:

  • ✅ Switches work smoothly both directions
  • ✅ No delays or errors
  • ✅ Perspective preference is saved

Test Case 8: Browser Console Check

Objective: Verify no unexpected errors or warnings

Steps:

  1. Open browser DevTools console (F12)
  2. Perform Test Cases 1-3 above
  3. Monitor console for errors

Expected Result:

  • ✅ No JavaScript errors related to perspective switching
  • ✅ No "BLOCKED during transition" logs (debug logs removed)
  • ✅ Only normal telemetry and navigation logs

Test Case 9: Multiple Plugin Perspectives

Objective: If multiple plugins register perspectives, verify switching works

Steps:

  1. In environment with multiple plugin perspectives (e.g., ACM + another plugin)
  2. Switch between: Admin → Plugin1 → Developer → Plugin2 → Admin

Expected Result:

  • ✅ All switches work correctly
  • ✅ No perspective gets stuck
  • ✅ Each perspective's routes load properly

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Reviewers and assignees:

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced perspective parameter handling to prevent navigation loops while preserving other query parameters and URL fragments
    • Added transition guard to prevent perspective changes during in-progress transitions for more stable navigation

Fixes perspective getting stuck when switching away from plugin-registered
perspectives (e.g., Fleet Management). Plugins watch activePerspective changes
and force back to their perspective, preventing user-initiated switches.

Root cause: Plugin effects fire during perspective transitions and override
the user's switch by calling setActivePerspective with the plugin's perspective.

Solution: Add transition guard (isTransitioning ref) that blocks setPerspective
calls during active transitions, preventing plugin interference.

Additional fixes:
- Extract getPathWithoutPerspectiveParam to utils.ts to eliminate duplication
- Strip only ?perspective= param to prevent loops while preserving other query params and hash
- Navigate before updating perspective state to prevent plugins from seeing mismatch
- Remove location from effect deps to prevent firing on every navigation
- Restore ACM default on initial load (when no previous perspective exists)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 7, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@TheRealJon: This pull request references Jira Issue OCPBUGS-84047, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Fixes perspective getting stuck when switching away from plugin-registered perspectives (e.g., Fleet Management). Plugins watch activePerspective changes and force back to their perspective, preventing user-initiated switches.

Analysis / Root cause

Plugin effects fire during perspective transitions and override the user's switch by calling setActivePerspective with the plugin's perspective.

Solution description

Add transition guard (isTransitioning ref) that blocks setPerspective calls during active transitions, preventing plugin interference.

Screenshots / screen recording:

Screen.Recording.2026-05-07.at.2.59.38.PM.mov

Test setup

  1. Launch a cluster with the changes from this PR using cluster bot
  2. Install ACM operator and create a multiclusterhub resource

Test cases

Test Case 1: Switching Away from Plugin Perspective (Primary Bug Fix)

Objective: Verify user can switch away from Fleet Management perspective

Steps:

  1. Navigate to Fleet Management perspective (ACM)
  2. Click on any ACM page (e.g., /multicloud/infrastructure/clusters/managed)
  3. Open perspective switcher dropdown
  4. Click "Administrator" or "Developer" perspective

Expected Result:

  • ✅ Console switches to selected perspective
  • ✅ Perspective stays on selected perspective (does NOT snap back to Fleet Management)
  • ✅ Page navigates to appropriate landing page for selected perspective

Failure Scenario (without fix):

  • ❌ Briefly switches then snaps back to Fleet Management
  • ❌ Gets stuck on Fleet Management perspective

Test Case 2: Switching TO Plugin Perspective

Objective: Verify switching TO Fleet Management still works

Steps:

  1. Start on Administrator or Developer perspective
  2. Open perspective switcher dropdown
  3. Click "Fleet Management" (ACM) perspective

Expected Result:

  • ✅ Console switches to Fleet Management
  • ✅ Displays Fleet Management landing page
  • ✅ No errors in console

--- ## Test Case 3: Rapid Perspective Switching

Objective: Verify transition guard handles rapid clicks

Steps:

  1. Start on Fleet Management perspective
  2. Quickly switch: Fleet Management → Admin → Developer → Fleet Management → Admin
  3. Try clicking another perspective while navigation is in progress

Expected Result:

  • ✅ Each switch completes successfully
  • ✅ Final perspective matches last click
  • ✅ No perspective fighting or flickering
  • ✅ No console errors

Test Case 4: Query Param Preservation

Objective: Verify query params (except ?perspective=) are preserved during switches

Steps:

  1. Navigate to Developer perspective
  2. Go to Topology page: /topology/ns/default?view=graph
  3. Open perspective switcher
  4. Switch to Administrator perspective

Expected Result:

  • ✅ URL params like ?view=graph should be stripped (navigates to clean admin page)
  • ✅ Check browser console - no errors about lost query params

Note: The navigation goes to perspective landing page (/ or /dashboards), so query params from previous page aren't expected to transfer. The fix ensures we don't carry over ?perspective= which caused loops.


Test Case 5: Hash Fragment Preservation

Objective: Verify URL hash is handled correctly

Steps:

  1. Navigate to a page with hash: /some/page#section
  2. Switch perspectives

Expected Result:

  • ✅ Navigation completes without errors
  • ✅ No hash-related loops or issues

Test Case 6: Initial Load with ACM Installed

Objective: Verify ACM default on first visit

Steps:

  1. Clear browser local storage (or use incognito)
  2. Navigate to console for first time with ACM installed
  3. Observe which perspective loads

Expected Result:

  • ✅ If no previous perspective preference exists, defaults to Fleet Management (ACM)
  • ✅ User can then switch to other perspectives normally

Test Case 7: Built-in Perspective Switching (Regression Test)

Objective: Verify switching between Admin/Dev still works normally

Steps:

  1. Switch from Administrator to Developer
  2. Switch from Developer to Administrator
  3. Repeat several times

Expected Result:

  • ✅ Switches work smoothly both directions
  • ✅ No delays or errors
  • ✅ Perspective preference is saved

Test Case 8: Browser Console Check

Objective: Verify no unexpected errors or warnings

Steps:

  1. Open browser DevTools console (F12)
  2. Perform Test Cases 1-3 above
  3. Monitor console for errors

Expected Result:

  • ✅ No JavaScript errors related to perspective switching
  • ✅ No "BLOCKED during transition" logs (debug logs removed)
  • ✅ Only normal telemetry and navigation logs

Test Case 9: Multiple Plugin Perspectives

Objective: If multiple plugins register perspectives, verify switching works

Steps:

  1. In environment with multiple plugin perspectives (e.g., ACM + another plugin)
  2. Switch between: Admin → Plugin1 → Developer → Plugin2 → Admin

Expected Result:

  • ✅ All switches work correctly
  • ✅ No perspective gets stuck
  • ✅ Each perspective's routes load properly

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Reviewers and assignees:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from cajieh and jhadvig May 7, 2026 19:24
@openshift-ci openshift-ci Bot added the component/core Related to console core functionality label May 7, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 7, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2026
@TheRealJon
Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 7, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@TheRealJon: This pull request references Jira Issue OCPBUGS-84047, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@TheRealJon
Copy link
Copy Markdown
Member Author

Console Approver
/assign @vojtechszocs

Docs Approver:
cc @jseseCCS

PX Approver:
cc @rh-joshbeverly

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@TheRealJon: This pull request references Jira Issue OCPBUGS-84047, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

Fixes perspective getting stuck when switching away from plugin-registered perspectives (e.g., Fleet Management). Plugins watch activePerspective changes and force back to their perspective, preventing user-initiated switches.

Analysis / Root cause

Plugin effects fire during perspective transitions and override the user's switch by calling setActivePerspective with the plugin's perspective.

Solution description

Add transition guard (isTransitioning ref) that blocks setPerspective calls during active transitions, preventing plugin interference.

Screenshots / screen recording:

Screen.Recording.2026-05-07.at.2.59.38.PM.mov

Test setup

  1. Launch a cluster with the changes from this PR using cluster bot
  2. Install ACM operator and create a multiclusterhub resource

Test cases

Test Case 1: Switching Away from Plugin Perspective (Primary Bug Fix)

Objective: Verify user can switch away from Fleet Management perspective

Steps:

  1. Navigate to Fleet Management perspective (ACM)
  2. Click on any ACM page (e.g., /multicloud/infrastructure/clusters/managed)
  3. Open perspective switcher dropdown
  4. Click "Administrator" or "Developer" perspective

Expected Result:

  • ✅ Console switches to selected perspective
  • ✅ Perspective stays on selected perspective (does NOT snap back to Fleet Management)
  • ✅ Page navigates to appropriate landing page for selected perspective

Failure Scenario (without fix):

  • ❌ Briefly switches then snaps back to Fleet Management
  • ❌ Gets stuck on Fleet Management perspective

Test Case 2: Switching TO Plugin Perspective

Objective: Verify switching TO Fleet Management still works

Steps:

  1. Start on Administrator or Developer perspective
  2. Open perspective switcher dropdown
  3. Click "Fleet Management" (ACM) perspective

Expected Result:

  • ✅ Console switches to Fleet Management
  • ✅ Displays Fleet Management landing page
  • ✅ No errors in console

--- ## Test Case 3: Rapid Perspective Switching

Objective: Verify transition guard handles rapid clicks

Steps:

  1. Start on Fleet Management perspective
  2. Quickly switch: Fleet Management → Admin → Developer → Fleet Management → Admin
  3. Try clicking another perspective while navigation is in progress

Expected Result:

  • ✅ Each switch completes successfully
  • ✅ Final perspective matches last click
  • ✅ No perspective fighting or flickering
  • ✅ No console errors

Test Case 4: Query Param Preservation

Objective: Verify query params (except ?perspective=) are preserved during switches

Steps:

  1. Navigate to Developer perspective
  2. Go to Topology page: /topology/ns/default?view=graph
  3. Open perspective switcher
  4. Switch to Administrator perspective

Expected Result:

  • ✅ URL params like ?view=graph should be stripped (navigates to clean admin page)
  • ✅ Check browser console - no errors about lost query params

Note: The navigation goes to perspective landing page (/ or /dashboards), so query params from previous page aren't expected to transfer. The fix ensures we don't carry over ?perspective= which caused loops.


Test Case 5: Hash Fragment Preservation

Objective: Verify URL hash is handled correctly

Steps:

  1. Navigate to a page with hash: /some/page#section
  2. Switch perspectives

Expected Result:

  • ✅ Navigation completes without errors
  • ✅ No hash-related loops or issues

Test Case 6: Initial Load with ACM Installed

Objective: Verify ACM default on first visit

Steps:

  1. Clear browser local storage (or use incognito)
  2. Navigate to console for first time with ACM installed
  3. Observe which perspective loads

Expected Result:

  • ✅ If no previous perspective preference exists, defaults to Fleet Management (ACM)
  • ✅ User can then switch to other perspectives normally

Test Case 7: Built-in Perspective Switching (Regression Test)

Objective: Verify switching between Admin/Dev still works normally

Steps:

  1. Switch from Administrator to Developer
  2. Switch from Developer to Administrator
  3. Repeat several times

Expected Result:

  • ✅ Switches work smoothly both directions
  • ✅ No delays or errors
  • ✅ Perspective preference is saved

Test Case 8: Browser Console Check

Objective: Verify no unexpected errors or warnings

Steps:

  1. Open browser DevTools console (F12)
  2. Perform Test Cases 1-3 above
  3. Monitor console for errors

Expected Result:

  • ✅ No JavaScript errors related to perspective switching
  • ✅ No "BLOCKED during transition" logs (debug logs removed)
  • ✅ Only normal telemetry and navigation logs

Test Case 9: Multiple Plugin Perspectives

Objective: If multiple plugins register perspectives, verify switching works

Steps:

  1. In environment with multiple plugin perspectives (e.g., ACM + another plugin)
  2. Switch between: Admin → Plugin1 → Developer → Plugin2 → Admin

Expected Result:

  • ✅ All switches work correctly
  • ✅ No perspective gets stuck
  • ✅ Each perspective's routes load properly

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

Reviewers and assignees:

Summary by CodeRabbit

  • Bug Fixes
  • Enhanced perspective parameter handling to prevent navigation loops while preserving other query parameters and URL fragments
  • Added transition guard to prevent perspective changes during in-progress transitions for more stable navigation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown
Member

@logonoff logonoff left a comment

Choose a reason for hiding this comment

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

FYI we might have a conflict here - #16410

Feel free to include my changes in your changes or the other way around

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

📝 Walkthrough

Walkthrough

This PR modifies the perspective detection flow to strip the ?perspective= query parameter from navigated URLs while preserving other query parameters and hash fragments. A new utility function getPathWithoutPerspectiveParam handles parameter removal. The setPerspective callback gains a transition guard via useRef to prevent forced perspective changes during in-progress transitions, reordering navigation before state updates. Test expectations are updated to reflect the new path-stripping behavior in both detected and fallback perspective scenarios.

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the bug fix (perspective stuck issue) and the solution approach (transition guard), directly reflecting the core changes in the changeset.
Description check ✅ Passed The PR description is comprehensive and follows the template structure, including analysis, root cause, solution, test setup, nine detailed test cases, browser conformance, and supporting evidence.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Stable And Deterministic Test Names ✅ Passed Check is not applicable. This PR only modifies TypeScript/React tests using Jest, not Go tests using Ginkgo. The repository contains no Ginkgo tests.
Test Structure And Quality ✅ Passed Custom check requests Ginkgo test review for K8s cluster operations. PR modifies TypeScript/React frontend with Jest unit tests only. Check inapplicable to this codebase.
Microshift Test Compatibility ✅ Passed The custom check applies only to new Ginkgo e2e tests. This PR contains no Ginkgo tests—only frontend React/TypeScript components and Jest unit tests. The check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed SNO test compatibility check is not applicable. PR modifies React/TypeScript component tests using Jest, not Ginkgo e2e tests. Check applies only to new Go-based Ginkgo e2e tests.
Topology-Aware Scheduling Compatibility ✅ Passed Check not applicable: PR modifies only frontend React components and utilities, not deployment manifests, operators, or controllers. No Kubernetes scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed Not applicable. OTE check targets Go test infrastructure; this PR modifies only React/TypeScript frontend files (.ts/.tsx) with no Go or test framework code changes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR modifies only frontend TypeScript/React code (components, hooks, Jest unit tests). No Ginkgo e2e tests or Go test files present. Custom check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/packages/console-app/src/components/detect-perspective/__tests__/PerspectiveDetector.spec.tsx (1)

55-57: ⚡ Quick win

Assert the exact number of perspective updates.

toHaveBeenCalledWith(...) still passes if the detector emits an extra fallback or duplicate update. Since this bug is about competing effects, these tests should also lock down the call count.

Suggested tightening
     await waitFor(() => {
+      expect(setActivePerspective).toHaveBeenCalledTimes(1);
       expect(setActivePerspective).toHaveBeenCalledWith('admin', '/');
     });

Apply the same assertion to the other updated cases as well.

Also applies to: 73-75, 91-93, 139-141, 162-165

🤖 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
`@frontend/packages/console-app/src/components/detect-perspective/__tests__/PerspectiveDetector.spec.tsx`
around lines 55 - 57, The test in PerspectiveDetector.spec.tsx currently only
asserts setActivePerspective was called with specific args, which allows
extra/duplicate calls to slip by; update each expectation (the blocks around the
existing expects at the mentioned locations and all other cases where
setActivePerspective is asserted) to also assert the exact call count, e.g., use
setActivePerspective.toHaveBeenCalledTimes(1) in addition to
toHaveBeenCalledWith('admin', '/') so the detector cannot emit extra
fallback/duplicate updates; apply this tightening to the other assertion sites
referenced (the assertions around lines 73-75, 91-93, 139-141, 162-165) to lock
down call counts for all scenarios.
🤖 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
`@frontend/packages/console-app/src/components/detect-perspective/useValuesForPerspectiveContext.ts`:
- Around line 49-66: The transition guard currently sets isTransitioning.current
= true then calls navigate, setLastPerspective, setActivePerspective and
fireTelemetryEvent, but if any of those throw synchronously the guard stays
true; wrap the sequence from navigate through fireTelemetryEvent in a
try/finally so that isTransitioning.current is always set back to false in the
finally block (keeping the initial set to true before the try), ensuring the ref
is released even on exceptions.

---

Nitpick comments:
In
`@frontend/packages/console-app/src/components/detect-perspective/__tests__/PerspectiveDetector.spec.tsx`:
- Around line 55-57: The test in PerspectiveDetector.spec.tsx currently only
asserts setActivePerspective was called with specific args, which allows
extra/duplicate calls to slip by; update each expectation (the blocks around the
existing expects at the mentioned locations and all other cases where
setActivePerspective is asserted) to also assert the exact call count, e.g., use
setActivePerspective.toHaveBeenCalledTimes(1) in addition to
toHaveBeenCalledWith('admin', '/') so the detector cannot emit extra
fallback/duplicate updates; apply this tightening to the other assertion sites
referenced (the assertions around lines 73-75, 91-93, 139-141, 162-165) to lock
down call counts for all scenarios.
🪄 Autofix (Beta)

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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 4a899db9-d78b-4614-ab1f-78dfe96d672e

📥 Commits

Reviewing files that changed from the base of the PR and between 1b45874 and 26ea25b.

📒 Files selected for processing (5)
  • frontend/packages/console-app/src/components/detect-perspective/DetectPerspective.tsx
  • frontend/packages/console-app/src/components/detect-perspective/PerspectiveDetector.tsx
  • frontend/packages/console-app/src/components/detect-perspective/__tests__/PerspectiveDetector.spec.tsx
  • frontend/packages/console-app/src/components/detect-perspective/useValuesForPerspectiveContext.ts
  • frontend/packages/console-app/src/components/detect-perspective/utils.ts
📜 Review details
🔇 Additional comments (1)
frontend/packages/console-app/src/components/detect-perspective/utils.ts (1)

14-18: Nice extraction of the URL sanitizing logic.

This keeps the perspective stripping behavior consistent across both call sites while still preserving the rest of the URL state.

Comment on lines +49 to +66
// Set guard to block plugin interference
isTransitioning.current = true;

// Navigate FIRST, then update perspective state
// This prevents plugins from seeing activePerspective change while still on old route
// which triggers their perspective-forcing logic
navigate(next || '/');

// Update perspective state after navigation starts
setLastPerspective(newPerspective);
setActivePerspective(newPerspective);
// Navigate to next or root and let the default page determine where to go to next
navigate(next || '/');
fireTelemetryEvent('Perspective Changed', { perspective: newPerspective });

// Clear guard after navigation and state updates complete
// Use setTimeout to ensure this runs after all synchronous effects
setTimeout(() => {
isTransitioning.current = false;
}, 0);
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Make the transition guard exception-safe.

Once isTransitioning.current flips to true, any synchronous throw from navigate, setLastPerspective, or fireTelemetryEvent leaves perspective switching disabled until reload. Wrap the guarded block in try/finally so the ref is always released.

Suggested fix
       // Set guard to block plugin interference
       isTransitioning.current = true;

-      // Navigate FIRST, then update perspective state
-      // This prevents plugins from seeing activePerspective change while still on old route
-      // which triggers their perspective-forcing logic
-      navigate(next || '/');
-
-      // Update perspective state after navigation starts
-      setLastPerspective(newPerspective);
-      setActivePerspective(newPerspective);
-      fireTelemetryEvent('Perspective Changed', { perspective: newPerspective });
-
-      // Clear guard after navigation and state updates complete
-      // Use setTimeout to ensure this runs after all synchronous effects
-      setTimeout(() => {
-        isTransitioning.current = false;
-      }, 0);
+      try {
+        // Navigate FIRST, then update perspective state
+        // This prevents plugins from seeing activePerspective change while still on old route
+        // which triggers their perspective-forcing logic
+        navigate(next || '/');
+
+        // Update perspective state after navigation starts
+        setLastPerspective(newPerspective);
+        setActivePerspective(newPerspective);
+        fireTelemetryEvent('Perspective Changed', { perspective: newPerspective });
+      } finally {
+        // Clear guard after navigation and state updates complete
+        // Use setTimeout to ensure this runs after all synchronous effects
+        setTimeout(() => {
+          isTransitioning.current = false;
+        }, 0);
+      }
🤖 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
`@frontend/packages/console-app/src/components/detect-perspective/useValuesForPerspectiveContext.ts`
around lines 49 - 66, The transition guard currently sets
isTransitioning.current = true then calls navigate, setLastPerspective,
setActivePerspective and fireTelemetryEvent, but if any of those throw
synchronously the guard stays true; wrap the sequence from navigate through
fireTelemetryEvent in a try/finally so that isTransitioning.current is always
set back to false in the finally block (keeping the initial set to true before
the try), ensuring the ref is released even on exceptions.

@TheRealJon
Copy link
Copy Markdown
Member Author

/retest-required

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 8, 2026

@TheRealJon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console 26ea25b link true /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants