fix(codex): preserve configured display name

Use the catalog display name only as a fallback when no
configured name is present, so provider-specific names such as
Copilot variants are not overwritten.
This commit is contained in:
hkfires
2026-11-24 21:13:51 +08:00
parent 0acf4713ec
commit 237cbdaaf2
2 changed files with 22 additions and 13 deletions

View File

@@ -668,8 +668,8 @@ func applyCodexClientModelMetadata(entry map[string]any, id string, model map[st
thinkingSupport := codexClientThinkingSupport(model)
if info != nil {
if info.DisplayName != "" {
displayName = info.DisplayName
if displayName == "" {
displayName = strings.TrimSpace(info.DisplayName)
}
if info.Description != "" {
description = info.Description

View File

@@ -143,17 +143,26 @@ func TestCodexClientHidesSpeechModels(t *testing.T) {
}
}
func TestCodexClientModelsResponse_AppliesDisplayNameToTemplateModel(t *testing.T) {
resp := BuildResponse([]map[string]any{{
"id": "gpt-5.5",
"display_name": "Configured Codex Name",
}}, nil, false)
models, ok := resp["models"].([]map[string]any)
if !ok || len(models) != 1 {
t.Fatalf("models = %#v, want one model", resp["models"])
}
if got := stringModelValue(models[0], "display_name"); got != "Configured Codex Name" {
t.Fatalf("display_name = %q, want Configured Codex Name", got)
func TestCodexClientModelsResponse_DisplayName(t *testing.T) {
for _, tc := range []struct {
name, id, displayName, want string
}{
{"template", "gpt-5.5", "Configured Codex Name", "Configured Codex Name"},
{"copilot fable", "claude-fable-5.2", "Claude Fable 5.2 (Copilot)", "Claude Fable 5.2 (Copilot)"},
{"copilot mai", "mai-code-2", "MAI Code 2 (Copilot)", "MAI Code 2 (Copilot)"},
{"catalog fallback", "mai-code-2", "", "MAI Code 2"},
{"id fallback", "unknown-display-name-test", "", "unknown-display-name-test"},
} {
t.Run(tc.name, func(t *testing.T) {
resp := BuildResponseForClient([]map[string]any{{"id": tc.id, "display_name": tc.displayName}}, nil, false, "pi")
models, ok := resp["models"].([]map[string]any)
if !ok || len(models) != 1 {
t.Fatalf("models = %#v, want one model", resp["models"])
}
if got := stringModelValue(models[0], "display_name"); got != tc.want {
t.Errorf("display_name = %q, want %q", got, tc.want)
}
})
}
}