From 75c3fe49833d32ff2d662c2dcb485075ac33feb9 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Wed, 18 Nov 2026 17:45:11 +0000 Subject: [PATCH 1/2] fix(hosts): update an old host daemon normally once recovery is offered getHostSoftwareUpdates gives an old daemon (no force contract) a forceMethod of "recovery" as soon as this server's own release exists on GitHub. updateHostSoftware read that as "this update is a recovery" for every update, so the normal update of a 0.7.1-or-older host was refused with "This host requires explicitly approved recovery" once 0.7.2 was published. Recovery is now used only for a forced update; a normal one goes to the host's own updater as before. The tests that cover it reached the live GitHub API, so they passed while the release was unpublished or the API rate-limited the runner. They now serve the release lookup themselves. --- CHANGELOG.md | 4 ++++ lib/hosts/host-updates-route.test.mjs | 9 +++++++++ lib/hosts/hub.ts | 3 ++- lib/hosts/upgrade-shim.test.mjs | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0e2dfe5b..d31c95400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f ## [Unreleased] +### Fixed + +- **A host on 0.7.1 or older updates normally again.** Once this server's own release was published, Settings → Hosts refused the normal update of an older host daemon with "This host requires explicitly approved recovery": the forced-recovery method the server now offers such a host was applied to every update, not only to **Force update**. A normal update goes through the host's own updater again. + ## [v0.7.2] - 2026-11-18 ### Upgrading from 0.7.1 or older diff --git a/lib/hosts/host-updates-route.test.mjs b/lib/hosts/host-updates-route.test.mjs index c075ff408..935f00777 100644 --- a/lib/hosts/host-updates-route.test.mjs +++ b/lib/hosts/host-updates-route.test.mjs @@ -7,10 +7,19 @@ import test, { after } from "node:test"; const dir = mkdtempSync(join(tmpdir(), "ompweb-host-updates-route-")); const previous = process.env.PI_CODING_AGENT_DIR; process.env.PI_CODING_AGENT_DIR = dir; +// This server's own release is published, so an old daemon also offers forced recovery (hub.ts, recoveryHelperRelease). +// Served here: on GitHub it exists once the version under test is released, and a normal update must still be normal. +const realFetch = globalThis.fetch; +globalThis.fetch = async (url, init) => { + const tag = /^https:\/\/api\.github\.com\/repos\/[^/]+\/[^/]+\/releases\/tags\/(.+)$/.exec(String(url))?.[1]; + if (!tag) return realFetch(url, init); + return Response.json({ tag_name: decodeURIComponent(tag), draft: false, assets: [{ name: "ompweb-linux-x64.tar.gz", digest: `sha256:${"a".repeat(64)}` }] }); +}; const hub = await import("./hub.ts"); const { linkHost, linkLocalHost } = await import("./link-driver.test-helper.mjs"); const { HostOpError, MIN_LINK_PROTOCOL_VERSION, LINK_PROTOCOL_VERSION } = await import("./link-protocol.ts"); after(() => { + globalThis.fetch = realFetch; hub.flushLinkSamples(); if (previous === undefined) delete process.env.PI_CODING_AGENT_DIR; else process.env.PI_CODING_AGENT_DIR = previous; diff --git a/lib/hosts/hub.ts b/lib/hosts/hub.ts index e5d488e9d..a2d5f6468 100644 --- a/lib/hosts/hub.ts +++ b/lib/hosts/hub.ts @@ -1823,7 +1823,8 @@ export async function updateHostSoftware(id: string, target: HostUpdateTarget, v } const candidate = checked[target]; const link = linkFor(id); - const recovery = candidate.forceMethod === "recovery" || options.phase !== undefined && candidate.supportsTwoPhaseUpdate !== true; + // A recovery force method is what Force uses; an old daemon that can update itself still does so for a normal update. + const recovery = candidate.forceMethod === "recovery" && options.force === true || options.phase !== undefined && candidate.supportsTwoPhaseUpdate !== true; const pinnedRecovery = options.releasePin !== undefined && recovery; if (!matching && (!candidate.updateAvailable || !(options.force ? candidate.canForceUpdate || candidate.canUpdate : candidate.canUpdate) || candidate.availableVersion !== version && !pinnedRecovery)) { // An omp update names its blocker (ompweb_update_active, omp_install_active...) for a caller that must not read English. diff --git a/lib/hosts/upgrade-shim.test.mjs b/lib/hosts/upgrade-shim.test.mjs index 0c2891142..e8de974fa 100644 --- a/lib/hosts/upgrade-shim.test.mjs +++ b/lib/hosts/upgrade-shim.test.mjs @@ -7,11 +7,20 @@ import test, { after } from "node:test"; const dir = mkdtempSync(join(tmpdir(), "ompweb-upgrade-shim-")); const previous = process.env.PI_CODING_AGENT_DIR; process.env.PI_CODING_AGENT_DIR = dir; +// This server's own release is published, so an old daemon also offers forced recovery (hub.ts, recoveryHelperRelease). +// Served here: on GitHub it exists once the version under test is released, and a normal update must still be normal. +const realFetch = globalThis.fetch; +globalThis.fetch = async (url, init) => { + const tag = /^https:\/\/api\.github\.com\/repos\/[^/]+\/[^/]+\/releases\/tags\/(.+)$/.exec(String(url))?.[1]; + if (!tag) return realFetch(url, init); + return Response.json({ tag_name: decodeURIComponent(tag), draft: false, assets: [{ name: "ompweb-linux-x64.tar.gz", digest: `sha256:${"a".repeat(64)}` }] }); +}; const hub = await import("./hub.ts"); const { linkHost, upgradeSocket, until } = await import("./link-driver.test-helper.mjs"); const { LINK_PROTOCOL_VERSION } = await import("./link-protocol.ts"); const { getRpcSession } = await import("../rpc-manager.ts"); after(() => { + globalThis.fetch = realFetch; hub.flushLinkSamples(); if (previous === undefined) delete process.env.PI_CODING_AGENT_DIR; else process.env.PI_CODING_AGENT_DIR = previous; From 763e66538978cc9ba15a57f0e6419f15ef87ab8d Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Wed, 18 Nov 2026 18:08:01 +0000 Subject: [PATCH 2/2] fix(hosts): keep this machine's old daemon on Force-confirmed recovery The old-server GUI update e2e (#524) requires the plain update of this machine's 0.7.0/0.7.1 daemon to be refused so that only Force starts its recovery, as the 0.7.2 upgrade note says. Only a linked host's old daemon takes a normal update through its own updater. --- CHANGELOG.md | 2 +- lib/hosts/hub.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d31c95400..fca36f98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f ### Fixed -- **A host on 0.7.1 or older updates normally again.** Once this server's own release was published, Settings → Hosts refused the normal update of an older host daemon with "This host requires explicitly approved recovery": the forced-recovery method the server now offers such a host was applied to every update, not only to **Force update**. A normal update goes through the host's own updater again. +- **A linked host on 0.7.1 or older updates normally again.** Once this server's own release was published, Settings → Hosts refused the normal update of an older linked host's daemon with "This host requires explicitly approved recovery": the forced-recovery method the server now offers such a host was applied to every update, not only to **Force update**. A normal update goes through that host's own updater again. This machine's older daemon is still updated with **Force update**, as before. ## [v0.7.2] - 2026-11-18 diff --git a/lib/hosts/hub.ts b/lib/hosts/hub.ts index a2d5f6468..c2cbc4e38 100644 --- a/lib/hosts/hub.ts +++ b/lib/hosts/hub.ts @@ -1823,8 +1823,9 @@ export async function updateHostSoftware(id: string, target: HostUpdateTarget, v } const candidate = checked[target]; const link = linkFor(id); - // A recovery force method is what Force uses; an old daemon that can update itself still does so for a normal update. - const recovery = candidate.forceMethod === "recovery" && options.force === true || options.phase !== undefined && candidate.supportsTwoPhaseUpdate !== true; + // This machine's old daemon is updated only by recovery, which Force confirms. A linked host's old daemon still updates + // itself for a normal update: the recovery helper its Force uses is offered beside that, not instead of it. + const recovery = candidate.forceMethod === "recovery" && (options.force === true || id === LOCAL_HOST_ID) || options.phase !== undefined && candidate.supportsTwoPhaseUpdate !== true; const pinnedRecovery = options.releasePin !== undefined && recovery; if (!matching && (!candidate.updateAvailable || !(options.force ? candidate.canForceUpdate || candidate.canUpdate : candidate.canUpdate) || candidate.availableVersion !== version && !pinnedRecovery)) { // An omp update names its blocker (ompweb_update_active, omp_install_active...) for a caller that must not read English.