diff --git a/packages/app/src/context/global-sync/utils.test.ts b/packages/app/src/context/global-sync/utils.test.ts index 5c62a8f6a07b..a0efceaf2328 100644 --- a/packages/app/src/context/global-sync/utils.test.ts +++ b/packages/app/src/context/global-sync/utils.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, test } from "bun:test" +import { describe, expect, test } from "bun:test" import type { AgentListOutput, ModelDefaultOutput, @@ -118,6 +118,36 @@ describe("normalizeProviderList", () => { test("preserves an empty current default", () => { expect(normalizeProviderList([] as ProviderListOutput["data"], [], null).defaultModel).toBeNull() }) + + test("sets release_date to undefined when the server reports released=0", () => { + // Models with time.released === 0 have no known release date. The server + // uses 0 as a sentinel for "unreleased" or "config-only" models. Mapping 0 + // to "1970-01-01" produces a valid DateTime in the visibility filter, which + // then hides the model because 1970-01-01 is outside the recent 6-month + // window. Setting release_date to undefined instead triggers the + // unknown-date escape hatch in models.tsx and keeps the model visible. + const result = normalizeProviderList( + [{ id: "custom", name: "Custom", package: "@custom/provider" }] as ProviderListOutput["data"], + [ + { + id: "my-model", + modelID: "my-model", + providerID: "custom", + name: "My Model", + capabilities: { tools: true, input: ["text"], output: ["text"] }, + variants: [], + time: { released: 0 }, + cost: [], + status: "active", + enabled: true, + limit: { context: 32_000, output: 4_096 }, + }, + ] as ModelListOutput["data"], + undefined, + ) + + expect(result.all.get("custom")?.models["my-model"]?.release_date).toBeUndefined() + }) }) describe("directoryKey", () => { @@ -135,4 +165,4 @@ describe("directoryKey", () => { expect(String(directoryKey("C:/"))).toBe("C:/") expect(String(directoryKey("/"))).toBe("/") }) -}) +}) \ No newline at end of file diff --git a/packages/app/src/context/global-sync/utils.ts b/packages/app/src/context/global-sync/utils.ts index 1b2c2f4d2da4..d37fdf93219b 100644 --- a/packages/app/src/context/global-sync/utils.ts +++ b/packages/app/src/context/global-sync/utils.ts @@ -1,4 +1,4 @@ -import type { +import type { AgentListOutput, ModelDefaultOutput, ModelListOutput, @@ -131,7 +131,7 @@ export function normalizeProviderList( status: model.status, options: model.settings ?? {}, headers: model.headers ?? {}, - release_date: new Date(model.time.released).toISOString().slice(0, 10), + release_date: model.time.released === 0 ? undefined : new Date(model.time.released).toISOString().slice(0, 10), variants: Object.fromEntries(model.variants.map((variant) => [variant.id, variant.settings ?? {}])), } } @@ -169,4 +169,4 @@ export function normalizeProjectInfo(project: Project | CurrentProject): Project ...project, vcs: project.vcs === "git" ? "git" : undefined, } -} +} \ No newline at end of file