From 236e13b4af84d32217f68fc82aa9fb6dea08fc06 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 24 Oct 2026 17:25:53 +0200 Subject: [PATCH] Settings update check: a failed check of the app itself says so in one plain line, with the raw error behind Details (it used to show only Control's new-version text) --- apps/host/server/updates.mjs | 9 +++++++-- apps/host/src/components/SettingsUpdates.tsx | 2 +- apps/host/src/lib/types.ts | 2 ++ apps/host/tests/component-updates.test.mjs | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/apps/host/server/updates.mjs b/apps/host/server/updates.mjs index 3b0c6704..e5337258 100644 --- a/apps/host/server/updates.mjs +++ b/apps/host/server/updates.mjs @@ -74,6 +74,7 @@ export async function checkComponentUpdates({ control, appUpdater = null, appVer const app = report.app ?? {}; let appNew = app.status === 'available' ? app.offered : null; let appNotes = app.notes ?? ''; + let appCheckFailed = null; // the shell's own (Tauri) check threw: before this, the Settings check hid it and showed only Control's text let appCannot = null; // browser mode: the app window's updater is not running, so the app itself cannot be updated from here if (appUpdater) { try { @@ -81,13 +82,17 @@ export async function checkComponentUpdates({ control, appUpdater = null, appVer appNew = verdict.available ? verdict.version : null; appNotes = verdict.notes ?? appNotes; } catch (error) { - if (error?.code === 'app-update-unavailable' && appUpdater.unavailable) appCannot = appUpdater.unavailable; // otherwise the feed's own view stands + if (error?.code === 'app-update-unavailable' && appUpdater.unavailable) appCannot = appUpdater.unavailable; + else appCheckFailed = String(error?.message ?? error ?? 'The app update check failed.'); // the app's own check did not work: say so, raw text behind Details } } const controlNew = control_.status === 'available' ? control_.offered : null; const strata = { installedVersion: appVersion ?? control_.installed ?? control.version ?? null, canInstall: !!((appNew && !appCannot) || controlNew) }; - if (appNew || controlNew) Object.assign(strata, { status: 'available', latestVersion: appNew ?? controlNew, message: `A new version of Strata is available.${appNotes ? ` ${appNotes}` : ''}${appNew && appCannot ? ` ${appCannot}` : ''}` }); + const appCheckLine = "Strata couldn't check for a new version of the app itself. Try again later."; + if (appNew || controlNew) Object.assign(strata, { status: 'available', latestVersion: appNew ?? controlNew, message: `A new version of Strata is available.${appNotes ? ` ${appNotes}` : ''}${appNew && appCannot ? ` ${appCannot}` : ''}${appCheckFailed ? ` ${appCheckLine}` : ''}` }); + else if (appCheckFailed) Object.assign(strata, { status: 'error', message: appCheckLine }); else Object.assign(strata, { status: 'current', message: 'Strata is up to date.' }); + if (appCheckFailed) strata.details = appCheckFailed; return { checkedAt, feed: report.feed, strata, engine: engineView, serving: report.serving ?? [] }; } diff --git a/apps/host/src/components/SettingsUpdates.tsx b/apps/host/src/components/SettingsUpdates.tsx index df845f42..5a907738 100644 --- a/apps/host/src/components/SettingsUpdates.tsx +++ b/apps/host/src/components/SettingsUpdates.tsx @@ -71,7 +71,7 @@ export function SettingsUpdates() { const labels: Record = { available: 'Update available', current: 'Up to date', unavailable: 'Check unavailable', error: 'Check failed', 'no-releases': 'No release yet' }; return
- {tr(name)}{tr(version ?? 'Version unavailable')}{tr(!checking && update ? {tr(update.message)} : null)} + {tr(name)}{tr(version ?? 'Version unavailable')}{tr(!checking && update ? {tr(update.message)} : null)}{tr(!checking && name === 'Strata' && update?.details ?
{tr("Details")}

{update.details}

: null)}
{tr(!checking && update?.status === 'available' ? (native?.available ? setConfirm(name === 'Strata' ? 'update-strata' : 'update-engine')}>{tr("Update available")} : update.releaseUrl ? {tr("Update available")} : {tr(labels[update.status])}) : {tr(checking ? 'Checking…' : update ? labels[update.status] : version === 'Not installed' ? 'Not installed' : 'Installed')})}
; } diff --git a/apps/host/src/lib/types.ts b/apps/host/src/lib/types.ts index 94d745e3..28e044bd 100644 --- a/apps/host/src/lib/types.ts +++ b/apps/host/src/lib/types.ts @@ -8,6 +8,8 @@ export interface SoftwareUpdate { releaseUrl?: string; canInstall: boolean; message: string; + /** The technical reason behind `message`, shown only behind the Details disclosure. */ + details?: string; } export interface UpdateCheckResult { checkedAt: string; strata: SoftwareUpdate; engine: SoftwareUpdate } diff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjs index 3e7ca714..d9ec73f9 100644 --- a/apps/host/tests/component-updates.test.mjs +++ b/apps/host/tests/component-updates.test.mjs @@ -103,6 +103,23 @@ test('createControl: the update calls ask the explicit commands; a failed step c await assert.rejects(failing.update({}), err => err.code === 'engine_serving' && /serving/.test(err.message) && err.exitCode === 7); }); +test('the Settings check says so, in plain words, when the own update check of the app fails, and keeps the raw text for Details', async () => { + const feed = (control = { installed: '0.2.5', offered: '0.2.5', status: 'current' }) => ({ version: '0.2.5', async updateCheck() { return { ok: true, feed: { sequence: 3 }, engine: { installed: { version: '0.1.50' }, offered: { version: '0.1.50' }, status: 'current' }, control, app: { status: 'not-in-feed' } }; } }); + const failing = { check: async () => { throw new Error('error decoding response body for url (http://127.0.0.1:19090/latest.json)'); } }; + const nothing = await checkComponentUpdates({ control: feed(), appUpdater: failing, appVersion: '0.2.5' }); + assert.equal(nothing.strata.status, 'error', 'it no longer says "up to date" when the app could not be checked'); + assert.match(nothing.strata.message, /couldn't check for a new version of the app itself/); + assert.doesNotMatch(nothing.strata.message, /decoding|http|latest\.json/, 'no raw text in the main line'); + assert.match(nothing.strata.details, /error decoding response body/); + const withControl = await checkComponentUpdates({ control: feed({ installed: '0.2.5', offered: '0.2.6', status: 'available' }), appUpdater: failing, appVersion: '0.2.5' }); + assert.equal(withControl.strata.status, 'available'); + assert.match(withControl.strata.message, /new version of Strata is available.*couldn't check for a new version of the app itself/s); + assert.match(withControl.strata.details, /decoding/); + const fine = await checkComponentUpdates({ control: feed(), appUpdater: { check: async () => ({ available: false }) }, appVersion: '0.2.5' }); + assert.equal(fine.strata.status, 'current'); + assert.equal(fine.strata.details, undefined); +}); + test('the Settings update check maps the feed to the existing result shape', async () => { const report = overrides => ({ ok: true, feed: { sequence: 3 }, engine: { installed: { version: '0.1.45' }, offered: { version: '0.1.46' }, status: 'available', download_bytes: 505 * (1 << 20) }, control: { installed: '0.1.45', offered: '0.1.45', status: 'current' }, app: { status: 'not-in-feed' }, ...overrides }); const make = value => ({ version: '0.1.45', async updateCheck() { if (value instanceof Error) throw value; return value; } });