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++

storage and version: one Downloaded models list from the real files, Check folder unloads nothing, app version shown as Strata

Niko122131030b170a54
diff --git a/apps/host/server/app-version.mjs b/apps/host/server/app-version.mjs
index ee915fafc..73ded1ee5 100644
--- a/apps/host/server/app-version.mjs
+++ b/apps/host/server/app-version.mjs
@@ -17,3 +17,9 @@ export function appVersionFrom({ env = process.env, here }) {
} catch { /* not a checkout */ }
return 'dev';
}
+
+/** The version "Strata" means on screen and in the update check: the app's own, not Strata Control's (see src/lib/app-version.ts). */
+export function appVersionToShow(app, control) {
+ const real = value => (typeof value === 'string' && value.trim() && value.trim().toLowerCase() !== 'dev' ? value.trim() : null);
+ return real(app) ?? real(control) ?? (typeof app === 'string' && app.trim() ? app.trim() : null);
+}
diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs
index ede15db88..144423df5 100644
--- a/apps/host/server/index.mjs
+++ b/apps/host/server/index.mjs
@@ -58,10 +58,11 @@ import { createChatFolders, openFile, resolveChatFile, previewFile, rawFile, cre
import { createLlmProxy, samplingFromExpert } from './agent/llm-shape.mjs';
import { checkUpdates, checkComponentUpdates } from './updates.mjs';
import { createAppUi } from './app-ui.mjs';
-import { appVersionFrom } from './app-version.mjs';
+import { appVersionFrom, appVersionToShow } from './app-version.mjs';
import { createImageModels } from './image-models.mjs';
import { createRuntimeModels } from './runtime-models.mjs';
import { createNativeControl } from './native-control.mjs';
+import { nativeUnloadPlan } from './storage-check.mjs';
import { installBundledEngine } from './bundled-engine.mjs';
import { findControl, createControl, componentsDirectory } from './control-runtime.mjs';
import { forbidden as acquisitionForbidden } from './acquisition.mjs';
@@ -1272,7 +1273,7 @@ async function api(req, res, path, method, url) {
if (path === '/api/setup' && method === 'GET') return json(res, 200, setupState());
if (path === '/api/updates/check' && method === 'GET' && control?.updateCheck) return json(res, 200, await checkComponentUpdates({ control, appUpdater, appVersion: process.env.STRATA_APP_VERSION || null }));
- if (path === '/api/updates/check' && method === 'GET') return json(res, 200, await checkUpdates({ appVersion:native.state().version??setupState().app.version, engineVersion:native.state().available?(native.state().installed?.engine?.version??null):(await engine.config()).engine.version }));
+ if (path === '/api/updates/check' && method === 'GET') return json(res, 200, await checkUpdates({ appVersion:appVersionToShow(setupState().app.version,native.state().version), engineVersion:native.state().available?(native.state().installed?.engine?.version??null):(await engine.config()).engine.version }));
if (path === '/api/setup/step' && method === 'POST') {
const body = await readBody(req);
@@ -1334,7 +1335,9 @@ async function api(req, res, path, method, url) {
if (storageChanging || modelOperations || models.directoryBusy() || imageModels.busy()||native.state().jobs.some(j=>j.state==='running')) return error(res, 409, 'Finish or cancel model downloads and loading before changing the folder.');
if (serving.state().requests.some(r => ['queued', 'generating'].includes(r.state))) return error(res, 409, 'Finish or cancel model requests before changing the folder.');
if (changed && instances.length && body.unload !== true) return error(res, 409, 'Unload the current models before changing the folder.');
- if(native.state().instances.length){if(!body.unload)return error(res,409,'Unload native models before changing the model folder.');for(const instance of native.state().instances)await native.unload(instance.id);}
+ const nativePlan=nativeUnloadPlan({changed,unload:body.unload,instances:native.state().instances});
+ if(nativePlan.refuse)return error(res,409,nativePlan.refuse);
+ for(const id of nativePlan.ids)await native.unload(id);
storageChanging = true;
try {
if (changed) {
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjs
index 1a99dbbaa..19fc1bb3f 100644
--- a/apps/host/server/native-control.mjs
+++ b/apps/host/server/native-control.mjs
@@ -67,7 +67,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
for(const name of names){const path=join(dir,name),config=readJson(path,null);if(!config||typeof config!=='object')continue;
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 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,sharedBytes:entry.sharedBytes??entry.shared_bytes,removableGb:entry.removableGb??entry.removable_gb,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].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});}
@@ -96,12 +96,12 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
packagedInstall=list.install_dir;
const engine=await control.engine();
const installer=await mcpCall('strata_status',{hardware:true}).catch(error=>({error:error.message}));
- const disk=Object.fromEntries((installer.installed?.models??[]).map(m=>[m.model,{diskGb:m.disk_gb,diskBytes:m.disk_bytes}]));
- const models=(list.models??[]).filter(m=>m.component_status!=='invalid'&&m.source_config).map(m=>({...(disk[m.id]??{}),model:m.id,config:basename(m.source_config),configPath:m.source_config,model_name:m.name,context:m.context_tokens??0,backend:m.backend,ready:m.component_status==='present',images:'off',port:undefined,last_used:null}));
+ const disk=Object.fromEntries((installer.installed?.models??[]).map(m=>[m.model,{diskGb:m.disk_gb,diskBytes:m.disk_bytes,sharedBytes:m.shared_bytes,removableGb:m.removable_gb,partsMissing:m.parts_missing??0}]));
+ const models=(list.models??[]).filter(m=>m.component_status!=='invalid'&&m.source_config).map(m=>({...(disk[m.id]??{}),model:m.id,config:basename(m.source_config),configPath:m.source_config,model_name:m.name,context:m.context_tokens??0,backend:m.backend,ready:m.component_status==='present'&&!(disk[m.id]?.partsMissing),images:'off',port:undefined,last_used:null}));
const cores=os.cpus().length;
return {summary:engine.usable?`Strata Control is ready; engine ${engine.engine.version} (${engine.engine.platform}-${engine.engine.backend}).`:(engine.notice??'No engine for this PC was found.'),
installDir:list.install_dir,engine:{usable:engine.usable,notice:engine.notice,version:engine.engine?.version??null,backend:engine.backend,componentsDir:engine.components_dir,previous:engine.previous??null,pinned:engine.pinned??null,updateNotice:engine.update_notice??null},
- installed:{strata_folder:list.install_dir,data_folder:null,engine:engine.engine?{version:engine.engine.version,backend:engine.engine.backend,folder:engine.engine.root}:{folder:null,version:null},models},
+ installed:{strata_folder:list.install_dir,data_folder:null,engine:engine.engine?{version:engine.engine.version,backend:engine.engine.backend,folder:engine.engine.root}:{folder:null,version:null},models,usage:installer.installed?.usage??null},
hardware:installer.hardware?{...installer.hardware,cpu:{...(installer.hardware.cpu??{}),cores:installer.hardware.cpu?.cores??cores},gpus:installer.hardware.gpus??[]}:{cpu:{cores},ram_gb:Math.round(os.totalmem()/1024**3),gpus:[]},
recommendation:installer.recommendation??null,installerError:installer.error??null,install:installer.install??null,running:null};
}
diff --git a/apps/host/server/storage-check.mjs b/apps/host/server/storage-check.mjs
new file mode 100644
index 000000000..fc09a1979
--- /dev/null
+++ b/apps/host/server/storage-check.mjs
@@ -0,0 +1,13 @@
+/**
+ * What changing (or only checking) the model folder does to the models that are loaded.
+ *
+ * "Check folder" reads the SAME folder again, so nothing that is loaded may be touched: it used to unload every optimized model
+ * and the status went to "No model loaded" (QA 2026-10-18, O01). Only an actual change of folder unloads them, and only when
+ * the person agreed (the screen says so first and offers "Unload and change directory").
+ */
+export function nativeUnloadPlan({ changed, unload, instances }) {
+ const running = Array.isArray(instances) ? instances : [];
+ if (!running.length || !changed) return { refuse: null, ids: [] };
+ if (unload !== true) return { refuse: 'Unload native models before changing the model folder.', ids: [] };
+ return { refuse: null, ids: running.map(i => i.id) };
+}
diff --git a/apps/host/src/components/NativeDelete.tsx b/apps/host/src/components/NativeDelete.tsx
index 07e9ba62f..97cf3fd33 100644
--- a/apps/host/src/components/NativeDelete.tsx
+++ b/apps/host/src/components/NativeDelete.tsx
@@ -14,7 +14,9 @@ export function NativeDeleteDialog({ id, onClose }: { id: string | null; onClose
const label = (() => { const sizes = nativeCatalogModels(native?.catalog?.families ?? []).flatMap(f => f.sizes); const v = sizes.find(s => s.id === id); return v ? `${catalogVersionLabel(v)} · ${v.model}` : entry?.model_name ?? id ?? ''; })();
const running = !!native?.instances.some(i => i.model === id);
const busy = !!native?.jobs.some(j => j.state === 'running');
- const gb = entry?.diskGb ?? 0;
+ const size = entry?.diskGb ?? 0, gb = entry?.removableGb ?? size;
+ // Files in the person's own folder (an adopted GGUF) stay where they are: only the entry is removed.
+ const keepsFiles = entry?.removableGb === 0 && size > 0;
function close() { if (!pending) { onClose(); setError(''); } }
async function remove() {
setPending(true);
@@ -36,8 +38,8 @@ export function NativeDeleteDialog({ id, onClose }: { id: string | null; onClose
finally { setPending(false); }
}
return <Dialog open={!!id} compact title={tr("Delete this version?")} onClose={close} actions={<><Btn disabled={pending} onClick={close}>{tr("Keep version")}</Btn><Btn variant="danger" disabled={pending || busy || !entry} onClick={() => void remove()}>{tr(pending ? 'Working…' : 'Delete version')}</Btn></>}>
- <p>{tr(label)}{tr(gb ? ` · ${sizeGb(gb)}` : '')}</p>
- {tr(entry ? <p className="small muted storage-delete-note">{tr('Remove {0} GB of downloaded files. You can download this version again.', [gb ? gb.toFixed(1) : '0'])}{tr(running ? ' ' : '')}{tr(running ? 'The running model will be unloaded and its files deleted.' : '')}</p> : <p className="small muted">{tr("This version is no longer downloaded.")}</p>)}
+ <p>{tr(label)}{tr(size ? ` · ${sizeGb(size)}` : '')}</p>
+ {tr(!entry ? <p className="small muted">{tr("This version is no longer downloaded.")}</p> : <p className="small muted storage-delete-note">{keepsFiles ? tr('These files are in your own folder, so they stay there. Only the entry in Strata is removed.') : tr('Remove {0} GB of downloaded files. You can download this version again.', [gb ? gb.toFixed(1) : '0'])}{tr(running ? ' ' : '')}{tr(running ? (keepsFiles ? 'The running model will be unloaded.' : 'The running model will be unloaded and its files deleted.') : '')}</p>)}
{tr(error ? <ErrorNotice message={error}/> : null)}
</Dialog>;
}
diff --git a/apps/host/src/components/SettingsStorage.tsx b/apps/host/src/components/SettingsStorage.tsx
index 1f7778fc5..10700d6a6 100644
--- a/apps/host/src/components/SettingsStorage.tsx
+++ b/apps/host/src/components/SettingsStorage.tsx
@@ -1,6 +1,6 @@
import { tr } from '../lib/i18n';
import { useState } from 'react';
-import { Btn, Dialog, ErrorNotice, Field, Icon, Select } from './ui';
+import { Btn, Dialog, ErrorNotice, Field, Icon } from './ui';
import { changeModelDirectory, getState, lifecycleStatus, removeVariant, runtimeModelAction, unloadModel, useStore } from '../lib/store';
import { pickerGroups, pickerVersionState } from '../lib/model-picker';
import { sizeGb } from '../lib/format';
@@ -17,6 +17,12 @@ export function SettingsStorage() {
const [directoryPending, setDirectoryPending] = useState(false), [directoryError, setDirectoryError] = useState(''), [notice, setNotice] = useState('');
const library = state.library;
const versions = library ? pickerGroups(library).flatMap(group => group.versions) : [];
+ // ONE list and ONE total: the optimized models (sizes from their real files, shared files counted once) and the other local models together.
+ const nativeModels = native?.installed?.models ?? [];
+ const sharedGb = (native?.installed?.usage?.shared_bytes ?? 0) / 1e9;
+ const nativeGb = native?.installed?.usage ? native.installed.usage.total_gb : nativeModels.reduce((n, m) => n + (m.diskGb ?? 0), 0);
+ const totalGb = nativeGb + versions.reduce((n, v) => n + (v.diskGb ?? 0), 0);
+ const rows = nativeModels.length + versions.length;
const version = versions.find(v => v.id === selected);
const running = !!version && (state.runtime?.instances.some(i => i.variantId === version.id) || library?.loaded === version.id);
const lifecycle = lifecycleStatus(state);
@@ -29,7 +35,7 @@ export function SettingsStorage() {
setDirectoryError('');
setNotice('');
try {
- const result = await changeModelDirectory(path, true);
+ const result = await changeModelDirectory(path, path.trim() !== currentDirectory); // checking the same folder unloads nothing
const count = result.library.variants.filter(v => ['installed', 'loaded'].includes(v.state)).length + result.imageModels.variants.filter(v => v.state === 'installed').length;
setEditing(false);
setNotice(`${count} ${count === 1 ? 'version' : 'versions'} found${result.library.mode === 'simulated' ? ' in this example library' : ''}. Future downloads will use this folder.`);
@@ -92,15 +98,13 @@ export function SettingsStorage() {
{tr(notice ? <p className="small storage-directory__notice" role="status"><Icon name="check" size={15}/>{tr(notice)}</p> : null)}
{tr(directoryError ? <ErrorNotice message={directoryError}/> : null)}
</section>
- <Field label={tr("Downloaded models")} hint={tr("{0} on this computer. Choose a version to delete its files.", [sizeGb(library?.disk.usedGb ?? 0)])}>
- <Select value="" ariaLabel={tr("Delete downloaded model version")} menuSize="comfortable" menuMinWidth={520} singleLine disabled={!versions.length || pending || directoryPending} options={[
- { value: '', label: versions.length ? 'Choose a version…' : 'No downloaded models', disabled: true },
- ...versions.map(v => ({ value: v.id, label: `${v.local ? v.name : v.family} · ${v.quant} · ${sizeGb(v.diskGb)}${v.local ? ' · Local' : ''}`, disabled: pickerVersionState(v, library?.loaded ?? null).busy })),
- ]} onChange={id => { setError(''); setSelected(id); }}/>
+ <Field label={tr("Downloaded models")} hint={tr("{0} on this computer. Choose a version to delete its files.", [sizeGb(totalGb)])}>
+ {tr(rows ? <ul className="storage-models" aria-label={tr("Downloaded models")}>
+ {tr(nativeModels.map(m => <li className="storage-model" key={m.model}><span className="storage-model__name" title={m.model_name || m.model}><strong>{nativeShortName(m.model)}</strong>{tr(native?.instances.some(i => i.model === m.model) ? <small className="muted">{tr('Loaded')}</small> : null)}</span><span className="storage-model__size muted">{tr(sizeGb(m.diskGb ?? 0))}</span><Btn size="sm" variant="danger" disabled={!!native?.jobs.some(j => j.state === 'running')} onClick={() => setNativeDeleting(m.model)}>{tr("Delete")}</Btn></li>))}
+ {tr(versions.map(v => <li className="storage-model" key={v.id}><span className="storage-model__name" title={`${v.family} · ${v.quant}`}><strong>{`${v.local ? v.name : v.family} · ${v.quant}`}</strong>{tr(v.local ? <small className="muted">{tr('Local')}</small> : null)}{tr(v.id === library?.loaded ? <small className="muted">{tr('Loaded')}</small> : null)}</span><span className="storage-model__size muted">{tr(sizeGb(v.diskGb))}</span><Btn size="sm" variant="danger" disabled={pickerVersionState(v, library?.loaded ?? null).busy || pending || directoryPending} onClick={() => { setError(''); setSelected(v.id); }}>{tr("Delete")}</Btn></li>))}
+ {tr(sharedGb > 0 ? <li className="storage-model storage-model--shared"><span className="storage-model__name"><strong>{tr("Shared files")}</strong><small className="muted">{tr("Used by more than one model")}</small></span><span className="storage-model__size muted">{tr(sizeGb(sharedGb))}</span><span/></li> : null)}
+ </ul> : <p className="small muted">{tr("No downloaded models")}</p>)}
</Field>
- {tr(native?.installed?.models.length ? <Field label={tr("Downloaded models")} hint={tr("{0} on this computer. Choose a version to delete its files.", [sizeGb((native.installed.models).reduce((n, m) => n + (m.diskGb ?? 0), 0))])}>
- <ul className="storage-models">{tr(native.installed.models.map(m => <li className="storage-model" key={m.model}><span className="storage-model__name" title={m.model_name || m.model}><strong>{nativeShortName(m.model)}</strong>{tr(native.instances.some(i => i.model === m.model) ? <small className="muted">{tr('Loaded')}</small> : null)}</span><span className="storage-model__size muted">{tr(sizeGb(m.diskGb ?? 0))}</span><Btn size="sm" variant="danger" disabled={!!native.jobs.some(j => j.state === 'running')} onClick={() => setNativeDeleting(m.model)}>{tr("Delete")}</Btn></li>))}</ul>
- </Field> : null)}
<NativeDeleteDialog id={nativeDeleting} onClose={() => setNativeDeleting(null)}/>
<Dialog open={!!selected} compact title={tr(version?.local ? 'Remove from Strata?' : `Delete ${version?.quant ?? 'model version'}?`)} onClose={close} actions={<><Btn disabled={pending} onClick={close}>{tr("Keep version")}</Btn><Btn variant="danger" disabled={pending || unavailable} onClick={() => void remove()}>{tr(pending ? 'Working…' : version?.local ? 'Remove model' : 'Delete version')}</Btn></>}>
<p>{tr(version ? `${version.local ? version.name : version.family} · ${version.quant} · ${sizeGb(version.diskGb)}` : 'This version is no longer downloaded.')}</p>
diff --git a/apps/host/src/components/SettingsUpdates.tsx b/apps/host/src/components/SettingsUpdates.tsx
index 1f3e65c91..42cb142d0 100644
--- a/apps/host/src/components/SettingsUpdates.tsx
+++ b/apps/host/src/components/SettingsUpdates.tsx
@@ -6,11 +6,12 @@ import { useStore } from '../lib/store';
import type { SoftwareUpdate, UpdateCheckResult } from '../lib/types';
import { nativeAction, useNative } from '../lib/native';
import { NativeProgress } from './NativeModels';
+import { appVersionLabel } from '../lib/app-version';
/** Installed versions are real host values. Installation needs a host updater. */
export function SettingsUpdates() {
const native = useNative();
const [confirm, setConfirm] = useState('');
- const appVersion = useStore(s => s.setup?.app.version);
+ const appVersion = appVersionLabel(useStore(s => s.setup?.app.version), native?.version);
const engineVersion = useStore(s => s.engine?.engine.version);
const [rollback, setRollback] = useState(false);
const [component, setComponent] = useState<'strata' | 'engine'>('strata');
@@ -19,7 +20,7 @@ export function SettingsUpdates() {
const [error, setError] = useState('');
const request = useRef<AbortController | null>(null);
useEffect(() => () => request.current?.abort(), []);
- const installed = component === 'strata' ? native?.version ?? appVersion : native?.available ? (native.installed?.engine?.version ?? 'Not installed') : engineVersion;
+ const installed = component === 'strata' ? appVersion : native?.available ? (native.installed?.engine?.version ?? 'Not installed') : engineVersion;
const active = native?.jobs.find(j => j.state === 'running');
async function operate(kind: string) {
setError('');
@@ -68,7 +69,7 @@ export function SettingsUpdates() {
}
return <>
<div className="settings-versions" aria-busy={checking}>
- {tr(versionRow('Strata', native?.version ?? appVersion, result?.strata))}
+ {tr(versionRow('Strata', appVersion, result?.strata))}
{tr(versionRow('Engine', native?.available ? (native.installed?.engine?.version ?? 'Not installed') : engineVersion, result?.engine))}
<div className="settings-update-actions"><Btn size="sm" icon="refresh" disabled={checking} className={checking ? 'settings-update-checking' : undefined} onClick={() => void check()}>{tr(checking ? 'Checking…' : error || result?.strata.status === 'error' ? 'Try again' : result ? 'Check again' : 'Check for updates')}</Btn><Btn size="sm" variant="ghost" onClick={() => setRollback(true)}>{tr("Roll back\u2026")}</Btn></div>
<div className="settings-update-inline" role="status" aria-live="polite">{tr(checking ? 'Checking for new versions…' : error ? <span className="inline-error">{tr(error)}</span> : result ? <><span className="sr-only">{tr(result.strata.message)} {tr(result.engine.message)} </span>{tr("Checked at ")}{tr(new Date(result.checkedAt).toLocaleTimeString(localeTag(), { hour: '2-digit', minute: '2-digit' }))}</> : null)}</div>
@@ -85,3 +86,12 @@ export function SettingsUpdates() {
<Dialog open={!!confirm} compact title={tr(confirm === 'update-strata' ? 'Update Strata?' : 'Update engine?')} onClose={() => setConfirm('')} actions={<><Btn onClick={() => setConfirm('')}>{tr("Cancel")}</Btn><Btn variant="primary" disabled={!!active || (native?.instances.length ?? 0) > 0} onClick={() => void operate(confirm)}>{tr("Update")}</Btn></>}><p>{tr("The native installer updates the installation. Model files and settings are kept. Unload native models before updating.")}</p>{tr((native?.instances.length ?? 0) > 0 ? <p className="small muted">{tr("Open Models and unload the running native models first.")}</p> : null)}</Dialog>
</>;
}
+
+/** "Strata 0.2.0-beta · Engine 0.1.45.3": the app's own version first, the engine's beside it (About). */
+export function AboutVersions() {
+ const native = useNative();
+ const app = appVersionLabel(useStore(s => s.setup?.app.version), native?.version);
+ const engineVersion = useStore(s => s.engine?.engine.version);
+ const engine = native?.available ? native.installed?.engine?.version : engineVersion;
+ return <p className="settings-about-version"><strong>{tr("Strata")} {app ?? ''}</strong>{engine ? <span className="muted"> · {tr("Engine")} {engine}</span> : null}</p>;
+}
diff --git a/apps/host/src/lib/app-version.ts b/apps/host/src/lib/app-version.ts
new file mode 100644
index 000000000..258c97f82
--- /dev/null
+++ b/apps/host/src/lib/app-version.ts
@@ -0,0 +1,9 @@
+/**
+ * The version the person sees as "Strata". It is the DESKTOP APP's version (0.2.0-beta), not that of Strata Control, the tools the app runs
+ * (0.1.45, the version of the Terminal). Showing Control's number as "Strata" made a tester report "Strata 0.1.45" for the 0.2.0-beta app.
+ * Without a real app version (a source checkout reports 'dev') the other number is the best there is.
+ */
+export function appVersionLabel(app: string | null | undefined, control?: string | null): string | undefined {
+ const real = (v: string | null | undefined) => (typeof v === 'string' && v.trim() && v.trim().toLowerCase() !== 'dev' ? v.trim() : undefined);
+ return real(app) ?? real(control) ?? (typeof app === 'string' && app.trim() ? app.trim() : undefined);
+}
diff --git a/apps/host/src/lib/native.ts b/apps/host/src/lib/native.ts
index e30f2985f..6053f2112 100644
--- a/apps/host/src/lib/native.ts
+++ b/apps/host/src/lib/native.ts
@@ -10,7 +10,7 @@ export interface NativeJob {id:string;kind:string;guided?:boolean;model?:string;
export interface NativeInstance {id:string;apiModelId:string;model:string;label:string;aliases?:string[];vision?:boolean;resourceProfile?:'work'|'performance'|null;context?:number;port:number;gpus:number[];status:'loading'|'ready'|'unloading'|'error';phase:string;loadedAt:string;error:string|null;metrics:Record<string,any>|null}
export interface NativeState {
/** The picture reader (strata-vision) is installed with the engine, so models marked for pictures can read them here. */
- visionReader?: boolean;available:boolean;repo:string;downloadDirectory?:string;version?:string|null;summary:string;error:string|null;catalog:{families:NativeFamily[];contexts:number[];recommendation:{family:string|null;model:string|null;context?:number;why?:string};context_note:string}|null;installed:{models:{model:string;config:string;model_name:string;ready:boolean;/** The picture-reading files are on this computer (notes-split-agent8.md, item 8). */visionPrepared?:boolean;context?:number;kv?:string;images?:string;visionEnabled?:boolean;visionDevice?:string;lowRamMode?:string;resourceProfile?:'work'|'performance';dataFolder?:string;diskGb?:number;diskBytes?:number;missing_files?:string[]}[];data_folder:string;engine:{version:string|null}}|null;hardware:{ram_gb:number;gpus:{index:number;name:string;vram_gb:number;usable:boolean}[]}|null;fields:NativeField[];instances:NativeInstance[];defaultId:string|null;jobs:NativeJob[];capabilities:{responses?:boolean;updates:boolean;rollback:boolean;calibration:boolean;componentUpdates?:boolean}}
+ visionReader?: boolean;available:boolean;repo:string;downloadDirectory?:string;version?:string|null;summary:string;error:string|null;catalog:{families:NativeFamily[];contexts:number[];recommendation:{family:string|null;model:string|null;context?:number;why?:string};context_note:string}|null;installed:{models:{model:string;config:string;model_name:string;ready:boolean;/** The picture-reading files are on this computer (notes-split-agent8.md, item 8). */visionPrepared?:boolean;context?:number;kv?:string;images?:string;visionEnabled?:boolean;visionDevice?:string;lowRamMode?:string;resourceProfile?:'work'|'performance';dataFolder?:string;diskGb?:number;diskBytes?:number;/** Files this model shares with another (the picture reader, the draft layer): counted once, in `usage`. */sharedBytes?:number;/** What Delete frees: files in Strata's own folders that no other model uses. */removableGb?:number;missing_files?:string[]}[];/** What all models take on disk, from their real files, shared files counted once. */usage?:{total_bytes:number;total_gb:number;shared_bytes:number;shared_gb:number;models:Record<string,{bytes:number;gb:number}>}|null;data_folder:string;engine:{version:string|null}}|null;hardware:{ram_gb:number;gpus:{index:number;name:string;vram_gb:number;usable:boolean}[]}|null;fields:NativeField[];instances:NativeInstance[];defaultId:string|null;jobs:NativeJob[];capabilities:{responses?:boolean;updates:boolean;rollback:boolean;calibration:boolean;componentUpdates?:boolean}}
let state:NativeState|null=null;
const listeners=new Set<()=>void>();
function put(value:NativeState){if(state&&JSON.stringify(state)===JSON.stringify(value))return;state=value;listeners.forEach(fn=>fn());}
diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.json
index 918a1fad1..832bc343e 100644
--- a/apps/host/src/locales/de.json
+++ b/apps/host/src/locales/de.json
@@ -3235,5 +3235,10 @@
"s3239": "Die Engine für diesen PC wird heruntergeladen…",
"s3240": "{0} wird vorbereitet",
"s3241": "Teile des Downloads",
- "s3242": "Bildleser"
+ "s3242": "Bildleser",
+ "s3243": "Gemeinsame Dateien",
+ "s3244": "Von mehr als einem Modell genutzt",
+ "s3245": "Diese Dateien liegen in deinem eigenen Ordner und bleiben dort. Nur der Eintrag in Strata wird entfernt.",
+ "s3246": "Das laufende Modell wird entladen.",
+ "s3247": "Lokal"
}
diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.json
index 7502344ce..cd8a27c5c 100644
--- a/apps/host/src/locales/en.json
+++ b/apps/host/src/locales/en.json
@@ -3235,5 +3235,10 @@
"s3239": "Downloading the engine for this PC…",
"s3240": "Preparing {0}",
"s3241": "Download parts",
- "s3242": "Picture reader"
+ "s3242": "Picture reader",
+ "s3243": "Shared files",
+ "s3244": "Used by more than one model",
+ "s3245": "These files are in your own folder, so they stay there. Only the entry in Strata is removed.",
+ "s3246": "The running model will be unloaded.",
+ "s3247": "Local"
}
diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.json
index e9710a805..f1ca1558f 100644
--- a/apps/host/src/locales/es.json
+++ b/apps/host/src/locales/es.json
@@ -3235,5 +3235,10 @@
"s3239": "Descargando el motor para este PC…",
"s3240": "Preparando {0}",
"s3241": "Partes de la descarga",
- "s3242": "Lector de imágenes"
+ "s3242": "Lector de imágenes",
+ "s3243": "Archivos compartidos",
+ "s3244": "Los usa más de un modelo",
+ "s3245": "Estos archivos están en tu propia carpeta y se quedan allí. Solo se quita la entrada en Strata.",
+ "s3246": "El modelo en ejecución se descargará de la memoria.",
+ "s3247": "Local"
}
diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.json
index 8b48a9747..d971d5298 100644
--- a/apps/host/src/locales/ja.json
+++ b/apps/host/src/locales/ja.json
@@ -3235,5 +3235,10 @@
"s3239": "このパソコン用のエンジンをダウンロード中…",
"s3240": "{0} を準備中",
"s3241": "ダウンロードの内訳",
- "s3242": "画像読み取り"
+ "s3242": "画像読み取り",
+ "s3243": "共有ファイル",
+ "s3244": "複数のモデルで使われています",
+ "s3245": "これらのファイルはあなた自身のフォルダーにあるため、そのまま残ります。Strata 上の項目だけが削除されます。",
+ "s3246": "動作中のモデルの読み込みを解除します。",
+ "s3247": "ローカル"
}
diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.json
index f1274ebc0..3d548412c 100644
--- a/apps/host/src/locales/ko.json
+++ b/apps/host/src/locales/ko.json
@@ -3235,5 +3235,10 @@
"s3239": "이 PC용 엔진 다운로드 중…",
"s3240": "{0} 준비 중",
"s3241": "다운로드 구성",
- "s3242": "이미지 읽기"
+ "s3242": "이미지 읽기",
+ "s3243": "공유 파일",
+ "s3244": "여러 모델에서 함께 사용",
+ "s3245": "이 파일들은 내 폴더에 있으므로 그대로 남습니다. Strata의 항목만 삭제됩니다.",
+ "s3246": "실행 중인 모델을 해제합니다.",
+ "s3247": "로컬"
}
diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.json
index a3c2748b1..be22c5f91 100644
--- a/apps/host/src/locales/pt.json
+++ b/apps/host/src/locales/pt.json
@@ -3235,5 +3235,10 @@
"s3239": "Baixando o mecanismo para este PC…",
"s3240": "Preparando {0}",
"s3241": "Partes do download",
- "s3242": "Leitor de imagens"
+ "s3242": "Leitor de imagens",
+ "s3243": "Arquivos compartilhados",
+ "s3244": "Usados por mais de um modelo",
+ "s3245": "Esses arquivos estão na sua própria pasta e continuam lá. Só a entrada no Strata é removida.",
+ "s3246": "O modelo em execução será descarregado.",
+ "s3247": "Local"
}
diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.json
index 453038915..47c6551f9 100644
--- a/apps/host/src/locales/ru.json
+++ b/apps/host/src/locales/ru.json
@@ -3235,5 +3235,10 @@
"s3239": "Скачивание движка для этого компьютера…",
"s3240": "Подготовка: {0}",
"s3241": "Части загрузки",
- "s3242": "Чтение изображений"
+ "s3242": "Чтение изображений",
+ "s3243": "Общие файлы",
+ "s3244": "Используются несколькими моделями",
+ "s3245": "Эти файлы лежат в вашей папке и останутся там. Из Strata удаляется только запись.",
+ "s3246": "Работающая модель будет выгружена.",
+ "s3247": "Локальная"
}
diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.json
index 5452b649b..66b33556e 100644
--- a/apps/host/src/locales/zh.json
+++ b/apps/host/src/locales/zh.json
@@ -3235,5 +3235,10 @@
"s3239": "正在下载适用于此电脑的引擎…",
"s3240": "正在准备 {0}",
"s3241": "下载分段",
- "s3242": "图片读取组件"
+ "s3242": "图片读取组件",
+ "s3243": "共享文件",
+ "s3244": "被多个模型共用",
+ "s3245": "这些文件在你自己的文件夹中,会保留在原处,只会从 Strata 中移除该条目。",
+ "s3246": "将卸载运行中的模型。",
+ "s3247": "本地"
}
diff --git a/apps/host/src/screens/Settings.tsx b/apps/host/src/screens/Settings.tsx
index d608f2d9c..a14854f27 100644
--- a/apps/host/src/screens/Settings.tsx
+++ b/apps/host/src/screens/Settings.tsx
@@ -7,7 +7,7 @@ import { SettingsModels } from '../components/SettingsModels';
import { SettingsTools } from '../components/SettingsTools';
import { SettingsStorage } from '../components/SettingsStorage';
import { PrivacyNotes } from '../components/PrivacyNotes';
-import { SettingsUpdates } from '../components/SettingsUpdates';
+import { AboutVersions, SettingsUpdates } from '../components/SettingsUpdates';
import { NativeOperations } from '../components/NativeOperations';
import { FontChoice } from '../components/FontChoice';
import { LANGUAGES } from '../lib/i18n';
@@ -58,7 +58,7 @@ export function SettingsScreen() {
{tr(panel.sections.map(section => <section className="settings-section" key={section}>
<h2 className="h3" style={{ marginBottom: 14 }}>{tr(section)}</h2>
<div className="st-card st-card--flush">
- {tr(section === 'About' ? <div className="settings-about-brand"><Brand variant="lockup" height={28}/></div> : null)}
+ {tr(section === 'About' ? <div className="settings-about-brand"><Brand variant="lockup" height={28}/><AboutVersions/></div> : null)}
{tr(section === 'Storage' ? <SettingsStorage /> : null)}
{tr(section === 'Privacy' ? <PrivacyNotes /> : null)}
{tr(section === 'Update' ? <SettingsUpdates /> : null)}
diff --git a/apps/host/src/styles/app.css b/apps/host/src/styles/app.css
index 842f5f018..d3b342187 100644
--- a/apps/host/src/styles/app.css
+++ b/apps/host/src/styles/app.css
@@ -5653,7 +5653,8 @@ textarea.config-editor.st-input {
.key-input .st-input { min-width: 0; flex: 1; }
.dialog-feature-icon { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid var(--st-line); border-radius: 16px; background: var(--st-surface-2); color: var(--st-accent); }
.key-url { overflow-wrap: anywhere; padding: 14px; background: var(--st-surface-2); border-radius: 10px; }
-.settings-about-brand { display: flex; padding: 22px 20px 0; }
+.settings-about-brand { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 22px 20px 0; }
+.settings-about-version { margin: 0; font-size: var(--st-fs-base); }
.prompt-progress { display: flex; align-items: center; gap: 16px; }
.prompt-progress > .st-bar { flex: 1; }
.hardware-section { display: flex; flex-direction: column; gap: 20px; }
@@ -7493,3 +7494,5 @@ textarea {
.st-btn.btn-neutral { background: var(--st-surface); color: var(--st-ink); border: 1px solid var(--st-line); box-shadow: none; }
.st-btn.btn-neutral:hover:not(:disabled) { background: var(--st-surface-2); }
.native-vision-missing { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: var(--st-fs-sm); color: var(--st-ink-soft); }
+.storage-model--shared { background: var(--st-surface-2); }
+.storage-model--shared small { font-size: var(--st-fs-xs); }
diff --git a/apps/host/tests/qa1-storage.test.mjs b/apps/host/tests/qa1-storage.test.mjs
new file mode 100644
index 000000000..af23db09e
--- /dev/null
+++ b/apps/host/tests/qa1-storage.test.mjs
@@ -0,0 +1,61 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import { nativeUnloadPlan } from '../server/storage-check.mjs';
+
+const loaded = [{ id: 'a', model: 'gyro-gyro-s' }, { id: 'b', model: 'iq3_s' }];
+
+test('O01: checking the same folder unloads nothing', () => {
+ assert.deepEqual(nativeUnloadPlan({ changed: false, unload: true, instances: loaded }), { refuse: null, ids: [] });
+ assert.deepEqual(nativeUnloadPlan({ changed: false, unload: undefined, instances: loaded }), { refuse: null, ids: [] });
+});
+
+test('O01: changing the folder unloads the loaded models only when the person agreed', () => {
+ assert.match(nativeUnloadPlan({ changed: true, unload: false, instances: loaded }).refuse, /Unload native models/);
+ assert.deepEqual(nativeUnloadPlan({ changed: true, unload: true, instances: loaded }), { refuse: null, ids: ['a', 'b'] });
+ assert.deepEqual(nativeUnloadPlan({ changed: true, unload: false, instances: [] }), { refuse: null, ids: [] });
+ assert.deepEqual(nativeUnloadPlan({ changed: true, unload: true, instances: undefined }), { refuse: null, ids: [] });
+});
+
+test('O01: the route uses that plan and the screen asks for an unload only when the folder differs', async () => {
+ const route = await readFile(new URL('../server/index.mjs', import.meta.url), 'utf8');
+ assert.match(route, /nativeUnloadPlan\(\{changed,unload:body\.unload,instances:native\.state\(\)\.instances\}\)/);
+ assert.doesNotMatch(route, /for\(const instance of native\.state\(\)\.instances\)await native\.unload\(instance\.id\);\}\s*\n\s*storageChanging = true/);
+ const screen = await readFile(new URL('../src/components/SettingsStorage.tsx', import.meta.url), 'utf8');
+ assert.match(screen, /changeModelDirectory\(path, path\.trim\(\) !== currentDirectory\)/);
+});
+
+test('F02: Settings -> Storage has ONE Downloaded models list and one total, with the shared files as a line of their own', async () => {
+ const screen = await readFile(new URL('../src/components/SettingsStorage.tsx', import.meta.url), 'utf8');
+ assert.equal((screen.match(/<Field label=\{tr\("Downloaded models"\)\}/g) ?? []).length, 1, 'no second section that contradicts the first');
+ assert.match(screen, /totalGb/);
+ assert.match(screen, /Shared files/);
+ assert.match(screen, /No downloaded models/);
+});
+
+test('item 8: "Strata" in Settings is the app\'s version; Strata Control\'s 0.1.45 is only a fallback; the update check gets the app version too', async () => {
+ const { appVersionToShow } = await import('../server/app-version.mjs');
+ assert.equal(appVersionToShow('0.2.0-beta', '0.1.45'), '0.2.0-beta');
+ assert.equal(appVersionToShow('dev', '0.1.45'), '0.1.45', 'a source checkout has no app version: the next best number');
+ assert.equal(appVersionToShow(undefined, null), null);
+ assert.equal(appVersionToShow('dev', null), 'dev');
+ const { build } = await import('esbuild');
+ const out = await build({ stdin: { contents: "export * from './src/lib/app-version';", resolveDir: process.cwd() }, bundle: true, write: false, platform: 'node', format: 'esm' });
+ const { appVersionLabel } = await import(`data:text/javascript;base64,${Buffer.from(out.outputFiles[0].text).toString('base64')}`);
+ assert.equal(appVersionLabel('0.2.0-beta', '0.1.45'), '0.2.0-beta');
+ assert.equal(appVersionLabel('dev', '0.1.45'), '0.1.45');
+ assert.equal(appVersionLabel(undefined, undefined), undefined);
+ const route = await readFile(new URL('../server/index.mjs', import.meta.url), 'utf8');
+ assert.match(route, /appVersion:appVersionToShow\(setupState\(\)\.app\.version,native\.state\(\)\.version\)/);
+ const updates = await readFile(new URL('../src/components/SettingsUpdates.tsx', import.meta.url), 'utf8');
+ assert.doesNotMatch(updates, /native\?\.version \?\? appVersion/, 'the Strata row no longer prefers Control\'s version');
+ assert.match(updates, /AboutVersions/);
+});
+
+test('Cargo.toml, tauri.conf.json and the desktop package agree on the app version the host reports', async () => {
+ const root = new URL('../../desktop/', import.meta.url);
+ const cargo = /^version\s*=\s*"([^"]+)"/m.exec(await readFile(new URL('src-tauri/Cargo.toml', root), 'utf8'))[1];
+ const pkg = JSON.parse(await readFile(new URL('package.json', root), 'utf8')).version;
+ assert.equal(cargo, pkg);
+ assert.equal(cargo, '0.2.0-beta');
+});
diff --git a/tools/strata_mcp.py b/tools/strata_mcp.py
index 5184aaaf7..ae2dcdc27 100644
--- a/tools/strata_mcp.py
+++ b/tools/strata_mcp.py
@@ -571,7 +571,7 @@ class Strata:
except (OSError, ValueError):
return {}
- def describe_config(self, path: Path) -> dict:
+ def describe_config(self, path: Path, usage: dict | None = None) -> dict:
cfg = self.read_config(path)
a = cfg.get("args") if isinstance(cfg.get("args"), list) else []
@@ -580,9 +580,12 @@ class Strata:
tag = path.stem[len("strata-"):]
missing = [p for p in [cfg.get("exe"), *[x for x in a if isinstance(x, str) and x.endswith(".gguf")]]
if not p or not Path(p).exists()]
- missing += shard_gaps([x for x in a if isinstance(x, str) and x.endswith(".gguf")]) # a model in parts is whole only with every part
+ gaps = shard_gaps([x for x in a if isinstance(x, str) and x.endswith(".gguf")]) # a model in parts is whole only with every part
+ missing += gaps
script = self.root / f"run-{tag}.{'bat' if WIN else 'sh'}"
vis = cfg.get("vision")
+ own_usage = (usage or self.disk_usage())["models"].get(tag) or {"gb": 0.0, "bytes": 0, "shared_bytes": 0}
+ plan = self.removal_plan(path)
return {"model": tag, "config": path.name, "model_name": cfg.get("model_name"),
"context": int(val("--max-context")) if str(val("--max-context") or "").isdigit() else None,
"kv": val("--kv"), "images": ("gpu" if vis.get("gpu") else "cpu") if isinstance(vis, dict) else "off",
@@ -590,8 +593,11 @@ class Strata:
"gpu": cfg.get("gpu"), "api_key_set": bool(cfg.get("api_key")),
"low_ram": "--resident-experts" in a or "--mmap-experts" in a,
"start_script": script.name if script.exists() else None,
- "ready": not missing and bool(cfg), "missing_files": missing[:3],
- "disk_gb": self.removal_plan(path)["gb"], "disk_bytes": self.removal_plan(path)["bytes"],
+ "ready": not missing and bool(cfg), "missing_files": missing[:3], "parts_missing": len(gaps),
+ "disk_gb": own_usage["gb"], "disk_bytes": own_usage["bytes"],
+ "shared_bytes": own_usage["shared_bytes"],
+ # what Delete would remove (files in Strata's own folders that no other model uses); the person's own GGUF folders stay
+ "removable_gb": plan["gb"], "kept_files": len(plan["keep"]),
"last_used": time.strftime("%Y-%m-%d %H:%M", time.localtime(path.stat().st_mtime))}
# ---- what a model owns on disk (Delete, and the per-model disk usage in Storage)
@@ -602,9 +608,19 @@ class Strata:
"""(the GGUF files, the folders) a run config names: --native/--ple-gguf/... and --pack/--mtp, plus any other .gguf."""
a = [x for x in (cfg.get("args") or []) if isinstance(x, str)]
files = [Path(a[i + 1]) for i, x in enumerate(a[:-1]) if x in self.FILE_FLAGS]
- files += [Path(x) for x in a if x.lower().endswith(".gguf") and Path(x) not in files]
+ files += [Path(x) for x in a if x.lower().endswith(".gguf")]
dirs = [Path(a[i + 1]) for i, x in enumerate(a[:-1]) if x in self.DIR_FLAGS]
- return files, dirs
+ seen, once = set(), []
+ for f in files: # one file named by several flags is still one file
+ if norm(f) not in seen:
+ seen.add(norm(f))
+ once.append(f)
+ seen_d, once_d = set(), []
+ for d in dirs:
+ if norm(d) not in seen_d:
+ seen_d.add(norm(d))
+ once_d.append(d)
+ return once, once_d
@staticmethod
def tree_bytes(path: Path) -> int:
@@ -622,6 +638,61 @@ class Strata:
pass
return total
+ @staticmethod
+ def file_key(path: Path):
+ """What makes two names the same file on disk: device + inode (hard links), else the resolved path."""
+ try:
+ st = os.stat(path)
+ if st.st_ino:
+ return ("ino", st.st_dev, st.st_ino), st.st_size
+ return ("path", str(norm(path))), st.st_size
+ except OSError:
+ return None, 0
+
+ def used_files(self, cfg: dict) -> dict:
+ """Every file a model really uses, from its run config: all parts of a multi-part GGUF (the config names the first), the
+ picture reader, the packs and the draft layer folders. {file identity: bytes}, wherever they live (the Strata folders or the
+ person's own)."""
+ files, dirs = self.model_paths(cfg)
+ paths = list(files)
+ vis = cfg.get("vision")
+ if isinstance(vis, dict) and isinstance(vis.get("mmproj"), str):
+ paths.append(Path(vis["mmproj"]))
+ for f in list(paths): # the other parts of a multi-part file
+ m = SHARD_NAME.match(str(f))
+ if m:
+ paths += [Path(f"{m.group(1)}-{i:05d}-of-{m.group(3)}.gguf") for i in range(1, int(m.group(3)) + 1)]
+ for d in dirs:
+ for base, _sub, names in os.walk(d):
+ paths += [Path(base) / n for n in names]
+ out = {}
+ for p in paths:
+ if p.is_file():
+ key, size = self.file_key(p)
+ if key is not None:
+ out[key] = size
+ return out
+
+ def disk_usage(self) -> dict:
+ """What the installed models take on disk, from the real files: each model's own files, the files shared between models
+ (the picture reader, the draft layer) counted ONCE, and the total. A model's own figure leaves out the shared files and
+ every other model's; rows plus 'shared' add up to the total."""
+ per = {c.stem[len("strata-"):]: self.used_files(self.read_config(c)) for c in self.configs()}
+ owners: dict = {}
+ for files in per.values():
+ for k in files:
+ owners[k] = owners.get(k, 0) + 1
+ models, shared = {}, {}
+ for tag, files in per.items():
+ own = sum(b for k, b in files.items() if owners[k] == 1)
+ models[tag] = {"bytes": own, "gb": round(own / 1e9, 2), "files": len(files),
+ "shared_bytes": sum(b for k, b in files.items() if owners[k] > 1)}
+ shared.update({k: b for k, b in files.items() if owners[k] > 1})
+ shared_bytes = sum(shared.values())
+ total = sum(m["bytes"] for m in models.values()) + shared_bytes
+ return {"models": models, "shared_bytes": shared_bytes, "shared_gb": round(shared_bytes / 1e9, 2),
+ "total_bytes": total, "total_gb": round(total / 1e9, 2)}
+
def removal_plan(self, config: Path) -> dict:
"""What deleting this model removes and what it keeps. A file or folder another installed model's config still names
(the shared MTP draft, a shared PLE shard) is kept; so is anything outside Strata's own folders."""
@@ -709,9 +780,11 @@ class Strata:
entry["downloading"] = bool(list(c.glob("*.part")))
items.setdefault(sub, []).append(entry)
mtp = data / "mtp" / "rt" / "experts.bin"
+ usage = self.disk_usage()
return {"strata_folder": str(self.root), "data_folder": str(data), "data_folder_exists": data.is_dir(),
"python_env": self.venv_python().exists(), "engine": self.engine_info(),
- "models": [self.describe_config(c) for c in self.configs()],
+ "models": [self.describe_config(c, usage) for c in self.configs()],
+ "usage": usage,
"downloads": items.get("models", []), "prepared": items.get("packs", []),
"draft_layer": mtp.exists()}
diff --git a/tools/test_strata_mcp.py b/tools/test_strata_mcp.py
index b8cc4ed43..923c5745a 100644
--- a/tools/test_strata_mcp.py
+++ b/tools/test_strata_mcp.py
@@ -799,3 +799,85 @@ class RemoveMissingFilesTest(unittest.TestCase):
self.assertFalse(folder.exists()); self.assertFalse(cfg.exists())
again = mod.Tools(S()).strata_remove(model="gyro-m", confirm=True)
self.assertEqual(again["failed"], [], "a second delete of the same model finds nothing left and still succeeds")
+
+
+class DiskUsageTest(unittest.TestCase):
+ """QA 2026-10-18 (F02): Storage showed IQ3_S as 0.0 GB while it uses 84 GB, and Gyro-S as 119 GB while it is 59 GB. The sizes come from the real
+ files: every part of a model in parts, the picture reader, the packs; a file one config names through several flags counts once; a
+ file two models share counts once in the total; a model's own figure leaves out another model's files."""
+
+ def setUp(self):
+ self.tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.tmp.cleanup)
+ d = Path(self.tmp.name)
+ self.root, self.data, self.own = d / "install", d / "data", d / "owner-folder"
+ for p in (self.root, self.data / "models" / "gyro-Gyro-S", self.data / "packs" / "swift-iq2_xs", self.data / "mtp" / "rt", self.own):
+ p.mkdir(parents=True)
+ (d / "settings.json").write_text(json.dumps({"data_dir": str(self.data)}), encoding="utf-8")
+ env = mock.patch.dict(os.environ, {"STRATA_SETTINGS_FILE": str(d / "settings.json")})
+ env.start()
+ self.addCleanup(env.stop)
+
+ def blob(self, path: Path, size: int) -> str:
+ path.write_bytes(b"x" * size)
+ return str(path)
+
+ def write_config(self, name: str, args: list, vision=None):
+ cfg = {"exe": sys.executable, "args": args, "port": 8080}
+ if vision:
+ cfg["vision"] = {"mmproj": vision}
+ (self.root / f"strata-{name}.json").write_text(json.dumps(cfg), encoding="utf-8")
+
+ def test_sizes_come_from_the_files_not_from_what_may_be_deleted(self):
+ gyro = self.blob(self.data / "models" / "gyro-Gyro-S" / "Gyro-S.gguf", 59_000)
+ reader = self.blob(self.data / "models" / "mmproj.gguf", 900)
+ part1 = self.blob(self.own / "Model-IQ3_S-00001-of-00002.gguf", 30_000)
+ self.blob(self.own / "Model-IQ3_S-00002-of-00002.gguf", 54_000)
+ # Gyro: the one file is --native, --ple-gguf, --embd-gguf and --native-dense-gguf at once
+ self.write_config("gyro-gyro-s", ["--native", gyro, "--ple-gguf", gyro, "--embd-gguf", gyro, "--native-dense-gguf", gyro], reader)
+ # IQ3_S: adopted from the person's own folder, the config names the first part only
+ self.write_config("iq3_s", ["--native", part1], reader)
+ s = M.Strata(self.root)
+ use = s.disk_usage()
+ self.assertEqual(use["models"]["gyro-gyro-s"]["bytes"], 59_000, "the Gyro file is counted once, not four times")
+ self.assertEqual(use["models"]["iq3_s"]["bytes"], 84_000, "both parts of IQ3_S, although the config names the first")
+ self.assertEqual(use["shared_bytes"], 900, "the picture reader both use is one file")
+ self.assertEqual(use["total_bytes"], 59_000 + 84_000 + 900, "rows plus the shared files add up to the total")
+ self.assertEqual(use["models"]["iq3_s"]["shared_bytes"], 900)
+ # deleting IQ3_S would remove nothing: its files are the person's own
+ by = {d["model"]: d for d in (s.describe_config(c, use) for c in s.configs())}
+ self.assertEqual(by["iq3_s"]["disk_bytes"], 84_000)
+ self.assertEqual(by["iq3_s"]["removable_gb"], 0.0)
+ self.assertEqual(by["gyro-gyro-s"]["disk_bytes"], 59_000)
+
+ def test_a_pack_folder_and_the_shared_draft_layer_count_once(self):
+ gguf = self.blob(self.data / "models" / "gyro-Gyro-S" / "m.gguf", 10_000)
+ pack = self.data / "packs" / "swift-iq2_xs"
+ self.blob(pack / "experts.bin", 40_000)
+ self.blob(pack / "index.txt", 100)
+ mtp = self.data / "mtp" / "rt"
+ self.blob(mtp / "experts.bin", 5_000)
+ self.write_config("swift-iq2_xs", ["--native", gguf, "--pack", str(pack), "--mtp", str(mtp)])
+ link_target = self.data / "models" / "gyro-Gyro-S" / "m2.gguf"
+ try:
+ os.link(gguf, link_target) # a hard link: the same bytes under another name
+ except OSError:
+ self.skipTest("no hard links here")
+ self.write_config("other", ["--native", str(link_target), "--mtp", str(mtp)])
+ use = M.Strata(self.root).disk_usage()
+ self.assertEqual(use["models"]["swift-iq2_xs"]["bytes"], 40_100)
+ self.assertEqual(use["models"]["other"]["bytes"], 0)
+ self.assertEqual(use["shared_bytes"], 10_000 + 5_000, "the hard-linked GGUF and the draft layer are shared")
+ self.assertEqual(use["total_bytes"], 55_100)
+
+ def test_a_model_with_a_part_missing_is_not_ready(self):
+ part1 = self.blob(self.own / "Model-00001-of-00003.gguf", 10)
+ self.blob(self.own / "Model-00002-of-00003.gguf", 10)
+ self.write_config("three-parts", ["--native", part1])
+ s = M.Strata(self.root)
+ desc = s.describe_config(s.configs()[0])
+ self.assertFalse(desc["ready"], "one part of three is on disk: not downloaded")
+ self.assertTrue(any(m.endswith("Model-00003-of-00003.gguf") for m in desc["missing_files"]), desc["missing_files"])
+ self.blob(self.own / "Model-00003-of-00003.gguf", 10)
+ desc = s.describe_config(s.configs()[0])
+ self.assertEqual([m for m in desc["missing_files"] if m.endswith(".gguf")], [])