# fix\(web\): measure collapsed model labels at their visible width · PR \#9540 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/9540)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: composer-followups/hidden-label-width

Target branch: composer-followups/partial-restore

Head commit: 8309a40d3aa36566409fcbfba2909a88fc11fe42

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/9540)

[Commits](https://git.cafe/pingdotgg/t3code/pull/9540/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/9540/diffs?format=markdown)

## Description

---

At narrow composer widths, the model label deliberately collapses to zero width with `flex-none`. Measurement still adds the label's `scrollWidth`, reserving space for text that will not be shown and moving other controls into overflow too early.

Do not recover the text width of a deliberately collapsed label. Keep recovering the natural width of flexible labels, even when they have been squeezed to zero, and retain the picker's maximum-width cap.

Verification:

- Four new measurement tests pass. With a collapsed label, a 52px picker and 140px mode block fit a 200px host with the 4px gap, instead of overflowing.
- All 35 measurement and composer layout tests pass together.
- Web typecheck and targeted lint pass.
- Integrated browser verification and before/after evidence have not been performed.

Stacked on [#9539](https://github.com/pingdotgg/t3code/pull/9539). This changes shared web/desktop rendering, not native mobile or provider behavior.

Implemented with Codex through T3 Code.


<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. -->
> [!NOTE]
> ### Fix `providerModelPickerNaturalWidth` to measure collapsed model labels at visible width
> - `providerModelPickerNaturalWidth` now treats a label as intentionally collapsed only when both its client width and computed flex growth are zero. Zero-width labels with flexible growth now recover their scroll-width overflow for natural-width calculations.
> - Previously every zero-width model label was treated as collapsed, so flexible labels squeezed to zero contributed no width even though their text was still present.
> - Adds a test suite covering collapsed labels, flexible truncated labels, flexible zero-width labels, and the existing 180-pixel picker maximum-width cap.
> - Risk: labels that are zero-width with non-zero flex growth now contribute recovered text width to picker sizing, which may change layout in narrow composer widths where labels were previously ignored.
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 8309a40.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Localized DOM measurement logic for composer footer layout; behavior change only affects when controls move to overflow at narrow widths.
> 
> **Overview**
> Fixes **resting composer control measurement** so narrow layouts no longer reserve space for model label text that is intentionally hidden.
> 
> `providerModelPickerNaturalWidth` now treats a label with **zero width and `flex-grow: 0`** as deliberately collapsed and **does not** add `scrollWidth − clientWidth` to the picker’s natural width. Flexible labels (`flex-grow` not `0`) still get truncated text recovered when squeezed, including when `clientWidth` is 0, and the picker **`max-width`** cap is unchanged.
> 
> Adds **four unit tests** for collapsed vs flexible labels, overflow layout at a 200px host, and the max-width ceiling.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8309a40d3aa36566409fcbfba2909a88fc11fe42. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
