From 8f2ada3b753debb805467c762ec62bc2474555e9 Mon Sep 17 00:00:00 2001 From: Spencer Byrne Date: Fri, 10 Jul 2026 21:01:57 -0700 Subject: [PATCH] Fix Windows Store desktop executable detection --- packages/installer/src/platform.ts | 4 ++++ packages/installer/test/platform.test.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/installer/src/platform.ts b/packages/installer/src/platform.ts index a3eb46a..3c2a7b6 100644 --- a/packages/installer/src/platform.ts +++ b/packages/installer/src/platform.ts @@ -306,6 +306,10 @@ function isWinCodexRoot(appRoot: string): boolean { function findWinExecutable(appRoot: string): string { try { + // Newer Microsoft Store builds ship a small Codex.exe helper alongside + // ChatGPT.exe, which is the actual Electron desktop application. + const chatGpt = join(appRoot, "ChatGPT.exe"); + if (existsSync(chatGpt)) return chatGpt; const exe = readdirSync(appRoot).find((name) => /\.exe$/i.test(name) && /\bcodex\b/i.test(name)); if (exe) return join(appRoot, exe); } catch {} diff --git a/packages/installer/test/platform.test.ts b/packages/installer/test/platform.test.ts index 0bb0430..a9045b6 100644 --- a/packages/installer/test/platform.test.ts +++ b/packages/installer/test/platform.test.ts @@ -42,6 +42,24 @@ test("locateCodex reads beta bundle metadata from override path on macOS", { ski } }); +test("locateCodex prefers the Store desktop executable over the Codex helper on Windows", { skip: process.platform !== "win32" }, () => { + const root = mkdtempSync(join(tmpdir(), "codexpp-platform-")); + try { + const app = join(root, "OpenAI.Codex", "app"); + mkdirSync(join(app, "resources"), { recursive: true }); + writeFileSync(join(app, "resources", "app.asar"), ""); + writeFileSync(join(app, "ChatGPT.exe"), "desktop"); + writeFileSync(join(app, "Codex.exe"), "helper"); + + const codex = locateCodex(app); + assert.equal(codex.executable, join(app, "ChatGPT.exe")); + assert.equal(codex.electronBinary, join(app, "ChatGPT.exe")); + assert.equal(codex.appName, "ChatGPT"); + } finally { + rmSync(root, { recursive: true, force: true }); + } +}); + test("resolveLinuxInstall supports am-will codex-app install directory", () => { const root = mkdtempSync(join(tmpdir(), "codexpp-platform-")); try {