Skip to content

Commit e994e8b

Browse files
committed
feat: show the spoken model name on the composer model button
1 parent 7de6d7d commit e994e8b

5 files changed

Lines changed: 124 additions & 3 deletions

File tree

‎apps/mobile/src/components/ComposerModelControl.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
buildTraitsTriggerDisplay,
44
getPromptControlledTraits,
55
} from "@t3tools/client-runtime/model-traits";
6+
import { composerModelLabel } from "@t3tools/client-runtime/model-label";
67
import type { ModelOption } from "../lib/modelOptions";
78
import { resolveProviderOptionDescriptors } from "../lib/providerOptions";
89
import { AppText as Text } from "./ui/AppText";
@@ -70,7 +71,11 @@ export function ComposerModelControl(props: {
7071
/>
7172
)
7273
}
73-
label={props.modelOption?.shortName ?? label}
74+
label={
75+
props.modelOption
76+
? composerModelLabel(props.modelOption.shortName ?? props.modelOption.label)
77+
: label
78+
}
7479
iconOnly={props.iconOnly}
7580
suffix={
7681
summary ? (

‎apps/web/src/components/chat/ProviderModelPicker.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type ProviderDriverKind,
66
type ResolvedKeybindingsConfig,
77
} from "@t3tools/contracts";
8+
import { composerModelLabel } from "@t3tools/client-runtime/model-label";
89
import { memo, useEffect, useState } from "react";
910
import { Badge } from "../ui/badge";
1011
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
@@ -70,7 +71,7 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
7071
? undefined
7172
: selectedInstanceOptions[0]);
7273
const triggerTitle = selectedModel
73-
? getTriggerDisplayModelName(selectedModel)
74+
? composerModelLabel(getTriggerDisplayModelName(selectedModel))
7475
: props.model === ANTIGRAVITY_DEFAULT_MODEL
7576
? "Choose model"
7677
: props.model || "Choose model";
@@ -157,7 +158,9 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
157158
return {
158159
...selection,
159160
entry,
160-
label: model ? `${getTriggerDisplayModelName(model)}${unavailable}` : selection.model,
161+
label: model
162+
? `${composerModelLabel(getTriggerDisplayModelName(model))}${unavailable}`
163+
: selection.model,
161164
fullLabel: model ? `${getDisplayModelName(model)}${unavailable}` : selection.model,
162165
};
163166
});

‎packages/client-runtime/package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@
442442
"./model-traits": {
443443
"types": "./src/modelTraits.ts",
444444
"default": "./src/modelTraits.ts"
445+
},
446+
"./model-label": {
447+
"types": "./src/modelLabel.ts",
448+
"default": "./src/modelLabel.ts"
445449
}
446450
},
447451
"scripts": {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
3+
import { composerModelLabel } from "./modelLabel.ts";
4+
5+
describe("composerModelLabel", () => {
6+
it.each([
7+
["Nemotron 3.5 Super VL Free", "Nemotron 3.5 Super"],
8+
["Ox Alpha Free (Unlimited)", "Ox Alpha"],
9+
["DeepSeek V4 Flash Vision Exp", "DeepSeek V4 Flash"],
10+
["LongCat 2.5 Preview Free", "LongCat 2.5"],
11+
["4 Argon Contributor", "4 Argon Contributor"],
12+
["Nemotron 3 Nano Omni (free)", "Nemotron 3 Nano Omni"],
13+
["Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)", "Nano Banana 2 Lite"],
14+
["GPT-OSS (Vertex AI (OpenAI-compatible))", "GPT-OSS"],
15+
["NVIDIA: Nemotron 3.5 Lightning Free", "Nemotron 3.5 Lightning"],
16+
["3.1 Pro Preview Custom Tools", "3.1 Pro"],
17+
["Qwen3 235B-A22B Thinking 2507", "Qwen3 235B"],
18+
["Qwen3-Next 80B-A3B (Thinking)", "Qwen3-Next 80B"],
19+
["Nemotron 3 Nano Omni 30B A3B Reasoning", "Nemotron 3 Nano Omni"],
20+
["Qwen3 Coder 480B A35B Instruct Turbo", "Qwen3 Coder"],
21+
["Llama 4 Maverick 17B Instruct (US)", "Llama 4 Maverick"],
22+
["DeepSeek V4.1 Flash 1017 Spot", "DeepSeek V4.1 Flash"],
23+
["GLM Flash Latest (GLM 5.3 Flash)", "GLM Flash"],
24+
["Grok 4.20 (Non-Reasoning)", "Grok 4.20"],
25+
["4.1 Fast Non-Reasoning", "4.1 Fast"],
26+
["3.1 Flash Image Preview (Nano Banana 2)", "3.1 Flash Image"],
27+
["Gemini 2.5 Flash Preview (09/2025) – Thinking", "Gemini 2.5 Flash"],
28+
["Opus 5.5", "Opus 5.5"],
29+
["GPT-5.5", "GPT-5.5"],
30+
["Grok 4", "Grok 4"],
31+
["Thinking", "Thinking"],
32+
["(Preview)", "(Preview)"],
33+
])("labels %s as %s", (name, label) => {
34+
expect(composerModelLabel(name)).toBe(label);
35+
});
36+
});
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const VENDOR_PREFIX = /^[^:()]+:\s+(?=\S)/;
2+
const PARENTHETICAL = /\s*\([^()]*\)/g;
3+
4+
const VARIANT_PHRASES: ReadonlyArray<ReadonlyArray<string>> = [
5+
["custom", "tools"],
6+
...[
7+
"free",
8+
"preview",
9+
"exp",
10+
"experimental",
11+
"instruct",
12+
"chat",
13+
"base",
14+
"turbo",
15+
"spot",
16+
"latest",
17+
"new",
18+
"thinking",
19+
"reasoning",
20+
"non-reasoning",
21+
"distilled",
22+
"fp8",
23+
"fp16",
24+
"bf16",
25+
"int4",
26+
"int8",
27+
"vl",
28+
"vision",
29+
].map((word) => [word]),
30+
];
31+
32+
const SEPARATOR = /^[^\p{L}\p{N}]+$/u;
33+
const STAMP = /^\d{4,}(?:-\d{2}){0,2}$/;
34+
const SIZE_PART = /^(?:\d+x)?a?\d+(?:\.\d+)?[bkmte]$/i;
35+
const VERSION = /^v?\d+(?:\.\d+)*[a-z]?$/i;
36+
37+
const isSize = (token: string) => token.split("-").every((part) => SIZE_PART.test(part));
38+
39+
function trailingVariantLength(tokens: ReadonlyArray<string>): number {
40+
const last = tokens.at(-1)!;
41+
if (STAMP.test(last) || SEPARATOR.test(last)) return 1;
42+
const phrase = VARIANT_PHRASES.find(
43+
(words) =>
44+
words.length < tokens.length &&
45+
words.every(
46+
(word, index) => tokens[tokens.length - words.length + index]!.toLowerCase() === word,
47+
),
48+
);
49+
return phrase?.length ?? 0;
50+
}
51+
52+
export function composerModelLabel(displayName: string): string {
53+
let name = displayName.trim().replace(VENDOR_PREFIX, "");
54+
for (let previous = ""; previous !== name;) {
55+
previous = name;
56+
name = name.replace(PARENTHETICAL, "");
57+
}
58+
const tokens = name.split(/\s+/).filter(Boolean);
59+
let size: string | undefined;
60+
while (tokens.length > 1) {
61+
const variantLength = trailingVariantLength(tokens);
62+
if (variantLength > 0) {
63+
tokens.splice(-variantLength);
64+
} else if (isSize(tokens.at(-1)!)) {
65+
size = tokens.pop()!.split("-")[0];
66+
} else {
67+
break;
68+
}
69+
}
70+
const distinguished = tokens.slice(1).some((token) => !VERSION.test(token) && !isSize(token));
71+
if (size && !distinguished) tokens.push(size);
72+
return tokens.join(" ") || displayName;
73+
}

0 commit comments

Comments
 (0)