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)
This commit is contained in:
1 parent
c893eeebf1
commit
236e13b4af
4 files changed
+27
-3
No files matched your search
@@ -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 ?? [] };
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ export function SettingsUpdates() {
|
||||
const labels: Record<SoftwareUpdate['status'], string> = { available: 'Update available', current: 'Up to date', unavailable: 'Check unavailable', error: 'Check failed', 'no-releases': 'No release yet' };
|
||||
return <div className="settings-version" data-update={update?.status}>
|
||||
<Icon name={name === 'Strata' ? 'layers' : 'engine'} size={20}/>
|
||||
<span><strong>{tr(name)}</strong><small>{tr(version ?? 'Version unavailable')}</small>{tr(!checking && update ? <small className="settings-version__message">{tr(update.message)}</small> : null)}</span>
|
||||
<span><strong>{tr(name)}</strong><small>{tr(version ?? 'Version unavailable')}</small>{tr(!checking && update ? <small className="settings-version__message">{tr(update.message)}</small> : null)}{tr(!checking && name === 'Strata' && update?.details ? <details className="native-settings-diagnostic"><summary className="small">{tr("Details")}</summary><p className="small muted">{update.details}</p></details> : null)}</span>
|
||||
{tr(!checking && update?.status === 'available' ? (native?.available ? <Btn size="sm" variant="primary" disabled={!!active || (name === 'Engine' && !native.installed?.models.length && !native.capabilities.componentUpdates)} onClick={() => setConfirm(name === 'Strata' ? 'update-strata' : 'update-engine')}>{tr("Update available")}</Btn> : update.releaseUrl ? <a className="st-btn st-btn--secondary st-btn--sm" href={update.releaseUrl} target="_blank" rel="noreferrer" title={tr("Open the release page to update this installation")}>{tr("Update available")}<Icon name="download" size={15}/></a> : <span className="settings-version__label">{tr(labels[update.status])}</span>) : <span className="settings-version__label">{tr(checking ? 'Checking…' : update ? labels[update.status] : version === 'Not installed' ? 'Not installed' : 'Installed')}</span>)}
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
|
||||
|
||||
@@ -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; } });
|
||||
|
||||
Reference in new issue
Block a user