Skip to content

Commit 2c3ef1d

Browse files
authored
Model presentation fix, tests stabiliation (#162)
* fix: Normalize casing of model display names * fix: Normalize path separators in fuzzy file search test assertions
1 parent 78f1b96 commit 2c3ef1d

4 files changed

Lines changed: 81 additions & 7 deletions

File tree

src/CodexAcpServer.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ interface PendingMcpStartupSession {
6666
}
6767

6868
export class CodexAcpServer implements acp.Agent {
69+
private static readonly MODEL_NAME_TOKEN_OVERRIDES: Record<string, string> = {
70+
gpt: "GPT",
71+
mini: "Mini",
72+
codex: "Codex",
73+
};
74+
6975
private readonly codexAcpClient: CodexAcpClient;
7076
private readonly connection: acp.AgentSideConnection;
7177
private readonly defaultAuthRequest: CodexAuthRequest | null;
@@ -403,12 +409,19 @@ export class CodexAcpServer implements acp.Agent {
403409
return models.find(m => m.id === modelId.model);
404410
}
405411

412+
private normalizeModelDisplayName(displayName: string): string {
413+
return displayName
414+
.split("-")
415+
.map((token) => CodexAcpServer.MODEL_NAME_TOKEN_OVERRIDES[token.toLowerCase()] ?? token)
416+
.join("-");
417+
}
418+
406419
private createModelState(availableModels: Model[], selectedModelId: string): SessionModelState {
407420
const allowedModels = availableModels
408421
.flatMap((model) =>
409422
model.supportedReasoningEfforts.map((effort) => ({
410423
modelId: ModelId.fromComponents(model, effort.reasoningEffort).toString(),
411-
name: `${model.displayName} (${effort.reasoningEffort})`,
424+
name: `${this.normalizeModelDisplayName(model.displayName)} (${effort.reasoningEffort})`,
412425
description: `${model.description} ${effort.description}`,
413426
}))
414427
);

src/__tests__/CodexACPAgent/data/model-filtering.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"modelId": "other-id[medium]",
14-
"name": "gpt-5.2 (medium)",
14+
"name": "GPT-5.2 (medium)",
1515
"description": "Allowed Default effort."
1616
},
1717
{
@@ -21,7 +21,17 @@
2121
},
2222
{
2323
"modelId": "gpt-4o[medium]",
24-
"name": "gpt-4o (medium)",
24+
"name": "GPT-4o (medium)",
2525
"description": "Allowed. Default effort."
26+
},
27+
{
28+
"modelId": "gpt-5.3-codex[medium]",
29+
"name": "GPT-5.3-Codex (medium)",
30+
"description": "Codex suffix lowercased. Default effort."
31+
},
32+
{
33+
"modelId": "gpt-5.4-mini[medium]",
34+
"name": "GPT-5.4-Mini (medium)",
35+
"description": "Mini suffix lowercased. Default effort."
2636
}
2737
]

src/__tests__/CodexACPAgent/fuzzy-file-search-events.test.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ import type { ServerNotification } from "../../app-server";
44
import { createCodexMockTestFixture, createTestSessionState, setupPromptAndSendNotifications, type CodexMockTestFixture } from "../acp-test-utils";
55
import { AgentMode } from "../../AgentMode";
66

7+
function normalizePathSeparators<T>(value: T): T {
8+
if (typeof value === "string") {
9+
return value.replace(/\\/g, "/") as unknown as T;
10+
}
11+
if (Array.isArray(value)) {
12+
return value.map(normalizePathSeparators) as unknown as T;
13+
}
14+
if (value && typeof value === "object") {
15+
const out: Record<string, unknown> = {};
16+
for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
17+
out[k] = normalizePathSeparators(v);
18+
}
19+
return out as unknown as T;
20+
}
21+
return value;
22+
}
23+
724
describe("CodexEventHandler - fuzzy file search events", () => {
825
let mockFixture: CodexMockTestFixture;
926
const sessionId = "test-session-id";
@@ -55,8 +72,10 @@ describe("CodexEventHandler - fuzzy file search events", () => {
5572

5673
await setupPromptAndSendNotifications(mockFixture, sessionId, sessionState, [updated1, updated2, completed]);
5774

58-
expect(events).toHaveLength(3);
59-
expect(events[0]).toEqual({
75+
const normalizedEvents = normalizePathSeparators(events);
76+
77+
expect(normalizedEvents).toHaveLength(3);
78+
expect(normalizedEvents[0]).toEqual({
6079
method: "sessionUpdate",
6180
args: [
6281
{
@@ -78,7 +97,7 @@ describe("CodexEventHandler - fuzzy file search events", () => {
7897
},
7998
],
8099
});
81-
expect(events[1]).toEqual({
100+
expect(normalizedEvents[1]).toEqual({
82101
method: "sessionUpdate",
83102
args: [
84103
{
@@ -93,7 +112,7 @@ describe("CodexEventHandler - fuzzy file search events", () => {
93112
},
94113
],
95114
});
96-
expect(events[2]).toEqual({
115+
expect(normalizedEvents[2]).toEqual({
97116
method: "sessionUpdate",
98117
args: [
99118
{

src/__tests__/CodexACPAgent/model-filtering.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,38 @@ describe("Model filtering", () => {
7777
isDefault: false,
7878
inputModalities: []
7979
},
80+
{
81+
id: "gpt-5.3-codex",
82+
model: "gpt-5.3-codex",
83+
upgrade: null,
84+
upgradeInfo: null,
85+
availabilityNux: null,
86+
displayName: "gpt-5.3-codex",
87+
description: "Codex suffix lowercased.",
88+
hidden: false,
89+
supportedReasoningEfforts: [defaultEffort],
90+
defaultReasoningEffort: "medium",
91+
supportsPersonality: false,
92+
additionalSpeedTiers: [],
93+
isDefault: false,
94+
inputModalities: []
95+
},
96+
{
97+
id: "gpt-5.4-mini",
98+
model: "gpt-5.4-mini",
99+
upgrade: null,
100+
upgradeInfo: null,
101+
availabilityNux: null,
102+
displayName: "gpt-5.4-mini",
103+
description: "Mini suffix lowercased.",
104+
hidden: false,
105+
supportedReasoningEfforts: [defaultEffort],
106+
defaultReasoningEffort: "medium",
107+
supportsPersonality: false,
108+
additionalSpeedTiers: [],
109+
isDefault: false,
110+
inputModalities: []
111+
},
80112
];
81113

82114
vi.spyOn(codexAcpClient, "authRequired").mockResolvedValue(false);

0 commit comments

Comments
 (0)