diff --git a/CHANGELOG.md b/CHANGELOG.md index b0e2dfe5b..fca36f98a 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 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 ### 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..c2cbc4e38 100644 --- a/lib/hosts/hub.ts +++ b/lib/hosts/hub.ts @@ -1823,7 +1823,9 @@ 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; + // 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. 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;