Skip to content

Commit 600126a

Browse files
authored
fix: picker option labels collapse to ellipsis at phone widths (#123085)
* fix(ui): keep picker labels readable on mobile Preserve readable unified model and channel option labels while allowing new-session mode controls to wrap at narrow widths. * fix(ui): propagate shared picker minimum
1 parent c5690c9 commit 600126a

5 files changed

Lines changed: 69 additions & 21 deletions

File tree

‎ui/src/components/select-picker.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export type PickerParams<Option extends PickerOption> = {
2323
};
2424

2525
export function renderPicker<Option extends PickerOption>(params: PickerParams<Option>) {
26+
// Web Awesome syncs the listbox to its trigger; keep 8ch for the label after
27+
// its fixed check and leading-icon columns instead of collapsing the options.
2628
const options =
2729
params.value === null ||
2830
params.value === "" ||
@@ -39,7 +41,7 @@ export function renderPicker<Option extends PickerOption>(params: PickerParams<O
3941
<wa-select
4042
id=${params.id ?? nothing}
4143
class=${`settings-select picker-select ${params.className ?? ""}`}
42-
style="width:100%;min-width:0"
44+
style="width:100%;min-width:138px"
4345
title=${params.title ?? nothing}
4446
placement=${params.placement ?? nothing}
4547
.value=${params.value}

‎ui/src/e2e/new-session-page.workspace-memory.e2e.test.ts‎

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const DESKTOP_CONTEXT: BrowserContextOptions = {
2727
};
2828
const MOBILE_CONTEXT: BrowserContextOptions = {
2929
...BASE_CONTEXT,
30-
viewport: { height: 568, width: 320 },
30+
viewport: { height: 740, width: 364 },
3131
};
3232
const MODELS = [
3333
{ id: "gpt-5.5", name: "GPT 5.5", provider: "openai" },
@@ -127,7 +127,20 @@ suite.define(() => {
127127
it("keeps the mobile footer controls separated and reveals session modes on hover or focus", async () => {
128128
await withNewSessionPage(MOBILE_CONTEXT, async (page) => {
129129
await installMockGateway(page, {
130-
models: [{ id: "gpt-5.6-sol", name: "GPT 5.6 Sol", provider: "openai" }],
130+
models: [
131+
{
132+
id: "gpt-5.6-luna",
133+
name: "GPT 5.6 Luna",
134+
provider: "openai",
135+
contextWindow: 400_000,
136+
},
137+
{
138+
id: "claude-sonnet-4-6",
139+
name: "Claude Sonnet 4.6",
140+
provider: "anthropic",
141+
contextWindow: 200_000,
142+
},
143+
],
131144
hasMultipleSessionSharingIdentities: true,
132145
});
133146
await page.goto(`${suite.server.baseUrl}new`);
@@ -178,23 +191,49 @@ suite.define(() => {
178191
expect(modelBox).not.toBeNull();
179192
expect((attachBox?.x ?? 0) + (attachBox?.width ?? 0)).toBeLessThanOrEqual(draftBox?.x ?? 0);
180193
expect((draftBox?.x ?? 0) + (draftBox?.width ?? 0)).toBeLessThanOrEqual(incognitoBox?.x ?? 0);
181-
expect((incognitoBox?.x ?? 0) + (incognitoBox?.width ?? 0)).toBeLessThanOrEqual(
182-
modelBox?.x ?? 0,
183-
);
184194
for (const control of [attachBox, draftBox, incognitoBox, modelBox]) {
185195
expect(control?.x ?? 0).toBeGreaterThanOrEqual(footerBox?.x ?? 0);
186196
expect((control?.x ?? 0) + (control?.width ?? 0)).toBeLessThanOrEqual(
187197
(footerBox?.x ?? 0) + (footerBox?.width ?? 0),
188198
);
189199
}
190200
// The new-session footer keeps flex (not the shared chat mobile grid), so
191-
// all four controls share one 320px row; wrap or overflow here means the
192-
// new-session.css mobile override regressed.
201+
// its transient mode switches can wrap before the model picker overflows.
193202
const controlsOverflow = await footer.evaluate(
194203
(element) => element.scrollWidth - element.clientWidth,
195204
);
196205
expect(controlsOverflow).toBe(0);
197206

207+
const picker = newSessionModelPicker(page);
208+
await picker.click();
209+
await expect.poll(() => picker.getAttribute("open")).toBe("");
210+
const optionLabelWidths = await picker.locator("wa-option").evaluateAll((options) =>
211+
options.flatMap((option) => {
212+
if (option.getBoundingClientRect().width === 0) {
213+
return [];
214+
}
215+
const label = option.querySelector<HTMLElement>(".picker-select__label")!;
216+
const probe = document.createElement("span");
217+
probe.style.cssText = `position:fixed;visibility:hidden;width:8ch;font:${getComputedStyle(label).font}`;
218+
document.body.append(probe);
219+
const minimum = probe.getBoundingClientRect().width;
220+
probe.remove();
221+
return [
222+
{
223+
label: label.textContent?.trim(),
224+
minimum,
225+
width: label.getBoundingClientRect().width,
226+
},
227+
];
228+
}),
229+
);
230+
expect(optionLabelWidths.length).toBeGreaterThanOrEqual(2);
231+
for (const entry of optionLabelWidths) {
232+
expect(entry.width, JSON.stringify(entry)).toBeGreaterThanOrEqual(entry.minimum);
233+
}
234+
await captureUiProof(page, "mobile-model-picker-labels.png");
235+
await picker.click();
236+
198237
await attach.click();
199238
await expect.poll(() => takePhoto.isVisible()).toBe(true);
200239
await page.keyboard.press("Escape");

‎ui/src/pages/chat/chat-responsive.browser.test.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,15 @@ function composerControlsHtml(crowded = false) {
292292
<div class="chat-composer-model-control">
293293
<div class="chat-controls__session chat-controls__model chat-controls__model-settings">
294294
<div class="chat-controls__model-control">
295-
<div class="chat-controls__inline-select-trigger chat-controls__model-trigger" data-chat-composer-model="true" aria-label="Chat model">
296-
<span class="chat-controls__inline-select-label">GPT-5.6 Luna</span>
297-
</div>
295+
<div class="chat-controls__model-control-row">
296+
<div class="model-picker">
297+
<wa-select class="settings-select picker-select model-picker__select chat-controls__model-picker" style="display:block;width:100%;min-width:138px">
298+
<div class="chat-controls__inline-select-trigger chat-controls__model-trigger" data-chat-composer-model="true" aria-label="Chat model">
299+
<span class="chat-controls__inline-select-label">GPT-5.6 Luna</span>
300+
</div>
301+
</wa-select>
302+
</div>
303+
</div>
298304
</div>
299305
<details class="chat-controls__inline-select chat-controls__effort-picker">
300306
<summary class="chat-controls__inline-select-trigger chat-controls__effort-trigger" data-chat-composer-effort="true" aria-label="Effort">
@@ -2515,14 +2521,17 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
25152521
footer: rectFor(".agent-chat__composer-footer"),
25162522
meta: rectFor(".agent-chat__composer-meta"),
25172523
model: rectFor(".chat-controls__model-trigger"),
2524+
modelPicker: rectFor(".chat-controls__model-picker"),
25182525
modelLabel: rectFor(".chat-controls__model-trigger .chat-controls__inline-select-label"),
25192526
overrides: rectFor(".agent-chat__session-overrides-pill"),
25202527
status: rectFor(".agent-chat__composer-run-status"),
25212528
typing: rectFor(".agent-chat__typing-indicator--outside"),
25222529
};
25232530
});
25242531

2525-
expect(layout.controls.scrollWidth).toBeLessThanOrEqual(layout.controls.clientWidth + 1);
2532+
expect(layout.controls.scrollWidth, JSON.stringify(layout)).toBeLessThanOrEqual(
2533+
layout.controls.clientWidth + 1,
2534+
);
25262535
for (const control of [
25272536
layout.status,
25282537
layout.overrides,
@@ -2539,6 +2548,7 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
25392548
expect(trigger.width).toBeGreaterThanOrEqual(TOUCH_TARGET_MIN_PX);
25402549
expect(trigger.height).toBeGreaterThanOrEqual(TOUCH_TARGET_MIN_PX);
25412550
}
2551+
expect(layout.modelPicker.width).toBeGreaterThanOrEqual(138);
25422552
expect(layout.modelLabel.scrollWidth).toBeLessThanOrEqual(layout.modelLabel.clientWidth + 1);
25432553
for (const [left, right] of [
25442554
[layout.status, layout.overrides],

‎ui/src/styles/chat/layout.css‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,17 +3758,13 @@ button.chat-reply-preview--message:disabled {
37583758
.agent-chat__composer-controls .chat-controls__model,
37593759
.chat-composer-model-control {
37603760
width: fit-content;
3761-
min-width: 0;
3761+
min-width: min-content;
37623762
max-width: min(70vw, 100%);
37633763
margin-left: 0;
37643764
}
37653765

3766-
/* Reserve the readable model trigger, 44px effort target, and their gap;
3767-
keep the picker cluster right-aligned like desktop while transient status
3768-
text yields before either picker does. */
37693766
.agent-chat__input .agent-chat__composer-controls .chat-composer-model-control {
37703767
flex: 0 1 auto;
3771-
min-width: 138px;
37723768
}
37733769

37743770
.agent-chat__input .agent-chat__composer-controls .chat-controls__model-picker {
@@ -4294,7 +4290,7 @@ button.chat-reply-preview--message:disabled {
42944290

42954291
.chat-controls__model {
42964292
grid-area: model;
4297-
min-width: 0;
4293+
min-width: min-content;
42984294
max-width: none;
42994295
}
43004296

@@ -4306,18 +4302,18 @@ button.chat-reply-preview--message:disabled {
43064302

43074303
.chat-controls__model-control {
43084304
display: grid;
4309-
min-width: 0;
4305+
min-width: min-content;
43104306
flex: 1 1 auto;
43114307
}
43124308

43134309
.chat-controls__model-control-row {
43144310
display: flex;
43154311
align-items: center;
4316-
min-width: 0;
4312+
min-width: min-content;
43174313
}
43184314

43194315
.chat-controls__model-control-row .model-picker {
4320-
min-width: 0;
4316+
min-width: min-content;
43214317
flex: 1 1 auto;
43224318
}
43234319

‎ui/src/styles/new-session.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ wa-dropdown.new-session-page__start-menu {
749749
Keep those pills intrinsic and let the model picker use the remaining width. */
750750
.new-session-page__composer .agent-chat__composer-controls {
751751
display: flex;
752+
flex-wrap: wrap;
752753
gap: 2px;
753754
}
754755

0 commit comments

Comments
 (0)