diff --git a/apps/server/src/provider/Layers/CodexProvider.ts b/apps/server/src/provider/Layers/CodexProvider.ts index a0e2b744c2a72febda1f4bc8a5c51238acf98457..cdf40f73b1bdddab0cbfdb52b16de68cd1509364 100644 --- a/apps/server/src/provider/Layers/CodexProvider.ts +++ b/apps/server/src/provider/Layers/CodexProvider.ts @@ -628,7 +628,10 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu auth: { status: "unknown" }, message: installed ? `Codex app-server provider probe failed: ${error.message}.` - : "Codex CLI (`codex`) was not found on PATH.", + : `Could not start Codex CLI (\`${codexSettings.binaryPath}\`). Check Settings → Providers → Codex → Binary path on the server.` + + (codexSettings.binaryPath === "codex" + ? " Installing ChatGPT or Codex desktop may not add codex to PATH." + : " Make sure the configured executable exists and can be run."), }, }); } diff --git a/apps/server/src/provider/Layers/ProviderRegistry.test.ts b/apps/server/src/provider/Layers/ProviderRegistry.test.ts index 988c89e1e679d5782c0b1c4ba08af3195e73cf35..caee1981d79f3fd269a42ed3161818dfbf5a1ea3 100644 --- a/apps/server/src/provider/Layers/ProviderRegistry.test.ts +++ b/apps/server/src/provider/Layers/ProviderRegistry.test.ts @@ -513,20 +513,35 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te }), ); - it.effect("returns unavailable when codex is missing", () => + it.effect.each([ + "codex", + "/Applications/Custom App.app/Contents/Resources/codex", + "C:\\Tools\\codex.exe", + ])("explains how to configure a Codex executable that cannot start: %s", (binaryPath) => Effect.gen(function* () { - const status = yield* checkCodexProviderStatus(defaultCodexSettings, () => - Effect.fail( + const settings = { ...defaultCodexSettings, binaryPath }; + const status = yield* checkCodexProviderStatus(settings, (input) => { + assert.strictEqual(input.binaryPath, binaryPath); + return Effect.fail( new CodexErrors.CodexAppServerSpawnError({ - command: "codex app-server", - cause: new Error("spawn codex ENOENT"), + command: `${binaryPath} app-server`, + cause: new Error("spawn ENOENT"), }), - ), - ); + ); + }); assert.strictEqual(status.status, "error"); assert.strictEqual(status.installed, false); assert.strictEqual(status.auth.status, "unknown"); - assert.strictEqual(status.message, "Codex CLI (`codex`) was not found on PATH."); + assert.include(status.message, binaryPath); + assert.include( + status.message, + "Settings → Providers → Codex → Binary path on the server", + ); + assert.strictEqual( + status.message?.includes("Installing ChatGPT or Codex desktop"), + binaryPath === "codex", + ); + assert.strictEqual(settings.binaryPath, binaryPath); }), ); @@ -2331,10 +2346,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te "Real Codex probe against a missing binary should surface as 'error' in the aggregator", ); assert.strictEqual(codexPersonal?.installed, false); - assert.strictEqual( - codexPersonal?.message, - "Codex CLI (`codex`) was not found on PATH.", - ); + assert.include(codexPersonal?.message, missingBinary); + assert.include(codexPersonal?.message, "Settings → Providers → Codex → Binary path"); }).pipe(Effect.provide(runtimeServices)); }), );