Skip to content

Commit 703aca2

Browse files
committed
fix(macos): allow cold ChatGPT Codex probes
1 parent 3c2667c commit 703aca2

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

‎src/commands/onboard-inference.test.ts‎

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,13 @@ describe("detectInferenceBackends", () => {
476476

477477
it("checks login status with the Codex executable discovered in a macOS app", async () => {
478478
const command = "/Applications/ChatGPT.app/Contents/Resources/codex";
479-
const probed: Array<{ command: string; args: string[] }> = [];
479+
const probed: Array<{ command: string; args: string[]; timeoutMs?: number }> = [];
480480
const candidates = await detectInferenceBackends({
481481
env: { HOME: "/Users/tester" },
482482
platform: "darwin",
483483
deps: {
484-
probeLocalCommand: async (probedCommand, args = ["--version"]) => {
485-
probed.push({ command: probedCommand, args });
484+
probeLocalCommand: async (probedCommand, args = ["--version"], opts = {}) => {
485+
probed.push({ command: probedCommand, args, timeoutMs: opts.timeoutMs });
486486
return {
487487
command: probedCommand,
488488
found: probedCommand === command,
@@ -494,7 +494,42 @@ describe("detectInferenceBackends", () => {
494494

495495
expect(candidates).toMatchObject([{ kind: "codex-cli", detail: "installed" }]);
496496
expect(candidates[0]?.credentials).toBeUndefined();
497-
expect(probed).toContainEqual({ command, args: ["login", "status"] });
497+
expect(probed).toContainEqual({ command, args: ["--version"], timeoutMs: 3_000 });
498+
expect(probed).toContainEqual({ command, args: ["login", "status"], timeoutMs: 3_000 });
499+
});
500+
501+
it("allows a cold ChatGPT app probe more time than generic CLI discovery", async () => {
502+
const command = "/Applications/ChatGPT.app/Contents/Resources/codex";
503+
const candidates = await detectInferenceBackends({
504+
env: { HOME: "/Users/tester" },
505+
platform: "darwin",
506+
deps: {
507+
probeLocalCommand: async (probedCommand, args = ["--version"], opts = {}) => {
508+
if (probedCommand !== command) {
509+
return { command: probedCommand, found: false };
510+
}
511+
if (args[0] === "login") {
512+
return { command: probedCommand, found: true, version: "Logged in using ChatGPT" };
513+
}
514+
return opts.timeoutMs === 3_000
515+
? { command: probedCommand, found: true, version: "codex-cli 0.149.0" }
516+
: {
517+
command: probedCommand,
518+
found: true,
519+
timedOut: true,
520+
error: "timed out after 1500ms",
521+
};
522+
},
523+
},
524+
});
525+
526+
expect(candidates).toMatchObject([
527+
{
528+
kind: "codex-cli",
529+
credentials: true,
530+
detail: "logged in · ChatGPT subscription",
531+
},
532+
]);
498533
});
499534

500535
it.each([

‎src/commands/onboard-inference.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function randomizeClaudeCodexTie(
171171

172172
// ChatGPT.app is the current desktop owner; keep Codex stable/beta as fallbacks.
173173
const CODEX_MACOS_APP_NAMES = ["ChatGPT.app", "Codex.app", "Codex Beta.app"] as const;
174+
const CODEX_MACOS_APP_PROBE_TIMEOUT_MS = 3_000;
174175

175176
async function probeCodexCommand(params: {
176177
probe: typeof probeLocalCommand;
@@ -189,7 +190,12 @@ async function probeCodexCommand(params: {
189190
]),
190191
);
191192
for (const executable of appExecutables) {
192-
const appProbe = await params.probe(executable);
193+
// ChatGPT.app's signed Codex binary can spend most of the generic 1.5s
194+
// probe budget in macOS cold-start validation. Keep the broader probe
195+
// contract tight while giving known desktop-app binaries enough headroom.
196+
const appProbe = await params.probe(executable, ["--version"], {
197+
timeoutMs: CODEX_MACOS_APP_PROBE_TIMEOUT_MS,
198+
});
193199
if (appProbe.found) {
194200
return appProbe;
195201
}

0 commit comments

Comments
 (0)