diff --git a/src/__tests__/catalog-cache.test.ts b/src/__tests__/catalog-cache.test.ts index 674954d..f06c5dc 100644 --- a/src/__tests__/catalog-cache.test.ts +++ b/src/__tests__/catalog-cache.test.ts @@ -75,6 +75,27 @@ describe("Qoder model cache", () => { expect(getCachedModelConfig("qfmodel", "global")).toBeNull(); }); + it("omits catalog entries without a friendly display name", async () => { + vi.stubGlobal( + "fetch", + vi.fn().mockResolvedValue({ + ok: true, + json: () => + Promise.resolve({ + chat: [ + { key: "q37fmodel", enable: true }, + { key: "qfmodel", enable: true, display_name: "Qwen3.8-Flash" }, + ], + }), + }), + ); + + await updateQoderModelsCache("access-token", "user-id", "Test User", "test@example.com", "global"); + + expect(getCachedModels("global").map((model) => model.id)).toEqual(["Qwen3.8-Flash"]); + expect(getCachedModelConfig("q37fmodel", "global")).toBeNull(); + }); + it("keeps only enabled service models without adding auto as a fallback", async () => { vi.stubGlobal( "fetch", diff --git a/src/catalog.ts b/src/catalog.ts index 174c23f..38c2b03 100644 --- a/src/catalog.ts +++ b/src/catalog.ts @@ -626,9 +626,9 @@ export async function updateQoderModelsCache( for (const entry of chatModels) { const key = entry.key; - if (!key || !entry.enable) continue; + if (!key || !entry.enable || !entry.display_name) continue; - const display = entry.display_name || key; + const display = entry.display_name; // Prefer the largest selectable context option the catalog advertises // (e.g. 1M when 200K/400K/1M are offered). If none is advertised, use // DEFAULT_CONTEXT_WINDOW rather than the stale 180K `max_input_tokens`