fix(web): settle the resting composer layout with a pixel of slack #9482
main fromrefs/pull/9482/head·merged by juliusmarminge View on GitHubWhat Changed#
resolveRestingComposerControlsLayout takes an optional previous layout and applies 1px of hysteresis in the re-showing direction only. Hiding a block stays unconditional — the controls would clip otherwise. ChatComposer passes the current layout through.
3 files, +107/-4.
Why#
The composer re-measures its resting controls on every render (useLayoutEffect(measure), no dependency array), and the model picker's natural width is recovered from a truncated label whose scrollWidth is integral while the rendered box is fractional. With the host sitting exactly on a threshold, that sub-pixel difference flipped a block in and out of the overflow menu on every render until React gave up with "Maximum update depth exceeded" (error #185) while opening a thread.
Requiring real slack before a block comes back makes that noise unable to drive the layout.
Follow-up to #9393, which removed the strip-reservation feedback path but left this one — it runs entirely inside the composer's own measure -> resolve -> render cycle.
Fixes #9481.
The new test settles when the measured picker width jitters below a pixel feeds alternating 149 / 149.5 measurements and asserts the layout converges: 2 distinct layouts before the fix, 1 after. The existing threshold tests call the resolver without previous and are unchanged.
UI Changes#
None visible. A block now needs 1px more room before it leaves the overflow menu.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes (no visual change)
- I included a video for animation/interaction changes (not applicable)
Note
Low Risk Localized layout math and state threading in the composer measure loop; behavior change is a 1px margin when controls leave overflow, with no auth or data impact.
Overview Fixes an infinite re-render loop when opening a thread by stabilizing resting composer overflow layout against sub-pixel measurement jitter.
resolveRestingComposerControlsLayout now accepts an optional previous layout. Hiding controls into overflow stays immediate (to avoid clipping). Bringing blocks back from overflow—or making the cluster visible again—requires about 1px of slack (RESTING_CONTROLS_SLACK_PX) so threshold flicker from the model picker’s fractional vs integral width does not flip hiddenCount every render.
ChatComposer passes the current layout into the resolver on each measure. New unit tests cover hysteresis thresholds, no-previous behavior, sub-pixel jitter convergence, and cluster visibility slack.
Note
Add 1px slack hysteresis to resolveRestingComposerControlsLayout to prevent control oscillation#
- Introduces
RESTING_CONTROLS_SLACK_PX(1px) in composerFooterLayout.ts; the resolver now requires one pixel of spare host width before restoring previously overflowed blocks or re-showing a previously hidden cluster. resolveRestingComposerControlsLayoutaccepts an optional previous layout and retains the prior hidden count when the newly expanded layout does not clear the slack margin. Calls without previous state use the original width check.- ChatComposer.tsx passes the hook's current layout as
previousinto each measurement, guarded by the existing state-change check. - Adds hysteresis tests in composerFooterLayout.test.ts covering exact-fit retention, 1px re-show, scratch resolution, fractional-width stabilization, and cluster visibility.
- Behavioral Change: controls that were hidden now stay hidden until host width exceeds their minimum by at least 1px; reviewers should verify the
previousparam threading inuseRestingComposerControlsLayoutdoes not cause stale layouts during rapid resize.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
ec1d9c1Macroscope's review found this PR approvable — This is a localized, test-covered fix that stabilizes the existing resting composer layout by adding a one-pixel re-show threshold. Its production impact is confined to overflow control placement in the composer, with no new capability, schema change, or sensitive-area impact.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge merged this0ba06a1
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes