TypeScript
fix(server): explain how to configure a missing Codex executable (#11345)
shivam2a264adc6f6c
diff --git a/apps/server/src/provider/Layers/CodexProvider.ts b/apps/server/src/provider/Layers/CodexProvider.tsindex a0e2b744c2a..cdf40f73b1b 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")(fuauth: { 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.tsindex 988c89e1e67..caee1981d79 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));}),);