Skip to content

Conversation

@Raubzeug
Copy link
Contributor

@Raubzeug Raubzeug commented Dec 17, 2025

Greptile Summary

This PR fixes a potential infinite loop bug in the tenant page navigation by removing a redundant state update from the handleTenantPageChange callback.

  • Removed setInitialTenantPage(value) call from handleTenantPageChange callback in useTenantPage hook
  • The useEffect (lines 89-103) already handles persisting the initial page preference to Redux when the query param changes
  • Having both the callback and the effect update the same state could cause a re-render cycle leading to an infinite loop

Confidence Score: 5/5

  • This PR is safe to merge - it removes redundant code that was causing a bug.
  • The change is minimal, targeted, and correctly addresses the infinite loop issue. The removed code was redundant since the useEffect already handles the same state update logic. No new functionality is added, only a bug fix.
  • No files require special attention.

Important Files Changed

Filename Overview
src/containers/Tenant/TenantNavigation/useTenantNavigation.tsx Removed redundant setInitialTenantPage call from handleTenantPageChange callback to fix potential infinite loop; the useEffect already handles persisting the initial page preference.

Sequence Diagram

sequenceDiagram
    participant User
    participant handleTenantPageChange
    participant setQueryParams
    participant useEffect
    participant setInitialTenantPage
    participant Redux

    User->>handleTenantPageChange: Click navigation item
    Note over handleTenantPageChange: Before fix: called both setQueryParams AND setInitialTenantPage
    handleTenantPageChange->>setQueryParams: Update URL query params
    setQueryParams-->>useEffect: tenantPageFromQuery changes
    useEffect->>useEffect: Parse query page
    alt Query page valid and different from initial
        useEffect->>setInitialTenantPage: Save as initial page
        setInitialTenantPage->>Redux: Update settings state
    else Query page invalid
        useEffect->>setQueryParams: Reset to initial page
    end
    Note over handleTenantPageChange: After fix: only calls setQueryParams<br/>useEffect handles initial page persistence
Loading

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
384 380 0 2 2
Test Changes Summary ⏭️2

⏭️ Skipped Tests (2)

  1. Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view (tenant/diagnostics/tabs/queries.test.ts)
  2. Copy result button copies to clipboard (tenant/queryEditor/queryEditor.test.ts)

Bundle Size: ✅

Current: 62.54 MB | Main: 62.54 MB
Diff: 0.10 KB (-0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Copilot AI review requested due to automatic review settings December 17, 2025 10:44
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 potential infinite loop in the tenant navigation system. The issue occurred when handleTenantPageChange was both updating the URL query parameter and directly updating the persisted initial page setting, which could trigger a chain of re-renders and side effects.

Key Change:

  • Removed the direct call to setInitialTenantPage from handleTenantPageChange callback and updated its dependency array accordingly

@Raubzeug Raubzeug enabled auto-merge December 17, 2025 10:47
@Raubzeug Raubzeug added this pull request to the merge queue Dec 17, 2025
Merged via the queue into main with commit 837e521 Dec 17, 2025
13 checks passed
@Raubzeug Raubzeug deleted the tenant-nav branch December 17, 2025 10:50
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