fix(tui): disambiguate /model picker rows when provider display names collide

If the gateway returns two providers that resolve to the same display name
(e.g. `kimi-coding` and `kimi-coding-cn` both → "Kimi For Coding"), the
picker now appends the slug so users can tell them apart, in both the
provider list and the selected-provider header. No-op when names are
already unique.

Refs #10526 — the Python backend dedupe from #10599 skips one alias, but
user-defined providers, canonical overlays, and future regressions can
still surface as indistinguishable rows in the picker. This is a
client-side safety net on top of that.
This commit is contained in:
Brooklyn Nicholson 2026-04-18 17:22:23 -05:00
parent 0175ff7516
commit 4aa52590d8
3 changed files with 84 additions and 3 deletions

View file

@ -0,0 +1,17 @@
export const providerDisplayNames = (providers: readonly { name: string; slug: string }[]): string[] => {
const counts = new Map<string, number>()
for (const p of providers) {
counts.set(p.name, (counts.get(p.name) ?? 0) + 1)
}
return providers.map(p => {
const dup = (counts.get(p.name) ?? 0) > 1
if (!dup || !p.slug || p.slug === p.name) {
return p.name
}
return `${p.name} (${p.slug})`
})
}