Skip to content

Commit 8ab5574

Browse files
committed
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.
1 parent 7235943 commit 8ab5574

4 files changed

Lines changed: 50 additions & 12 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/styles/chat/layout.css‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,12 +3763,8 @@ button.chat-reply-preview--message:disabled {
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 {

‎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)