Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@
},
"onlyBuiltDependencies": [
"sqlite3",
"node-pty",
"keytar",
"electron"
],
Expand All @@ -281,6 +280,7 @@
"core-js",
"cpu-features",
"esbuild",
"node-pty",
"protobufjs",
"ssh2"
],
Expand Down
6 changes: 6 additions & 0 deletions src/main/services/ConnectionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ class ConnectionsService {
.split(/\r?\n/)
.map((l) => l.trim())
.filter(Boolean);
if (process.platform === 'win32') {
const executable = lines.find((line) => /\.(com|exe|bat|cmd|ps1)$/i.test(line));
if (executable) {
return executable;
}
}
return lines[0] ?? null;
} catch {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/main/services/ptyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,8 @@ function resolveCommandPath(command: string): string | null {
.split(';')
.map((ext) => ext.trim())
.filter(Boolean);
return [base, ...exts.map((ext) => `${base}${ext.toLowerCase()}`)];
const expanded = exts.map((ext) => `${base}${ext.toLowerCase()}`);
return [...expanded, base];
};

const resolveFromCandidates = (bases: string[], makeAbsolute: boolean): string | null => {
Expand Down
28 changes: 28 additions & 0 deletions src/test/main/ConnectionsService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,32 @@ describe('ConnectionsService – resolveStatus', () => {
expect(statusMap.claude?.installed).toBe(true);
expect(statusMap.claude?.path).toBeNull();
});

it('prefers executable where results on Windows over extensionless shims', async () => {
const originalPlatformDescriptor = Object.getOwnPropertyDescriptor(process, 'platform');
Object.defineProperty(process, 'platform', {
value: 'win32',
configurable: true,
});

execFileSyncMock.mockReturnValue(
'C:\\Users\\test\\AppData\\Roaming\\npm\\codex\r\nC:\\Users\\test\\AppData\\Roaming\\npm\\codex.cmd\r\n'
);
spawnEmits({ stdout: '0.27.0\n', closeCode: 0 });

try {
const { connectionsService } = await import('../../main/services/ConnectionsService');
await connectionsService.checkProvider('codex', 'manual');
} finally {
if (originalPlatformDescriptor) {
Object.defineProperty(process, 'platform', originalPlatformDescriptor);
}
}

expect(statusMap.codex?.installed).toBe(true);
expect(statusMap.codex?.path).toBe('C:\\Users\\test\\AppData\\Roaming\\npm\\codex.cmd');
const firstSpawnCall = spawnMock.mock.calls[0];
expect(firstSpawnCall?.[0]).toMatch(/cmd\.exe$/i);
expect(firstSpawnCall?.[1]).toEqual(expect.arrayContaining(['/d', '/s', '/c']));
});
});