Skip to content
TypeScript

fix(server): Codex no longer offers a one-click update for installs it can't detect (#22504)

Koushik_xdc25ba721ae40
diff --git a/apps/server/src/provider/Drivers/CodexDriver.ts b/apps/server/src/provider/Drivers/CodexDriver.ts
index b6682d974b7..5452560d289 100644
--- a/apps/server/src/provider/Drivers/CodexDriver.ts
+++ b/apps/server/src/provider/Drivers/CodexDriver.ts
@@ -76,6 +76,7 @@ function makeCodexMaintenanceResolver(sharedHomePath: string) {
nativeUpdate: {
args: ["update"],
isCommandPath: isCodexStandaloneCommandPath,
+ requiresCommandPath: true,
env: { CODEX_HOME: sharedHomePath },
},
});
diff --git a/packages/provider-core/src/server/maintenanceResolver.test.ts b/packages/provider-core/src/server/maintenanceResolver.test.ts
index cbb24818eb5..9afedc66c5a 100644
--- a/packages/provider-core/src/server/maintenanceResolver.test.ts
+++ b/packages/provider-core/src/server/maintenanceResolver.test.ts
@@ -369,6 +369,39 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
}),
);
+ it.effect(
+ "keeps an unrecognized install manual-only when the native updater requires its path",
+ () =>
+ Effect.gen(function* () {
+ const systemPath =
+ "/usr/local/lib/codex/releases/rust-v0.162.1-x86_64-unknown-linux-musl/bin/codex";
+ const capabilities = yield* resolvePackageManagedProviderMaintenance(
+ {
+ provider: driver("codex"),
+ npmPackageName: "@openai/codex",
+ nativeUpdate: {
+ args: ["update"],
+ isCommandPath: isNativeTestCommandPath("/packages/standalone/"),
+ requiresCommandPath: true,
+ },
+ },
+ {
+ binaryPath: "codex",
+ resolvedCommandPath: "/usr/local/bin/codex",
+ realCommandPath: systemPath,
+ env: {},
+ platform: "linux",
+ },
+ ).pipe(
+ Effect.provideService(HostProcess.Platform, "linux"),
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
+ );
+
+ expect(capabilities.update).toBeNull();
+ expect(capabilities.installPath).toBe(systemPath);
+ }),
+ );
+
const claudeUpdate = {
provider: driver("claudeAgent"),
npmPackageName: "@anthropic-ai/claude-code",
diff --git a/packages/provider-core/src/server/maintenanceResolver.ts b/packages/provider-core/src/server/maintenanceResolver.ts
index ed3967ebb46..94889b4a0f1 100644
--- a/packages/provider-core/src/server/maintenanceResolver.ts
+++ b/packages/provider-core/src/server/maintenanceResolver.ts
@@ -85,6 +85,8 @@ export interface PackageManagedProviderMaintenanceDefinition {
readonly nativeUpdate: {
readonly args: ReadonlyArray<string>;
readonly isCommandPath?: (commandPath: string) => boolean;
+ /** The updater cannot detect installs outside `isCommandPath`, so leave those manual-only. */
+ readonly requiresCommandPath?: boolean;
readonly env?: NodeJS.ProcessEnv;
} | null;
}
@@ -474,11 +476,11 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
}
// A `node_modules` path not proven below belongs to another package or a
// project, so the provider's own updater could act on the wrong install.
- const fallback = commandPaths.some((commandPath) =>
- normalizeCommandPath(commandPath).includes("/node_modules/"),
- )
- ? manual
- : native;
+ const fallback =
+ nativeUpdate?.requiresCommandPath ||
+ commandPaths.some((commandPath) => normalizeCommandPath(commandPath).includes("/node_modules/"))
+ ? manual
+ : native;
if (commandPaths.some(isVitePlusGlobalCommandPath)) {
return makeProviderMaintenanceCapabilities({
provider: definition.provider,