Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix: avoid offering pinned installer for newer Codex releases

Afloat9a6218d7fb31
diff --git a/server/contracts.ts b/server/contracts.ts
index b422299b7d..a32afc7435 100644
--- a/server/contracts.ts
+++ b/server/contracts.ts
@@ -367,6 +367,8 @@ export interface ProviderSnapshot {
message: string;
/** Absent when there is nothing to run here, e.g. My Cloud's engines update with the Cloud. */
command?: string;
+ /** False when the app installer cannot supply this version; offer the terminal command instead. */
+ serverInstall?: false;
};
/** On a subscription a reported cost is notional. */
billing?: "metered" | "subscription";
diff --git a/server/drivers/codex-update.test.ts b/server/drivers/codex-update.test.ts
new file mode 100644
index 0000000000..56d653f8d2
--- /dev/null
+++ b/server/drivers/codex-update.test.ts
@@ -0,0 +1,41 @@
+import { afterEach, expect, it, vi } from "vitest";
+import { codexReleaseUpdate } from "./codex-update.ts";
+
+const releases = vi.hoisted(() => ({ latest: "0.169.0" as string | null, pinned: "0.167.0" as string | undefined }));
+vi.mock("./codex-release.ts", async (original) => ({
+ ...await original<typeof import("./codex-release.ts")>(),
+ readLatestCodexRelease: async () => releases.latest,
+}));
+vi.mock("../engine-versions.ts", () => ({ pinnedNpmVersion: () => releases.pinned }));
+afterEach(() => { releases.latest = "0.169.0"; releases.pinned = "0.167.0"; });
+
+it("does not offer the app installer for a release newer than the version it installs", async () => {
+ const update = await codexReleaseUpdate("codex-cli 0.167.0", "codex", false);
+ expect(update).toMatchObject({ title: "Update Codex to 0.169.0", command: "codex update", serverInstall: false });
+ expect(update?.message).toContain("0.167.0");
+ expect(update?.message).toContain("terminal");
+});
+
+it("keeps the app updater when the advertised release is the pinned version", async () => {
+ releases.latest = "0.167.0";
+ const update = await codexReleaseUpdate("codex-cli 0.166.0", "codex", false);
+ expect(update).toMatchObject({ title: "Update Codex to 0.167.0", command: "codex update" });
+ expect(update?.serverInstall).not.toBe(false);
+});
+
+it("keeps the configured executable's update command when a terminal update is needed", async () => {
+ const update = await codexReleaseUpdate("codex-cli 0.167.0", "'/Applications/My Codex/codex'", false);
+ expect(update?.command).toBe("'/Applications/My Codex/codex' update");
+});
+
+it("does not show an update on My Cloud or for an already current copy", async () => {
+ expect(await codexReleaseUpdate("codex-cli 0.167.0", "codex", true)).toBeUndefined();
+ expect(await codexReleaseUpdate("codex-cli 0.169.0", "codex", false)).toBeUndefined();
+});
+
+it("leaves an unpinned installer eligible and ignores an unavailable release lookup", async () => {
+ releases.pinned = undefined;
+ expect((await codexReleaseUpdate("codex-cli 0.167.0", "codex", false))?.serverInstall).not.toBe(false);
+ releases.latest = null;
+ expect(await codexReleaseUpdate("codex-cli 0.167.0", "codex", false)).toBeUndefined();
+});
diff --git a/server/drivers/codex-update.ts b/server/drivers/codex-update.ts
index 174020edf7..ba5c62a261 100644
--- a/server/drivers/codex-update.ts
+++ b/server/drivers/codex-update.ts
@@ -3,6 +3,7 @@ import { existsSync } from "node:fs";
import { cloudHomeConfigured } from "../cloud-home.ts";
import type { ProviderSnapshot } from "../contracts.ts";
import { splitCliString } from "../env-path.ts";
+import { pinnedNpmVersion } from "../engine-versions.ts";
import { codexVersionBehind, readLatestCodexRelease } from "./codex-release.ts";
/** Ask the configured executable to update itself, so a non-PATH Codex is the one updated. */
@@ -24,9 +25,14 @@ export async function codexReleaseUpdate(version: string, cli: string, onCloud =
if (!latest || !codexVersionBehind(version, latest)) return undefined;
// My Cloud's Codex comes with the image, in a folder nobody can write to, and updates with the Cloud: nothing to offer there.
if (onCloud) return undefined;
+ const pinned = pinnedNpmVersion("codex");
+ const needsTerminal = pinned !== undefined && codexVersionBehind(pinned, latest);
return {
title: `Update Codex to ${latest}`,
- message: `A newer stable Codex CLI is available (installed: ${version}). Update it, then refresh models. Model availability also depends on your signed-in account.`,
+ message: needsTerminal
+ ? `A newer stable Codex CLI is available (installed: ${version}). The app installer supplies tested version ${pinned}. To install ${latest}, use the terminal command below, then refresh models. Model availability also depends on your signed-in account.`
+ : `A newer stable Codex CLI is available (installed: ${version}). Update it, then refresh models. Model availability also depends on your signed-in account.`,
command: codexUpdateCommand(cli),
+ ...(needsTerminal ? { serverInstall: false as const } : {}),
};
}
diff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsx
index 55e723356d..bd435f331f 100644
--- a/src/components/EngineSetup.tsx
+++ b/src/components/EngineSetup.tsx
@@ -247,7 +247,7 @@ export function EngineUpdateNotice({
<p className="mt-0.5 text-[12px] leading-relaxed text-ink-secondary">{update.message}</p>
</div>
</div>
- {update.command && (instance?.install?.server
+ {update.command && (instance?.install?.server && update.serverInstall !== false
? <ServerEngineInstall instance={instance} mode="update" command={update.command} quiet={quiet} />
: <CommandRow command={update.command} actionLabel={t("engineSetup.openUpdate")} compact />)}
</div>
diff --git a/src/components/EngineUpdateNotice.test.ts b/src/components/EngineUpdateNotice.test.ts
index 3205e98840..0ee0c43709 100644
--- a/src/components/EngineUpdateNotice.test.ts
+++ b/src/components/EngineUpdateNotice.test.ts
@@ -3,6 +3,7 @@ import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, describe, expect, it, vi } from "vitest";
import { EngineUpdateNotice } from "./EngineSetup";
+import { StoreProvider, type InstanceInfo } from "@/state/store";
const update = {
title: "Update Codex for GPT-6 Astra",
@@ -13,6 +14,27 @@ const update = {
afterEach(() => vi.unstubAllGlobals());
describe("EngineUpdateNotice", () => {
+ const instance: InstanceInfo = {
+ instanceId: "codex", driverKind: "codex", displayName: "Codex",
+ models: { default: "fixture-model", options: [] }, snapshot: { state: "available" },
+ install: { server: { package: "@openai/codex" } },
+ };
+
+ it("uses the terminal action when the app installer cannot install the offered update", () => {
+ const newerThanPin = { ...update, serverInstall: false as const };
+ const markup = renderToStaticMarkup(createElement(StoreProvider, null,
+ createElement(EngineUpdateNotice, { update: newerThanPin, instance })));
+ expect(markup).toContain("codex update");
+ expect(markup).toContain('aria-label="Copy command"');
+ expect(markup).not.toContain("Update Codex here</button>");
+ });
+
+ it("keeps the one-click updater for an update the app installer can supply", () => {
+ const markup = renderToStaticMarkup(createElement(StoreProvider, null,
+ createElement(EngineUpdateNotice, { update, instance })));
+ expect(markup).toContain("Update Codex here</button>");
+ });
+
it("keeps the terminal command visible and copyable without blocking the model list", () => {
const markup = renderToStaticMarkup(createElement(EngineUpdateNotice, { update }));
diff --git a/src/state/store.tsx b/src/state/store.tsx
index 6ef51c91b2..45fcf0ba13 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -428,7 +428,7 @@ export interface InstanceInfo extends InstanceEndpointInfo {
authenticationUnavailableReason?: string;
account?: { email?: string; organization?: string; method?: "login" | "api-key" };
version?: string | null;
- update?: { title: string; message: string; command?: string };
+ update?: { title: string; message: string; command?: string; serverInstall?: false };
billing?: "metered" | "subscription";
warning?: { title: string; message: string }; ollama?: import("../../shared/local-model").OllamaProblem;
};