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 update: a job an older host left running is finished when the app's program file is newer than the job
Niko122191eb05a228a2
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjsindex 6b7862b6f..23f4f286b 100644--- a/apps/host/server/native-control.mjs+++ b/apps/host/server/native-control.mjs@@ -40,7 +40,9 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},spconst instances=new Map(),processes=new Map(),jobs=new Map(),logs=[];const savedJobs=readJson(join(directory,'native-jobs.json'),[]);/* An app update ends the app on purpose: the installer replaces it and starts it again. The job that asked for it was saved as running together with the app version it started from (appUpdateFrom); a start that finds a different version knows the update finished, instead of calling it an interrupted operation. */const thisAppVersion=()=>process.env.STRATA_APP_VERSION||null;- const settledByAppUpdate=j=>j.state==='running'&&j.kind==='update-strata'&&typeof j.appUpdateFrom==='string'&&!!thisAppVersion()&&thisAppVersion()!==j.appUpdateFrom;+ /* A record an OLDER host wrote (no appUpdateFrom): the app's own program file was replaced after the job began, so the installer finished. <install>/host/server is ROOT's parent chain: ROOT = <install>/host. */+ const appProgramNewerThan=started=>{try{const t=Date.parse(started);if(!Number.isFinite(t))return false;const exe=join(dirname(ROOT),process.platform==='win32'?'strata-desktop.exe':'strata-desktop');return existsSync(exe)&&statSync(exe).mtimeMs>t;}catch{return false;}};+ const settledByAppUpdate=j=>j.state==='running'&&j.kind==='update-strata'&&((typeof j.appUpdateFrom==='string'&&!!thisAppVersion()&&thisAppVersion()!==j.appUpdateFrom)||(typeof j.appUpdateFrom!=='string'&&appProgramNewerThan(j.startedAt)));const neverFinishedAppUpdate=j=>j.state==='running'&&j.kind==='update-strata'&&typeof j.appUpdateFrom==='string'&&!!thisAppVersion()&&thisAppVersion()===j.appUpdateFrom;for(const j of (Array.isArray(savedJobs)?savedJobs:[]).slice(-12))jobs.set(j.id,{...j,...(settledByAppUpdate(j)?{state:'done',error:null,summary:`Strata is updated to ${thisAppVersion()}.`,finishedAt:new Date().toISOString()}:neverFinishedAppUpdate(j)?{state:'error',error:`The update to ${j.appUpdateTo??'the new version'} did not finish: the app closed for the installer, but the old version ${j.appUpdateFrom} started again. Try Update again, or download the installer from the Strata release page (https://github.com/Niko1221/Strata/releases/latest).`,summary:'The app update did not finish',finishedAt:new Date().toISOString()}:j.state==='running'?{state:'error',error:'The host restarted before completion. Check diagnostics, then retry; completed files are kept.',summary:'Interrupted operation'}:{})});/* Packaged mode: the app ships Strata Control (control-runtime.mjs). Models are run configs in an install folder, the enginediff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjsindex c5a3d556d..3e7ca7142 100644--- a/apps/host/tests/component-updates.test.mjs+++ b/apps/host/tests/component-updates.test.mjs@@ -294,6 +294,28 @@ test('packaged: an app update that ends the app is recorded as finished by the n} finally { if (before === undefined) delete process.env.STRATA_APP_VERSION; else process.env.STRATA_APP_VERSION = before; await f.native.close(); f.cleanup(); }});+test('packaged: an update job an OLDER host left running is finished when the app program file is newer than the job', async () => {+ const exe = new URL('../../strata-desktop.exe', import.meta.url); // <install>/strata-desktop.exe as seen from <install>/host+ const f = fixture({ withApp: true });+ try {+ const { fileURLToPath } = await import('node:url');+ const old = { id: 'old-1', kind: 'update-strata', state: 'running', startedAt: new Date(Date.now() - 60_000).toISOString(), summary: 'Starting…', result: null, error: null };+ writeFileSync(join(f.data, 'native-jobs.json'), JSON.stringify([old]));+ const mk = () => createNativeControl({ control: f.control, directory: f.data, spawnProcess: () => { throw new Error('no process'); }, fetcher: async () => Response.json({}), requests: () => [] });+ const before = mk();+ assert.equal(before.state().jobs[0].state, 'error', 'no new program file: still an interruption');+ await before.close();+ writeFileSync(join(f.data, 'native-jobs.json'), JSON.stringify([old]));+ writeFileSync(fileURLToPath(exe), 'new program');+ try {+ const after = mk();+ assert.equal(after.state().jobs[0].state, 'done');+ assert.match(after.state().jobs[0].summary, /updated/i);+ await after.close();+ } finally { rmSync(fileURLToPath(exe), { force: true }); }+ } finally { await f.native.close(); f.cleanup(); }+});+test('packaged: "Update engine" works in the first seconds, before the native snapshot has connected', async () => {const f = fixture();try {