Problem#
An expanded tool-call group can still crash the thread with React #185, even with the 1px slack from #47145. The layout effect in ExpandedWorkGroupEntries sets fitsWithAllowance from scrollHeight - clientHeight, but that flag adds 48px to the box's maxHeight. So the overflow it reads moves with the value it sets. When the box grows by less than 48px (a parent caps it, zoom rounds by more than 1px, or the list measures more rows once the box is taller), the flag flips on every layout pass until React gives up.
Change#
Compare the content's height with the limit the allowance would give (the box's computed max-height, plus the allowance when it is off), not with the box's current height. That limit doesn't depend on the flag, so flipping it can't change the answer. The 1px slack for rounding stays.
Scope#
Fixes #47591 (same crash as #45997, #47106 and #47121, still happening on a build that has #47145).
Verification#
- New browser test
settles an expanded group whose box grows by less than the allowance caps the group's clientHeight at 300px (between its limit with and without the allowance). On main it fails with "Maximum update depth exceeded". With this change it passes.
- All 109 tests in
MessagesTimeline.browser.test.tsx pass, including the existing 1px rounding test.
vp lint and vp fmt --check are clean on the changed files.
- Not checked: a manual run in the real app.
Proved by a browser test that reproduces the crash on main and passes with the fix.
Reviewed with review-loop: 1 round with Claude Fable 5.2 on high effort. Verdict: approved
Made with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code
The automated pipeline stopped on this pull request and will not merge it:
the capture step could not show the problem on the base commit, so there is nothing to prove fixed.
On each fresh server, seed a layout-demo project and a thread using the repository's bench-heavy Replay (dev) recording (13 completed tools). Open the thread directly, expand Worked for and the tool summary. Set document CSS zoom to 100%, 90%, 95%, 105%, 110%, then 100%; collapse/reopen the tool summary at each zoom. At each zoom resize through heights 800, 650, 626, 624, 622, 602, 600, 598, 578, 576, 574, 550, 500, 450, 800px, using widths 950px when height is divisible by three and 1280px otherwise. Check for the React maximum-depth error, return to 1280×800 at 100%, attempt to scroll the group to its end, capture it, and check that Tool calls remains visible.
It stays open for a person to finish or close.