Skip to content

Commit 854453f

Browse files
committed
fix: strip vendor prefixes and native-only variant words from model short names
1 parent e13a657 commit 854453f

3 files changed

Lines changed: 40 additions & 8 deletions

File tree

‎apps/server/src/provider/ProviderRegistry.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,12 @@ it.layer(
895895
(yield* registry.getProviders)[0]?.models,
896896
restarted
897897
? presentedRetainedModels
898-
: [defaultModel, customModel, presentedCurrentModel, removedModel],
898+
: [
899+
defaultModel,
900+
customModel,
901+
presentedCurrentModel,
902+
{ ...removedModel, shortName: "Gemini 2.5 Pro" },
903+
],
899904
);
900905

901906
yield* registry.refreshInstance(instance.instanceId);

‎apps/server/src/provider/modelShortName.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ describe("modelShortName", () => {
1313
["GPT-5.4 Mini", "codex", "5.4 Mini"],
1414
["GPT-6.1 Sol", "opencode", "6.1 Sol"],
1515
["GPT-6.1-Sol", "opencode", "6.1 Sol"],
16-
["Grok Build", "grok", undefined],
16+
["Grok Build", "grok", "Build"],
17+
["Grok Build", "cursor", undefined],
18+
["Gemini 3.1 Pro Preview Custom Tools", "opencode", undefined],
19+
["NVIDIA: Nemotron 3 Super", "opencode", "Nemotron 3 Super"],
20+
["Google: Gemini 3.1 Pro", "opencode", "Gemini 3.1 Pro"],
1721
["GPT-5.4 Mini", "pi", undefined],
1822
["GPT-5.5", "codex", undefined],
23+
["GPT-4o", "opencode", undefined],
1924
["Gemini 3 (High)", "antigravity", undefined],
2025
["Gemini 3.8 Flash (High)", "antigravity", "3.8 Flash (High)"],
2126
["gpt-5.5", "opencode", undefined],

‎apps/server/src/provider/modelShortName.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ const MODEL_FAMILIES: ReadonlyArray<{ readonly prefix: string; readonly nativeDr
66
{ prefix: "Gemini ", nativeDriver: "antigravity" },
77
{ prefix: "Muse ", nativeDriver: "muse" },
88
{ prefix: "Grok ", nativeDriver: "grok" },
9+
{ prefix: "Cursor ", nativeDriver: "cursor" },
910
];
1011

11-
// Words that rank a model within its family rather than name one. Off the
12+
// Words that describe a variant within a family rather than name a model. Off the
1213
// family's native provider there is no icon saying which family "4 Pro" belongs to.
13-
const TIER_WORDS = new Set([
14+
const VARIANT_WORDS = new Set([
1415
"pro",
1516
"flash",
1617
"mini",
@@ -25,23 +26,44 @@ const TIER_WORDS = new Set([
2526
"latest",
2627
"thinking",
2728
"reasoning",
29+
"build",
30+
"image",
31+
"vision",
32+
"audio",
33+
"live",
34+
"custom",
35+
"tools",
36+
"exp",
37+
"experimental",
38+
"chat",
39+
"tts",
40+
"stt",
2841
]);
2942

30-
const VERSION = /^v?\d+(?:\.\d+)*$/i;
43+
const VERSION = /^v?\d+(?:\.\d+)*[a-z]?$/i;
3144

32-
const KEPT_WHOLE = new Set(["Grok Build"]);
45+
const VENDOR_PREFIX = /^[A-Z][\w.&\- ]{0,24}: (?=\S)/;
3346

3447
export function modelShortName(name: string, driver: string): string | undefined {
48+
const unprefixed = name.replace(VENDOR_PREFIX, "");
49+
const short = withoutFamily(unprefixed, driver) ?? unprefixed;
50+
return short === name ? undefined : short;
51+
}
52+
53+
function withoutFamily(name: string, driver: string): string | undefined {
3554
const family = MODEL_FAMILIES.find((candidate) => name.startsWith(candidate.prefix));
36-
if (!family || KEPT_WHOLE.has(name)) return undefined;
55+
if (!family) return undefined;
3756
const rest = name.slice(family.prefix.length).trim();
3857
const words = rest
3958
.replace(/\(.*?\)/g, " ")
4059
.split(/[\s-]+/)
4160
.filter(Boolean);
4261
const named = words.filter((word) => !VERSION.test(word));
4362
if (named.length === 0) return undefined;
44-
if (driver !== family.nativeDriver && named.every((word) => TIER_WORDS.has(word.toLowerCase()))) {
63+
if (
64+
driver !== family.nativeDriver &&
65+
named.every((word) => VARIANT_WORDS.has(word.toLowerCase()))
66+
) {
4567
return undefined;
4668
}
4769
return rest.replace(/(?<=\S)-(?=\S)/g, " ");

0 commit comments

Comments
 (0)