-
Notifications
You must be signed in to change notification settings - Fork 84
Fix duplicate rows in schema explorer tree on 'load more' #6843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
12e5ee8 to
0ce0e78
Compare
There was a problem hiding this 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
mergeTreeNodeDatafunction that intelligently merges detailed query results with existing fast query results by matching node keys - Refactored
fetchTreeDataWithDetailsto accept separatefastUpdateFnanddetailedUpdateFncallbacks - Wrapped
onLoadDataandonLoadMoreinuseCallbackwith 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
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
mergeTreeNodeDatafunction to intelligently merge detailed query results with fast query results by matching node keys - Refactored
fetchTreeDataWithDetailsto accept separate callbacks for fast and detailed query results - Wrapped
onLoadDataandonLoadMoreinuseCallbackwith 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
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
mergeTreeNodeDatafunction to intelligently merge detailed query results with existing fast results - Refactored
fetchTreeDataWithDetailsto accept separatefastUpdateFnanddetailedUpdateFncallbacks - Added race condition protection using sequence tracking
- Wrapped
onLoadDataandonLoadMoreinuseCallbackfor 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
onLoadMorefunction (once infastUpdateFnand again indetailedUpdateFn), 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
detailedUpdateFninonLoadMoreshould 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
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx
Show resolved
Hide resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
There was a problem hiding this 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
mergeTreeNodeDatafunction to intelligently merge detailed results with existing fast results by matching node keys - Refactored
fetchTreeDataWithDetailsto accept separatefastUpdateFnanddetailedUpdateFncallbacks - Wrapped
onLoadDataandonLoadMoreinuseCallbackwith 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
detailedUpdateFnproperty 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 (
detailedUpdateFnon 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
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx
Outdated
Show resolved
Hide resolved
This reverts commit 7d82a8b.
There was a problem hiding this 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
mergeTreeNodeDatafunction using Map-based O(1) lookups to merge detailed results into existing fast results without duplication - Refactored
fetchTreeDataWithDetailsto accept separatefastUpdateFnanddetailedUpdateFncallbacks for different update strategies - Wrapped
onLoadDataandonLoadMoreinuseCallbackto prevent stale closures - Implemented sequence tracking via refs to prevent stale queries from overwriting newer ones
- Updated
onLoadMoreto useappendTreeNodeDatafor fast query (immediate display) andmergeTreeNodeDatafor 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
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/MonitorTree.tsx
Show resolved
Hide resolved
| // 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); | ||
| } | ||
| }); |
There was a problem hiding this comment.
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.
speaker-ender
left a comment
There was a problem hiding this 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.
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
mergeTreeNodeDatafunction to intelligently merge detailed query results with existing fast query results by matching node keysfetchTreeDataWithDetailsto accept separatefastUpdateFnanddetailedUpdateFncallbacksonLoadDataandonLoadMoreinuseCallbackwith proper dependencies to prevent stale closuresSteps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works