Skip to content

Commit 5a4b2d3

Browse files
wpfleger96Duncan
andauthored
fix(desktop): show readable Claude Code model names and descriptions (#8053)
Claude Code agents' model dropdown showed raw IDs (`opus[1m]`, `claude-fable-5-1[1m]`, `haiku`) and its effort choices showed `low`/`xhigh`. Claude Code's ACP adapter labels config options and choices with `name`, but Buzz read `displayName`, which no adapter sends. **Adapter labels and descriptions** - `normalize_agent_models` reads `name`, keeps each model's `description`, and uses the model option's `currentValue` as the agent's default model (ahead of the unstable `currentModelId`). - `parse_config_options` / `parse_option_values` read `name` for option and choice labels, so effort shows "Low"/"Xhigh". - The create (`PersonaModelCombobox`) and edit (`PersonaDropdownField`) model pickers show the description as a muted second line, through both option builders (`modelDropdownOptions` and `buildTemplateModelDropdownOptions`). **Generated names for full Claude model IDs** - Claude Code's own names drop versions ("Sonnet" for `claude-sonnet-5`). The desktop's Databricks label grammar already parses a bare Claude ID once its wrapper is removed, so that body parse is exposed as `generateBareModelLabel`; Databricks entry points and outputs are unchanged. - For the `claude` runtime, `claudeCodeModelLabel` formats full IDs and keeps a `[1m]` suffix as "(1M context)". Short names (`opus`, `haiku`, `opus[1m]`), unknown bracket suffixes, and IDs containing any non-ASCII character keep the adapter's name. - This applies to the model dropdowns in the create and edit dialogs and the Agent defaults editor. The "Default model (…)" row appears in the edit dialog and the Agent defaults editor; the create dialog still requires an explicit model and shows no Default row. Model labels on agent cards are unchanged. - In the edit dialog, the Default row keeps the discovered label (e.g. "Default model (Opus)") unless a global default model is set, in which case it shows that model. When the adapter's default is its own `default` entry (e.g. "Default (recommended)"), the row reads plain "Default model" and keeps that entry's description. **`models` debug command** - The harness's readable `models` output reads option and choice labels from `name` and the option id from `id` (falling back to `configId`), so it no longer prints raw IDs for Claude Code. JSON output is unchanged. | Model ID | Before | After | |---|---|---| | `opus[1m]` | `opus[1m]` | Opus · Opus with 1M context · … | | `claude-fable-5-1[1m]` | `claude-fable-5-1[1m]` | Claude Fable 5.1 (1M context) · Fable 5.1 · … | | `claude-sonnet-5` | `claude-sonnet-5` | Claude Sonnet 5 · Sonnet 5 · … | | `claude-sonnet-4-6` | `claude-sonnet-4-6` | Claude Sonnet 4.6 · Previous Sonnet version | | `claude-sonnet-4-6[1m]` | `claude-sonnet-4-6[1m]` | Claude Sonnet 4.6 (1M context) · Sonnet 4.6 for long sessions · … | | `haiku` | `haiku` | Haiku · Haiku 4.5 · … | 🤖 --------- Signed-off-by: Will Pfleger <[email protected]> Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
1 parent cc528db commit 5a4b2d3

16 files changed

Lines changed: 538 additions & 36 deletions

‎crates/buzz-acp/src/acp.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,8 +2243,8 @@ pub enum ModelSwitchMethod {
22432243
/// Extract `configOptions` entries with `category == "model"` from a `session/new` result.
22442244
///
22452245
/// Returns the raw JSON array entries. Each entry has `configId` (spelled `id`
2246-
/// by some adapters, e.g. claude-agent-acp), `displayName`,
2247-
/// `options: [{ value, displayName }]`, etc.
2246+
/// by some adapters, e.g. claude-agent-acp), `name`,
2247+
/// `options: [{ value, name }]`, etc.
22482248
pub fn extract_model_config_options(result: &serde_json::Value) -> Vec<serde_json::Value> {
22492249
result["configOptions"]
22502250
.as_array()
@@ -2890,17 +2890,17 @@ mod tests {
28902890
{
28912891
"configId": "model",
28922892
"category": "model",
2893-
"displayName": "Model",
2893+
"name": "Model",
28942894
"options": [
2895-
{ "value": "claude-sonnet-4-20250514", "displayName": "Claude Sonnet 4" },
2896-
{ "value": "claude-opus-4-20250514", "displayName": "Claude Opus 4" }
2895+
{ "value": "claude-sonnet-4-20250514", "name": "Claude Sonnet 4" },
2896+
{ "value": "claude-opus-4-20250514", "name": "Claude Opus 4" }
28972897
]
28982898
},
28992899
{
29002900
"configId": "theme",
29012901
"category": "appearance",
2902-
"displayName": "Theme",
2903-
"options": [{ "value": "dark", "displayName": "Dark" }]
2902+
"name": "Theme",
2903+
"options": [{ "value": "dark", "name": "Dark" }]
29042904
}
29052905
]
29062906
});
@@ -3003,7 +3003,7 @@ mod tests {
30033003
"configId": "model",
30043004
"category": "model",
30053005
"options": [
3006-
{ "value": "claude-sonnet-4-20250514", "displayName": "Sonnet 4" }
3006+
{ "value": "claude-sonnet-4-20250514", "name": "Sonnet 4" }
30073007
]
30083008
}],
30093009
"models": {

‎crates/buzz-acp/src/lib.rs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6166,16 +6166,20 @@ async fn run_models(args: ModelsArgs) -> Result<()> {
61666166
if !config_options.is_empty() {
61676167
println!("Models (stable configOptions):");
61686168
for opt in &config_options {
6169-
let config_id = opt.get("configId").and_then(|v| v.as_str()).unwrap_or("?");
6169+
let config_id = opt
6170+
.get("id")
6171+
.or_else(|| opt.get("configId"))
6172+
.and_then(|v| v.as_str())
6173+
.unwrap_or("?");
61706174
let display = opt
6171-
.get("displayName")
6175+
.get("name")
61726176
.and_then(|v| v.as_str())
61736177
.unwrap_or(config_id);
6174-
println!(" {display} (configId: {config_id})");
6178+
println!(" {display} (id: {config_id})");
61756179
if let Some(options) = opt.get("options").and_then(|v| v.as_array()) {
61766180
for o in options {
61776181
let val = o.get("value").and_then(|v| v.as_str()).unwrap_or("?");
6178-
let name = o.get("displayName").and_then(|v| v.as_str()).unwrap_or(val);
6182+
let name = o.get("name").and_then(|v| v.as_str()).unwrap_or(val);
61796183
println!(" - {name} (value: {val})");
61806184
}
61816185
}

‎desktop/src-tauri/src/commands/agent_config.rs‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,7 @@ fn parse_config_options(raw: Option<&serde_json::Value>) -> Vec<AcpConfigOptionE
411411
.get("category")
412412
.and_then(|v| v.as_str())
413413
.map(str::to_string),
414-
display_name: opt
415-
.get("displayName")
416-
.and_then(|v| v.as_str())
417-
.map(str::to_string),
414+
display_name: opt.get("name").and_then(|v| v.as_str()).map(str::to_string),
418415
current_value: opt
419416
.get("value")
420417
.or_else(|| opt.get("currentValue"))
@@ -436,10 +433,7 @@ fn parse_option_values(raw: Option<&serde_json::Value>) -> Vec<AcpConfigOptionVa
436433
let value = o.get("value").and_then(|v| v.as_str())?.to_string();
437434
Some(AcpConfigOptionValue {
438435
value,
439-
display_name: o
440-
.get("displayName")
441-
.and_then(|v| v.as_str())
442-
.map(str::to_string),
436+
display_name: o.get("name").and_then(|v| v.as_str()).map(str::to_string),
443437
})
444438
})
445439
.collect()

‎desktop/src-tauri/src/commands/agent_config_tests.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,3 +772,30 @@ fn live_switch_null_models_parses_to_no_current_model() {
772772
);
773773
assert!(available.is_empty());
774774
}
775+
776+
#[test]
777+
fn claude_code_effort_option_uses_adapter_names() {
778+
// Trimmed from a real `claude-agent-acp` 0.36.1 `session/new` response.
779+
let raw = serde_json::json!([{
780+
"id": "effort",
781+
"name": "Effort",
782+
"category": "thought_level",
783+
"type": "select",
784+
"currentValue": "high",
785+
"options": [
786+
{ "value": "low", "name": "Low" },
787+
{ "value": "xhigh", "name": "Xhigh" }
788+
]
789+
}]);
790+
791+
let entries = parse_config_options(Some(&raw));
792+
793+
assert_eq!(entries[0].display_name.as_deref(), Some("Effort"));
794+
assert_eq!(entries[0].current_value.as_deref(), Some("high"));
795+
let labels: Vec<_> = entries[0]
796+
.options
797+
.iter()
798+
.map(|o| o.display_name.as_deref())
799+
.collect();
800+
assert_eq!(labels, [Some("Low"), Some("Xhigh")]);
801+
}

‎desktop/src-tauri/src/commands/agent_models.rs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ pub(super) fn normalize_agent_models(
721721
.to_string();
722722

723723
let mut models: Vec<AgentModelInfo> = Vec::new();
724+
let mut agent_default_model: Option<String> = None;
724725
let mut seen_ids: HashSet<String> = HashSet::new();
725726

726727
// 1. Stable configOptions (preferred). Only entries with category "model"
@@ -730,17 +731,23 @@ pub(super) fn normalize_agent_models(
730731
if opt.get("category").and_then(|c| c.as_str()) != Some("model") {
731732
continue;
732733
}
734+
if agent_default_model.is_none() {
735+
agent_default_model = opt
736+
.get("currentValue")
737+
.and_then(|v| v.as_str())
738+
.map(str::to_string);
739+
}
733740
if let Some(options) = opt.get("options").and_then(|v| v.as_array()) {
734741
for o in options {
735742
if let Some(value) = o.get("value").and_then(|v| v.as_str()) {
736743
if seen_ids.insert(value.to_string()) {
737744
models.push(AgentModelInfo {
738745
id: value.to_string(),
739-
name: o
740-
.get("displayName")
746+
name: o.get("name").and_then(|v| v.as_str()).map(str::to_string),
747+
description: o
748+
.get("description")
741749
.and_then(|v| v.as_str())
742750
.map(str::to_string),
743-
description: None,
744751
});
745752
}
746753
}
@@ -750,9 +757,10 @@ pub(super) fn normalize_agent_models(
750757
}
751758

752759
// 2. Unstable availableModels (fallback — skip duplicates from stable).
753-
let mut agent_default_model: Option<String> = None;
754760
if let Some(unstable) = raw.get("unstable") {
755-
agent_default_model = unstable["currentModelId"].as_str().map(str::to_string);
761+
if agent_default_model.is_none() {
762+
agent_default_model = unstable["currentModelId"].as_str().map(str::to_string);
763+
}
756764
if let Some(available) = unstable["availableModels"].as_array() {
757765
for m in available {
758766
if let Some(id) = m.get("modelId").and_then(|v| v.as_str()) {

‎desktop/src-tauri/src/commands/agent_models_tests.rs‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,3 +988,49 @@ fn databricks_static_token_error_redacts_echoed_token() {
988988
"error lost its remediation: {error}"
989989
);
990990
}
991+
992+
/// Trimmed from a real `claude-agent-acp` 0.36.1 `session/new` response: the
993+
/// adapter labels options with `name`, not `displayName`.
994+
fn claude_code_models_raw() -> serde_json::Value {
995+
serde_json::json!({
996+
"agent": { "name": "claude-agent-acp", "version": "0.36.1" },
997+
"stable": { "configOptions": [{
998+
"id": "model",
999+
"name": "Model",
1000+
"category": "model",
1001+
"type": "select",
1002+
"currentValue": "opus[1m]",
1003+
"options": [
1004+
{ "value": "default", "name": "Default (recommended)",
1005+
"description": "Use the default model (currently claude-opus-5-5[1m])" },
1006+
{ "value": "opus[1m]", "name": "Opus",
1007+
"description": "Opus with 1M context · Best for everyday, complex tasks" },
1008+
{ "value": "haiku", "name": "Haiku",
1009+
"description": "Haiku 4.5 · Fastest for quick answers · $1/$5 per Mtok" }
1010+
]
1011+
}]}
1012+
})
1013+
}
1014+
1015+
#[test]
1016+
fn claude_code_models_keep_adapter_name_description_and_current_value() {
1017+
let response = normalize_agent_models(&claude_code_models_raw(), None);
1018+
1019+
let haiku = response.models.iter().find(|m| m.id == "haiku").unwrap();
1020+
assert_eq!(haiku.name.as_deref(), Some("Haiku"));
1021+
assert_eq!(
1022+
haiku.description.as_deref(),
1023+
Some("Haiku 4.5 · Fastest for quick answers · $1/$5 per Mtok")
1024+
);
1025+
assert_eq!(response.agent_default_model.as_deref(), Some("opus[1m]"));
1026+
}
1027+
1028+
#[test]
1029+
fn stable_current_value_outranks_unstable_current_model_id() {
1030+
let mut raw = claude_code_models_raw();
1031+
raw["unstable"] = serde_json::json!({ "currentModelId": "haiku", "availableModels": [] });
1032+
1033+
let response = normalize_agent_models(&raw, None);
1034+
1035+
assert_eq!(response.agent_default_model.as_deref(), Some("opus[1m]"));
1036+
}

‎desktop/src/features/agents/ui/PersonaDropdownField.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
PERSONA_FIELD_CONTROL_CLASS,
1515
PERSONA_FIELD_SHELL_CLASS,
1616
} from "./agentConfigOptions";
17+
import { OptionLabel } from "./PersonaDropdownOptionLabel";
1718

1819
export function PersonaDropdownField({
1920
ariaDescribedBy,
@@ -91,7 +92,7 @@ export function PersonaDropdownField({
9192
key={option.value}
9293
value={option.value}
9394
>
94-
<span className="truncate">{option.label}</span>
95+
<OptionLabel option={option} />
9596
</DropdownMenuRadioItem>
9697
))}
9798
</DropdownMenuRadioGroup>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { PersonaDropdownOption } from "./agentConfigOptions";
2+
3+
/** Option label with the harness's optional description as a muted second line. */
4+
export function OptionLabel({ option }: { option: PersonaDropdownOption }) {
5+
return (
6+
<span className="flex min-w-0 flex-col">
7+
<span className="truncate">{option.label}</span>
8+
{option.description ? (
9+
<span className="truncate text-xs text-muted-foreground">
10+
{option.description}
11+
</span>
12+
) : null}
13+
</span>
14+
);
15+
}

‎desktop/src/features/agents/ui/PersonaModelCombobox.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
PERSONA_FIELD_CONTROL_CLASS,
99
PERSONA_FIELD_SHELL_CLASS,
1010
} from "./agentConfigOptions";
11+
import { OptionLabel } from "./PersonaDropdownOptionLabel";
1112

1213
type PersonaModelComboboxProps = {
1314
disabled?: boolean;
@@ -207,7 +208,7 @@ export function PersonaModelCombobox({
207208
)}
208209
/>
209210
</span>
210-
<span className="truncate">{option.label}</span>
211+
<OptionLabel option={option} />
211212
</button>
212213
))
213214
) : (

‎desktop/src/features/agents/ui/agentConfigOptions.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ type PersonaLlmProviderId = (typeof KNOWN_LLM_PROVIDER_IDS)[number];
5656
export type PersonaModelOption = {
5757
id: string;
5858
label: string;
59+
description?: string;
5960
};
6061

6162
export type PersonaDropdownOption = {
6263
disabled?: boolean;
6364
label: string;
65+
description?: string;
6466
value: string;
6567
};
6668

@@ -367,7 +369,11 @@ export function buildTemplateModelDropdownOptions(
367369
? [{ id: "", label: inheritedModelLabel }, ...modelOptions]
368370
: modelOptions;
369371
return base.map((option) => ({
370-
label: option.id === "" ? inheritedModelLabel : option.label,
372+
label:
373+
option.id === "" && trimmedInheritedModel.length > 0
374+
? inheritedModelLabel
375+
: option.label,
376+
description: option.description,
371377
value: option.id || AUTO_MODEL_DROPDOWN_VALUE,
372378
}));
373379
}

0 commit comments

Comments
 (0)