Skip to content

fix(diff): bring a find match into view on a wrapped row taller than the view - #2156

Merged
devswha merged 2 commits into
mainfrom
fix/diff-find-reveal-match
Oct 28, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/diff-find-reveal-match

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

What this does for the user

Find in a diff now brings the match itself into view when its row is a wrapped line taller than the screen, such as a long line on a phone with wrapping on. Before, the viewer centred the whole row, so a match near the end of a very long line could stay below the screen (#1602, the follow-up left from #1849).

How

RepoDiff.tsx's reveal (settle()) measures the active row as before; when that row is taller than the view, it centres the match's own text range (the same textRange the highlight paints) instead of the row. Every other row is unchanged: a row that fits is still centred whole, an unwrapped row is still scrolled across first, and an unmounted row still goes to the package's estimate first. Precedent: an editor's find (Zed, VS Code) scrolls to the match, not to the line holding it; DESIGN.md's Find in diff entry says so.

The diff-find demo regression (scripts/diff-find-demo-regression.ts), the issue's other open note, now takes its screenshots at fixed moments: its clock is Playwright's, run past the demo's one-shot turn completion (4.5 s after load), and each shot waits for finite animations (a closed sheet's drop, lib/sheets.ts) and ends running transitions first, as terminal-keyboard-demo-regression.ts does. Two runs back to back: 58 of 66 shots byte-identical, the other 8 differ by at most 5 grey levels on at most 183 pixels (rasterizer noise); before, 31 differed by state (a sheet mid-slide, a hover mid-fade).

Fixes #1602

How it was verified

  • scripts/repo-diff-browser-qa.ts gains a wrapped unchanged line taller than any view in the long-line fixture, its match at the very end, and asserts the painted match lies inside the scroll view. On main it fails: row {top:-205,bottom:1271}, match {top:1254,bottom:1270}, view {top:269,bottom:798}. With the fix it passes at 1440 and 390, dark and light, with the rest of the script.
  • scripts/diff-find-demo-regression.ts passes (all six widths/themes/languages), twice.
  • bun run check fast: typecheck, build, 7885 unit tests, 0 failures.
  • Reviewed by omo-native-code-reviewer (APPROVE, three LOW notes: none actionable) and Codex Sol 6.1 Fast xhigh (PASS). The demo screenshot wait (second commit, test-only) came after those reviews.

…the view

Find centred the active match's whole row. On a wrapped row taller than
the view (a long line on a phone with wrapping on) the row's middle
could leave a match near its end below the screen. A row taller than
the view now centres the match's own text instead.

The repository diff browser QA gains a wrapped unchanged line taller
than any view with its match at the end; it failed on main (match at
y=1254, view ending at 798) and passes at 1440 and 390.

Fixes #1602
The demo regression's screenshots were taken while the demo's own
timeline ran and while sheets and hover transitions moved. Its clock is
now Playwright's, run past the demo's one-shot turn completion, and each
shot waits for finite animations (a closed sheet's drop included) and
ends running transitions first, as terminal-keyboard-demo-regression.ts
does.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 99547b0 and 5b54eb5.

Files selected for processing: 5
  • DESIGN.md
  • changelog.d/diff-find-tall-row.md
  • scripts/diff-find-demo-regression.ts
  • scripts/repo-diff-browser-qa.ts
  • src/components/RepoDiff.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Find in a diff now brings the matched text into view when it appears near the end of a wrapped row taller than the viewport. Previously, centering the row could leave the match off-screen.
    • Search results on other rows continue to use the existing row-centering behavior.

When an active match is in a wrapped row taller than the viewport, the diff viewer now centers the match instead of the row. Regression scripts cover this case and control demo timing and animations during screenshot capture.

Changes: Tall Wrapped Diff Find

Layer / File(s) Summary
Match-based reveal
src/components/RepoDiff.tsx, DESIGN.md, changelog.d/diff-find-tall-row.md
When a row exceeds the view height, settle centers the active match’s text bounds. The design description and changelog document this behavior.
Reveal and screenshot regression coverage
scripts/repo-diff-browser-qa.ts, scripts/diff-find-demo-regression.ts
The browser QA script checks that a match in an exceptionally tall wrapped row is visible. The demo regression script advances the page clock and waits for finite animations before capturing screenshots.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • devswha/herdr-web-ui#1602 — The PR addresses the issue’s tall wrapped-row reveal and deterministic demo screenshot objectives.
Merge Risk: Minimal · up to 5b54e

No actionable merge risk was identified for the tall-row reveal or screenshot changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: fixing Find behavior for matches on wrapped rows taller than the view.
Description check Passed The description explains the problem, resulting behavior, implementation, regression coverage, and validation results. It uses headings different from the template, but it provides the required Change…
Linked Issues check Passed #1602 has two active coding follow-ups. RepoDiff.tsx now centers the active text range when a mounted wrapped row is taller than the view. The existing row, horizontal, unmounted-row, folded-context…
Out of Scope Changes check Passed The changes stay within #1602. DESIGN.md and the changelog document the tall-row fix. The browser QA fixture tests that fix. The demo regression changes remove timing nondeterminism for the linked f…
Full details: Description check

Explanation

The description explains the problem, resulting behavior, implementation, regression coverage, and validation results. It uses headings different from the template, but it provides the required Change and Validation information in substance.

Full details: Linked Issues check

Explanation

#1602 has two active coding follow-ups. RepoDiff.tsx now centers the active text range when a mounted wrapped row is taller than the view. The existing row, horizontal, unmounted-row, folded-context, and loaded-patch find behavior remains in place. repo-diff-browser-qa.ts verifies the end-of-row match inside the scroll view. diff-find-demo-regression.ts now controls the clock and finite animations before screenshots. The changed behavior and tests satisfy the current #1602 requirements.

Full details: Out of Scope Changes check

Explanation

The changes stay within #1602. DESIGN.md and the changelog document the tall-row fix. The browser QA fixture tests that fix. The demo regression changes remove timing nondeterminism for the linked find regression. No unrelated product behavior, network protocol, or workspace search change is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging 5b54eb5: omo-native-code-reviewer and Codex both pass this head, and the required checks are green, including the diff browser QA. CodeRabbit did not review this head. The LOW notes go to a follow-up issue.

@devswha
devswha merged commit ff63ba3 into main Oct 28, 2026
11 checks passed
@devswha
devswha deleted the fix/diff-find-reveal-match branch October 28, 2026 03:54
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.

Diff: find text in the file diff you're looking at

1 participant