A desktop coding agent with free access to frontier models.
TypeScript
fix: explain required updates the feed lacks
ogsamrat3c44cbc5dcc0
diff --git a/apps/app/src/app/lib/update-gate.ts b/apps/app/src/app/lib/update-gate.tsindex 24934dca..d9064dde 100644--- a/apps/app/src/app/lib/update-gate.ts+++ b/apps/app/src/app/lib/update-gate.ts@@ -112,8 +112,11 @@ export function requiredUpdateAction(input: {installMode: UpdaterInstallMode | null;updaterState: string | null | undefined;packageKind?: string | null;+ /** The feed has nothing newer to install (requiredUpdateUnreachable). */+ unreachable?: boolean;}): RequiredUpdateAction {if (!input.supported || input.installMode === "manual-dmg") return "open-download";+ if (input.unreachable) return "open-download";if (input.installMode === "package") {if (!input.packageKind) return "open-download";switch (input.updaterState) {@@ -142,6 +145,28 @@ export function requiredUpdateAction(input: {}}+/**+ * The server requires a version the update feed does not offer: a check+ * finished ("idle" with a check time) and found nothing newer than this app.+ * That happens when the release marked Latest on GitHub is this version or an+ * older one (a lower version number published after the required one), or+ * when the required release is not published yet. Retrying the check cannot+ * help, so the gate says so and offers the download page instead of a button+ * that spins and stops. Returns the message, or null.+ */+export function requiredUpdateUnreachable(input: {+ gate: UpdateGateState;+ updaterState: string | null | undefined;+ checkedAt?: number | null;+ feedVersion?: string | null;+}): string | null {+ if (input.gate.status === "none" || input.updaterState !== "idle" || !input.checkedAt) return null;+ const required = input.gate.minimum ? `Version ${input.gate.minimum} or newer` : "A newer version";+ const newest = input.feedVersion ? ` (the newest published release is ${input.feedVersion})` : "";+ const current = input.gate.current ? ` than ${input.gate.current}` : "";+ return `${required} is required, but the update service offers nothing newer${current}${newest}. Download the latest installer from the download page and run it; your chats and settings are kept.`;+}+const PACKAGE_LABELS: Record<string, string> = { deb: ".deb", rpm: ".rpm", pacman: ".pacman", appimage: "AppImage" };/**diff --git a/apps/app/src/react-app/shell/update-gate.tsx b/apps/app/src/react-app/shell/update-gate.tsxindex dc30e892..e4ec21db 100644--- a/apps/app/src/react-app/shell/update-gate.tsx+++ b/apps/app/src/react-app/shell/update-gate.tsx@@ -6,6 +6,7 @@ import {connectUpdateGate,refreshUpdateGate,requiredUpdateAction,+ requiredUpdateUnreachable,shouldStartBackgroundDownload,updateBannerText,updateButtonLabel,@@ -103,10 +104,23 @@ function useRequiredUpdate(gate: UpdateGateState) {void updater.downloadUpdate();return;}- if (updaterState === "error" || updaterState === "blocked" || updaterState === "installer-opened") finish();- }, [installMode, installRequested, updater, updaterState]);+ // "idle" after a check: the feed has nothing newer, so nothing will+ // download. Ending the request here keeps the button from waiting forever.+ if (+ updaterState === "error"+ || updaterState === "blocked"+ || updaterState === "installer-opened"+ || (updaterState === "idle" && status?.lastCheckedAt)+ ) finish();+ }, [installMode, installRequested, status?.lastCheckedAt, updater, updaterState]);- const action = requiredUpdateAction({ supported, installMode, updaterState, packageKind });+ const unreachable = requiredUpdateUnreachable({+ gate,+ updaterState,+ checkedAt: status?.lastCheckedAt,+ feedVersion: status?.version,+ });+ const action = requiredUpdateAction({ supported, installMode, updaterState, packageKind, unreachable: Boolean(unreachable) });const updateNow = useCallback(() => {switch (action) {@@ -147,12 +161,12 @@ function useRequiredUpdate(gate: UpdateGateState) {const progress = updaterState === "downloading" && status?.totalBytes? Math.min(100, Math.round(((status.downloadedBytes ?? 0) / status.totalBytes) * 100)): null;- const version = status?.version ?? gate.minimum;+ const version = unreachable ? gate.minimum : status?.version ?? gate.minimum;const label = copied? "Copied": updateButtonLabel({ action, version, progress, updaterState, packageKind, restarting: status?.restarting });const working = action === "wait" || Boolean(status?.restarting);- const detail = updaterState === "error" && status?.message+ const detail = unreachable ?? (updaterState === "error" && status?.message? `The update did not finish: ${status.message}`: updaterState === "ready" && installMode === "package" && status?.installCommand? "Downloaded. Run the install command in a terminal, then open the app again."@@ -160,7 +174,7 @@ function useRequiredUpdate(gate: UpdateGateState) {? "Downloaded. The app closes and reopens on the new version.": updaterState === "installer-opened"? "The installer is open. Replace the app from it, then open it again."- : null;+ : null);const command = installMode === "package" && updaterState === "ready" ? status?.installCommand ?? null : null;// A restart that did not go through: offer the manual download next to the retry.const installFailed = updaterState === "error" && status?.failedAction === "install";diff --git a/apps/app/tests/update-gate.test.tsx b/apps/app/tests/update-gate.test.tsxindex 3e25c10d..5888b4e1 100644--- a/apps/app/tests/update-gate.test.tsx+++ b/apps/app/tests/update-gate.test.tsx@@ -9,6 +9,7 @@ import {formatUpdateCountdown,normalizeUpdateGateState,requiredUpdateAction,+ requiredUpdateUnreachable,shouldStartBackgroundDownload,updateBannerText,updateButtonLabel,@@ -192,6 +193,51 @@ describe("Update now", () => {});});+describe("required version the feed does not offer", () => {+ // 3.3.8 was published after 3.4.1 and marked Latest while the server+ // required 3.4.1: the check found nothing newer, the button spun and stopped.+ const gated: UpdateGateState = { ...blocked, current: "3.3.8", minimum: "3.4.1" };++ test("a finished check with nothing newer is a dead end the gate names", () => {+ const message = requiredUpdateUnreachable({ gate: gated, updaterState: "idle", checkedAt: NOW, feedVersion: "3.3.8" });+ expect(message).toContain("3.4.1 or newer is required");+ expect(message).toContain("nothing newer than 3.3.8");+ expect(message).toContain("newest published release is 3.3.8");+ expect(message).toContain("download page");+ });++ test("is not reported before a check finished, while it runs, or without a gate", () => {+ expect(requiredUpdateUnreachable({ gate: gated, updaterState: "idle", checkedAt: null })).toBeNull();+ expect(requiredUpdateUnreachable({ gate: gated, updaterState: null, checkedAt: NOW })).toBeNull();+ expect(requiredUpdateUnreachable({ gate: gated, updaterState: "checking", checkedAt: NOW })).toBeNull();+ expect(requiredUpdateUnreachable({ gate: gated, updaterState: "available", checkedAt: NOW })).toBeNull();+ expect(requiredUpdateUnreachable({ gate: NO_UPDATE_GATE, updaterState: "idle", checkedAt: NOW })).toBeNull();+ });++ test("the button opens the download page instead of retrying a check that cannot help", () => {+ const action = requiredUpdateAction({ supported: true, installMode: "in-place", updaterState: "idle", unreachable: true });+ expect(action).toBe("open-download");+ expect(updateButtonLabel({ action })).toBe("Open download page");+ expect(requiredUpdateAction({ supported: true, installMode: "package", packageKind: "deb", updaterState: "idle", unreachable: true })).toBe("open-download");+ // A newer release appearing later turns the button back into the update.+ expect(requiredUpdateAction({ supported: true, installMode: "in-place", updaterState: "available", unreachable: false })).toBe("download-then-install");+ });++ test("the blocked view shows why instead of an idle button", () => {+ const message = requiredUpdateUnreachable({ gate: gated, updaterState: "idle", checkedAt: NOW, feedVersion: "3.3.8" });+ const html = renderToStaticMarkup(+ <UpdateRequiredView gate={gated} appName="OmniRush.ai" update={fakeUpdate({ detail: message, label: "Open download page" })} />,+ );+ expect(html).toContain("nothing newer than 3.3.8");+ expect(html).toContain("Open download page");+ });++ test("an install request ends when the check finds nothing", () => {+ const hook = read("../src/react-app/shell/update-gate.tsx");+ expect(hook).toContain('(updaterState === "idle" && status?.lastCheckedAt)');+ });+});+describe("wiring", () => {test("both composers are disabled while the gate blocks", () => {expect(read("../src/react-app/domains/session/surface/session-surface.tsx")).toMatch(/disabled=\{[^}]*\|\| updateBlocked\}/);diff --git a/apps/desktop/electron/updater.mjs b/apps/desktop/electron/updater.mjsindex b7ec060f..8837eaa0 100644--- a/apps/desktop/electron/updater.mjs+++ b/apps/desktop/electron/updater.mjs@@ -279,9 +279,11 @@ async function applyElectronUpdaterFeed(}: updaterChannelState(app, channel, null, feedOptions);updater.allowPrerelease = state.channel === "alpha";- // Moving from alpha back to stable can be a semver downgrade; still show- // the latest stable so users can return to the stable channel deliberately.- updater.allowDowngrade = state.channel === "stable" && (!targetVersion || allowOlder);+ // Only a recovery install (an explicit, verified older version) may go+ // backwards. The feed's Latest release can be a lower version than this app+ // (a lower version number published after a higher one); electron-updater+ // must then report "no update" rather than treat that release as installable.+ updater.allowDowngrade = Boolean(targetVersion && allowOlder);// Select the manifest through the generic provider's own `channel` option// rather than AppUpdater#channel: that setter is a no-op unless the instance// was constructed with a channel, which would silently leave a custom@@ -1238,7 +1240,12 @@ export function registerUpdaterIpc({throw new Error(`Target update manifest did not resolve to v${targetVersion}.`);}const available = recordCheckedUpdate(info, channelState, targetVersion, installMode);- if (!available) clearDownloadedUpdate();+ if (!available) {+ clearDownloadedUpdate();+ if (info?.version && compareVersions(info.version, currentVersion) < 0) {+ console.warn(`[updater] the update feed offers v${info.version}, older than the installed v${currentVersion}; nothing to install`);+ }+ }return {available,currentVersion,@@ -1272,9 +1279,11 @@ export function registerUpdaterIpc({checkedUpdateChannel ?? undefined,);const currentVersion = resolveAppVersion(app);+ let feedVersion = null;if (!checkedUpdateVersion || !isVersionNewer(checkedUpdateVersion, currentVersion)) {const result = await updater.checkForUpdates();const info = result?.updateInfo ?? null;+ feedVersion = typeof info?.version === "string" ? info.version : null;if (checkedUpdateTargetVersion &&compareVersions(info?.version ?? "", checkedUpdateTargetVersion) !== 0@@ -1284,7 +1293,12 @@ export function registerUpdaterIpc({recordCheckedUpdate(info, channelState, checkedUpdateTargetVersion, installMode);}if (!checkedUpdateVersion) {- return { ok: false, reason: "No update available." };+ // Said plainly: a bare "no update" left a required update spinning+ // and stopping with nothing to act on.+ return {+ ok: false,+ reason: `No update available: the update feed offers nothing newer than ${currentVersion}${feedVersion ? ` (its newest release is ${feedVersion})` : ""}.`,+ };}await cacheCurrentHealthyRelease().catch((error) => {console.warn("[updater] could not cache the current healthy installer", error);diff --git a/apps/desktop/electron/updater.test.mjs b/apps/desktop/electron/updater.test.mjsindex 12d16fb5..4ecf6c3f 100644--- a/apps/desktop/electron/updater.test.mjs+++ b/apps/desktop/electron/updater.test.mjs@@ -1055,7 +1055,10 @@ describe("installing the newest published release", () => {feed.version = "2.2.0";const checked = await handlers.get("omnirush:updater:check")(null, "stable");assert.equal(checked.available, false);- assert.deepEqual(await handlers.get("omnirush:updater:download")(), { ok: false, reason: "No update available." });+ assert.deepEqual(await handlers.get("omnirush:updater:download")(), {+ ok: false,+ reason: "No update available: the update feed offers nothing newer than 2.2.0 (its newest release is 2.2.0).",+ });assert.deepEqual(await handlers.get("omnirush:updater:installAndRestart")(), { ok: false, reason: "update-not-downloaded" });assert.deepEqual(downloaded, []);assert.deepEqual(installs, []);@@ -1169,6 +1172,83 @@ describe("installing the newest published release", () => {});});+describe("older builds and the release marked Latest", () => {+ // v3.3.8 was published from code newer than v3.4.1, with a lower version+ // number, and was marked Latest while the server required 3.4.1. These are+ // the versions installed in the field; each must take the next release.+ async function installedHarness(installed, latest) {+ const harness = await publishingFeedHarness();+ harness.app.getVersion = () => installed;+ harness.feed.version = latest;+ return harness;+ }++ for (const installed of ["3.3.7", "3.3.8", "3.4.0", "3.4.1"]) {+ it(`${installed} downloads 3.4.2 from the Latest feed and installs it in place`, async () => {+ const { tempDir, handlers, feeds, downloaded, installs, updater } = await installedHarness(installed, "3.4.2");+ try {+ const checked = await handlers.get("omnirush:updater:check")(null, "stable");+ assert.equal(checked.available, true);+ assert.equal(checked.latestVersion, "3.4.2");+ assert.equal(feeds.at(-1).url, STABLE_FEED, "the public feed follows the release marked Latest");+ assert.equal(updater.allowDowngrade, false);+ assert.deepEqual(await handlers.get("omnirush:updater:download")(), { ok: true, mode: "in-place" });+ assert.deepEqual(await handlers.get("omnirush:updater:installAndRestart")(), { ok: true, mode: "in-place" });+ assert.deepEqual(downloaded, ["3.4.2"]);+ assert.deepEqual(installs, [{ version: "3.4.2", isSilent: false, isForceRunAfter: true }]);+ } finally {+ await rm(tempDir, { recursive: true, force: true });+ }+ });+ }++ it("3.3.8 with 3.3.8 marked Latest has nothing to install and says why", async () => {+ const { tempDir, handlers, downloaded, installs } = await installedHarness("3.3.8", "3.3.8");+ try {+ const checked = await handlers.get("omnirush:updater:check")(null, "stable");+ assert.equal(checked.available, false);+ assert.equal(checked.latestVersion, "3.3.8");+ const download = await handlers.get("omnirush:updater:download")();+ assert.equal(download.ok, false);+ assert.match(download.reason, /nothing newer than 3\.3\.8/);+ assert.deepEqual(downloaded, []);+ assert.deepEqual(installs, []);+ } finally {+ await rm(tempDir, { recursive: true, force: true });+ }+ });++ it("a lower version marked Latest is never offered or downloaded as a downgrade", async () => {+ const { tempDir, handlers, downloaded, installs, updater } = await installedHarness("3.4.1", "3.3.8");+ try {+ const checked = await handlers.get("omnirush:updater:check")(null, "stable");+ assert.equal(checked.available, false);+ assert.equal(updater.allowDowngrade, false, "electron-updater itself must not treat 3.3.8 as installable");+ const download = await handlers.get("omnirush:updater:download")();+ assert.equal(download.ok, false);+ assert.match(download.reason, /its newest release is 3\.3\.8/);+ assert.deepEqual(downloaded, []);+ assert.deepEqual(installs, []);+ } finally {+ await rm(tempDir, { recursive: true, force: true });+ }+ });++ it("a staged update is dropped when the Latest release moves below this version", async () => {+ const { tempDir, handlers, feed, downloaded, installs } = await installedHarness("3.4.0", "3.4.1");+ try {+ await handlers.get("omnirush:updater:check")(null, "stable");+ assert.deepEqual(await handlers.get("omnirush:updater:download")(), { ok: true, mode: "in-place" });+ feed.version = "3.3.8";+ assert.deepEqual(await handlers.get("omnirush:updater:installAndRestart")(), { ok: false, reason: "update-not-downloaded" });+ assert.deepEqual(downloaded, ["3.4.1"]);+ assert.deepEqual(installs, []);+ } finally {+ await rm(tempDir, { recursive: true, force: true });+ }+ });+});+describe("dev update feed override", () => {it("honors only loopback URLs", () => {assert.equal(loopbackDevFeedUrl("http://127.0.0.1:8765/feed/"), "http://127.0.0.1:8765/feed");