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
This commit is contained in:
@@ -30,8 +30,10 @@ class ModelSceneController implements SetupSceneController {
|
||||
this.#syncModels();
|
||||
}
|
||||
|
||||
onMount(): void {
|
||||
void this.#refreshModels();
|
||||
async onMount(): Promise<void> {
|
||||
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<void> {
|
||||
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;
|
||||
|
||||
@@ -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<string>();
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user