Mount only the first 8 lines of each file-change diff in the `clai2` web UI
Fixes #11302
Why we make these changes
In the clai2 web UI, every Wrote/Edited row mounted its whole syntax-highlighted diff, one table row per line plus highlight.js spans. Since #11309, those rows start open, so a long session's transcript is mostly diff DOM that nobody is reading. The issue measured this at 88% of a long session's nodes, which slows session switching and reloads.
Each diff in a file-change row now mounts only its first 8 code lines, followed by an "N more lines" button that mounts the rest. Rows still start open, and clicking the row still folds it (#11309).
New public surface
none (web UI internals only)
User-visible behavior
- Before: an open "Wrote long.py +200 −0" row renders all 200 highlighted lines.
- After: it renders 8 lines and a "192 more lines" button that shows the whole diff. Each diff in a card expands on its own.
On the test session below, which has one 200-line write_file:
| page nodes | nodes in .diff | highlight.js spans | |
|---|---|---|---|
main | 1041 | 810 | 200 |
| this PR | 274 | 43 | 8 |
Verification
-
New browser regression
test_file_change_row_mounts_a_diff_previewintests/clai2/browser/test_web_browser.py. It replays a 200-linewrite_fileand checks:- the open row mounts 8 diff rows;
- "192 more lines" mounts all 200;
- clicking the row folds it.
Against
main's bundle it fails with 200 rows instead of 8. -
Locally:
tests/clai2/browser/test_web_browser.py: 10 passed;tests/clai2/test_web_assets.py(bundle freshness): passed;tsc --noEmit, ruff, pyright and pre-commit: passed.
The bundle was rebuilt with
npm run buildon Node v24.22.1 (.nvmrc). -
Not run as-is locally: Chromium on my machine (WSL) has a stalled GPU process, so
requestAnimationFramenever fires and Playwright clicks time out, onmaintoo. The browser tests above ran with--disable-gpu --disable-software-rasterizeradded through an uncommitted local pytest plugin. CI runs them unmodified.
What changes for existing users
A long diff in the web UI shows its first 8 lines until you click "N more lines".
PR decisions
- Scope (Mike): #11309 landed while this was in progress. Rows stay open by default, and the preview applies inside the open row. Starting rows closed was considered and rejected.
- Pre-push reviews 1–2 covered an earlier design that previewed the old collapsed
.tool-diffs, which #11309 removed. Their fixes carried over:- hunk headers don't count toward the limit;
- the preview never ends on a trailing hunk header;
- the test uses a named constant.
- Pre-push review 3 of 3 (at
bd164a751) was remediated: the expanded state now lives in eachDiffView, so one button expands only its own diff, and no new callback prop defeatsDiffView'smemo. The review budget is used up. - Rebased onto
main(#11309, #11310, #11331 and others). The generated bundle was rebuilt rather than resolved by picking a side, and fixture and component conflicts kept both sides.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.