Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export function ModelRowContent(
)}
>
<Pressable
accessibilityLabel={[props.option.label, props.option.subtitle].filter(Boolean).join(", ")}
accessibilityLabel={[props.option.label, props.option.subtitle, props.option.description]
.filter(Boolean)
.join(", ")}
accessibilityRole="radio"
accessibilityState={{
checked: props.selected,
Expand Down Expand Up @@ -105,6 +107,9 @@ export function ModelRowContent(
{props.option.subtitle}
</Text>
) : null}
{props.option.description ? (
<Text className="text-xs text-foreground-muted">{props.option.description}</Text>
) : null}
</View>
{props.trailingSelection}
</Pressable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function modelMatchesCatalogQuery(input: {
return [
input.model.label,
input.model.subtitle,
input.model.description ?? "",
input.model.selection.model,
input.providerLabel,
].some((value) => value.toLocaleLowerCase().includes(query));
Expand Down
10 changes: 7 additions & 3 deletions apps/mobile/src/features/threads/use-composer-command-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export function buildComposerModelItems(
query,
(option) => ({
name: option.label,
...(option.description ? { description: option.description } : {}),
...(option.subtitle ? { subProvider: option.subtitle } : {}),
driverKind: option.providerDriver,
providerDisplayName: option.providerLabel,
Expand All @@ -221,9 +222,12 @@ export function buildComposerModelItems(
type: "model",
option,
label: option.label,
description: option.subtitle
? `${option.providerLabel} · ${option.subtitle}`
: option.providerLabel,
description: [
option.subtitle ? `${option.providerLabel} · ${option.subtitle}` : option.providerLabel,
option.description,
]
.filter(Boolean)
.join(" · "),
}));
}

Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/src/lib/modelOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export type ModelOption = {
readonly key: string;
readonly label: string;
readonly shortName?: string;
/** Secondary provider metadata, such as a credit multiplier. Kept separate from `subtitle`, which groups models by sub-provider. */
readonly description?: string | undefined;
readonly subtitle: string;
readonly providerKey: string;
readonly providerLabel: string;
Expand Down Expand Up @@ -421,6 +423,7 @@ export function buildModelOptions(
key,
label: model.name,
...(shortName ? { shortName } : {}),
...(model.description ? { description: model.description } : {}),
subtitle: model.subProvider ?? "",
providerKey: provider.instanceId,
providerLabel,
Expand Down Expand Up @@ -491,6 +494,7 @@ export function buildModelOptions(
key,
label: model?.name ?? fallbackModelSelection.model,
...(shortName ? { shortName } : {}),
...(model?.description ? { description: model.description } : {}),
subtitle: model?.subProvider ?? "",
providerKey: fallbackModelSelection.instanceId,
providerLabel,
Expand Down
15 changes: 15 additions & 0 deletions apps/web/src/components/chat/ModelListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const ModelListRow = memo(function ModelListRow(props: {
index: number;
slug: string;
name: string;
description?: string | undefined;
subProvider?: string | undefined;
instanceId: ProviderInstanceId;
driverKind: ProviderDriverKind;
Expand Down Expand Up @@ -87,6 +88,20 @@ export const ModelListRow = memo(function ModelListRow(props: {
{props.subProvider}
</span>
) : null}
{props.description ? (
<Tooltip>
<TooltipTrigger
render={
<span className="min-w-0 shrink truncate text-xs text-muted-foreground/70">
{props.description}
</span>
}
/>
<TooltipPopup side="top" align="center">
{props.description}
</TooltipPopup>
</Tooltip>
) : null}
{props.showNewBadge ? (
<span
className="shrink-0 rounded border border-update/35 bg-update/15 px-0.5 py-px text-3xs font-bold uppercase leading-none tracking-wide text-update-foreground"
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/components/chat/ModelPickerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import { hasRuntimeModelCatalog } from "../../providerModels";
type ModelPickerItem = {
slug: string;
name: string;
description?: string | undefined;
shortName?: string;
subProvider?: string;
badge?: "new";
Expand Down Expand Up @@ -612,6 +613,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
out.push({
slug: model.slug,
name: model.name,
...(model.description ? { description: model.description } : {}),
...(model.shortName ? { shortName: model.shortName } : {}),
...(model.subProvider ? { subProvider: model.subProvider } : {}),
...(model.badge ? { badge: model.badge } : {}),
Expand Down Expand Up @@ -707,6 +709,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
lockedProvider !== null ? result.filter((m) => matchesLockedProvider(m)) : result;
return rankModelPickerSearch(candidates, searchQuery, (model) => ({
name: model.name,
...(model.description ? { description: model.description } : {}),
...(model.shortName ? { shortName: model.shortName } : {}),
...(model.subProvider ? { subProvider: model.subProvider } : {}),
driverKind: model.driverKind,
Expand Down Expand Up @@ -1215,6 +1218,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
index={index}
slug={model.slug}
name={model.name}
description={model.description}
subProvider={model.subProvider}
instanceId={model.instanceId}
driverKind={model.driverKind}
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/components/chat/composerModelMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function matchComposerModelItems(input: {

return rankComposerModelMentions(candidates, input.query, ({ entry, option }) => ({
name: option.name,
...(option.description ? { description: option.description } : {}),
...(option.shortName ? { shortName: option.shortName } : {}),
...(option.subProvider ? { subProvider: option.subProvider } : {}),
driverKind: entry.driverKind,
Expand All @@ -38,6 +39,8 @@ export function matchComposerModelItems(input: {
acpRegistryAgentId: entry.acpRegistryAgentId,
acpRegistryIconUrl: entry.acpRegistryIconUrl,
label: getDisplayModelName(option),
description: option.subProvider ?? entry.displayName,
description: option.description
? `${option.subProvider ?? entry.displayName} · ${option.description}`
: (option.subProvider ?? entry.displayName),
}));
}
1 change: 1 addition & 0 deletions apps/web/src/components/chat/providerIconUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { resolveModelShortName } from "@t3tools/client-runtime/provider-clients"
export type ModelEsque = {
slug: string;
name: string;
description?: string | undefined;
shortName?: string | undefined;
subProvider?: string | undefined;
aliases?: ReadonlyArray<string> | undefined;
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/modelSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function readInstanceCustomModels(
export interface AppModelOption {
slug: string;
name: string;
description?: string;
shortName?: string;
subProvider?: string;
aliases?: ReadonlyArray<string>;
Expand Down Expand Up @@ -102,6 +103,7 @@ function toAppModelOption(
name: model.name,
isCustom: model.isCustom,
};
if (model.description) option.description = model.description;
const shortName = resolveModelShortName(model, driverKind);
if (shortName) option.shortName = shortName;
if (model.subProvider) option.subProvider = model.subProvider;
Expand Down
1 change: 1 addition & 0 deletions packages/client-runtime/src/composerModelMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function rankComposerModelMentions<T>(
model.name,
model.shortName,
model.subProvider,
model.description,
model.driverKind,
model.providerDisplayName,
]
Expand Down
20 changes: 20 additions & 0 deletions packages/client-runtime/src/modelSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type CatalogModel = {
providerDisplayName: string;
name: string;
subProvider?: string;
description?: string;
isFavorite?: boolean;
};

Expand Down Expand Up @@ -134,6 +135,25 @@ function search(query: string, models: ReadonlyArray<CatalogModel> = catalog): s
}

describe("rankModelPickerSearch", () => {
it("matches provider metadata such as a credit multiplier", () => {
const models: CatalogModel[] = [
{
driverKind: "acpRegistry",
providerDisplayName: "Codebuddy",
name: "Hy4",
description: "x0.29 credits",
},
{
driverKind: "acpRegistry",
providerDisplayName: "Codebuddy",
name: "Hy4 flash",
description: "x0.00 credits",
},
];
expect(search("x0.00", models)).toEqual(["Hy4 flash"]);
expect(search("credits", models)).toEqual(["Hy4", "Hy4 flash"]);
});

it("keeps newest first when a version token narrows the family", () => {
expect(search("opus 4")).toEqual([
"Claude Opus 4.8",
Expand Down
11 changes: 10 additions & 1 deletion packages/client-runtime/src/modelSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ModelPickerSearchableModel = {
name: string;
shortName?: string;
subProvider?: string;
description?: string;
isFavorite?: boolean;
};

Expand All @@ -20,6 +21,7 @@ function getModelPickerSearchFields(model: ModelPickerSearchableModel): string[]
normalizeSearchQuery(model.driverKind),
normalizeSearchQuery(model.providerDisplayName),
buildModelPickerSearchText(model),
...(model.description ? [normalizeSearchQuery(model.description)] : []),
];
}

Expand All @@ -46,7 +48,14 @@ function normalizeModelName(name: string): string {

function buildModelPickerSearchText(model: ModelPickerSearchableModel): string {
return normalizeSearchQuery(
[model.name, model.shortName, model.subProvider, model.driverKind, model.providerDisplayName]
[
model.name,
model.shortName,
model.subProvider,
model.driverKind,
model.providerDisplayName,
model.description,
]
.filter((value): value is string => typeof value === "string" && value.length > 0)
.join(" "),
);
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export type ServerProviderAuth = typeof ServerProviderAuth.Type;
export const ServerProviderModel = Schema.Struct({
slug: TrimmedNonEmptyString,
name: TrimmedNonEmptyString,
/** Secondary model metadata reported by the provider, such as a credit multiplier. */
description: Schema.optional(TrimmedNonEmptyString),
shortName: Schema.optional(TrimmedNonEmptyString),
subProvider: Schema.optional(TrimmedNonEmptyString),
aliases: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
Expand Down
34 changes: 33 additions & 1 deletion packages/provider-acp-registry/src/server/driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,37 @@ function providerWithModels(
}

describe("acpRegistrySnapshotReadiness", () => {
it("forwards ACP model descriptions to the client model catalog", () => {
const provider = providerWithModels(
[{ id: "hy4", name: "Hy4", description: "x0.29 credits" }],
"hy4",
);
expect(provider.models).toMatchObject([
{ slug: "hy4", name: "Hy4", description: "x0.29 credits" },
]);

const live = normalizeAcpRegistryLiveConfiguration([
{
id: "model",
name: "Model",
description: "Select the AI model to use for this session",
category: "model",
type: "select",
currentValue: "hy4",
options: [{ value: "hy4", name: "Hy4", description: "x0.29 credits" }],
},
]);
expect(
applyAcpRegistryLiveConfiguration(providerWithModels([], null), live, []).models,
).toMatchObject([{ slug: "hy4", description: "x0.29 credits" }]);

const verbose = providerWithModels(
[{ id: "verbose", name: "Verbose", description: "A very long prose description ".repeat(3) }],
"verbose",
);
expect(verbose.models[0]).not.toHaveProperty("description");
});

it("keeps the custom model display name and options saved by the Settings editor", () => {
const fastMode = { id: "fast", label: "Fast mode", type: "boolean" } as const;
const snapshot = buildCheckedAcpRegistrySnapshot({
Expand Down Expand Up @@ -260,7 +291,7 @@ describe("acpRegistrySnapshotReadiness", () => {
ready: true,
icon: null,
authMethods: [],
models: [{ id: "probe-model", name: "Probe model", description: null }],
models: [{ id: "probe-model", name: "Probe model", description: "x0.29 credits" }],
currentModelId: "probe-model",
configOptions: [],
sessionManagement: {
Expand Down Expand Up @@ -325,6 +356,7 @@ describe("acpRegistrySnapshotReadiness", () => {
).toMatchObject([
{
slug: "probe-model",
description: "x0.29 credits",
isDefault: true,
capabilities: { optionDescriptors: [{ id: "effort", currentValue: "high" }] },
},
Expand Down
14 changes: 13 additions & 1 deletion packages/provider-acp-registry/src/server/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ const makeUnsupportedTextGeneration = (): ProviderTextGeneration => {
};
};

/**
* Only compact provider metadata belongs in a model picker row. ACP agents can report long
* prose as an option description; forwarding that would crowd out the model name in every
* client. Credit multipliers such as `x0.29 credits` stay well under this limit.
*/
const MAX_FORWARDED_MODEL_DESCRIPTION_LENGTH = 32;
const isPickerDescription = (description: string | null | undefined): description is string =>
typeof description === "string" &&
description.length > 0 &&
description.length <= MAX_FORWARDED_MODEL_DESCRIPTION_LENGTH;

function modelsFromDiscovery(
discovery:
| Pick<
Expand Down Expand Up @@ -206,6 +217,7 @@ function modelsFromDiscovery(
: discovered.map((model) => ({
slug: model.id,
name: model.name,
...(isPickerDescription(model.description) ? { description: model.description } : {}),
isCustom: false,
...(model.id === discovery?.currentModelId ? { isDefault: true } : {}),
capabilities: capabilitiesFor(model),
Expand Down Expand Up @@ -382,7 +394,7 @@ export function applyAcpRegistryLiveConfiguration(
models: probedModels.map((model) => ({
id: model.slug,
name: model.name,
description: null,
description: model.description ?? null,
})),
currentModelId: selectedProbedModelId,
};
Expand Down
Loading