From 14cc802b3c6fcfb0e5be0ed1aebed264e71beffe Mon Sep 17 00:00:00 2001 From: Bart Spaans Date: Thu, 8 Oct 2026 03:45:46 +0200 Subject: [PATCH] Fix discovery of the repackaged ChatGPT Codex CLI --- electron/__tests__/codex.test.ts | 43 ++++++++++++++++++++------------ electron/codex.cjs | 2 ++ 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/electron/__tests__/codex.test.ts b/electron/__tests__/codex.test.ts index 48c53193..e93fb070 100644 --- a/electron/__tests__/codex.test.ts +++ b/electron/__tests__/codex.test.ts @@ -107,23 +107,34 @@ test('rejects invalid explicit Codex CLI overrides', async () => { } }); -test('resolves the ChatGPT app CLI without a codex command on PATH', async () => { - await using directory = await createTemporaryDirectory('codiff-chatgpt-cli-'); - const bundledCLI = join(directory.path, 'Applications/ChatGPT.app/Contents/Resources/codex'); - await mkdir(dirname(bundledCLI), { recursive: true }); - await writeFile(bundledCLI, '#!/bin/sh\n'); - await chmod(bundledCLI, 0o755); - await using _environment = createTemporaryEnvironment({ - CODIFF_CODEX_PATH: undefined, - PATH: directory.path, - }); +test.each(['codex', 'codex-cli/bin/codex'])( + 'resolves the ChatGPT app CLI at %s without a codex command on PATH', + async (entryPoint) => { + await using directory = await createTemporaryDirectory('codiff-chatgpt-cli-'); + const bundledCLI = join( + directory.path, + 'Applications/ChatGPT.app/Contents/Resources', + entryPoint, + ); + await mkdir(dirname(bundledCLI), { recursive: true }); + await writeFile(bundledCLI, '#!/bin/sh\n'); + await chmod(bundledCLI, 0o755); + await using _environment = createTemporaryEnvironment({ + CODIFF_CODEX_PATH: undefined, + PATH: directory.path, + }); - // Keep the test hermetic when a real CLI is installed in /Applications. - const macOSInstallPaths = getCodexInstallPaths('darwin', directory.path); - expect(macOSInstallPaths).toContain('/Applications/ChatGPT.app/Contents/Resources/codex'); - const installPaths = macOSInstallPaths.filter((path: string) => path.startsWith(directory.path)); - expect(getCodexCommand(installPaths)).toBe(bundledCLI); -}); + // Keep the test hermetic when a real CLI is installed in /Applications. + const macOSInstallPaths = getCodexInstallPaths('darwin', directory.path); + expect(macOSInstallPaths).toContain( + join('/Applications/ChatGPT.app/Contents/Resources', entryPoint), + ); + const installPaths = macOSInstallPaths.filter((path: string) => + path.startsWith(directory.path), + ); + expect(getCodexCommand(installPaths)).toBe(bundledCLI); + }, +); test.skipIf(process.platform !== 'darwin')( 'explains macOS Codex CLI security blocks through runCodex', diff --git a/electron/codex.cjs b/electron/codex.cjs index adaa78c7..27639020 100644 --- a/electron/codex.cjs +++ b/electron/codex.cjs @@ -102,6 +102,8 @@ const getCodexInstallPaths = (platform = process.platform, home = homedir()) => join(home, 'Applications/Codex.app/Contents/Resources/codex'), '/Applications/ChatGPT.app/Contents/Resources/codex', join(home, 'Applications/ChatGPT.app/Contents/Resources/codex'), + '/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex', + join(home, 'Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex'), ] : []), ];