Repository navigation
feat(diff): find literal text in the loaded patch - #1849
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
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 |
|
Merge-pass review-work for 9b9f49c: REVIEW FAILED on keyboard ownership. Everything else about Find checks out. Blocker: Ctrl/Cmd+F takes over while the command palette has the keyboard. The gate reproduced this in a browser against a fresh demo build. Steps:
The palette stays open with an empty query, and the diff's Find bar underneath it receives Please take the shortcut only when focus is inside the viewer, or when no dialog sits above it. Add an app-level regression with the palette open over the diff. Checked and passing:
Non-blocking:
|
|
Fixed the keyboard-ownership blocker in b9f95d0.
Verification:
Non-blocking notes left as they are: the test-only |
The diff viewer gets a Find bar of its own (its Search button, or Ctrl/Cmd+F while it has the keyboard). It searches the loaded patch as logical lines (src/lib/repoDiffFind.ts): added, removed and unchanged lines, an unchanged line once on its new side, case-sensitive and literal, never the mounted rows. A match on a folded line turns Fold context off, and the row is brought into view by a bounded measured reveal like VirtualSource's, through split, wrap and theme changes. The active row gets an accent ring (only its side in split) and its text a CSS highlight; the count and the match's kind and line are spoken. Enter/Shift+Enter step and wrap; Escape closes Find before the viewer and returns the focus. A new file, comparison or patch drops the results; without a patch Find is off and says so. No new endpoint or frame; nothing is fetched to widen the search. Checked with bun test ./src/lib/repoDiffFind.test.ts, the extended scripts/repo-diff-browser-qa.ts under bun run check run --build (10 000-line fixture: folded hits at the top, middle and end, both sides, split and wrap, loading, refused, offline and watch-only patches), the new scripts/diff-find-demo-regression.ts on the demo build (enrolled in ci-browser.sh), and bun run check fast.
The count and the active match's place sat flush against Previous, whose focus ring is drawn outside the button, so the ring touched the text. The count now keeps a space step before the buttons. The repository diff browser check draws its phone runs at a phone's pixel ratio (3), so its captures read as a phone's. Checked with CHECK_WAIT_SECONDS=3600 bun run check run --build bun scripts/repo-diff-browser-qa.ts and bun scripts/diff-find-demo-regression.ts.
On a phone, closing the Files sheet goes Back in history; the diff opened right after it could be closed again by that late traversal. The find comparison checks now open their diffs over the open list, as a row does, and close the list at the end. Checked with CHECK_WAIT_SECONDS=3600 bun run check run --build bun scripts/repo-diff-browser-qa.ts, three passes in a row.
On a touch screen the find query was 34px tall beside 44px buttons. It now takes the same touch-target height as the viewer's actions. Checked with bun run check fast, bun scripts/diff-find-demo-regression.ts and CHECK_WAIT_SECONDS=3600 bun run check run --build bun scripts/repo-diff-browser-qa.ts, and by measuring the field at 390px.
A match past the right edge of an unwrapped row is scrolled into view in its side's horizontal scroller. A repeated Ctrl/Cmd+F keeps the control that first opened Find as the focus return, and reopening Find shows the kept query's count and active match again. The bar's own words are read at the body size (the reading size on a phone), its name stays visible beside the query, its buttons keep an 8px gap, and the Korean scope hint keeps each predicate on one line.
Opening Find over the Show text fallback counted matches in rows that were not mounted. It now returns to the diff, whose rows Find marks.
…ares them The diff find bar reuses Previous match, Next match, Close search, No matches and the count from the terminal find bar, so they leave the terminal part for the base dictionary.
With the command palette open over the diff, Ctrl/Cmd+F opened Find underneath and the typing went to its query. The viewer now takes the shortcut only when the focus is not in another dialog, and the demo regression covers the palette over the diff.
|
Merge pass: approved, but held for a recount. The PR CI's Fast checks fail in |
|
Rebased onto main (now including #1828) and recounted the browser lane in 6031d81: |
b9f95d0 to
6031d81
Compare
|
Merge pass review-work report. Overall: PASSED.
QA
Behaviour
Round 1 finding, fixed in b9f95d0: the viewer now leaves Ctrl/Cmd+F to a dialog above it. In the gate's browser run, the palette kept its focus and text, and Find still opened from the viewer, from the page body, and with the viewer inside a modal. Settings and other modals keep their keys. Without the guard, the new regression step fails at Follow-ups (MINOR)
All required checks are green, and no review thread is open. CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it. |
… a pinned count (#1874) ## What `scripts/ci-browser.test.ts` pinned the number of browser scripts (`toHaveLength(83)`), a list of `toContain` lines and the last script. So every PR that adds a browser script edited the same lines, and parallel PRs conflicted on them just for that (#1831, #1837, #1849 and #1852 needed rebases for it). This PR removes those pins and checks the same things against the files on disk: - The serial lane's summary must equal `scripts/demo-build.ts` followed by the list parsed from `scripts/ci-browser.sh` (`serialBrowserScripts()`), in order. This checks more than the old count did. - The lane must not repeat a script or name one that does not exist. - Every `scripts/*-regression.ts` and `scripts/*-browser-qa.ts` must be run by the lane in one of three ways: it has its own `run_script` line; it is imported by a script the lane runs (transitively, e.g. through `ui-regression.ts` or `ui-contexts-checks.ts`); or it is spawned by one (`join(import.meta.dir, "x.ts")`). Spawns are followed only from files that run as scripts, not from imported helpers, because those spawns sit under `import.meta.main`. A script CI does not run has to be named in a new `MANUAL_BROWSER_SCRIPTS` list. Today that list holds 13 scripts that are run by hand (Android emulator, SSH fixture, native Windows, update QA, ...). - The manual list must only name scripts that exist and that CI does not reach, so it cannot go stale. A PR that adds a browser script now adds only its `run_script` line in `scripts/ci-browser.sh` (or a line in the manual list), so two such PRs no longer touch the same line. `docs/development.md` describes the check. Test-only change: CI behaviour is unchanged. ## Verification - `bun test scripts/ci-browser.test.ts`: 7 pass. - Mutation checks, each restored afterwards: - Deleting the `run_script scripts/workspace-rows-regression.ts` line fails "runs every browser script on disk ..." and lists that script as unassigned. - Adding `run_script scripts/does-not-exist-regression.ts` fails "runs each script once, and only scripts that exist". - Adding an untracked `scripts/brand-new-regression.ts` fails the assignment check. - The restored tree passes. - `bun run check fast`: green (typecheck, build, 6396 unit tests). - Reviewed by a code-review agent. Its one HIGH finding (a spawn inside an imported helper's `import.meta.main` block was being counted as run by CI, hiding `keyboard-viewport-demo-regression.ts`) is fixed in this commit. --------- Co-authored-by: mp <mp@local>
…the view (#2156) ## 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.
What this does for the user
The Changes (diff) viewer can now find text in the file's loaded patch. Ctrl/Cmd+F while the viewer has the keyboard, or the new Find button first among its actions, opens a find bar between the header and the rows:
2 of 4,No matches) and the active match's kind and line in words (Removed line 4).Why
The diff rows are virtualized, so the browser's own find cannot reach rows that are not mounted. Searching the patch model instead of the DOM makes every line findable. Precedent: an editor's find bar (Zed, VS Code), scoped to the one virtualized diff (see the DESIGN.md entry).
Notes
src/lib/i18n/files.{ja,ko,zh}.tsafter the i18n split, and the demo regression uses theovis:settingskey.i18n/terminal.*.tsto the base dictionary (assrc/lib/i18n.test.tsrequires for a key two parts share).How it was verified
bun test src/lib/repoDiffFind.test.ts scripts/ci-browser.test.ts scripts/conventions.test.tsbun run check fastscripts/diff-find-demo-regression.ts(new, in the browser lane): the static demo at 1440 and on a phone (390, DPR 3, touch), light and dark, and in Korean on the phone. It covers counting, stepping and wrapping, the ring and paint, the literal match of pattern punctuation, Escape order and focus return, the disabled state for a binary file, no network request while searching, and that the terminal's find never opens.scripts/repo-diff-browser-qa.ts, extended for Find in the fixture viewer.check fast: typecheck, build, 6388 unit tests, 0 failures; both browser scripts exit 0).matchKey/line fields used only by tests.