Skip to content

Commit 475d20a

Browse files
authored
fix(ui): stop the model picker from nagging about refresh failures (#125661)
* fix(ui): stop the model picker from nagging about refresh failures A failed background catalog refresh rendered a "Couldn't refresh models" banner plus a Retry button on top of a complete, working model list, and replaced the composer trigger's model name with that error text. The picker already keeps the last-known catalog and re-requests it on every open, so the operator was being asked to press a button for something the UI does by itself. The error stays recorded on the host — it is what drops the stale availability gate so the composer remains usable — but it is no longer surfaced while there are models to show. Only a genuinely empty catalog still says "Models unavailable". The new-session picker gains the chat picker's open-triggers-revalidate behavior so re-opening it is the retry there too, instead of dead-ending until a page reload. Two adjacent simplifications in the same surface: - Model rows reserve their provider-icon slot as an invisible stem, so names line up with the provider heading label (same 34px stem grouped and filtered, nothing shifts while typing). - The "Using agent default" footer is gone: the default row already carries a DEFAULT badge and the checkmark. Typing "default" in the picker search now matches the default model instead. Proof: scripts/capture-model-picker-proof.mts captures the open picker against a mocked gateway; alignment delta 0px (was -24px), search "default" matches the default row (was nothing), and a failed models.list leaves no catalog-state element with all rows intact. * fix(ci): register the model-picker proof script and await its picker revalidation The unused-file scan needs every scripts/ entry point referenced, like the sibling ui:proof:* recipes. The catalog-reconnect assertion also has to wait for the picker's own metadata request instead of reading the log the moment the rows render. * test(ui): split model-catalog scenarios out of the new-session e2e file The catalog-reconnect file hit the 1000-line cap. Its model-catalog metadata failure/recovery pair is a separate surface from CLI-agent targets, terminal start, and draft reconnect, so it moves to its own file rather than earning a max-lines suppression. * test(audit): give the pinned-reader contract test a realistic timeout It adds a pinned-SHA git worktree and cold-compiles the audit and state modules under tsx, which takes minutes on a contended runner. The 120s default made it fail by construction; it timed out on an unrelated PR shard while passing locally at ~55s.
1 parent 079a874 commit 475d20a

18 files changed

Lines changed: 508 additions & 324 deletions

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,7 @@
19891989
"ui:i18n:sync": "node --import tsx scripts/control-ui-i18n.ts sync --write",
19901990
"ui:i18n:verify": "node --import tsx scripts/control-ui-i18n-verify.ts verify",
19911991
"ui:proof:composer-mic-hover": "node --import tsx scripts/capture-composer-mic-hover-proof.mts",
1992+
"ui:proof:model-picker": "node --import tsx scripts/capture-model-picker-proof.mts",
19921993
"ui:proof:workboard": "node --import tsx scripts/capture-workboard-ui-proof.mts",
19931994
"native:i18n:baseline": "node --import tsx scripts/native-app-i18n.ts baseline --write",
19941995
"native:i18n:check": "node --import tsx scripts/native-app-i18n.ts check",
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/usr/bin/env node
2+
// Captures chat model-picker proof shots: the open picker inheriting the agent
3+
// default, the same picker with a session override, and the picker after a
4+
// failed catalog refresh. Also reports the x offset between the provider
5+
// heading label and the model row name (the row-alignment change).
6+
import { mkdir } from "node:fs/promises";
7+
import path from "node:path";
8+
import { chromium } from "playwright";
9+
import {
10+
canRunPlaywrightChromium,
11+
installMockGateway,
12+
resolvePlaywrightChromiumExecutablePath,
13+
startControlUiE2eServer,
14+
} from "../ui/src/test-helpers/control-ui-e2e.ts";
15+
16+
function readOption(name: string): string | undefined {
17+
const prefix = `--${name}=`;
18+
const inline = process.argv.slice(2).find((arg) => arg.startsWith(prefix));
19+
if (inline) {
20+
return inline.slice(prefix.length);
21+
}
22+
const index = process.argv.indexOf(`--${name}`);
23+
return index >= 0 ? process.argv[index + 1] : undefined;
24+
}
25+
26+
const outputDir = path.resolve(
27+
readOption("output-dir") ?? ".artifacts/control-ui-e2e/model-picker-proof",
28+
);
29+
const label = readOption("label") ?? "after";
30+
const executablePath = resolvePlaywrightChromiumExecutablePath(chromium.executablePath());
31+
if (!canRunPlaywrightChromium(executablePath)) {
32+
throw new Error(`Playwright Chromium is unavailable at ${executablePath}`);
33+
}
34+
35+
const models = [
36+
{ id: "gpt-5.5", name: "GPT-5.5", provider: "openai", contextWindow: 400_000 },
37+
{ id: "gpt-5.6-luna", name: "GPT-5.6 Luna", provider: "openai", contextWindow: 1_000_000 },
38+
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol", provider: "openai", contextWindow: 1_000_000 },
39+
{ id: "gpt-5.6-terra", name: "GPT-5.6 Terra", provider: "openai", contextWindow: 1_000_000 },
40+
{
41+
id: "claude-sonnet-4-6",
42+
name: "Claude Sonnet 4.6",
43+
provider: "anthropic",
44+
contextWindow: 200_000,
45+
},
46+
{ id: "claude-opus-4-6", name: "Claude Opus 4.6", provider: "anthropic", contextWindow: 200_000 },
47+
];
48+
49+
await mkdir(outputDir, { recursive: true });
50+
const server = await startControlUiE2eServer(undefined, { source: true });
51+
const browser = await chromium.launch({ executablePath });
52+
const context = await browser.newContext({
53+
colorScheme: "dark",
54+
viewport: { width: 1280, height: 900 },
55+
});
56+
const page = await context.newPage();
57+
page.setDefaultTimeout(30_000);
58+
59+
try {
60+
const gateway = await installMockGateway(page, { agentModel: "openai/gpt-5.5", models });
61+
await page.goto(`${server.baseUrl}chat`);
62+
await gateway.waitForRequest("chat.startup");
63+
64+
const composer = page.locator(".agent-chat__input");
65+
await composer.waitFor({ state: "visible" });
66+
const trigger = composer.locator('[data-chat-model-select="true"]');
67+
const menu = composer.locator(".chat-controls__model-menu");
68+
69+
const openPicker = async () => {
70+
await trigger.click();
71+
await menu.waitFor({ state: "visible" });
72+
await page.waitForTimeout(500);
73+
};
74+
const closePicker = async () => {
75+
await page.keyboard.press("Escape");
76+
await page.waitForTimeout(250);
77+
};
78+
const shoot = async (name: string) => {
79+
const box = await menu.boundingBox();
80+
if (!box) {
81+
throw new Error(`model menu has no layout box for ${name}`);
82+
}
83+
await page.screenshot({
84+
path: path.join(outputDir, `${label}-${name}.png`),
85+
clip: {
86+
x: Math.max(0, box.x - 8),
87+
y: Math.max(0, box.y - 8),
88+
width: box.width + 16,
89+
height: box.height + 16,
90+
},
91+
});
92+
};
93+
94+
await openPicker();
95+
await shoot("default");
96+
97+
const headingLabel = menu.locator(".chat-controls__provider-heading span").last();
98+
const rowName = menu.locator(".chat-controls__model-option-name").first();
99+
const headingBox = await headingLabel.boundingBox();
100+
const rowBox = await rowName.boundingBox();
101+
102+
const search = menu.locator("[data-chat-model-search]");
103+
await search.fill("default");
104+
await page.waitForTimeout(400);
105+
await shoot("search-default");
106+
const searchMatches = await menu
107+
.locator("[data-chat-model-option]:not([hidden])")
108+
.evaluateAll((rows) => rows.map((row) => row.textContent?.replace(/\s+/gu, " ").trim() ?? ""));
109+
await search.fill("");
110+
await page.waitForTimeout(250);
111+
112+
const override = menu.locator('[data-chat-model-option="openai/gpt-5.6-terra"]');
113+
await override.click();
114+
await page.waitForTimeout(600);
115+
await openPicker();
116+
await shoot("override");
117+
await closePicker();
118+
119+
// A fresh page drops the per-client catalog cache, so the picker's own load
120+
// reaches the mock gateway and fails there.
121+
await gateway.setMethodResponse("models.list", {
122+
__mockError: { code: "UNAVAILABLE", message: "mock catalog refresh failed" },
123+
});
124+
await page.reload();
125+
await composer.waitFor({ state: "visible" });
126+
await page.waitForTimeout(1000);
127+
await openPicker();
128+
await page.waitForTimeout(1500);
129+
await shoot("refresh-failure");
130+
const catalogStateText = await menu.locator("[data-chat-model-catalog-state]").allTextContents();
131+
const rowsAfterFailure = await menu.locator("[data-chat-model-option]").count();
132+
await closePicker();
133+
134+
console.log(
135+
JSON.stringify(
136+
{
137+
label,
138+
outputDir,
139+
providerHeadingLabelX: headingBox?.x ?? null,
140+
modelRowNameX: rowBox?.x ?? null,
141+
alignmentDeltaPx: headingBox && rowBox ? rowBox.x - headingBox.x : null,
142+
searchDefaultMatches: searchMatches,
143+
catalogStateAfterRefreshFailure: catalogStateText,
144+
modelRowsAfterRefreshFailure: rowsAfterFailure,
145+
},
146+
null,
147+
2,
148+
),
149+
);
150+
} finally {
151+
await context.close();
152+
await browser.close();
153+
await server.close();
154+
}

‎src/audit/message-delivery-progress-store.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ describe("outbound message progress companion", () => {
345345
limit: 10,
346346
}).events.map((event) => event.outcome),
347347
).toEqual(["queued", "platform_started", "sent"]);
348-
});
348+
// A pinned-SHA worktree plus a cold tsx compile of the audit/state modules costs
349+
// minutes on a contended runner; the 120s default makes this fail by construction.
350+
}, 300_000);
349351

350352
it("pages large offsets across bounded owner-stream chunks", () => {
351353
const database = databaseOptions();

‎ui/src/e2e/chat-composer-catalog.e2e.test.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ suite.define(() => {
305305
});
306306
});
307307

308-
it("keeps startup models visible and retries failed picker discovery", async () => {
308+
it("keeps startup models visible and retries discovery when the picker reopens", async () => {
309309
await suite.withPage({ viewport: { width: 1280, height: 900 } }, async ({ page }) => {
310310
const startupModel = {
311311
id: "startup-model",
@@ -343,22 +343,21 @@ suite.define(() => {
343343
const composer = page.locator(".agent-chat__input");
344344
await composer.locator('[data-chat-model-select="true"]').click();
345345
await expect.poll(async () => (await gateway.getRequests("models.list")).length).toBe(1);
346-
await expect
347-
.poll(() => composer.locator('[data-chat-model-catalog-state="error"]').isVisible())
348-
.toBe(true);
346+
await expect.poll(() => composer.locator("[data-chat-model-catalog-state]").count()).toBe(0);
349347
await expect
350348
.poll(() => composer.locator('[data-chat-model-option="openai/startup-model"]').isVisible())
351349
.toBe(true);
352350

353-
await composer.locator('[data-chat-model-catalog-retry="true"]').click();
351+
await composer.locator('[data-chat-model-select="true"]').click();
352+
await composer.locator('[data-chat-model-select="true"]').click();
354353

355354
await expect.poll(async () => (await gateway.getRequests("models.list")).length).toBe(2);
356355
await expect
357356
.poll(() =>
358357
composer.locator('[data-chat-model-option="anthropic/discovered-model"]').isVisible(),
359358
)
360359
.toBe(true);
361-
expect(await composer.locator('[data-chat-model-catalog-state="error"]').count()).toBe(0);
360+
expect(await composer.locator("[data-chat-model-catalog-state]").count()).toBe(0);
362361
for (const request of await gateway.getRequests("models.list")) {
363362
expect(request.params).toEqual(expect.objectContaining({ view: "configured" }));
364363
expect(request.params).not.toEqual(expect.objectContaining({ preparedOnly: true }));

‎ui/src/e2e/chat-composer-redesign.e2e.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,26 @@ suite.define(() => {
6565
const beforeFailure = (await gateway.getRequests("models.list")).length;
6666
await model.click();
6767
await gateway.waitForRequest("models.list", { after: beforeFailure });
68+
await expect.poll(() => composer.locator("[data-chat-model-catalog-state]").count()).toBe(0);
6869
await expect
69-
.poll(() => composer.locator('[data-chat-model-catalog-state="error"]').textContent())
70-
.toContain("Couldn’t refresh models");
70+
.poll(() => composer.locator('[data-chat-model-option="openai/gpt-5.5"]').count())
71+
.toBe(1);
7172
await expect.poll(() => textarea.isEnabled()).toBe(true);
7273
await expect.poll(() => disabledReason.count()).toBe(0);
7374

7475
await gateway.setMethodResponse("models.list", {
7576
models: [{ ...coldModels[0], available: true }],
7677
});
7778
const beforeRetry = (await gateway.getRequests("models.list")).length;
78-
await composer.locator('[data-chat-model-catalog-retry="true"]').click();
79+
await model.click();
80+
await model.click();
7981
const retry = await gateway.waitForRequest("models.list", { after: beforeRetry });
80-
expect(retry.params).toEqual({ agentId: "main", refresh: true, view: "configured" });
82+
expect(retry.params).toEqual({ agentId: "main", view: "configured" });
8183
await expect.poll(() => textarea.isEnabled()).toBe(true);
8284
await expect.poll(() => composer.locator("[data-chat-model-catalog-state]").count()).toBe(0);
85+
await expect
86+
.poll(() => composer.locator('[data-chat-model-option="openai/gpt-5.5"]').isEnabled())
87+
.toBe(true);
8388
});
8489
});
8590

‎ui/src/e2e/new-session-page.catalog-reconnect.e2e.test.ts‎

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -475,127 +475,6 @@ suite.define(() => {
475475
}
476476
});
477477

478-
it("shows metadata failure truthfully and recovers the full catalog on retry", async () => {
479-
const context = await suite.browser.newContext({
480-
locale: "en-US",
481-
serviceWorkers: "block",
482-
viewport: { height: 900, width: 1280 },
483-
});
484-
const page = await context.newPage();
485-
const models = [
486-
{
487-
available: true,
488-
id: "gpt-5.6-luna",
489-
name: "GPT-5.6 Luna",
490-
provider: "openai",
491-
},
492-
{
493-
available: true,
494-
id: "gpt-5.6-sol",
495-
name: "GPT-5.6 Sol",
496-
provider: "openai",
497-
},
498-
{
499-
available: true,
500-
id: "gpt-5.6-terra",
501-
name: "GPT-5.6 Terra",
502-
provider: "openai",
503-
},
504-
];
505-
const gateway = await installMockGateway(page, {
506-
agentModel: "openai/gpt-5.6-luna",
507-
methodResponses: {
508-
"chat.metadata": {
509-
sequence: [
510-
{
511-
__mockError: {
512-
code: "UNAVAILABLE",
513-
message: "metadata request timed out",
514-
},
515-
},
516-
{ commands: [], models },
517-
],
518-
},
519-
},
520-
models,
521-
});
522-
523-
try {
524-
await page.goto(`${suite.server.baseUrl}new`);
525-
await gateway.waitForRequest("chat.metadata");
526-
527-
const modelSelect = page.locator('[data-chat-model-select="true"]');
528-
await expect.poll(() => modelSelect.textContent()).toContain("Models unavailable");
529-
await modelSelect.click();
530-
await expect
531-
.poll(() => page.locator('[data-chat-model-catalog-state="error"]').isVisible())
532-
.toBe(true);
533-
expect(await page.locator("[data-chat-model-option]").count()).toBe(0);
534-
535-
await page.locator('[data-chat-model-catalog-retry="true"]').click();
536-
537-
await expect.poll(async () => (await gateway.getRequests("chat.metadata")).length).toBe(2);
538-
await expect.poll(() => page.locator("[data-chat-model-option]").count()).toBe(3);
539-
expect(await page.locator('[data-chat-model-catalog-state="error"]').count()).toBe(0);
540-
} finally {
541-
await context.close();
542-
}
543-
});
544-
545-
it("restores the model picker after startup-sidecars metadata becomes available", async () => {
546-
const context = await suite.browser.newContext({
547-
locale: "en-US",
548-
serviceWorkers: "block",
549-
viewport: { height: 900, width: 1280 },
550-
});
551-
const page = await context.newPage();
552-
const recoveredModel = {
553-
available: true,
554-
id: "gpt-5.6-luna",
555-
name: "Recovered GPT-5.6 Luna",
556-
provider: "openai",
557-
reasoning: true,
558-
};
559-
const gateway = await installMockGateway(page, {
560-
methodResponses: {
561-
"chat.metadata": {
562-
sequence: [
563-
{
564-
__mockError: {
565-
code: "UNAVAILABLE",
566-
details: { reason: "startup-sidecars" },
567-
message: "gateway startup sidecars are still initializing",
568-
retryable: true,
569-
retryAfterMs: 100,
570-
},
571-
},
572-
{ commands: [], models: [recoveredModel] },
573-
],
574-
},
575-
},
576-
});
577-
578-
try {
579-
await page.goto(`${suite.server.baseUrl}new`);
580-
await expect.poll(async () => (await gateway.getRequests("chat.metadata")).length).toBe(2);
581-
582-
const modelSelect = page.locator(
583-
'.new-session-page__composer [data-chat-model-select="true"]',
584-
);
585-
await modelSelect.click();
586-
await expect
587-
.poll(() => page.locator('[data-chat-model-option="openai/gpt-5.6-luna"]').textContent())
588-
.toContain(recoveredModel.name);
589-
590-
expect(await gateway.getRequests("chat.metadata")).toEqual([
591-
expect.objectContaining({ params: { agentId: "main" } }),
592-
expect.objectContaining({ params: { agentId: "main" } }),
593-
]);
594-
} finally {
595-
await context.close();
596-
}
597-
});
598-
599478
it("creates a catalog-targeted draft with its advertised model", async () => {
600479
const context = await suite.browser.newContext({
601480
locale: "en-US",

0 commit comments

Comments
 (0)