Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions packages/app/src/context/global-sync/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test"
import { describe, expect, test } from "bun:test"
import type {
AgentListOutput,
ModelDefaultOutput,
Expand Down Expand Up @@ -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", () => {
Expand All @@ -135,4 +165,4 @@ describe("directoryKey", () => {
expect(String(directoryKey("C:/"))).toBe("C:/")
expect(String(directoryKey("/"))).toBe("/")
})
})
})
6 changes: 3 additions & 3 deletions packages/app/src/context/global-sync/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {
import type {
AgentListOutput,
ModelDefaultOutput,
ModelListOutput,
Expand Down Expand Up @@ -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 ?? {}])),
}
}
Expand Down Expand Up @@ -169,4 +169,4 @@ export function normalizeProjectInfo(project: Project | CurrentProject): Project
...project,
vcs: project.vcs === "git" ? "git" : undefined,
}
}
}
Loading