fix(web): prevent streamed search result navigation cancellation - #1577
Conversation
This comment has been minimized.
This comment has been minimized.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe search results panel now preserves existing Next.js history metadata during scroll-state updates. Tests cover streamed result rerenders, navigation continuity, virtualization state restoration, and final browse navigation. The changelog documents the fix. ChangesSearch history state
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to This localized change preserves search navigation and scroll-restoration state during streamed result updates; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/web/src/app/(app)/search/components/searchResultsPanel/index.tsx (1)
104-112: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePreserve the
ScrollHistoryStatetype check
history.stateisany, so spreading it preventssatisfies ScrollHistoryStatefrom rejecting incompatible field values. Build the scroll state in a separately typed object before merging it withhistory.state.🤖 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 `@packages/web/src/app/`(app)/search/components/searchResultsPanel/index.tsx around lines 104 - 112, Update the history state construction in the search results panel to create a separately typed ScrollHistoryState object before merging with history.state, so its fields are validated by the satisfies check. Preserve the existing scrollOffset, measurementsCache, and showAllMatchesMap values, then pass the merged state to history.replaceState.
🤖 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.
Nitpick comments:
In `@packages/web/src/app/`(app)/search/components/searchResultsPanel/index.tsx:
- Around line 104-112: Update the history state construction in the search
results panel to create a separately typed ScrollHistoryState object before
merging with history.state, so its fields are validated by the satisfies check.
Preserve the existing scrollOffset, measurementsCache, and showAllMatchesMap
values, then pass the merged state to history.replaceState.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f233dfe3-3727-429c-953b-7db427b7af83
📒 Files selected for processing (3)
CHANGELOG.mdpackages/web/src/app/(app)/search/components/searchResultsPanel/index.test.tsxpackages/web/src/app/(app)/search/components/searchResultsPanel/index.tsx
Summary
Testing
Note
Low Risk
Localized search UI history/scroll restoration change with regression coverage; no auth, API, or data-path impact.
Overview
Fixes in-flight navigation to a file being aborted when streamed search results arrive and the results panel refreshes virtualizer measurements.
SearchResultsPanel now writes scroll restoration data with
history.replaceStateby merging into the currenthistory.state(keeping Next.js internals like__NA) and drops the URL argument, so Next.js 16’s patchedreplaceStateno longer treats the update as a route restore while a result link navigation is pending. Scroll offset, measurement cache, and expanded-match state still persist for back navigation.Adds a regression test that simulates Next.js’s
replaceStatebehavior during a click-to-browse while the match list grows from streaming.Reviewed by Cursor Bugbot for commit 624df1a. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Tests