From e6f108f3406413e5ddc142e265cd6293bed4d385 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 18 Jul 2026 11:24:12 +0000 Subject: [PATCH] fix(setup): refreshed uncached models online Changed the setup picker refresh to online-if-uncached so first-run discovery endpoints populate before model selection. Covered an initially empty registry that discovers the custom model during mount. Fixes #5979 --- .../src/modes/setup-wizard/scenes/model.ts | 9 ++++++--- packages/coding-agent/test/setup-wizard.test.ts | 14 ++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/coding-agent/src/modes/setup-wizard/scenes/model.ts b/packages/coding-agent/src/modes/setup-wizard/scenes/model.ts index a7a7b4173..3a6d80bd6 100644 --- a/packages/coding-agent/src/modes/setup-wizard/scenes/model.ts +++ b/packages/coding-agent/src/modes/setup-wizard/scenes/model.ts @@ -30,8 +30,10 @@ class ModelSceneController implements SetupSceneController { this.#syncModels(); } - onMount(): void { - void this.#refreshModels(); + async onMount(): Promise { + this.#status = theme.fg("muted", "Discovering available models…"); + this.host.requestRender(); + await this.#refreshModels(); } dispose(): void { @@ -89,9 +91,10 @@ class ModelSceneController implements SetupSceneController { async #refreshModels(): Promise { try { - await this.host.ctx.session.modelRegistry.refresh("offline"); + await this.host.ctx.session.modelRegistry.refresh("online-if-uncached"); if (this.#disposed) return; this.#syncModels(); + this.#status = undefined; this.host.requestRender(); } catch (error) { if (this.#disposed) return; diff --git a/packages/coding-agent/test/setup-wizard.test.ts b/packages/coding-agent/test/setup-wizard.test.ts index 0797bf7d4..309fa19d9 100644 --- a/packages/coding-agent/test/setup-wizard.test.ts +++ b/packages/coding-agent/test/setup-wizard.test.ts @@ -113,7 +113,7 @@ describe("setup wizard scene selection", () => { }); describe("setup wizard model selection", () => { - it("saves a configured custom model as the default", async () => { + it("discovers and saves an uncached custom model as the default", async () => { await initTheme(false, "unicode", false, "titanium", "dark"); const settings = Settings.isolated(); const model: Model = buildModel({ @@ -128,6 +128,7 @@ describe("setup wizard model selection", () => { contextWindow: 100_000, maxTokens: 32_000, }); + let available: Model[] = []; const finished = Promise.withResolvers(); const setModel = mock( async ( @@ -147,9 +148,11 @@ describe("setup wizard model selection", () => { session: { model: undefined, modelRegistry: { - getAvailable: () => [model], - getAll: () => [model], - refresh: async () => {}, + getAvailable: () => available, + getAll: () => available, + refresh: async (strategy: string) => { + if (strategy === "online-if-uncached") available = [model]; + }, }, setModel, }, @@ -164,6 +167,9 @@ describe("setup wizard model selection", () => { expect(scene).toBeDefined(); const controller = scene!.mount(host); + expect(controller.render?.(120).join("\n")).not.toContain("minimax-m3"); + await controller.onMount?.(); + expect(controller.render?.(120).join("\n")).toContain("minimax-m3"); controller.handleInput?.("\r"); const result = await finished.promise;