Collapse a Wrote/Edited tool row's diff when it's clicked in the `clai2` web UI
Fixes #11287
Why we make these changes
In the clai2 web UI a "Wrote/Edited" row showed its diff whether closed (inline tool-diffs) or open (ToolDetails, which also renders the diffs), so clicking flipped the chevron and aria-expanded but never hid the diff. Long transcripts with many writes couldn't be scanned.
A row with a diff now starts open, as before, and clicking closes it to the header with its +N −M stats. OpenCards now records the open/closed state the user chose for each card, not a toggle from the default. That way a row keeps that state when its diffs appear (arguments finish streaming) or disappear (the call fails) while the call is running.
New public surface
none (web UI internals only)
User-visible behavior
- Before: clicking "Wrote notes.py +2 −0" changes nothing visible.
- After: clicking it hides the diff, and clicking again shows it. An open file-change row also shows the tool's result line (for example "Wrote 23 chars (2 lines) to notes.py." or a failure message), which used to appear only after clicking.
Verification
- New browser regression
test_file_change_row_folds_its_diff: it replays awrite_filecall and checks that the diff and result appear, disappear, and reappear as the row is clicked, along witharia-expanded. It fails onmain: after the clickaria-expandedistrueand the diff is still shown. CLAI2_BROWSER_TESTS=1 pytest tests/clai2/browser(6 passed after rebasing ontomain),tests/clai2/test_web.py(51 passed), ruff and pyright on the test file, andnpm run build(tsc + vite). The rebuilt bundle is committed.
What changes for existing users
File-change rows can be collapsed. They start open as before and now also show the tool's one-line result.
PR decisions
- Pre-push review 1 of 3 at 863f57f: remediated. Open file-change rows render
ToolDetailsagain, so the result text stays reachable. - Pre-push review 2 of 3 at 5211ef2: remediated.
OpenCardsstores the user's chosen open state, so a row whose diffs appear or vanish mid-call keeps it. Removed the dead.tool-diffsselector. - Pre-push review 3 of 3 at 2ea93ee: no findings.
- Rebased onto
maintwice (#11306, #11310). The only conflicts were the generated bundle, regenerated withnpm run build, and the browser fixture, which keeps both #11310'slinessession and this PR'sgammasession. #11310's fixture docstring also resolves the CI Review nit, so the stacked follow-up #11336 was closed.
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.