Skip to content

Commit 39f192b

Browse files
committed
Preserve ACP model descriptions in the catalog and pickers
ACP agents send a per-model description (e.g. "provider/model-id") that disambiguates duplicate display names across providers. The wire schema passed it through but the catalog hard-coded an empty string, and the desktop picker dropped it. Keep the description through the catalog and render it as secondary text in desktop model rows, matching the mobile picker. > AGENT GENERATED: by zai/glm-5.3
1 parent 0056109 commit 39f192b

8 files changed

Lines changed: 140 additions & 12 deletions

File tree

‎apps/app/src/components/pickers/ModelReasoningPicker.test.tsx‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,19 @@ const splitPaneContext: PaneContextValue = {
103103
function availableModel({
104104
value,
105105
label,
106+
description = "",
106107
isDefault = false,
107108
}: {
108109
value: string;
109110
label: string;
111+
description?: string;
110112
isDefault?: boolean;
111113
}): AvailableModel {
112114
return {
113115
id: value,
114116
model: value,
115117
displayName: label,
116-
description: "",
118+
description,
117119
supportedReasoningEfforts: [
118120
{ reasoningEffort: "medium", description: "Medium" },
119121
],
@@ -546,6 +548,43 @@ describe("ModelReasoningPicker", () => {
546548
expect(onModelChange).toHaveBeenCalledWith(apiModel);
547549
});
548550

551+
it("distinguishes duplicate preview models by description and preserves value", async () => {
552+
const { onModelChange } = renderPicker({
553+
alternateProviderModels: [
554+
availableModel({
555+
value: "zai/glm-4.7",
556+
label: "GLM 4.7",
557+
description: "zai/glm-4.7",
558+
isDefault: true,
559+
}),
560+
availableModel({
561+
value: "openrouter/glm-4.7",
562+
label: "GLM 4.7",
563+
description: "openrouter/glm-4.7",
564+
}),
565+
],
566+
});
567+
const trigger = screen.getByRole("button", {
568+
name: "Provider, model and reasoning",
569+
});
570+
fireEvent.click(trigger);
571+
fireEvent.click(screen.getByTitle("Claude Code"));
572+
573+
const zaiDescription = await screen.findByText("zai/glm-4.7");
574+
const openRouterDescription = screen.getByText("openrouter/glm-4.7");
575+
const zaiRow = zaiDescription.closest("button");
576+
const openRouterRow = openRouterDescription.closest("button");
577+
expect(zaiRow).not.toBeNull();
578+
expect(openRouterRow).not.toBeNull();
579+
expect(zaiRow).not.toBe(openRouterRow);
580+
expect(zaiRow?.textContent).toContain("GLM 4.7");
581+
expect(openRouterRow?.textContent).toContain("GLM 4.7");
582+
583+
fireEvent.click(openRouterDescription);
584+
585+
expect(onModelChange).toHaveBeenCalledWith("openrouter/glm-4.7");
586+
});
587+
549588
it("fuzzy-filters a long model list and selects the match by keyboard", () => {
550589
const { onModelChange } = renderPicker({ modelOptions: manyCodexModels });
551590

‎apps/app/src/components/pickers/ModelReasoningPicker.tsx‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ export function ModelReasoningPicker({
391391
...(model.routeProviderId
392392
? { routeProviderId: model.routeProviderId }
393393
: {}),
394+
...(model.description ? { description: model.description } : {}),
394395
}));
395396
}, [isPreviewing, modelOptions, previewQuery.data?.models, formatModelLabel]);
396397
const previewMoreModelOptions = useMemo((): readonly ModelPickerOption[] => {
@@ -405,6 +406,7 @@ export function ModelReasoningPicker({
405406
...(model.routeProviderId
406407
? { routeProviderId: model.routeProviderId }
407408
: {}),
409+
...(model.description ? { description: model.description } : {}),
408410
}));
409411
}, [
410412
isPreviewing,
@@ -1045,6 +1047,7 @@ export function ModelReasoningPicker({
10451047
activeProviderId,
10461048
)}
10471049
qualifier={option.routeProviderId}
1050+
description={option.description}
10481051
selected={!isPreviewing && option.value === modelValue}
10491052
onClick={() => handleModelSelect(option.value)}
10501053
/>
@@ -1359,6 +1362,7 @@ function MoreModelsSubmenu({
13591362
key={option.value}
13601363
label={stripModelBrandPrefix(option.label, activeProviderId)}
13611364
qualifier={option.routeProviderId}
1365+
description={option.description}
13621366
selected={!isPreviewing && option.value === modelValue}
13631367
onClick={() => onSelect(option.value)}
13641368
/>
@@ -1386,6 +1390,7 @@ function ResetBrowseStateOnContentUnmount({
13861390
function MenuRowButton({
13871391
label,
13881392
qualifier,
1393+
description,
13891394
selected,
13901395
onClick,
13911396
isActive,
@@ -1396,6 +1401,7 @@ function MenuRowButton({
13961401
}: {
13971402
label: string;
13981403
qualifier?: string;
1404+
description?: string;
13991405
selected: boolean;
14001406
onClick: () => void;
14011407
isActive?: boolean;
@@ -1429,16 +1435,21 @@ function MenuRowButton({
14291435
)}
14301436
{...hoverProps}
14311437
>
1432-
<span
1433-
className="truncate"
1434-
title={qualifier ? `${label} · ${qualifier}` : label}
1435-
>
1436-
{base}
1437-
{tag ? (
1438-
<span className="ml-1.5 text-subtle-foreground">{tag}</span>
1439-
) : null}
1440-
{qualifier ? (
1441-
<span className="ml-1.5 text-subtle-foreground">{qualifier}</span>
1438+
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
1439+
<span
1440+
className="truncate"
1441+
title={qualifier ? `${label} · ${qualifier}` : label}
1442+
>
1443+
{base}
1444+
{tag ? (
1445+
<span className="ml-1.5 text-subtle-foreground">{tag}</span>
1446+
) : null}
1447+
{qualifier ? (
1448+
<span className="ml-1.5 text-subtle-foreground">{qualifier}</span>
1449+
) : null}
1450+
</span>
1451+
{description ? (
1452+
<span className="truncate text-subtle-foreground">{description}</span>
14421453
) : null}
14431454
</span>
14441455
<span className="flex shrink-0 items-center gap-1.5">

‎apps/app/src/hooks/useThreadCreationOptions.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ export function useThreadCreationOptions(
599599
...(model.routeProviderId
600600
? { routeProviderId: model.routeProviderId }
601601
: {}),
602+
...(model.description ? { description: model.description } : {}),
602603
})),
603604
[availableModels],
604605
);
@@ -619,6 +620,7 @@ export function useThreadCreationOptions(
619620
...(model.routeProviderId
620621
? { routeProviderId: model.routeProviderId }
621622
: {}),
623+
...(model.description ? { description: model.description } : {}),
622624
})),
623625
[executionOptionsQuery.data?.selectedOnlyModels, availableModels],
624626
);

‎apps/mobile/src/data/compose/execution-options.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ describe("resolveModelSelection", () => {
6666
expect(resolved.isRecovery).toBe(false);
6767
});
6868

69+
it("carries the model description verbatim into the picker option", () => {
70+
const resolved = resolveModelSelection({
71+
executionOptions: response({
72+
models: [
73+
model({
74+
model: "acme/glm-4.7",
75+
displayName: "GLM 4.7",
76+
description: "acme/glm-4.7",
77+
}),
78+
],
79+
}),
80+
selectedModel: "acme/glm-4.7",
81+
catalogVerified: true,
82+
});
83+
expect(resolved.options).toEqual([
84+
{
85+
value: "acme/glm-4.7",
86+
label: "GLM 4.7",
87+
description: "acme/glm-4.7",
88+
},
89+
]);
90+
});
91+
6992
it("promotes a retired-but-selected model instead of silently switching", () => {
7093
const resolved = resolveModelSelection({
7194
executionOptions: catalog,

‎plugins/provider-acp/src/bridge/model-catalog.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,47 @@ describe("acp configOptions model catalog", () => {
438438
]);
439439
});
440440

441+
it("keeps per-option descriptions that disambiguate duplicate model names", () => {
442+
// OMP-style agents send description: "provider/modelId" on every model
443+
// select option, and two providers can expose the same display name;
444+
// the picker needs each option's description to tell them apart.
445+
const models = buildModelCatalogFromConfigOptions({
446+
id: "model",
447+
category: "model",
448+
type: "select",
449+
options: [
450+
{ value: "zai/glm-4.7", name: "GLM 4.7", description: "zai/glm-4.7" },
451+
{
452+
value: "openai/glm-4.7",
453+
name: "GLM 4.7",
454+
description: "openai/glm-4.7",
455+
},
456+
{ value: "opencode/big-pickle", name: "Big Pickle" },
457+
],
458+
});
459+
460+
expect(models).toMatchObject([
461+
{
462+
id: "zai/glm-4.7",
463+
model: "zai/glm-4.7",
464+
displayName: "GLM 4.7",
465+
description: "zai/glm-4.7",
466+
},
467+
{
468+
id: "openai/glm-4.7",
469+
model: "openai/glm-4.7",
470+
displayName: "GLM 4.7",
471+
description: "openai/glm-4.7",
472+
},
473+
{
474+
id: "opencode/big-pickle",
475+
model: "opencode/big-pickle",
476+
displayName: "Big Pickle",
477+
description: "",
478+
},
479+
]);
480+
});
481+
441482
it("finds and maps ACP thought_level config options", () => {
442483
const thoughtLevel = {
443484
id: "effort",

‎plugins/provider-acp/src/bridge/model-catalog.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export function buildModelCatalogFromConfigOptions(
280280
id: option.value,
281281
model: option.value,
282282
displayName: option.name ?? option.value,
283-
description: "",
283+
description: option.description ?? "",
284284
supportedReasoningEfforts: reasoning.supportedReasoningEfforts,
285285
defaultReasoningEffort: reasoning.defaultReasoningEffort,
286286
isDefault,

‎plugins/provider-acp/src/wire.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ describe("acpSessionNewResultSchema", () => {
4747
{
4848
value: "openai-codex/gpt-5.5",
4949
name: "openai-codex/GPT-5.5",
50+
description: "openai-codex/gpt-5.5",
51+
},
52+
{
53+
value: "zai/glm-4.7",
54+
name: "GLM 4.7",
5055
description: null,
5156
},
5257
],
@@ -74,6 +79,12 @@ describe("acpSessionNewResultSchema", () => {
7479
);
7580
expect(parsed.data.configOptions?.[1].category).toBeUndefined();
7681
expect(parsed.data.configOptions?.[1].options?.[0].name).toBeUndefined();
82+
expect(parsed.data.configOptions?.[0].options?.[0].description).toBe(
83+
"openai-codex/gpt-5.5",
84+
);
85+
expect(
86+
parsed.data.configOptions?.[0].options?.[1].description,
87+
).toBeUndefined();
7788
});
7889
});
7990

‎plugins/provider-acp/src/wire.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ const acpConfigOptionSelectOptionSchema = z
236236
.object({
237237
value: z.string(),
238238
name: acpOptionalString,
239+
description: acpOptionalString,
239240
})
240241
.passthrough();
241242
export type AcpConfigOptionSelectOption = z.infer<

0 commit comments

Comments
 (0)