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++
In-app update: a finished app update is no longer shown as an interrupted operation; a test update feed used once is not remembered as the feed for later checks
Niko122115fdb6956347
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjsindex 8b1678685..f986ae341 100644--- a/apps/host/server/native-control.mjs+++ b/apps/host/server/native-control.mjs@@ -38,7 +38,10 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},splet child=null,seq=0,buffer='',pending=new Map(),definitions=[],refreshing=null,lastRead=0,connecting=null;let snapshot={available:false,repo:preferences.repo,summary:'Connect a local Strata installation.',catalog:null,installed:null,hardware:null,error:null};const instances=new Map(),processes=new Map(),jobs=new Map(),logs=[];- const savedJobs=readJson(join(directory,'native-jobs.json'),[]);for(const j of (Array.isArray(savedJobs)?savedJobs:[]).slice(-12))jobs.set(j.id,{...j,...(j.state==='running'?{state:'error',error:'The host restarted before completion. Check diagnostics, then retry; completed files are kept.',summary:'Interrupted operation'}:{})});+ 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;+ 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()}: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 enginecomes from the component folder, and a start is `strata runtime start` under the owner runtime. Nothing is installed,updated or fetched from here. Without `control` (a source checkout) every path below is the original one. */@@ -364,7 +367,7 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}job.summary='Looking for a new version of the app…';emit();let verdict;try{verdict=await appUpdater.check();}catch(error){if(error?.code!=='app-update-unavailable')throw error;verdict={available:false};notes.push(appUpdater.unavailable||error.message);}- 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.');}+ if(verdict.available){job.appUpdateFrom=thisAppVersion();emit();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};}diff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjsindex 6a2ed9e52..cc19ef00a 100644--- a/apps/host/tests/component-updates.test.mjs+++ b/apps/host/tests/component-updates.test.mjs@@ -1,7 +1,7 @@import test from 'node:test';import assert from 'node:assert/strict';import { EventEmitter } from 'node:events';-import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';+import { mkdtempSync, mkdirSync, writeFileSync, rmSync, readFileSync } from 'node:fs';import { join, basename } from 'node:path';import { tmpdir } from 'node:os';import { bundledPython, controlEnvironment, createControl, findControl, runCli, updatedControlDirectory } from '../server/control-runtime.mjs';@@ -165,7 +165,7 @@ test('the shell bridge client exists only inside the desktop app, speaks to loop// ---------------------------------------------------------------------------------- the Settings buttons in the packaged app-function fixture({ withApp = false, update } = {}) {+function fixture({ withApp = false, update, appInstall } = {}) {const root = mkdtempSync(join(tmpdir(), 'strata-update-ops-'));const install = join(root, 'install'), data = join(root, 'data');mkdirSync(install, { recursive: true });@@ -192,10 +192,10 @@ function fixture({ withApp = false, update } = {}) {const spawned = [];const appUpdater = withApp ? {check: async () => ({ available: true, version: '0.2.0' }),- install: async ({ onProgress }) => { calls.push(['app-install']); onProgress({ downloaded: 50, total: 100 }); return { state: 'done' }; },+ install: appInstall ?? (async ({ onProgress }) => { calls.push(['app-install']); onProgress({ downloaded: 50, total: 100 }); return { state: 'done' }; }),} : null;const native = createNativeControl({ control, appUpdater, directory: data, spawnProcess: (...args) => { if (!args[1]?.some(a => String(a).endsWith('strata_mcp.py'))) spawned.push(args); throw new Error('no process but the installer tool (Control strata_mcp.py, absent in this fixture) may be started by the host in packaged mode'); }, fetcher: async () => Response.json({}), requests: () => [] });- return { native, calls, spawned, cleanup: () => rmSync(root, { recursive: true, force: true }) };+ return { native, calls, spawned, data, control, cleanup: () => rmSync(root, { recursive: true, force: true }) };}const finish = async (native, id) => { for (let i = 0; i < 400; i++) { const job = native.state().jobs.find(j => j.id === id); if (job.state !== 'running') return job; await new Promise(r => setTimeout(r, 10)); } throw new Error('job did not finish'); };@@ -264,6 +264,33 @@ test('packaged: "Update Strata" updates Control through the feed, then the app t} finally { await f.native.close(); f.cleanup(); }});+test('packaged: an app update that ends the app is recorded as finished by the new version, not as an interrupted operation', async () => {+ const before = process.env.STRATA_APP_VERSION;+ process.env.STRATA_APP_VERSION = '0.2.2';+ const f = fixture({ withApp: true, appInstall: () => new Promise(() => {}) }); // the installer ends the app: install() never returns+ try {+ await f.native.refresh(true);+ const started = f.native.operation('update-strata', {});+ await new Promise(r => setTimeout(r, 60));+ assert.equal(f.native.state().jobs.find(j => j.id === started.id).state, 'running');+ const saved = JSON.parse(readFileSync(join(f.data, 'native-jobs.json'), 'utf8')).find(j => j.id === started.id);+ assert.equal(saved.appUpdateFrom, '0.2.2', 'the job was saved with the version it started from before the app was ended');+ // the app is gone; the installer starts the new one (0.2.3) on the same data+ process.env.STRATA_APP_VERSION = '0.2.3';+ const again = createNativeControl({ control: f.control, directory: f.data, spawnProcess: () => { throw new Error('no process'); }, fetcher: async () => Response.json({}), requests: () => [] });+ const job = again.state().jobs.find(j => j.id === started.id);+ assert.equal(job.state, 'done');+ assert.equal(job.error, null);+ assert.match(job.summary, /updated to 0\.2\.3/);+ await again.close();+ // the same record read by an app that did NOT change version stays an interruption+ process.env.STRATA_APP_VERSION = '0.2.2';+ const same = createNativeControl({ control: f.control, directory: f.data, spawnProcess: () => { throw new Error('no process'); }, fetcher: async () => Response.json({}), requests: () => [] });+ assert.equal(same.state().jobs.find(j => j.id === started.id).state, 'error');+ await same.close();+ } finally { if (before === undefined) delete process.env.STRATA_APP_VERSION; else process.env.STRATA_APP_VERSION = before; await f.native.close(); f.cleanup(); }+});+test('without the shell bridge "Update Strata" still updates Control and says nothing false about the app', async () => {const f = fixture();try {diff --git a/strata_cli/update_cmd.py b/strata_cli/update_cmd.pyindex 31b87df24..11a7b8932 100644--- a/strata_cli/update_cmd.py+++ b/strata_cli/update_cmd.py@@ -91,7 +91,14 @@ def _feed_source(a, root: Path) -> str:if os.environ.get(ENV_FEED):return os.environ[ENV_FEED]remembered = (updater.State(root).data.get("feed") or {}).get("source")- return remembered or DEFAULT_FEED+ return remembered if _may_be_remembered(remembered) else DEFAULT_FEED+++def _may_be_remembered(source) -> bool:+ """Only an https address is carried over to later runs. A loopback address or a folder is what a test of an update feed uses; once+ one such run had been made on a PC, every later check (the app's Settings included) tried that dead address and said "No internet+ connection". Those runs name their feed again each time (--feed or STRATA_UPDATE_FEED)."""+ return isinstance(source, str) and source.lower().startswith("https://")def _mib(n: int | None) -> str:diff --git a/tests/terminal/test_update_feed_memory.py b/tests/terminal/test_update_feed_memory.pynew file mode 100644index 000000000..2d156ea73--- /dev/null+++ b/tests/terminal/test_update_feed_memory.py@@ -0,0 +1,45 @@+"""A test feed (a loopback address or a folder) used once on a PC is not the feed every later update check goes to."""++import tempfile+import unittest+from pathlib import Path+from types import SimpleNamespace+from unittest import mock++from strata_cli import update_cmd+from strata_control import updater+++def remembered(root, source):+ state = updater.State(root)+ state.data["feed"] = {"source": source}+ state.save()+++class FeedMemoryTest(unittest.TestCase):+ def source(self, stored, **args):+ with tempfile.TemporaryDirectory() as tmp, mock.patch.dict("os.environ", {}, clear=False):+ import os+ os.environ.pop(update_cmd.ENV_FEED, None)+ remembered(Path(tmp), stored)+ return update_cmd._feed_source(SimpleNamespace(feed=args.get("feed")), Path(tmp))++ def test_a_loopback_test_feed_is_forgotten(self):+ self.assertEqual(self.source("http://127.0.0.1:18831"), update_cmd.DEFAULT_FEED)++ def test_a_local_folder_is_forgotten(self):+ self.assertEqual(self.source(r"C:\rel\FEED-interim"), update_cmd.DEFAULT_FEED)+ self.assertEqual(self.source("/tmp/feed"), update_cmd.DEFAULT_FEED)++ def test_an_https_mirror_is_kept(self):+ self.assertEqual(self.source("https://mirror.example.com/strata-feed.json"), "https://mirror.example.com/strata-feed.json")++ def test_nothing_remembered_is_the_project_feed(self):+ self.assertEqual(self.source(None), update_cmd.DEFAULT_FEED)++ def test_a_named_feed_still_wins(self):+ self.assertEqual(self.source("https://a.example/f.json", feed="http://127.0.0.1:1"), "http://127.0.0.1:1")+++if __name__ == "__main__":+ unittest.main()