GeezerVison is showing github.com — fix: keep vendor prefixes when the rest names no model · pingdotgg/t3code@e5b2da1
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/modelShortName.test.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,7 @@ describe("modelShortName", () => { | 19 | 19 | ["Gemini 3.1 Pro Preview Custom Tools", "opencode", undefined], | 20 | 20 | ["NVIDIA: Nemotron 3 Super", "opencode", "Nemotron 3 Super"], | 21 | 21 | ["Google: Gemini 3.1 Pro", "opencode", "Gemini 3.1 Pro"], | | 22 | + ["Google: 3.1 Pro", "opencode", undefined], | 22 | 23 | ["GPT-5.4 Mini", "pi", undefined], | 23 | 24 | ["GPT-5.5", "codex", undefined], | 24 | 25 | ["GPT-4o", "opencode", undefined], | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/modelShortName.ts +14-12Lines changed: 14 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,29 +48,31 @@ const VENDOR_PREFIX = /^[A-Z][\w.&\- ]{0,24}: (?=\S)/; | 48 | 48 |
| 49 | 49 | export function modelShortName(name: string, driver: string): string | undefined { | 50 | 50 | const unprefixed = name.replace(VENDOR_PREFIX, ""); | 51 | | - const short = withoutFamily(unprefixed, driver) ?? unprefixed; | | 51 | + const short = withoutFamily(unprefixed, driver) ?? (namesModel(unprefixed) ? unprefixed : name); | 52 | 52 | return short === name ? undefined : short; | 53 | 53 | } | 54 | 54 |
| 55 | 55 | function withoutFamily(name: string, driver: string): string | undefined { | 56 | 56 | const family = MODEL_FAMILIES.find((candidate) => name.startsWith(candidate.prefix)); | 57 | 57 | if (!family) return undefined; | 58 | 58 | const rest = name.slice(family.prefix.length).trim(); | 59 | | - const words = rest | 60 | | - .replace(/\(.*?\)/g, " ") | 61 | | - .split(/[\s-]+/) | 62 | | - .filter(Boolean); | 63 | | - const named = words.filter((word) => !VERSION.test(word)); | | 59 | + const named = nonVersionWords(rest); | 64 | 60 | if (named.length === 0) return undefined; | 65 | | - if ( | 66 | | - !family.nativeDrivers.includes(driver) && | 67 | | - named.every((word) => VARIANT_WORDS.has(word.toLowerCase())) | 68 | | - ) { | 69 | | - return undefined; | 70 | | - } | | 61 | + if (!family.nativeDrivers.includes(driver) && !namesModel(rest)) return undefined; | 71 | 62 | return rest.replace(/(?<=\S)-(?=\S)/g, " "); | 72 | 63 | } | 73 | 64 |
| | 65 | +function nonVersionWords(text: string): ReadonlyArray<string> { | | 66 | + return text | | 67 | + .replace(/\(.*?\)/g, " ") | | 68 | + .split(/[\s-]+/) | | 69 | + .filter((word) => word.length > 0 && !VERSION.test(word)); | | 70 | +} | | 71 | + | | 72 | +function namesModel(text: string): boolean { | | 73 | + return nonVersionWords(text).some((word) => !VARIANT_WORDS.has(word.toLowerCase())); | | 74 | +} | | 75 | + | 74 | 76 | export function withModelShortNames(provider: ServerProvider): ServerProvider { | 75 | 77 | let changed = false; | 76 | 78 | const models = provider.models.map((model) => { | |
|