Problem#
Since #7855, the desktop app crashes with React error 185 (maximum update depth) on some existing threads at common window widths. Nightly 0.0.39-nightly.20260903.1267 reproduces it.
The context strip and the resting composer each measure the same row in a layout effect and change its layout. The strip judged its expanded labels against the controls left visible after the composer moved blocks into overflow, so it expanded into that room. The composer then lost the room, hid the blocks again, and the two decisions alternated on every render. The overflow menu also took a new React key on each flip, so Base UI cleaned up a popup mid-loop, which is the exact frame React reported.
Captured from the crashed renderer: a 724px strip, compact labels leaving a 587px host, composer controls needing about 364px with everything visible, and expanded labels needing 327px. Those cannot all fit, but each side thought they could when it only looked at the other side's collapsed state.
Fix#
- The strip now reserves the natural width of the composer controls, with every block visible, before it expands its labels. Both components read that width through one shared measurement (
restingComposerControlsMeasurement.ts), so neither decision depends on what the other one hid last render.
- The compact decision moved to a pure helper in
BranchToolbar.logic.ts so the coupled case is testable.
- Block and overflow wrappers keep stable keys across visibility changes. They already go
inert and out of flow when hidden, so nothing needs a remount.
A regression test models the captured widths and checks that the two decisions land on the same answer on the second pass, and that the old visible-only reservation did not.
Verified with the touched tests, apps/web typecheck, and lint on the touched files.
Written by Claude Fable 5.1 through Claude Code.
Note
Medium Risk
Touches coupled layout measurement in a hot resize path; incorrect width reservation could still mis-compact labels or hide controls, but scope is UI-only with dedicated regression tests.
Overview
Fixes React error 185 (infinite update loop) when the branch toolbar context strip and resting composer both resize the same row.
The strip was deciding whether to expand Git/env labels using only the currently visible composer control width. That let labels expand into space the composer had just freed by moving blocks into overflow, which shrank the host, hid blocks again, and repeated every render.
Changes: A shared DOM measurement (restingComposerControlsMeasurement.ts) feeds both ChatComposer and BranchToolbar. The strip now reserves resolveRestingComposerControlsNaturalWidth (full controls with nothing in overflow) before expanding labels. Label compact/expand hysteresis moves to testable resolveContextStripLabelsCompact in BranchToolbar.logic.ts.
Stability: Resting block and overflow wrappers keep stable React keys across hidden/visible states; CompactComposerControlsMenu gets a hidden prop and closes its menu when the overflow trigger is out of flow. Regression tests model the captured 724px crash geometry.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fe27c7850b1b0aba0b3ed66845e69ca89603fe5f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
Note
Fix resting composer layout loop by measuring natural control width and adding 16px hysteresis#
- The context strip measured only currently visible controls when deciding whether to compact labels. Labels would expand into freed width, push controls into overflow, free width again, and loop. The hook now reserves the natural width of all resting controls including hidden ones.
- Context-strip label compaction adds a 16-pixel expansion hysteresis via
resolveContextStripLabelsCompact in BranchToolbar.logic.ts: an already-compact strip stays compact until required width fits plus 16px; an expanded strip compacts immediately on overflow.
- DOM width helpers move from ChatComposer.tsx into the shared restingComposerControlsMeasurement.ts module, which exposes
measureRestingComposerControls and resolveRestingComposerControlsNaturalWidth.
- Resting composer block keys now use only block ID, so blocks keep React identity when moving between inline and overflow. The overflow menu in CompactComposerControlsMenu.tsx closes and stays closed when its trigger is hidden.
- Risk:
resolveRestingComposerControlsLayout in composerFooterLayout.ts now requires the shared RestingComposerControlsMeasurement interface; callers that previously passed ad-hoc width data must be updated.
Macroscope summarized fe27c78.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
5d1b02c· PR result:fe27c78· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.