Repository navigation
fix(document-view): bound Find highlights and navigation - #1063
Conversation
dovvnloading
left a comment
There was a problem hiding this comment.
Reviewed all six changed files against #1051. The shared 1,000-match limit and sibling-array reconstruction remove the unbounded splice while retaining the unmarked tail; navigation caches the rendered marks and the search bar communicates both deferred results and the cap. The literal/whitespace semantics, decorative anchor exclusion, document order, and citation pipeline remain intact.
CI run 2341 succeeded: Python compile/pytest, POSIX permissions, wheel installation/build, and frontend schema/typecheck/lint/Vitest/build. The frontend log confirms 51 DocumentViewPanel, 14 DocumentViewSearch, and 16 highlighter tests passed (4,173 total). Main has advanced since this head; I inspected the intervening DocumentViewMarkdown citation changes for compatibility. No blocking source-review findings.
Limitations: Playwright boot-smoke was skipped by CI, and a separate manual desktop/browser run, visual checks in both themes, and latency measurement could not be performed because the local checkout is blocked by DNS. This is a maintainer-delegated review comment, not an independent GitHub approval.
Summary
Fixes #1051. A frequent Find query could spread hundreds of thousands of replacement nodes into one splice call and crash Document View. Build each changed sibling array once, cap rendered matches at 1,000 in document order, and retain all original document text. The search bar explicitly labels the highlight limit rather than presenting it as the exhaustive number of occurrences.
What Changed
Why
The number of added highlight nodes is bounded regardless of document size or frequency of the query. A 1,000-highlight ceiling is an intentional product tradeoff: later occurrences remain ordinary text; refine the query to find them. Search is still limited to individual HAST text nodes. The count explicitly says
(limit)at the ceiling (including exactly 1,000 matches, since the scan stops there). No change to stored content or citation offsets.Validation
python -m compileall -q .passes (run from the repo root - matches CI)python -m pytest -qpasses (run from the repo root - matches CI)cd web_ui && npm run checkpasses (matches CI)Local checkout is blocked by GitHub DNS resolution. The isolated checks do not run React, React Markdown, Vitest, the full TypeScript project, lint or the application. The new component tests and all required CI checks remain to be run. From a configured checkout:
npm --prefix web_ui run test -- src/app/canvas/documentViewSearchHighlight.test.ts src/app/canvas/DocumentViewSearch.test.tsx src/app/canvas/DocumentViewPanel.test.tsx npm --prefix web_ui run checkManual verification: open a long Markdown document with many occurrences of a common character; type and refine the query; verify the limit label, intact document, wraparound, keyboard navigation, clearing search and both themes. No browser latency or memory benchmark has been run.
UI Notes
Visible status text changes, but there are no styling changes. Dark/light and narrow-panel visual checks remain pending.
Additional Context
No dependency, schema, CI, or unrelated changes. Draft pending CI and manual verification; do not merge until these pass.