Repository navigation
perf: limit Find highlights to visible editors - #12245
Merged
Merged
Conversation
After a notebook has been traversed, most mounted editors are offscreen. Deliver each query to visible views and refresh a returning editor from the shared query. Keep match enumeration and replacement on the document layer so dormant editors remain searchable.
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
Contributor
Coverage Report for ./frontend
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
kirangadhave
requested review from
mscolnick
and
a balanced review from Copilot
December 2, 2026 20:37
kirangadhave
marked this pull request as ready for review
December 2, 2026 20:37
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the notebook Find performance changes.
No open issues 🎉
What changed in this PR
Improves notebook Find performance by sharing one highlight query and updating only visible editors, while preserving search across unmounted cell documents.
Changes:
- Synchronizes highlights when editors enter the viewport.
- Skips unchanged selection resets and refreshes match counts after undoing Replace All.
- Expands coverage for highlight lifecycle, navigation, and unmounted-cell replacements.
| File | Description |
|---|---|
| frontend/src/utils/shared-intersection-observer.ts | Supports a custom visibility predicate. |
| frontend/src/core/codemirror/find-replace/search-highlight.ts | Shares highlight queries and subscribes visible editors. |
| frontend/src/core/codemirror/find-replace/navigate.ts | Avoids redundant selection resets. |
| frontend/src/core/codemirror/find-replace/__tests__/unmounted-cells.test.ts | Expands regex navigation, replacement, and undo coverage. |
| frontend/src/core/codemirror/find-replace/__tests__/search-highlight.test.ts | Tests viewport synchronization and subscription cleanup. |
| frontend/src/core/codemirror/find-replace/__tests__/navigate.test.ts | Tests skipped and required selection resets. |
| frontend/src/components/find-replace/find-replace.tsx | Removes global highlight dispatches and refreshes counts after undo. |
| frontend/src/__mocks__/intersection-observer.ts | Allows explicit intersection ratios in tests. |
Review effort: Balanced
mscolnick
previously approved these changes
Dec 2, 2026
The reset can fire after the modal unmounts and Vitest removes the browser environment. Tie the timer to the confirmation state so unmounting cancels it.
kirangadhave
enabled auto-merge (squash)
December 3, 2026 00:56
mscolnick
previously approved these changes
Dec 3, 2026
mscolnick
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Share one Find highlight query and dispatch it to visible CodeMirror editors. A new editor starts with the current query. An editor that returns to the viewport receives the latest query or clear. Counts and replacements still read cell documents, including cells whose editors have yet to mount. Cells in collapsed sections without handles remain outside the search scope.
Find Next still builds the destination editor on demand and keeps keyboard focus in Find. Skip selection resets that leave the caret unchanged. Refresh the match count after undoing Replace All.
Addresses the Find highlight work in MO-8797.
Production benchmark
Four alternating pairs on the 500-cell smoke fixture in headless Chromium at 1280 × 720 and 1× CPU. Both builds use
f54c35700eas the base. The fresh case had 2 mounted editors. Traversal mounted 251. Both cases had 2 visible editors at the top of the notebook. Both builds reported 4,051 matches forjson.After traversal, the median paired paint changes were -272.81 ms for open and -260.86 ms for typing. The candidate was faster in 4/4 open pairs and 4/4 typing pairs. Each table entry is baseline → candidate. Paint is the first renderer-main-thread paint after the expected panel update. Forced layout counts use Chromium trace attribution. The sample covers one fixture and one browser. The paint proxy measures renderer work before display presentation.