Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): stop the resting composer layout loop #9393

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/9393/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

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.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.7 KiB13.5 KiB−229 B (−1.6%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB−5 B (−0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.7 KiB6.5 KiB−224 B (−3.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded58.5 KiB57.0 KiB−1.5 KiB (−2.6%)66.4 KiB✅
      CodexLive turn messages108−2 (−20.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.6 KiB0 B (0.0%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−1 B (−0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.6 KiB6.6 KiB+1 B (+0.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.9 KiB57.9 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages10100 (0.0%)21✅

      Baseline: 5d1b02c · PR result: fe27c78 · Source CI: success

      Scenario 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.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at fe27c78

      Macroscope's review found this PR approvable — This is a localized UI bug fix that stabilizes existing composer/context-strip sizing by sharing natural-width measurements and preserving component identity. The added regression coverage models the reported layout loop, and no sensitive, schema, deployment, or product-default changes are involved.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b64bb1dc3f8874dae483e920f563b600da4ccff5. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.