Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

app: every updater message in plain words, technical reasons in details

Niko1221844f91c6066d
diff --git a/apps/host/server/engine-step.mjs b/apps/host/server/engine-step.mjs
index 1b00b3871..fa40d0e6b 100644
--- a/apps/host/server/engine-step.mjs
+++ b/apps/host/server/engine-step.mjs
@@ -10,6 +10,8 @@
* job the user started. Contract: see phaseA-tests/notes-split-s6.md ("Job contract").
*/
+import { plainUpdateError, PHASE_TEXT } from './update-messages.mjs';
+
const GB = 1e9;
const round = (value, digits = 2) => Math.round(value * 10 ** digits) / 10 ** digits;
@@ -17,47 +19,50 @@ export const RETRY = 'Update engine';
export function createEngineStep({ control, signal = null, onChange = () => {} } = {}) {
const part = { kind: 'engine', name: 'Engine', version: null, state: 'pending', percent: 0, done_gb: 0, total_gb: 0, message: 'Waiting for the model download to start.' };
+ let note = null;
const set = patch => { Object.assign(part, patch); onChange({ ...part }); };
async function run() {
if (!control || typeof control.update !== 'function') { set({ state: 'skipped', message: 'This build has no component updater.' }); return { ...part }; }
try {
- set({ state: 'checking', message: 'Checking the engine for this PC.' });
+ set({ state: 'checking', message: 'Checking the engine for this PC…' });
let usable = false;
try { usable = !!(await control.engine()).usable; } catch { /* treated as not usable */ }
let report = null;
try {
report = await control.updateCheck();
} catch (error) {
- if (usable) { set({ state: 'skipped', message: 'The engine is installed; the update feed could not be reached, so it was not checked for a newer one.' }); return { ...part }; }
+ if (usable) { set({ state: 'skipped', message: 'The engine for this PC is installed.', details: 'The update server could not be reached, so a newer engine was not looked for.' }); return { ...part }; }
throw error;
}
const engine = report.engine ?? {};
const wanted = engine.status === 'install' || engine.status === 'available';
if (!wanted) {
if (!usable && engine.status !== 'current') throw new Error(engine.reasons?.[0] ?? 'The update feed has no engine for this PC.');
- set({ state: 'current', version: engine.installed?.version ?? null, message: 'The engine for this PC is up to date.', percent: 100 });
+ set({ state: 'current', version: engine.installed?.version ?? null, message: 'The engine for this PC is ready.', percent: 100 });
return { ...part };
}
const version = engine.offered?.version ?? null;
- set({ state: 'downloading', version, name: `Engine ${version ?? ''}`.trim(), total_gb: round((engine.download_bytes ?? 0) / GB), message: `Downloading engine ${version ?? ''} for this PC.` });
+ set({ state: 'downloading', version, name: `Engine ${version ?? ''}`.trim(), total_gb: round((engine.download_bytes ?? 0) / GB), message: 'Downloading the engine for this PC…' });
const result = await control.update({
engine: true, control: false, signal,
onEvent: event => {
if (event.event === 'progress') {
- set({ state: 'downloading', percent: event.percent ?? 0, done_gb: round((event.done ?? 0) / GB), total_gb: round((event.total ?? 0) / GB), message: `Downloading engine ${version ?? ''}: ${event.percent ?? 0}%` });
+ set({ state: 'downloading', percent: event.percent ?? 0, done_gb: round((event.done ?? 0) / GB), total_gb: round((event.total ?? 0) / GB), message: `Downloading the engine for this PC: ${event.percent ?? 0}%` });
} else if (event.event === 'phase') {
const state = { verify: 'verifying', test: 'testing', switch: 'switching' }[event.phase];
- if (state) set({ state, message: event.message ?? part.message });
+ if (state) set({ state, message: PHASE_TEXT[event.phase] ?? part.message });
} else if (event.event === 'waiting') {
- set({ message: event.message });
+ set({ message: 'Waiting for the model to stop before finishing the engine…' });
}
},
});
const done = (result.results ?? []).find(r => r.component === 'engine');
- set({ state: 'done', percent: 100, done_gb: part.total_gb, version: done?.installed_after?.version ?? version, message: `Engine ${done?.installed_after?.version ?? version ?? ''} is installed and tested.`.replace(' ', ' ') });
+ set({ state: 'done', percent: 100, done_gb: part.total_gb, version: done?.installed_after?.version ?? version, message: 'The engine for this PC is ready.' });
} catch (error) {
- set({ state: 'failed', error: error?.message ?? String(error), retry: RETRY, message: `The engine for this PC could not be downloaded: ${error?.message ?? error}. Your model files are kept. Press ${RETRY} in Settings to try again.` });
+ const plain = plainUpdateError(error, 'engine');
+ note = `Your model is ready. The engine for this PC couldn't be downloaded. ${plain.next}`;
+ set({ state: 'failed', error: plain.headline, details: plain.details, retry: RETRY, message: note });
}
return { ...part };
}
@@ -87,7 +92,7 @@ export function createEngineStep({ control, signal = null, onChange = () => {} }
/** What to tell the user when the model is ready but the engine is not. Null when all is well. */
function summaryNote() {
- return part.state === 'failed' ? `The engine for this PC could not be downloaded: ${part.error}. Press ${RETRY} in Settings to retry.` : null;
+ return part.state === 'failed' ? note : null;
}
return { run, merge, summaryNote, part: () => ({ ...part }) };
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjs
index 9e77e78a7..9bc183e1e 100644
--- a/apps/host/server/native-control.mjs
+++ b/apps/host/server/native-control.mjs
@@ -11,6 +11,7 @@ import { resolvePython, venvPython } from './python-resolver.mjs';
import os from 'node:os';
import { runtimeVision } from './native-vision.mjs';
import { createEngineStep } from './engine-step.mjs';
+import { plainError, PHASE_TEXT } from './update-messages.mjs';
const ROOT=resolve(dirname(fileURLToPath(import.meta.url)),'..');
const safeId=value=>typeof value==='string'&&/^[a-z0-9_-]{1,80}$/i.test(value);
@@ -82,7 +83,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
async function plan(args){await refresh();if(!snapshot.available)throw new Error(snapshot.error);return tool('strata_install',installArgs(args,false));}
function installArgs(args,confirm){const allowed=['family','model','context','vision','kv','gpu','gpus','backend','low_ram','port'];const size=snapshot.catalog?.families?.find(f=>f.family===args.family)?.sizes.find(s=>s.model===args.model);const existing=snapshot.installed?.models?.find(m=>m.model===size?.id);const data=nativeDataDirectory(args.data_dir??existing?.dataFolder??preferences.downloadDirectory??modelsDirectory?.());return {...(data?{data_dir:data}:{}),...Object.fromEntries(allowed.filter(k=>args[k]!==undefined).map(k=>[k,args[k]])),confirm};}
- function begin(kind,run,metadata={}){if([...jobs.values()].some(j=>j.state==='running'))throw new Error('Finish or cancel the current engine operation first.');const job={id:randomUUID(),kind,state:'running',startedAt:new Date().toISOString(),summary:'Starting…',result:null,error:null,...metadata};for(const [id,old] of jobs)if(jobs.size>=12&&old.state!=='running')jobs.delete(id);jobs.set(job.id,job);emit();void run(job).then(result=>{if(job.state==='running'){Object.assign(job,{state:'done',summary:result?.summary??'Complete',result,finishedAt:new Date().toISOString()});}}).catch(error=>{if(job.state==='running')Object.assign(job,{state:'error',error:error.message,summary:error.message,finishedAt:new Date().toISOString()});}).finally(()=>{if(job.kind.startsWith('update')||job.kind==='rollback')disconnect();lastRead=0;emit();void refresh(true);});return state().jobs.find(j=>j.id===job.id);}
+ function begin(kind,run,metadata={}){if([...jobs.values()].some(j=>j.state==='running'))throw new Error('Finish or cancel the current engine operation first.');const job={id:randomUUID(),kind,state:'running',startedAt:new Date().toISOString(),summary:'Starting…',result:null,error:null,...metadata};for(const [id,old] of jobs)if(jobs.size>=12&&old.state!=='running')jobs.delete(id);jobs.set(job.id,job);emit();void run(job).then(result=>{if(job.state==='running'){Object.assign(job,{state:'done',summary:result?.summary??'Complete',result,finishedAt:new Date().toISOString()});}}).catch(error=>{if(job.state==='running')Object.assign(job,{state:'error',error:error.message,summary:error.message,...(error.details?{details:error.details}:{}),finishedAt:new Date().toISOString()});}).finally(()=>{if(job.kind.startsWith('update')||job.kind==='rollback')disconnect();lastRead=0;emit();void refresh(true);});return state().jobs.find(j=>j.id===job.id);}
async function watchInstall(job,current){job.summary=current.step??'Resuming preparation status…';job.result={install:current};while(job.state==='running'){await new Promise(r=>setTimeout(r,1500));const result=await tool('strata_install');job.summary=result.summary;job.result=result;emit();if(!result.install?.running){if(result.install?.exit_code!==0)throw new Error(result.install?.error??'Preparation did not finish. Retry to reuse completed files.');return {summary:'Model preparation complete. Load it from Models.'};}}}
function externalRunning(){return Array.isArray(snapshot.external)?snapshot.external.filter(s=>![...instances.values()].some(i=>i.port===s.port)):[];}
async function install(job,args){
@@ -111,7 +112,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
if(engineTask){job.summary='Model files are ready. Finishing the engine for this PC…';emit();await engineTask;publish(result);}
await refresh(true);
const note=engineStep?.summaryNote();
- if(note)return {...result,summary:`Model ready. ${note}`};
+ if(note)return {...result,summary:note};
if(args.loadAfter){const model=(result.install.family??args.family??'qwen')==='qwen'?String(args.model).toLowerCase():`${args.family}-${String(args.model).toLowerCase()}`;return loadEngine(job,{model,multiple:!!args.multiple,resourceProfile:args.resourceProfile,vision:args.loadVision});}
return result;
}
@@ -189,24 +190,28 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
if(!['update-engine','update-strata','rollback'].includes(job.kind)||typeof control.update!=='function')throw new Error(NO_INSTALL);
if(instances.size)throw new Error('Unload native models before changing engine files.');
job.abort=new AbortController();
+ const subject=job.kind==='update-strata'?'Strata':'engine';
+ try{return await componentSteps(job,subject);}catch(error){throw error?.details!==undefined&&error.message?error:plainError(error,subject);}
+ }
+ async function componentSteps(job,subject){
const onEvent=event=>{
- if(event.event==='progress'){job.summary=`Downloading ${event.label}: ${event.percent}%`;job.result={install:{step:job.summary,download:{file:event.label,percent:event.percent}}};}
- else if(event.event==='phase'&&event.message)job.summary=event.message;
- else if(event.event==='waiting')job.summary=event.message;
+ if(event.event==='progress'){job.summary=`Downloading: ${event.percent}%`;job.result={install:{step:job.summary,download:{file:event.label,percent:event.percent}}};}
+ else if(event.event==='phase'&&PHASE_TEXT[event.phase])job.summary=PHASE_TEXT[event.phase];
+ else if(event.event==='waiting')job.summary='Waiting for the running model to stop…';
emit();
};
- if(job.kind==='rollback'){const done=await control.rollbackEngine();return {summary:`Engine ${done.to} restored. Model files and settings are kept.`,result:done};}
+ if(job.kind==='rollback'){const done=await control.rollbackEngine();return {summary:'The previous engine is back. Your models and settings are unchanged.',result:done};}
if(job.kind==='update-engine'){const done=await control.update({engine:true,control:false,onEvent,signal:job.abort.signal});return {summary:updateSummary(done),result:done};}
const done=await control.update({engine:false,control:true,onEvent,signal:job.abort.signal});
const notes=[updateSummary(done)];
if(appUpdater){
- job.summary='Checking the Strata app for updates…';emit();
+ job.summary='Looking for a new version of the app…';emit();
const verdict=await appUpdater.check();
- if(verdict.available){await appUpdater.install({signal:job.abort.signal,onProgress:p=>{if(p.total){job.summary=`Downloading Strata ${verdict.version}: ${Math.round(100*p.downloaded/p.total)}%`;job.result={install:{step:job.summary,download:{file:`Strata ${verdict.version}`,percent:Math.round(100*p.downloaded/p.total)}}};emit();}}});notes.push(`Strata ${verdict.version} installed; the app restarts.`);}
+ if(verdict.available){await appUpdater.install({signal:job.abort.signal,onProgress:p=>{if(p.total){job.summary=`Downloading the app update: ${Math.round(100*p.downloaded/p.total)}%`;job.result={install:{step:job.summary,download:{file:'Strata app',percent:Math.round(100*p.downloaded/p.total)}}};emit();}}});notes.push('The app update is installed. Strata will restart.');}
}
return {summary:notes.filter(Boolean).join(' '),result:done};
}
- function updateSummary(done){const r=(done.results??[]).filter(x=>x.status==='updated').map(x=>x.component==='engine'?`Engine ${x.installed_after?.version??''} installed and tested.`:`Control ${x.installed_after??''} installed (takes effect on the next start).`);return r.length?r.join(' '):'Already up to date.';}
+ function updateSummary(done){const r=(done.results??[]).filter(x=>x.status==='updated').map(x=>x.component==='engine'?'The engine is updated and ready.':'Strata is updated. It takes effect the next time you open the app.');return r.length?r.join(' '):'Everything is already up to date.';}
function execute(cmd,args,cwd){return new Promise((resolve,reject)=>{let output='';const process=spawnProcess(cmd,args,{cwd,stdio:['ignore','pipe','pipe']});process.stdout.on('data',c=>{output+=c;if(output.length>100000)process.kill();});process.stderr.on('data',c=>append('update',c.toString()));process.on('error',reject);process.on('exit',code=>code===0?resolve(output):reject(new Error('Git could not update this installation. Open diagnostics.')));});}
function writeModelConfig(path,next){copyFileSync(path,path+'.bak');chmodSync(path+'.bak',0o600);const temp=path+'.ui-tmp';writeFileSync(temp,JSON.stringify(next,null,2)+'\n',{mode:0o600});renameSync(temp,path);}
async function tune(job,args){
diff --git a/apps/host/server/update-messages.mjs b/apps/host/server/update-messages.mjs
new file mode 100644
index 000000000..81ec5f2f0
--- /dev/null
+++ b/apps/host/server/update-messages.mjs
@@ -0,0 +1,53 @@
+/**
+ * Plain words for the app. Whatever the updater says (HTTP codes, hash names, exit codes, file names) stays in `details`, which the UI
+ * shows behind the existing "Details" disclosure; the main text says what happened and the one next step (`next`). The Terminal keeps
+ * the precise messages: this module is only used on the app side.
+ */
+
+export const PHASE_TEXT = {
+ feed: 'Looking for updates…',
+ download: 'Downloading…',
+ verify: 'Checking the download…',
+ test: 'Making sure it works…',
+ switch: 'Finishing up…',
+ done: 'Done.',
+};
+
+/** { message, details, next } for an error thrown by Control's update calls (or the shell bridge). `subject` is "engine" or "Strata". */
+export function plainUpdateError(error, subject = 'engine') {
+ const raw = String(error?.message ?? error ?? '');
+ const code = error?.code ?? '';
+ const exit = error?.exitCode ?? null;
+ const button = `Update ${subject === 'engine' ? 'engine' : 'Strata'}`;
+ const keep = 'Your current version still works.';
+ let message = `The update didn't finish and nothing was changed. ${keep}`;
+ let next = `Press ${button} in Settings to try again.`;
+ if (code === 'engine_serving' || exit === 7 || /is serving/i.test(raw)) {
+ message = 'A model is running, so nothing was changed.';
+ next = `Unload the model in Models, then press ${button} in Settings.`;
+ } else if (/another update is already running/i.test(raw)) {
+ message = 'An update is already running.';
+ next = `Wait a moment, then press ${button} in Settings.`;
+ } else if (/test start|did not answer a one-token|did not become ready/i.test(raw)) {
+ message = `The new ${subject} didn't start correctly, so nothing was changed. ${keep}`;
+ } else if (/could not be read|interrupted|timed out|timeout|ECONN|ENOTFOUND|fetch failed|could not reach|server answered|not answer within/i.test(raw)) {
+ message = "Couldn't reach the update server.";
+ next = `Check your internet connection, then press ${button} in Settings.`;
+ } else if (/free space|not enough/i.test(raw)) {
+ message = 'There is not enough free disk space for the update.';
+ next = `Free some disk space, then press ${button} in Settings.`;
+ } else if (/no engine for this PC|has no engine|no package/i.test(raw)) {
+ message = "There isn't an engine for this PC's graphics card yet.";
+ next = 'Check for updates again later.';
+ } else if (/trusts no update key|signature|SHA-256|does not match|not trusted|expired|older than|replayed|integrity|refused/i.test(raw) || exit === 5) {
+ message = `The update didn't pass its safety check, so it was not installed. ${keep}`;
+ next = 'Try again later.';
+ }
+ return { message: `${message} ${next}`.trim(), headline: message, next, details: raw || undefined };
+}
+
+/** An Error carrying the plain message and, behind it, the technical reason. */
+export function plainError(error, subject) {
+ const { message, details } = plainUpdateError(error, subject);
+ return Object.assign(new Error(message), { details, code: error?.code });
+}
diff --git a/apps/host/server/updates.mjs b/apps/host/server/updates.mjs
index 7ca86c078..b1754294a 100644
--- a/apps/host/server/updates.mjs
+++ b/apps/host/server/updates.mjs
@@ -1,3 +1,5 @@
+import { plainUpdateError } from './update-messages.mjs';
+
/** Read-only release checks. Installing/rolling back needs a managed installer. */
const RELEASES = 'https://api.github.com/repos/Niko1221/Strata/releases?per_page=30';
const RELEASE_PREFIX = 'https://github.com/Niko1221/Strata/releases/';
@@ -53,18 +55,19 @@ export async function checkComponentUpdates({ control, appUpdater = null, appVer
try {
report = await control.updateCheck({ appVersion });
} catch (error) {
- const message = error?.message ?? 'Could not check for updates.';
- return { checkedAt, strata: { installedVersion: appVersion ?? control.version ?? null, status: 'error', message, canInstall: false }, engine: { installedVersion: null, status: 'error', message, canInstall: false } };
+ const plain = plainUpdateError(error, 'Strata');
+ const message = /update server/.test(plain.headline) ? `${plain.headline} Check your internet connection and try again.` : `Couldn't check for updates. Try again in a moment.`;
+ return { checkedAt, strata: { installedVersion: appVersion ?? control.version ?? null, status: 'error', message, details: plain.details, canInstall: false }, engine: { installedVersion: null, status: 'error', message, details: plain.details, canInstall: false } };
}
const mib = bytes => `${Math.round((bytes ?? 0) / (1 << 20))} MB`;
const engine = report.engine ?? {};
const installedEngine = engine.installed?.version ?? null;
const offered = engine.offered?.version ?? null;
const engineView = { installedVersion: installedEngine, latestVersion: offered ?? undefined, canInstall: engine.status === 'available' || engine.status === 'install' };
- if (engine.status === 'available') Object.assign(engineView, { status: 'available', message: `Engine ${offered} is available (${mib(engine.download_bytes)}).` });
- else if (engine.status === 'install') Object.assign(engineView, { status: 'available', message: `No engine is installed yet. The right one for this PC, ${offered} (${mib(engine.download_bytes)}), can be downloaded now.` });
- else if (engine.status === 'current' || engine.status === 'failed-before' || engine.status === 'skipped') Object.assign(engineView, { status: 'current', message: engine.note ?? 'The engine is up to date.' });
- else Object.assign(engineView, { status: 'unavailable', message: engine.reasons?.[0] ?? 'The update feed has no engine for this PC.' });
+ if (engine.status === 'available') Object.assign(engineView, { status: 'available', message: `A new engine is available (${mib(engine.download_bytes)}).` });
+ else if (engine.status === 'install') Object.assign(engineView, { status: 'available', message: `This PC needs an engine to run models. Press Update engine to download it (${mib(engine.download_bytes)}).` });
+ else if (engine.status === 'current' || engine.status === 'failed-before' || engine.status === 'skipped') Object.assign(engineView, { status: 'current', message: 'The engine is up to date.', details: engine.note });
+ else Object.assign(engineView, { status: 'unavailable', message: "There isn't an engine for this PC's graphics card yet.", details: (engine.reasons ?? []).join('\n') || undefined });
const control_ = report.control ?? {};
const app = report.app ?? {};
let appNew = app.status === 'available' ? app.offered : null;
@@ -78,7 +81,7 @@ export async function checkComponentUpdates({ control, appUpdater = null, appVer
}
const controlNew = control_.status === 'available' ? control_.offered : null;
const strata = { installedVersion: appVersion ?? control_.installed ?? control.version ?? null, canInstall: !!(appNew || controlNew) };
- if (appNew || controlNew) Object.assign(strata, { status: 'available', latestVersion: appNew ?? controlNew, message: `Strata ${appNew ?? controlNew} is available.${appNotes ? ` ${appNotes}` : ''}` });
+ if (appNew || controlNew) Object.assign(strata, { status: 'available', latestVersion: appNew ?? controlNew, message: `A new version of Strata is available.${appNotes ? ` ${appNotes}` : ''}` });
else Object.assign(strata, { status: 'current', message: 'Strata is up to date.' });
return { checkedAt, feed: report.feed, strata, engine: engineView, serving: report.serving ?? [] };
}
diff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjs
index cc43fbe3a..37fcf66e7 100644
--- a/apps/host/tests/component-updates.test.mjs
+++ b/apps/host/tests/component-updates.test.mjs
@@ -109,27 +109,31 @@ test('the Settings update check maps the feed to the existing result shape', asy
let result = await checkComponentUpdates({ control: make(report()), appVersion: '0.1.0' });
assert.equal(result.engine.status, 'available');
assert.equal(result.engine.latestVersion, '0.1.46');
- assert.match(result.engine.message, /0\.1\.46 is available \(505 MB\)/);
+ assert.match(result.engine.message, /new engine is available \(505 MB\)/);
+ assert.doesNotMatch(result.engine.message, /0\.1\.4|sha|exit/i);
assert.equal(result.engine.canInstall, true);
assert.equal(result.strata.status, 'current');
result = await checkComponentUpdates({ control: make(report({ engine: { installed: null, offered: { version: '0.1.46' }, status: 'install', download_bytes: 505 * (1 << 20) } })) });
assert.equal(result.engine.status, 'available');
- assert.match(result.engine.message, /No engine is installed yet/);
+ assert.match(result.engine.message, /needs an engine to run models\. Press Update engine/);
result = await checkComponentUpdates({ control: make(report({ engine: { installed: { version: '0.1.46' }, offered: { version: '0.1.46' }, status: 'current' } })) });
assert.equal(result.engine.status, 'current');
result = await checkComponentUpdates({ control: make(report({ engine: { installed: null, offered: null, status: 'none-for-this-pc', reasons: ['0.1.46 is for linux-x86_64, this PC is windows-x86_64'] } })) });
assert.equal(result.engine.status, 'unavailable');
- assert.match(result.engine.message, /windows-x86_64/);
+ assert.doesNotMatch(result.engine.message, /windows-x86_64/);
+ assert.match(result.engine.details, /windows-x86_64/, 'the technical reason is kept for the Details disclosure');
result = await checkComponentUpdates({ control: make(new Error('this build trusts no update key')) });
assert.equal(result.strata.status, 'error');
assert.equal(result.engine.status, 'error');
- assert.match(result.engine.message, /no update key/);
+ assert.doesNotMatch(result.engine.message, /update key/);
+ assert.match(result.engine.details, /no update key/);
+ assert.match(result.engine.message, /Try again/);
// the app's verdict comes from the shell's updater when the bridge exists
const appUpdater = { check: async () => ({ available: true, version: '0.2.0', notes: 'Faster starts.' }) };
result = await checkComponentUpdates({ control: make(report()), appUpdater, appVersion: '0.1.0' });
assert.equal(result.strata.status, 'available');
assert.equal(result.strata.latestVersion, '0.2.0');
- assert.match(result.strata.message, /Faster starts/);
+ assert.match(result.strata.message, /new version of Strata is available\. Faster starts/);
});
test('the shell bridge client exists only inside the desktop app, speaks to loopback with the token, and polls to the end', async () => {
@@ -199,14 +203,14 @@ test('packaged: "Update engine" runs the explicit component update, shows its pr
await new Promise(r => setTimeout(r, 5));
const job = await finish(f.native, started.id);
assert.equal(job.state, 'done', job.error);
- assert.match(job.summary, /Engine 0\.1\.46 installed and tested/);
+ assert.match(job.summary, /engine is updated and ready/);
assert.deepEqual(f.calls[0], ['update', true, false], 'the engine only: Control and the app are not touched by "Update engine"');
assert.equal(f.spawned.length, 0);
await f.native.refresh(true);
assert.equal(f.native.state().capabilities.rollback, true, 'the previous engine the update kept is offered for rollback');
const back = await finish(f.native, f.native.operation('rollback', {}).id);
assert.equal(back.state, 'done', back.error);
- assert.match(back.summary, /Engine 0\.1\.45 restored/);
+ assert.match(back.summary, /previous engine is back/);
} finally { await f.native.close(); f.cleanup(); }
});
@@ -223,7 +227,7 @@ test('packaged: progress events become the existing job summary and download bar
}
await finish(f.native, started.id);
assert.deepEqual(seen[0], { file: 'engine 0.1.46', percent: 42 });
- assert.equal(seen[1], 'Downloading engine 0.1.46: 42%');
+ assert.equal(seen[1], 'Downloading: 42%');
} finally { await f.native.close(); f.cleanup(); }
});
@@ -250,7 +254,7 @@ test('packaged: "Update Strata" updates Control through the feed, then the app t
assert.equal(job.state, 'done', job.error);
assert.deepEqual(f.calls.map(c => c[0]), ['update', 'app-install']);
assert.deepEqual(f.calls[0], ['update', false, true]);
- assert.match(job.summary, /Strata 0\.2\.0 installed/);
+ assert.match(job.summary, /app update is installed\. Strata will restart/);
} finally { await f.native.close(); f.cleanup(); }
});
@@ -260,7 +264,7 @@ test('without the shell bridge "Update Strata" still updates Control and says no
await f.native.refresh(true);
const job = await finish(f.native, f.native.operation('update-strata', {}).id);
assert.equal(job.state, 'done', job.error);
- assert.doesNotMatch(job.summary, /Strata 0\.2\.0/);
+ assert.doesNotMatch(job.summary, /app update is installed/);
} finally { await f.native.close(); f.cleanup(); }
});
@@ -274,3 +278,35 @@ test('packaged: opening the app, listing models and loading one never reach the
assert.equal(f.spawned.length, 0);
} finally { await f.native.close(); f.cleanup(); }
});
+
+test('plain words in the app: codes, hashes and exit codes stay in details, never in the main text', async () => {
+ const { plainUpdateError } = await import('../server/update-messages.mjs');
+ const raw = [
+ 'the download of http://x/e.tar.gz was interrupted after 100 of 200 bytes (ConnectionResetError)',
+ 'The new engine 0.1.46 did not pass its test start (it did not answer a one-token probe (server_exited))',
+ 'http://x/e.tar.gz does not match the SHA-256 in the signed feed; the download was deleted',
+ 'this build trusts no update key (update_keys.json is empty)',
+ 'app-1 is serving.',
+ 'something unexpected: exit 9',
+ ];
+ for (const text of raw) {
+ const plain = plainUpdateError(new Error(text));
+ assert.doesNotMatch(plain.message, /SHA|HTTP|http|exit|0\.1\.|server_exited|\.tar|key|bytes|probe/i, plain.message);
+ assert.equal(plain.details, text);
+ assert.ok(plain.next.length > 0);
+ }
+ assert.match(plainUpdateError(new Error(raw[0])).message, /internet connection/);
+ assert.match(plainUpdateError(new Error(raw[4])).message, /Unload the model/);
+});
+
+test('a failed update job shows plain words and keeps the technical reason as details', async () => {
+ const f = fixture({ update: async () => { throw new Error('the download of http://x/e.tar.gz was interrupted after 1 of 2 bytes (ConnectionResetError)'); } });
+ try {
+ await f.native.refresh(true);
+ const job = await finish(f.native, f.native.operation('update-engine', {}).id);
+ assert.equal(job.state, 'error');
+ assert.match(job.error, /Couldn't reach the update server\. Check your internet connection, then press Update engine in Settings\./);
+ assert.doesNotMatch(job.error, /http|bytes|Reset/);
+ assert.match(job.details, /ConnectionResetError/);
+ } finally { await f.native.close(); f.cleanup(); }
+});
diff --git a/apps/host/tests/engine-step.test.mjs b/apps/host/tests/engine-step.test.mjs
index c1f1f5ac3..03d063a89 100644
--- a/apps/host/tests/engine-step.test.mjs
+++ b/apps/host/tests/engine-step.test.mjs
@@ -59,8 +59,10 @@ test('a failed engine download keeps the model and says how to retry', async ()
const part = await step.run();
assert.equal(part.state, 'failed');
assert.equal(part.retry, 'Update engine');
- assert.match(part.message, /Your model files are kept/);
- assert.match(step.summaryNote(), /connection dropped.*Update engine in Settings/);
+ assert.match(part.message, /^Your model is ready\. The engine for this PC couldn't be downloaded\. .*Update engine in Settings/);
+ assert.doesNotMatch(part.message, /dropped|HTTP|exit|sha/i);
+ assert.match(part.details, /connection dropped/, 'the reason is kept for the Details disclosure');
+ assert.equal(step.summaryNote(), part.message);
const merged = step.merge({ running: false, download: { file: 'm', percent: 100, done_gb: 10, remaining_gb: 0 } });
assert.equal(merged.download.remaining_gb, 0, 'a failed engine does not leave the progress bar short');
});
@@ -70,7 +72,8 @@ test('a feed that cannot be reached is a failure only when there is no engine ye
assert.equal(none.state, 'failed');
const have = await createEngineStep({ control: control({ usable: true, checkError: 'could not be read' }) }).run();
assert.equal(have.state, 'skipped');
- assert.match(have.message, /engine is installed/);
+ assert.match(have.message, /engine for this PC is installed/);
+ assert.match(have.details, /could not be reached/);
});
test('an engine that is already current downloads nothing; one with no package for this PC is a failure', async () => {
@@ -80,7 +83,8 @@ test('an engine that is already current downloads nothing; one with no package f
assert.deepEqual(c.calls, ['engine', 'updateCheck']);
const none = await createEngineStep({ control: control({ usable: false, check: { engine: { status: 'none-for-this-pc', reasons: ['0.1.46 is for linux-x86_64, this PC is windows-x86_64'] } } }) }).run();
assert.equal(none.state, 'failed');
- assert.match(none.error, /windows-x86_64/);
+ assert.doesNotMatch(none.message, /windows-x86_64/);
+ assert.match(none.details, /windows-x86_64/);
});
test('without a component updater the step is skipped and never throws', async () => {