refactor(claude-desktop): drop displayName from model route schema

Claude Desktop's new model menu reads model IDs directly and ignores the
display_name field, so a separate displayName slot added UI noise without
any product value. Collapse the routeId / model / displayName tuple down
to routeId / model, and let the route ID carry the user-visible name
through a non-editable claude- prefix rendered next to the input.

Drop display_name from ClaudeDesktopModelRoute, ClaudeDesktopDefaultRoute,
and ResolvedModelRoute on the Rust side plus the matching TS interfaces,
stop emitting it in /v1/models responses, derive route IDs from upstream
model IDs when picked via the model dropdown, and update zh/en/ja copy to
describe the new two-field layout.
This commit is contained in:
Jason
2026-05-12 10:46:35 +08:00
parent 417ad8149d
commit 953b7cdcf9
10 changed files with 124 additions and 106 deletions
-9
View File
@@ -28,7 +28,6 @@ const ONE_M_CONTEXT_SUFFIX: &str = " [1M]";
pub struct ClaudeDesktopDefaultRoute {
pub route_id: &'static str,
pub env_key: &'static str,
pub display_name: &'static str,
#[serde(rename = "supports1m")]
pub supports_1m: bool,
}
@@ -37,19 +36,16 @@ pub const DEFAULT_PROXY_ROUTES: &[ClaudeDesktopDefaultRoute] = &[
ClaudeDesktopDefaultRoute {
route_id: "claude-sonnet-4-6",
env_key: "ANTHROPIC_DEFAULT_SONNET_MODEL",
display_name: "Sonnet",
supports_1m: true,
},
ClaudeDesktopDefaultRoute {
route_id: "claude-opus-4-7",
env_key: "ANTHROPIC_DEFAULT_OPUS_MODEL",
display_name: "Opus",
supports_1m: true,
},
ClaudeDesktopDefaultRoute {
route_id: "claude-haiku-4-5",
env_key: "ANTHROPIC_DEFAULT_HAIKU_MODEL",
display_name: "Haiku",
supports_1m: true,
},
];
@@ -96,7 +92,6 @@ pub struct ClaudeDesktopStatus {
pub struct ResolvedModelRoute {
pub route_id: String,
pub upstream_model: String,
pub display_name: Option<String>,
pub supports_1m: bool,
}
@@ -518,7 +513,6 @@ pub fn proxy_model_routes(provider: &Provider) -> Result<Vec<ResolvedModelRoute>
result.push(ResolvedModelRoute {
route_id: desktop_model_id(&route_id, supports_1m),
upstream_model: upstream_model_id(upstream_model, supports_1m),
display_name: route.display_name.clone(),
supports_1m,
});
}
@@ -546,7 +540,6 @@ pub fn model_list_response(provider: &Provider) -> Result<Value, AppError> {
let mut item = json!({
"type": "model",
"id": model_id,
"display_name": route.display_name.as_deref().unwrap_or(&route.route_id),
"created_at": DEFAULT_CREATED_AT,
});
if route.supports_1m {
@@ -1065,7 +1058,6 @@ mod tests {
"claude-sonnet-4-6".to_string(),
ClaudeDesktopModelRoute {
model: "kimi-k2".to_string(),
display_name: Some("Kimi".to_string()),
supports_1m: Some(true),
},
)]),
@@ -1083,7 +1075,6 @@ mod tests {
"claude-deepseek-chat".to_string(),
ClaudeDesktopModelRoute {
model: "claude-deepseek-chat".to_string(),
display_name: Some("DeepSeek".to_string()),
supports_1m: Some(true),
},
)]),
+2 -16
View File
@@ -255,7 +255,6 @@ fn suggested_claude_desktop_routes(
env: &serde_json::Map<String, serde_json::Value>,
route_id: &str,
env_key: &str,
display_name: &str,
) {
if let Some(model) = env
.get(env_key)
@@ -267,7 +266,6 @@ fn suggested_claude_desktop_routes(
route_id.to_string(),
crate::provider::ClaudeDesktopModelRoute {
model: model.to_string(),
display_name: Some(display_name.to_string()),
supports_1m: Some(true),
},
);
@@ -275,24 +273,12 @@ fn suggested_claude_desktop_routes(
}
for spec in crate::claude_desktop_config::DEFAULT_PROXY_ROUTES {
add_route(
&mut routes,
env,
spec.route_id,
spec.env_key,
spec.display_name,
);
add_route(&mut routes, env, spec.route_id, spec.env_key);
}
let primary_route = crate::claude_desktop_config::DEFAULT_PROXY_ROUTES[0];
if !routes.contains_key(primary_route.route_id) {
add_route(
&mut routes,
env,
primary_route.route_id,
"ANTHROPIC_MODEL",
primary_route.display_name,
);
add_route(&mut routes, env, primary_route.route_id, "ANTHROPIC_MODEL");
}
(!routes.is_empty()).then_some(routes)
-3
View File
@@ -230,9 +230,6 @@ pub enum ClaudeDesktopMode {
pub struct ClaudeDesktopModelRoute {
/// 真实上游模型名,只保存在 CC Switch 内部,不写入 Claude Desktop profile。
pub model: String,
/// Desktop /v1/models 中显示的名称。
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
/// Claude Desktop 3P 识别的 1M 上下文能力标记。
#[serde(rename = "supports1m", skip_serializing_if = "Option::is_none")]
pub supports_1m: Option<bool>,