fix(tui): distinguish variant switch notices (#35315)

This commit is contained in:
Kit Langton 2026-07-04 10:58:56 -04:00 committed by GitHub
commit 62af66a74f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 98 additions and 21 deletions

View file

@ -34,11 +34,12 @@ export function formatRef(model: { providerID: string; id: string; variant?: str
export function switchLabel(
model: { providerID: string; id: string; variant?: string },
models?: readonly { providerID: string; id: string; name: string }[],
previous?: { providerID: string; id: string; variant?: string },
) {
if (previous?.providerID === model.providerID && previous.id === model.id)
return `Switched variant to ${model.variant ?? "default"}`
const display = models?.find((item) => item.providerID === model.providerID && item.id === model.id)?.name
if (display === undefined) return `Switched model to ${formatRef(model)}`
// Variant-only switches publish the same model id; without the variant the
// notice would look like a redundant model switch.
const variant = model.variant && model.variant !== "default" ? ` (${model.variant})` : ""
return `Switched model to ${display}${variant}`
}