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 never adopts an older CLI install: own settings file for Control and the installer, explicit install folder, tests

Niko1221ad3b340d3033
diff --git a/apps/host/server/control-runtime.mjs b/apps/host/server/control-runtime.mjs
index 4f7fc610c..6f352b543 100644
--- a/apps/host/server/control-runtime.mjs
+++ b/apps/host/server/control-runtime.mjs
@@ -82,6 +82,9 @@ export function controlEnvironment(control, { env = process.env, components = co
...next,
PYTHONNOUSERSITE: '1', PYTHONUTF8: '1', PYTHONUNBUFFERED: '1', PYTHONIOENCODING: 'utf-8',
STRATA_NO_ACQUIRE: '1', STRATA_COMPONENTS_DIR: components,
+ // The app's own settings file, beside its components: Control and the installer never read or write the file an older
+ // command-line Strata keeps in %APPDATA% / ~/.config (its list of Strata folders), so an old install is never adopted.
+ ...(components ? { STRATA_SETTINGS_FILE: env.STRATA_SETTINGS_FILE || join(dirname(components), 'app-settings.json') } : {}),
...(control?.dir ? { STRATA_CONTROL_DIR: control.dir } : {}),
};
// Only the explicit update step (`strata update`) may acquire; every other Control process keeps the switch on.
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjs
index 196aa65ac..8a3ce5e07 100644
--- a/apps/host/server/native-control.mjs
+++ b/apps/host/server/native-control.mjs
@@ -38,7 +38,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
/* In the packaged app the model catalog, the GPU probe and the install job are Control's bundled tools/strata_mcp.py and
setup.py, run on Control's own Python in the installer's mode (STRATA_CONTROL_INSTALL: no pip, no engine, no compiler).
The install only runs when the user clicks Download; starting and serving (control.start) keep STRATA_NO_ACQUIRE. */
- const defaultInstall=()=>join(dirname(componentsDirectory()),'install');
+ const defaultInstall=()=>process.env.STRATA_INSTALL_DIR?resolve(process.env.STRATA_INSTALL_DIR):join(dirname(componentsDirectory()),'install');
let packagedInstall=null;
const NO_INSTALL='Installing, updating, tuning with calibration or rolling back model files and engines happens from the Terminal (strata install), never while the app runs.';
let defaultId=null,timer=null,closing=false,polling=false;
@@ -63,7 +63,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
const next={...config,...(config.cwd!==undefined?{cwd:fix(config.cwd)}:{}),...(Array.isArray(config.args)?{args:config.args.map(fix)}:{})};
if(JSON.stringify(next)!==JSON.stringify(config)){try{writeModelConfig(path,next);}catch{/* read-only folder: the load reports it */}}}}
function installedInfo(info){if(!info)return info;return {...info,models:(info.models??[]).map(entry=>{const cfg=/^strata-[a-z0-9_-]+\.json$/i.test(entry.config??'')?readJson(entry.configPath??join(repo(),entry.config)):{};const at=cfg.args?.indexOf('--native')??-1,nativeFile=at>=0?cfg.args[at+1]:null;const dataFolder=typeof nativeFile==='string'&&basename(dirname(dirname(nativeFile)))==='models'?dirname(dirname(dirname(nativeFile))):info.data_folder;return {...entry,diskGb:entry.diskGb??entry.disk_gb,diskBytes:entry.diskBytes??entry.disk_bytes,dataFolder,visionPrepared:!!cfg.vision,visionEnabled:cfg.ui_vision_enabled??[...instances.values()].some(i=>i.model===entry.model&&i.status==='ready'&&i.vision),visionDevice:cfg.ui_vision_device,resourceProfile:cfg.ui_resource_profile,lowRamMode:cfg.args?.includes('--resident-experts')?'resident':cfg.args?.includes('--mmap-experts')?'mmap':'auto'};})};}
- function installRoot(){const found=[preferences.installDir,packagedInstall,snapshot.installDir].find(d=>d&&existsSync(d));if(found)return realpathSync(found);mkdirSync(defaultInstall(),{recursive:true});return realpathSync(defaultInstall());}
+ function installRoot(){const found=[preferences.installDir].find(d=>d&&existsSync(d));if(found)return realpathSync(found);mkdirSync(defaultInstall(),{recursive:true});return realpathSync(defaultInstall());}
function repo(){if(packaged)return installRoot();const path=realpathSync(preferences.repo);if(!existsSync(join(path,'setup.py'))||!existsSync(join(path,'tools/strata_mcp.py'))||!existsSync(join(path,'serve/server.py')))throw new Error('Choose the Strata repository folder containing setup.py and tools/strata_mcp.py.');return path;}
function python(){return resolvePython({repo:preferences.repo});}
function send(method,params,timeout=30000){return new Promise((resolve,reject)=>{const id=++seq;const alarm=setTimeout(()=>{pending.delete(id);reject(new Error('The native engine did not respond in time. Check engine logs.'));},timeout);pending.set(id,{resolve,reject,alarm});child.stdin.write(JSON.stringify({jsonrpc:'2.0',id,method,params})+'\n');});}
@@ -85,9 +85,9 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
async function controlTool(name){
if(name==='strata_status'){
for(const dir of [preferences.installDir,packagedInstall,installRoot()])repairControlPaths(dir);
- let list=await control.installedModels({installDir:preferences.installDir&&existsSync(preferences.installDir)?preferences.installDir:null});
- if(!preferences.installDir&&!(list.models??[]).length){const own=installRoot();if(realpathSync(list.install_dir)!==own)list=await control.installedModels({installDir:own});}
- if(!preferences.installDir&&list.install_dir&&![preferences.installDir,packagedInstall,installRoot()].some(d=>d&&resolve(d).toLowerCase()===resolve(list.install_dir).toLowerCase())){repairControlPaths(list.install_dir);list=await control.installedModels({installDir:list.install_dir});}
+ // Always the app's own install folder (or the one the person chose in Settings): Control is told explicitly, so it never falls
+ // back to an older command-line Strata's folder remembered in %APPDATA% (tester report 2026-10-17: logs landed in T:\Strata).
+ const list=await control.installedModels({installDir:installRoot()});
packagedInstall=list.install_dir;
const engine=await control.engine();
const installer=await mcpCall('strata_status',{hardware:true}).catch(error=>({error:error.message}));
diff --git a/apps/host/tests/packaged-control.test.mjs b/apps/host/tests/packaged-control.test.mjs
index b4a98cc20..5677980aa 100644
--- a/apps/host/tests/packaged-control.test.mjs
+++ b/apps/host/tests/packaged-control.test.mjs
@@ -89,6 +89,8 @@ function packagedFixture({ engineUsable = true, updater = null, repair = false }
const root = mkdtempSync(join(tmpdir(), 'strata-packaged-test-'));
const install = join(root, 'install'), data = join(root, 'data');
mkdirSync(install, { recursive: true });
+ const earlierInstallEnv = process.env.STRATA_INSTALL_DIR;
+ process.env.STRATA_INSTALL_DIR = install; // the app's own install folder (the host always tells Control which one; it never falls back to an older CLI folder)
const configs = ['iq2_xs', 'iq3_s'].map(id => {
const path = join(install, `strata-${id}.json`);
writeFileSync(path, JSON.stringify({ exe: 'component:strata-engine', tokenizer: join(install, 'tok'), args: ['--max-context', '32768'], model_name: `Qwen ${id}`, port: 8080 }));
@@ -148,7 +150,7 @@ function packagedFixture({ engineUsable = true, updater = null, repair = false }
};
const native = createNativeControl({ control, directory: data, spawnProcess, fetcher, requests: () => requests });
const others = () => spawned.filter(s => !String(s.args[0]).endsWith('strata_mcp.py'));
- return { native, calls, saved, spawned, others, rpc, failStart: (v, times = Infinity) => { startFailure = v; startFailureLeft = times; }, catalog, hardware, install, root, cleanup: () => { rmSync(root, { recursive: true, force: true }); } };
+ return { native, calls, saved, spawned, others, rpc, failStart: (v, times = Infinity) => { startFailure = v; startFailureLeft = times; }, catalog, hardware, install, root, cleanup: () => { if (earlierInstallEnv === undefined) delete process.env.STRATA_INSTALL_DIR; else process.env.STRATA_INSTALL_DIR = earlierInstallEnv; 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'); };
@@ -521,3 +523,14 @@ test("preparing an adopted GGUF folder again never takes the folder's parent for
assert.equal(sent.gguf_dir, join(own, 'models', 'IQ3_S'));
} finally { await f.native.close(); f.cleanup(); }
});
+
+test('the app never adopts an older command-line install: Control is always told the app\'s own folder, and has its own settings file', async () => {
+ const f = packagedFixture();
+ try {
+ await f.native.refresh(true);
+ const asked = f.calls.filter(c => c[0] === 'installedModels').map(c => c[1]);
+ assert.ok(asked.length > 0 && asked.every(dir => dir === f.install || (dir && dir.toLowerCase() === f.install.toLowerCase())), `Control was asked about ${JSON.stringify(asked)}`);
+ } finally { f.cleanup(); }
+ const env = controlEnvironment({ dir: '/c' }, { env: { APPDATA: '/old/appdata' }, components: join(tmpdir(), 'Strata', 'components') });
+ assert.equal(env.STRATA_SETTINGS_FILE, join(tmpdir(), 'Strata', 'app-settings.json'));
+});
diff --git a/setup.py b/setup.py
index 60663fc3e..9e11b8f1e 100644
--- a/setup.py
+++ b/setup.py
@@ -4551,7 +4551,17 @@ def ram_ctx(model, ram, low_ram=False) -> int:
return max(c for c in CONTEXTS if c <= 131072 or (c != 204800 and (ctx_ram_need(model, c, low_ram) or 0) <= ram))
+def app_settings_file() -> Path | None:
+ """The desktop app keeps its own settings file (STRATA_SETTINGS_FILE, in the app's data folder) and never reads or writes the
+ one an older command-line Strata uses, so an old install is never adopted or moved."""
+ raw = os.environ.get("STRATA_SETTINGS_FILE")
+ return Path(raw) if raw else None
+
+
def settings_path() -> Path:
+ own = app_settings_file()
+ if own is not None:
+ return own
if WIN:
return Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") / "Strata" / "settings.json"
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "strata" / "settings.json"
@@ -4586,7 +4596,7 @@ def other_installs(settings: dict) -> list:
"""Strata folders besides this one that may hold model files: the ones this user ran before, and Strata* folders
next to this one (a zip unpacked again lands in e.g. `Strata-main (1)\\Strata-main`)."""
cands = [Path(p) for p in settings.get("installs", [])]
- for base in dict.fromkeys((home().parent, home().parent.parent)):
+ for base in dict.fromkeys(() if app_settings_file() else (home().parent, home().parent.parent)):
try:
for d in base.iterdir():
if d.is_dir() and d.name.lower().startswith("strata"):
diff --git a/strata_control/models.py b/strata_control/models.py
index eec730d6f..c5daeab0e 100644
--- a/strata_control/models.py
+++ b/strata_control/models.py
@@ -38,7 +38,11 @@ SUPPORTED_SELECTIONS = frozenset({"qwen/Q2_0", "qwen/IQ2_XS", "qwen/IQ3_XXS", "q
def settings_path() -> Path:
"""The user's Strata settings file: the same place setup.py writes it (%APPDATA%\\Strata\\settings.json, or
- $XDG_CONFIG_HOME/strata/settings.json)."""
+ $XDG_CONFIG_HOME/strata/settings.json). The desktop app sets STRATA_SETTINGS_FILE to a file of its own (in its data folder), so it
+ never reads an older command-line install's list of Strata folders."""
+ own = os.environ.get("STRATA_SETTINGS_FILE")
+ if own:
+ return Path(own)
if os.name == "nt":
return Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") / "Strata" / "settings.json"
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "strata" / "settings.json"
diff --git a/tests/terminal/test_app_isolation.py b/tests/terminal/test_app_isolation.py
new file mode 100644
index 000000000..1c9f5baf5
--- /dev/null
+++ b/tests/terminal/test_app_isolation.py
@@ -0,0 +1,68 @@
+"""The desktop app never adopts an older command-line Strata install (tester report 2026-10-17: the app wrote
+strata-gyro-gyro-s.log/.json into the tester's old T:\\Strata). The app points Control and the installer at a settings file of its
+own (STRATA_SETTINGS_FILE); the shared %APPDATA% / ~/.config file with the old install's folders is not read."""
+
+import json
+import os
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[2]
+sys.path.insert(0, str(ROOT))
+from strata_control import models # noqa: E402
+import setup as strata_setup # noqa: E402
+
+
+class AppIsolation(unittest.TestCase):
+ def setUp(self):
+ self.dir = tempfile.TemporaryDirectory()
+ self.addCleanup(self.dir.cleanup)
+ base = Path(self.dir.name)
+ self.old = base / "T-Strata"
+ self.old.mkdir()
+ (self.old / "strata-gyro-gyro-s.json").write_text(json.dumps({"exe": "strata.exe", "tokenizer": "t", "args": []}))
+ shared = base / "appdata" / "Strata"
+ shared.mkdir(parents=True)
+ (shared / "settings.json").write_text(json.dumps({"installs": [str(self.old)], "data_dir": str(base / "T-data")}))
+ (base / "xdg" / "strata").mkdir(parents=True)
+ (base / "xdg" / "strata" / "settings.json").write_text(json.dumps({"installs": [str(self.old)], "data_dir": str(base / "T-data")}))
+ self.app_data = base / "app" / "Strata"
+ self.app_data.mkdir(parents=True)
+ self.env = {"APPDATA": str(base / "appdata"), "XDG_CONFIG_HOME": str(base / "xdg")}
+ self.base = base
+ self.terminal = base / "terminal"
+ self.terminal.mkdir()
+
+ def test_the_terminal_still_remembers_the_old_install(self):
+ with mock.patch.dict(os.environ, self.env), mock.patch.dict(os.environ, {}, clear=False), mock.patch.object(models, "ROOT", self.terminal):
+ os.environ.pop("STRATA_SETTINGS_FILE", None)
+ os.environ.pop("STRATA_INSTALL_DIR", None)
+ self.assertEqual(models.resolve_install(), (self.old.resolve(), "remembered"))
+
+ def test_the_app_does_not(self):
+ env = {**self.env, "STRATA_SETTINGS_FILE": str(self.app_data / "app-settings.json")}
+ with mock.patch.dict(os.environ, env), mock.patch.object(models, "ROOT", self.terminal):
+ os.environ.pop("STRATA_INSTALL_DIR", None)
+ self.assertEqual(models.settings_path(), self.app_data / "app-settings.json")
+ self.assertEqual(models.remembered_installs(), [])
+ self.assertEqual(models.resolve_install(), (self.terminal, "default"))
+ self.assertEqual(strata_setup.settings_path(), self.app_data / "app-settings.json")
+ self.assertEqual(strata_setup.load_settings(), {})
+ # the installer's own list of "other installs" has no sibling scan and no shared settings
+ self.assertEqual(strata_setup.other_installs(strata_setup.load_settings()), [])
+
+ def test_saving_settings_goes_to_the_app_file_only(self):
+ env = {**self.env, "STRATA_SETTINGS_FILE": str(self.app_data / "app-settings.json")}
+ shared = self.base / "appdata" / "Strata" / "settings.json"
+ before = shared.read_bytes()
+ with mock.patch.dict(os.environ, env):
+ strata_setup.save_settings({"data_dir": str(self.app_data / "data")})
+ self.assertEqual(shared.read_bytes(), before)
+ self.assertIn("data_dir", json.loads((self.app_data / "app-settings.json").read_text()))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tools/strata_mcp.py b/tools/strata_mcp.py
index 93fb8f9b8..a0eec205b 100644
--- a/tools/strata_mcp.py
+++ b/tools/strata_mcp.py
@@ -483,6 +483,8 @@ class Strata:
# ---- paths
def settings_path(self) -> Path:
+ if os.environ.get("STRATA_SETTINGS_FILE"):
+ return Path(os.environ["STRATA_SETTINGS_FILE"])
if WIN:
return Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") / "Strata" / "settings.json"
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "strata" / "settings.json"