Skip to content

Commit ea24841

Browse files
authored
Fix Windows AI model selection
Fix the Windows issue where AI models could not be selected.
1 parent bf9f557 commit ea24841

5 files changed

Lines changed: 36 additions & 17 deletions

File tree

components/AIChatSidePanelHelpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export function isCopilotAgentConfig(agent?: ExternalAgentConfig): boolean {
2222
getExternalAgentSdkBackend(agent),
2323
]
2424
.filter((value): value is string => typeof value === 'string' && value.length > 0)
25-
.map((value) => value.split('/').pop()?.toLowerCase() ?? value.toLowerCase());
25+
// Split on both separators so Windows command paths (e.g. "...\\copilot.exe")
26+
// reduce to their basename rather than staying as the full path.
27+
.map((value) => value.split(/[\\/]/).pop()?.toLowerCase() ?? value.toLowerCase());
2628
return tokens.some((token) => token.includes('copilot'));
2729
}
2830

infrastructure/ai/types.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import test from 'node:test';
22
import assert from 'node:assert/strict';
33

44
import {
5+
CLAUDE_MODEL_PRESETS,
56
CODEBUDDY_MODEL_PRESETS,
67
CODEX_MODEL_PRESETS,
78
getAgentModelPresets,
@@ -19,3 +20,14 @@ test('getAgentModelPresets keeps Codex presets separate from CodeBuddy presets',
1920
assert.deepEqual(getAgentModelPresets('codex'), CODEX_MODEL_PRESETS);
2021
assert.notDeepEqual(CODEBUDDY_MODEL_PRESETS, CODEX_MODEL_PRESETS);
2122
});
23+
24+
test('getAgentModelPresets resolves Windows command paths with backslashes', () => {
25+
assert.deepEqual(
26+
getAgentModelPresets('C\\Users\\foo\\AppData\\Roaming\\npm\\codex.cmd'),
27+
CODEX_MODEL_PRESETS,
28+
);
29+
assert.deepEqual(
30+
getAgentModelPresets('C\\Program Files\\nodejs\\claude.exe'),
31+
CLAUDE_MODEL_PRESETS,
32+
);
33+
});

infrastructure/ai/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,11 @@ export const CODEBUDDY_MODEL_PRESETS: AgentModelPreset[] = [
477477

478478
export function getAgentModelPresets(agentCommand?: string): AgentModelPreset[] {
479479
if (!agentCommand) return [];
480-
const basename = agentCommand.split('/').pop()?.toLowerCase() ?? '';
480+
// Split on both POSIX (/) and Windows (\) separators so command paths like
481+
// "C:\\Users\\foo\\codex.cmd" resolve to the right basename. Splitting only
482+
// on "/" leaves the full path intact on Windows, which never matches the
483+
// preset prefixes below and yields an empty list (presets silently lost).
484+
const basename = agentCommand.split(/[\\/]/).pop()?.toLowerCase() ?? '';
481485
if (basename.startsWith('claude')) return CLAUDE_MODEL_PRESETS;
482486
if (basename.startsWith('codex')) return CODEX_MODEL_PRESETS;
483487
if (basename.startsWith('cursor')) return CURSOR_MODEL_PRESETS;

package-lock.json

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"@anthropic-ai/claude-agent-sdk": "^0.3.161",
116116
"@cursor/sdk": "^1.0.18",
117117
"@github/copilot-sdk": "1.0.0",
118-
"@tencent-ai/agent-sdk": "^0.3.169",
118+
"@tencent-ai/agent-sdk": "^0.3.173",
119119
"@vscode/windows-process-tree": "^0.7.0"
120120
},
121121
"overrides": {

0 commit comments

Comments
 (0)