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

Settings: opening Engine and Update makes no network call; the last check is shown and a new one runs only on a button press

Niko122154a02dc32c3b
diff --git a/apps/host/src/components/NativeOperations.tsx b/apps/host/src/components/NativeOperations.tsx
index 3805f0096..5a3fcb6c5 100644
--- a/apps/host/src/components/NativeOperations.tsx
+++ b/apps/host/src/components/NativeOperations.tsx
@@ -2,6 +2,7 @@ import {localeTag} from '../lib/i18n';
import { tr } from '../lib/i18n';
import { useEffect, useState } from 'react';
import { api } from '../lib/client';
+import { fetchUpdateCheck, publishUpdateCheck, useInstalledVersions, useLastUpdateCheck } from '../lib/update-check';
import { nativeAction, useNative, type NativeJob } from '../lib/native';
import { Btn, Dialog, ErrorNotice, Select } from './ui';
import { NativeProgress } from './NativeModels';
@@ -53,14 +54,28 @@ export function NativeOperations() {
instanceId: string;
line: string;
}[]>([]), [showLogs, setShowLogs] = useState(false), [confirm, setConfirm] = useState(false);
- const [update, setUpdate] = useState<'checking' | 'available' | 'current' | 'unknown'>('checking');
+ // Opening this page shows the last check kept on this computer and makes no network call. The check runs when "Check for updates" is pressed.
+ const versions = useInstalledVersions();
+ const last = useLastUpdateCheck(versions);
+ const [checking, setChecking] = useState(false), [checkError, setCheckError] = useState('');
+ const update: 'checking' | 'available' | 'current' | 'unknown' = checking ? 'checking' : last?.engine.status === 'available' ? 'available' : last?.engine.status === 'current' ? 'current' : 'unknown';
const active = native?.jobs.find(j => j.state === 'running');
- // The engine's update is offered only when the update check says there is one.
- useEffect(() => {
- let alive = true;
- void api.get<{ engine?: { status?: string } }>('/api/updates/check').then(r => { if (alive) setUpdate(r.engine?.status === 'available' ? 'available' : r.engine?.status === 'current' ? 'current' : 'unknown'); }).catch(() => { if (alive) setUpdate('unknown'); });
- return () => { alive = false; };
- }, []);
+ async function checkForUpdates() {
+ setChecking(true);
+ setCheckError('');
+ try {
+ const data = await fetchUpdateCheck();
+ publishUpdateCheck(data, versions);
+ if (data.engine.status === 'error')
+ setCheckError(data.engine.message);
+ }
+ catch (e) {
+ setCheckError(e instanceof Error ? e.message : String(e));
+ }
+ finally {
+ setChecking(false);
+ }
+ }
useEffect(() => {
if (!showLogs)
return;
@@ -98,7 +113,7 @@ export function NativeOperations() {
}
}
return <div className="stack stack--lg native-engine-settings">
- <section className="st-card"><div className="section-toolbar"><h2 className="h3">{tr("Update component")}</h2>{tr(update === 'available' ? <Btn size="sm" variant="primary" disabled={!!active || (native?.instances.length ?? 0) > 0} onClick={() => setConfirm(true)}>{tr("Update available")}</Btn> : null)}</div><p className="small muted">{tr("Update the engine for this computer. Your models and settings are kept.")}</p>{tr(update === 'current' ? <p className="small muted">{tr("Up to date")}</p> : null)}{tr(update === 'available' && (native?.instances.length ?? 0) > 0 ? <p className="small muted">{tr("Open Models and unload the running native models first.")}</p> : null)}</section>
+ <section className="st-card"><div className="section-toolbar"><h2 className="h3">{tr("Update component")}</h2>{tr(update === 'available' ? <Btn size="sm" variant="primary" disabled={!!active || (native?.instances.length ?? 0) > 0} onClick={() => setConfirm(true)}>{tr("Update available")}</Btn> : null)}{tr(update !== 'available' ? <Btn size="sm" disabled={update === 'checking'} onClick={() => void checkForUpdates()}>{tr(update === 'checking' ? 'Checking…' : 'Check for updates')}</Btn> : null)}</div><p className="small muted">{tr("Update the engine for this computer. Your models and settings are kept.")}</p>{tr(update === 'current' ? <p className="small muted">{tr("Up to date")}</p> : null)}{tr(checkError ? <p className="small inline-error" role="alert">{tr(checkError)}</p> : null)}{tr(update === 'available' && (native?.instances.length ?? 0) > 0 ? <p className="small muted">{tr("Open Models and unload the running native models first.")}</p> : null)}</section>
<section className="st-card"><div className="section-toolbar"><h2 className="h3">{tr("Diagnostics")}</h2><Btn size="sm" onClick={() => setShowLogs(true)}>{tr("View logs")}</Btn></div><p className="small muted">{tr("Downloads, preparation and engine failures include their original messages here.")}</p>{tr(native?.jobs.filter(j => j.state === 'error').slice(-3).map(j => <ErrorNotice key={j.id} message={j.error ?? j.summary} detail={j.details}/>))}</section>
<Dialog open={showLogs} wide title={tr("Engine logs")} onClose={() => setShowLogs(false)} actions={<><Btn icon="download" disabled={saving} onClick={() => void saveLogs()}>{tr(saving ? 'Working…' : 'Save logs')}</Btn><Btn variant="primary" onClick={() => setShowLogs(false)}>{tr("Close")}</Btn></>}>
<pre className="native-log" aria-label={tr("Engine log")}>{logs.length ? logs.map(l => `${l.at} · ${l.line}`).join(String.fromCharCode(10)) : tr('No engine messages yet.')}</pre>
diff --git a/apps/host/src/components/SettingsUpdates.tsx b/apps/host/src/components/SettingsUpdates.tsx
index 42cb142d0..5b078e3eb 100644
--- a/apps/host/src/components/SettingsUpdates.tsx
+++ b/apps/host/src/components/SettingsUpdates.tsx
@@ -7,6 +7,12 @@ import type { SoftwareUpdate, UpdateCheckResult } from '../lib/types';
import { nativeAction, useNative } from '../lib/native';
import { NativeProgress } from './NativeModels';
import { appVersionLabel } from '../lib/app-version';
+import { fetchUpdateCheck, publishUpdateCheck, useInstalledVersions, useLastUpdateCheck } from '../lib/update-check';
+/** A check from an earlier day shows its date too, because the result is kept between visits. */
+function checkedLabel(at: string) {
+ const when = new Date(at), sameDay = when.toDateString() === new Date().toDateString();
+ return sameDay ? when.toLocaleTimeString(localeTag(), { hour: '2-digit', minute: '2-digit' }) : when.toLocaleString(localeTag(), { dateStyle: 'medium', timeStyle: 'short' });
+}
/** Installed versions are real host values. Installation needs a host updater. */
export function SettingsUpdates() {
const native = useNative();
@@ -16,12 +22,16 @@ export function SettingsUpdates() {
const [rollback, setRollback] = useState(false);
const [component, setComponent] = useState<'strata' | 'engine'>('strata');
const [checking, setChecking] = useState(false);
- const [result, setResult] = useState<UpdateCheckResult | null>(null);
+ // Opening Settings shows the last check kept on this computer. The network is touched only when "Check for updates" is pressed.
+ const versions = useInstalledVersions();
+ const last = useLastUpdateCheck(versions);
+ const [fresh, setFresh] = useState<UpdateCheckResult | null>(null);
const [error, setError] = useState('');
const request = useRef<AbortController | null>(null);
useEffect(() => () => request.current?.abort(), []);
const installed = component === 'strata' ? appVersion : native?.available ? (native.installed?.engine?.version ?? 'Not installed') : engineVersion;
const active = native?.jobs.find(j => j.state === 'running');
+ const result = checking || error ? null : (fresh ?? last);
async function operate(kind: string) {
setError('');
try {
@@ -39,16 +49,13 @@ export function SettingsUpdates() {
request.current = controller;
setChecking(true);
setError('');
- setResult(null);
+ setFresh(null);
try {
- const response = await fetch('/api/updates/check', { signal: controller.signal });
- if (!response.ok)
- throw new Error('Could not check for updates. Try again.');
- const data = await response.json() as UpdateCheckResult;
- if (!data.strata?.status || !data.engine?.status || !data.checkedAt)
- throw new Error('The update service returned an incomplete result.');
- if (!controller.signal.aborted)
- setResult(data);
+ const data = await fetchUpdateCheck(controller.signal);
+ if (!controller.signal.aborted) {
+ setFresh(data);
+ publishUpdateCheck(data, versions);
+ }
}
catch (e) {
if (!controller.signal.aborted)
@@ -72,7 +79,7 @@ export function SettingsUpdates() {
{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>
+ <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(checkedLabel(result.checkedAt))}</> : null)}</div>
</div>
<Dialog open={rollback} compact title={tr("Roll back a version")} onClose={() => setRollback(false)} actions={<Btn onClick={() => setRollback(false)}>{tr("Done")}</Btn>}>
<div className="settings-update-dialog">
diff --git a/apps/host/src/lib/update-cache.ts b/apps/host/src/lib/update-cache.ts
new file mode 100644
index 000000000..643c8d17a
--- /dev/null
+++ b/apps/host/src/lib/update-cache.ts
@@ -0,0 +1,30 @@
+import type { UpdateCheckResult } from './types';
+
+/**
+ * The last update check, kept on this computer so Settings can show it without touching the network. A check runs only when the
+ * person presses "Check for updates" (or "Update engine" / "Update Strata"). The result is kept together with the versions it was
+ * for, and it is ignored once the installed version changes (an update, a roll back), so an old "Update available" never lingers.
+ */
+const KEY = 'strata.update-check.v1';
+
+interface Stored { result: UpdateCheckResult; appVersion: string | null; engineVersion: string | null }
+export interface InstalledVersions { appVersion?: string | null; engineVersion?: string | null }
+
+const same = (a: string | null | undefined, b: string | null | undefined) => (a ?? null) === (b ?? null);
+
+export function readUpdateCache(now: InstalledVersions): UpdateCheckResult | null {
+ try {
+ const stored = JSON.parse(localStorage.getItem(KEY) ?? 'null') as Stored | null;
+ if (!stored?.result?.strata?.status || !stored.result.engine?.status || !stored.result.checkedAt) return null;
+ if (!same(stored.appVersion, now.appVersion) || !same(stored.engineVersion, now.engineVersion)) return null;
+ return stored.result;
+ } catch { return null; }
+}
+
+export function saveUpdateCache(result: UpdateCheckResult, now: InstalledVersions) {
+ try { localStorage.setItem(KEY, JSON.stringify({ result, appVersion: now.appVersion ?? null, engineVersion: now.engineVersion ?? null } satisfies Stored)); } catch { /* Not remembering a result is harmless. */ }
+}
+
+export function clearUpdateCache() {
+ try { localStorage.removeItem(KEY); } catch { /* Nothing to clear. */ }
+}
diff --git a/apps/host/src/lib/update-check.ts b/apps/host/src/lib/update-check.ts
new file mode 100644
index 000000000..8512c9532
--- /dev/null
+++ b/apps/host/src/lib/update-check.ts
@@ -0,0 +1,42 @@
+import { useEffect, useState } from 'react';
+import { useStore } from './store';
+import { useNative } from './native';
+import { appVersionLabel } from './app-version';
+import { readUpdateCache, saveUpdateCache, type InstalledVersions } from './update-cache';
+import type { UpdateCheckResult } from './types';
+
+/** The installed versions the cached check belongs to. Same values the Settings version rows show. */
+export function useInstalledVersions(): InstalledVersions {
+ const native = useNative();
+ const engineVersion = useStore(s => s.engine?.engine.version);
+ const appVersion = appVersionLabel(useStore(s => s.setup?.app.version), native?.version);
+ return { appVersion: appVersion ?? null, engineVersion: (native?.available ? native.installed?.engine?.version : engineVersion) ?? null };
+}
+
+/** The one place the app asks the host to check for updates. Called only from a button press. */
+export async function fetchUpdateCheck(signal?: AbortSignal): Promise<UpdateCheckResult> {
+ const response = await fetch('/api/updates/check', { signal });
+ if (!response.ok) throw new Error('Could not check for updates. Try again.');
+ const data = await response.json() as UpdateCheckResult;
+ if (!data.strata?.status || !data.engine?.status || !data.checkedAt) throw new Error('The update service returned an incomplete result.');
+ return data;
+}
+
+const EVENT = 'strata:update-check';
+
+/** Remember a finished check and tell every Settings panel that shows it. */
+export function publishUpdateCheck(result: UpdateCheckResult, now: InstalledVersions) {
+ saveUpdateCache(result, now);
+ try { window.dispatchEvent(new Event(EVENT)); } catch { /* No window, nothing to refresh. */ }
+}
+
+/** The last known check result, read from this computer. Never touches the network. */
+export function useLastUpdateCheck(now: InstalledVersions): UpdateCheckResult | null {
+ const [, tick] = useState(0);
+ useEffect(() => {
+ const refresh = () => tick(n => n + 1);
+ window.addEventListener(EVENT, refresh);
+ return () => window.removeEventListener(EVENT, refresh);
+ }, []);
+ return readUpdateCache(now);
+}
diff --git a/apps/host/tests/update-cache.test.mjs b/apps/host/tests/update-cache.test.mjs
new file mode 100644
index 000000000..45145f3a3
--- /dev/null
+++ b/apps/host/tests/update-cache.test.mjs
@@ -0,0 +1,55 @@
+/** Settings shows the last known update check from this computer and never asks the network when it opens. */
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import { transform } from 'esbuild';
+
+const load = async name => {
+ const { code } = await transform(await readFile(new URL(`../src/lib/${name}.ts`, import.meta.url), 'utf8'), { loader: 'ts', format: 'esm' });
+ return import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);
+};
+const { readUpdateCache, saveUpdateCache, clearUpdateCache } = await load('update-cache');
+
+const store = new Map();
+globalThis.localStorage = { getItem: k => store.get(k) ?? null, setItem: (k, v) => void store.set(k, String(v)), removeItem: k => void store.delete(k) };
+const result = (status = 'available') => ({ checkedAt: '2026-10-19T10:00:00Z', strata: { status: 'current', message: 'ok' }, engine: { status, message: 'x' } });
+
+test('a saved check is read back for the same installed versions', () => {
+ clearUpdateCache();
+ assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45' }), null, 'never checked');
+ saveUpdateCache(result(), { appVersion: '0.2.0', engineVersion: '0.1.45' });
+ assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45' }).engine.status, 'available');
+});
+
+test('a check made for other versions is ignored, so an old "Update available" does not linger after an update', () => {
+ saveUpdateCache(result(), { appVersion: '0.2.0', engineVersion: '0.1.45' });
+ assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.46' }), null);
+ assert.equal(readUpdateCache({ appVersion: '0.2.1', engineVersion: '0.1.45' }), null);
+});
+
+test('unreadable or blocked storage is harmless', () => {
+ store.set('strata.update-check.v1', '{not json');
+ assert.equal(readUpdateCache({}), null);
+ const saved = globalThis.localStorage;
+ globalThis.localStorage = { getItem() { throw new Error('blocked'); }, setItem() { throw new Error('blocked'); }, removeItem() { throw new Error('blocked'); } };
+ assert.equal(readUpdateCache({}), null);
+ assert.doesNotThrow(() => saveUpdateCache(result(), {}));
+ assert.doesNotThrow(() => clearUpdateCache());
+ globalThis.localStorage = saved;
+});
+
+test('opening the Engine and Update settings makes no update call: only a button press does', async () => {
+ const src = async name => (await readFile(new URL(`../src/${name}`, import.meta.url), 'utf8')).replace(/\r\n/g, '\n');
+ const ops = await src('components/NativeOperations.tsx'), upd = await src('components/SettingsUpdates.tsx'), lib = await src('lib/update-check.ts');
+ assert.doesNotMatch(ops, /\/api\/updates\/check/, 'NativeOperations has no direct call');
+ assert.doesNotMatch(upd, /\/api\/updates\/check/);
+ assert.equal(lib.match(/\/api\/updates\/check/g).length, 1, 'one place asks the host');
+ // every caller of the check sits inside a function that only a click starts
+ for (const [name, text] of [['NativeOperations', ops], ['SettingsUpdates', upd]]) {
+ const body = text.replace(/async function (checkForUpdates|check)\(\) \{[\s\S]*?\n \}\n/, '');
+ assert.doesNotMatch(body, /fetchUpdateCheck\(/, `${name}: the check runs only inside the button handler`);
+ assert.match(text, /void (checkForUpdates|check)\(\)/, `${name}: a button starts it`);
+ }
+ // nothing in either component runs a check from an effect
+ for (const text of [ops, upd]) for (const effect of text.match(/useEffect\(\(\) => \{[\s\S]*?\n \}, \[[^\]]*\]\);/g) ?? []) assert.doesNotMatch(effect, /fetchUpdateCheck|updates\/check/);
+});