Skip to content

Conversation

@gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Oct 24, 2025

Ticket ENG-1758

Description Of Changes

Fixes duplicate rows appearing in the monitor tree schema explorer by implementing a dual-query pattern with intelligent merge logic. The component now fires both fast (without details) and detailed queries simultaneously, displaying fast results immediately while updating with detailed results when available. Added race condition protection to ensure stale queries don't overwrite newer ones.

Code Changes

  • Added mergeTreeNodeData function to intelligently merge detailed query results with existing fast query results by matching node keys
  • Refactored fetchTreeDataWithDetails to accept separate fastUpdateFn and detailedUpdateFn callbacks
  • Wrapped onLoadData and onLoadMore in useCallback with proper dependencies to prevent stale closures
  • Updated pagination state updates to use updater function pattern for consistency
  • Optimized merge algorithm using Map and Set data structures for lookups
  • Added sequence tracking to prevent race conditions when rapid expansions/paginations occur

Steps to Confirm

  1. Navigate to a data discovery monitor's action center with many tables
  2. Expand nodes in the schema explorer tree
  3. Click "Load more..." button at bottom of long table list
  4. Verify no duplicate rows appear when detailed query results load

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@vercel
Copy link

vercel bot commented Oct 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
fides-plus-nightly Ready Ready Preview Comment Oct 24, 2025 11:21pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
fides-privacy-center Ignored Ignored Oct 24, 2025 11:21pm

@gilluminate gilluminate force-pushed the gill/ENG-1758/duplicate-rows-in-schema branch from 12e5ee8 to 0ce0e78 Compare October 24, 2025 22:29
@gilluminate gilluminate marked this pull request as ready for review October 24, 2025 22:30
@gilluminate gilluminate requested a review from a team as a code owner October 24, 2025 22:30
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR fixes duplicate rows appearing in the monitor tree schema explorer by implementing a dual-query pattern. The component now fires both a fast query (without details) and a detailed query simultaneously, displaying fast results immediately while updating with detailed results when available.

Key changes:

  • Added mergeTreeNodeData function that intelligently merges detailed query results with existing fast query results by matching node keys
  • Refactored fetchTreeDataWithDetails to accept separate fastUpdateFn and detailedUpdateFn callbacks
  • Wrapped onLoadData and onLoadMore in useCallback with proper dependencies to prevent stale closures
  • For "load more" operations, the fast query appends new nodes while the detailed query merges/updates them to prevent duplicates
  • Optimized merge algorithm using Map data structures for O(1) lookups

Issues found:

  • One critical pagination state update issue that could cause incorrect page tracking under rapid successive "load more" clicks

Confidence Score: 3/5

  • This PR has a critical race condition that could cause data loading issues under rapid user interaction
  • The PR successfully implements the dual-query pattern and merge logic to fix duplicates, but contains a race condition in pagination state management that could cause incorrect page loading if users rapidly click "Load more" multiple times. The race condition tracking via requestSequenceRef prevents stale data updates, but doesn't prevent duplicate page fetches due to stale pagination reads.
  • MonitorTree.tsx requires attention for the pagination race condition in the onLoadMore callback

Important Files Changed

File Analysis

Filename Score Overview
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx 4/5 Implements dual-query pattern with merge logic to fix duplicate rows, uses useCallback for stability, good race condition protection

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@gilluminate
Copy link
Contributor Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Implements a dual-query pattern (fast + detailed) with intelligent merge logic to fix duplicate rows in the schema explorer tree. The approach fires both queries simultaneously and uses sequence tracking to prevent stale results from overwriting newer ones.

Key changes:

  • Added mergeTreeNodeData function to intelligently merge detailed query results with fast query results by matching node keys
  • Refactored fetchTreeDataWithDetails to accept separate callbacks for fast and detailed query results
  • Wrapped onLoadData and onLoadMore in useCallback with proper dependencies
  • Added sequence tracking refs to handle race conditions

Issues found:

  • Critical: Pagination state not updated when detailed query completes before fast query (line 340-345), which breaks subsequent "Load more" operations

Confidence Score: 3/5

  • This PR has a solid approach but contains a critical pagination bug that needs to be fixed before merge
  • The dual-query pattern and merge logic are well-designed and should fix the duplicate rows issue. The sequence tracking correctly prevents race conditions. However, there's a critical bug where pagination state isn't updated if the detailed query completes before the fast query, which will break subsequent paginations. This needs to be fixed by also updating pagination state in the detailedUpdateFn callback.
  • clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx requires attention for the pagination state update bug in the onLoadMore function

Important Files Changed

File Analysis

Filename Score Overview
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx 3/5 Implements dual-query pattern to fix duplicates, but has a critical bug where pagination state isn't updated if detailed query completes before fast query

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@gilluminate gilluminate enabled auto-merge October 24, 2025 22:58
@gilluminate
Copy link
Contributor Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Implements a dual-query pattern to fix duplicate rows in the schema explorer tree by firing fast (without details) and detailed queries simultaneously, displaying fast results immediately and updating with detailed results when available.

Key Changes:

  • Added mergeTreeNodeData function to intelligently merge detailed query results with existing fast results
  • Refactored fetchTreeDataWithDetails to accept separate fastUpdateFn and detailedUpdateFn callbacks
  • Added race condition protection using sequence tracking
  • Wrapped onLoadData and onLoadMore in useCallback for proper dependency management

Issues Found:

  • Critical: Pagination state incremented twice in onLoadMore - once when fast query completes and again when detailed query completes, causing page index to be incorrect after both queries finish

Confidence Score: 2/5

  • This PR has a critical pagination bug that will cause incorrect page tracking
  • The dual-query pattern and merge logic are well-designed, but the pagination state is incremented twice in the onLoadMore function (once in fastUpdateFn and again in detailedUpdateFn), which will cause the page index to be 2 higher than expected after both queries complete. This breaks the pagination logic and could lead to missing data or incorrect "Load more" behavior.
  • MonitorTree.tsx requires attention - the detailedUpdateFn in onLoadMore should not update pagination state

Important Files Changed

File Analysis

Filename Score Overview
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx 2/5 Implements dual-query pattern with merge logic to fix duplicate rows. Critical bug: pagination state incremented twice in onLoadMore (lines 332-351), causing incorrect page tracking.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@gilluminate
Copy link
Contributor Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR implements a dual-query pattern to fix duplicate rows in the schema explorer tree when clicking "Load more". The solution fires both a fast query (without details) and a detailed query simultaneously, displaying fast results immediately while updating with detailed results when available.

Key Changes:

  • Added mergeTreeNodeData function to intelligently merge detailed results with existing fast results by matching node keys
  • Refactored fetchTreeDataWithDetails to accept separate fastUpdateFn and detailedUpdateFn callbacks
  • Wrapped onLoadData and onLoadMore in useCallback with proper dependencies
  • Updated pagination state to use updater function pattern for consistency
  • Added sequence tracking to prevent race conditions from rapid expansions/paginations

Critical Issue:

  • Lines 340-351 contain a syntax error with duplicate detailedUpdateFn property definition and malformed object structure that will prevent the code from compiling

Confidence Score: 0/5

  • This PR cannot be merged due to a critical syntax error that will prevent compilation
  • The code contains a duplicate property definition (detailedUpdateFn on lines 340-351) with malformed object syntax that will cause TypeScript compilation to fail. This is a blocking syntax error that must be resolved before the PR can be merged.
  • MonitorTree.tsx requires immediate attention to fix the syntax error on lines 340-351

Important Files Changed

File Analysis

Filename Score Overview
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx 0/5 Implements dual-query pattern to fix duplicate rows, but contains critical syntax error with duplicate detailedUpdateFn property (lines 340-351) that will prevent compilation

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@gilluminate
Copy link
Contributor Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Fixes duplicate rows in schema explorer by implementing a dual-query pattern (fast without details, detailed with details) with intelligent merge logic and race condition protection.

Key Changes:

  • Added mergeTreeNodeData function using Map-based O(1) lookups to merge detailed results into existing fast results without duplication
  • Refactored fetchTreeDataWithDetails to accept separate fastUpdateFn and detailedUpdateFn callbacks for different update strategies
  • Wrapped onLoadData and onLoadMore in useCallback to prevent stale closures
  • Implemented sequence tracking via refs to prevent stale queries from overwriting newer ones
  • Updated onLoadMore to use appendTreeNodeData for fast query (immediate display) and mergeTreeNodeData for detailed query (updates with details)

Analysis:
The implementation correctly addresses the duplicate rows issue. The race condition protection ensures that only the latest request updates state, preventing corruption from out-of-order query completions. The merge logic preserves order and correctly handles matching keys between fast and detailed results.

Minor inefficiency: rapid double-clicks on "Load more" read stale pagination state and request the same page twice before state updates, though race protection prevents actual corruption.

Confidence Score: 4/5

  • Safe to merge with minor inefficiency that doesn't affect correctness
  • The PR successfully fixes the duplicate rows bug with solid race condition protection and merge logic. All previous review comments appear to have been addressed. One minor inefficiency exists with rapid clicks reading stale pagination state, but this doesn't cause correctness issues due to sequence tracking. The implementation is well-documented and uses appropriate data structures (Maps) for performance.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx 4/5 Implements dual-query pattern with race condition protection to fix duplicate rows issue; logic is mostly sound with minor inefficiency in rapid clicks

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +140 to +159
// Create maps for efficient O(1) lookups
const newChildrenMap = new Map(
newChildren.map((child) => [child.key, child]),
);
const existingChildrenMap = new Map(
filteredChildren.map((child) => [child.key, child]),
);

// Merge new children: update existing ones with detailed data, keep order
const mergedChildren = filteredChildren.map((existingChild) => {
const matchingNewChild = newChildrenMap.get(existingChild.key);
return matchingNewChild ?? existingChild;
});

// Add any new children that weren't in the existing list
newChildren.forEach((newChild) => {
if (!existingChildrenMap.has(newChild.key)) {
mergedChildren.push(newChild);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker but it would be nice to have a standardized way of doing these operations + using generic utilities to reduce the amount of boilerplate + reduce bugs.
Not sure if lodash has something for this.

Copy link
Contributor

@speaker-ender speaker-ender left a comment

Choose a reason for hiding this comment

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

Small comment but def not a blocker.
Looks good.
Def want to revisit this component after initial launch.
I think there are some inherit issues with the data returned from the BE + how ant expects the data to be handled that are incompatible.

@gilluminate gilluminate added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit 6a17b32 Oct 27, 2025
46 checks passed
@gilluminate gilluminate deleted the gill/ENG-1758/duplicate-rows-in-schema branch October 27, 2025 14:40
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