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: Tune dialog tidy, short Check again label; headless UI fixture for it

Niko12217d43470f319d
diff --git a/apps/host/scripts/make-tune-locales.py b/apps/host/scripts/make-tune-locales.py
index f7a186f03..c364a66dc 100644
--- a/apps/host/scripts/make-tune-locales.py
+++ b/apps/host/scripts/make-tune-locales.py
@@ -159,6 +159,13 @@ T = {
],
}
+# the "Check again" button keeps to one short line; the 2 minutes are said in the sentence above it
+import re as _re
+_i = KEYS.index("Check again (about 2 minutes)")
+KEYS[_i] = "Check again"
+for _v in T.values():
+ _v[_i] = _re.split(r"\s*[((]", _v[_i])[0].strip()
+
out = Path(__file__).resolve().parent.parent / "src" / "locales"
ids = [f"tune{i + 1:02d}" for i in range(len(KEYS))]
for lang, values in T.items():
diff --git a/apps/host/src/components/NativeTune.tsx b/apps/host/src/components/NativeTune.tsx
index 94fb95ee6..75b366a99 100644
--- a/apps/host/src/components/NativeTune.tsx
+++ b/apps/host/src/components/NativeTune.tsx
@@ -80,7 +80,7 @@ export function NativeTune({ open, onClose, model, resourceProfile, vision }: {
const stale = active && status?.state && status.state !== 'fresh';
body = <div className="stack">
{error ? <p className="small inline-error" role="alert">{error}</p> : null}
- {active ? <div className="stack"><p className="strong">{tr("Saved tuning in use: {0}", [active.name])}</p>
+ {active ? <div><p className="strong">{tr("Saved tuning in use: {0}", [active.name])}</p>
{active.gain_pct ? <p className="small muted">{tr("+{0}% faster answers", [Math.round(active.gain_pct)])}</p> : null}
{notice(active.answers?.class)}
{stale ? <p className="small">{status?.state === 'hard' ? tr("This PC changed since it was tuned, so these settings are not used until you tune again.") : tr("This PC or the engine changed since it was tuned. A short check takes about 2 minutes.")}</p> : null}</div>
@@ -99,9 +99,9 @@ export function NativeTune({ open, onClose, model, resourceProfile, vision }: {
</section> : null}
{renaming ? <div className="row"><input className="st-input" aria-label={tr("Name")} value={name} maxLength={80} onChange={e => setName(e.target.value)}/><Btn size="sm" variant="primary" disabled={!name.trim() || busy} onClick={() => void act(async () => { await tunePresetAction(renaming.id, 'rename', { name: name.trim() }); setRenaming(null); })}>{tr("Save")}</Btn><Btn size="sm" onClick={() => setRenaming(null)}>{tr("Cancel")}</Btn></div> : null}
</div>;
- actions = <><Btn onClick={close}>{tr("Close")}</Btn>
+ actions = <>
{status?.can_undo ? <Btn disabled={busy || !!other} onClick={() => void act(async () => { await tuneUndo(model, resourceProfile, vision); })}>{tr("Undo")}</Btn> : null}
- {active && status?.state === 'soft' ? <Btn disabled={busy || !!other} onClick={() => void start('recheck')}>{tr("Check again (about 2 minutes)")}</Btn> : null}
+ {active && status?.state === 'soft' ? <Btn disabled={busy || !!other} onClick={() => void start('recheck')}>{tr("Check again")}</Btn> : null}
<Btn variant="primary" icon="gauge" disabled={busy || !!other || !status} onClick={() => void start('autotune')}>{tr(active ? "Tune again" : "Start tuning")}</Btn></>;
}
return <Dialog open={open} title={tr("Tune this model")} onClose={close} actions={actions}>{body}</Dialog>;
diff --git a/apps/host/src/locales/tune-de.json b/apps/host/src/locales/tune-de.json
index 9d3ded556..2b95ea112 100644
--- a/apps/host/src/locales/tune-de.json
+++ b/apps/host/src/locales/tune-de.json
@@ -33,7 +33,7 @@
"tune32": "Gespeicherte Abstimmungen",
"tune33": "In Gebrauch",
"tune34": "Verwenden",
- "tune35": "Erneut prüfen (etwa 2 Minuten)",
+ "tune35": "Erneut prüfen",
"tune36": "Erneut abstimmen",
"tune37": "Abstimmung starten",
"tune38": "Dein Modell wird abgestimmt"
diff --git a/apps/host/src/locales/tune-en.json b/apps/host/src/locales/tune-en.json
index 5761db290..969cf56eb 100644
--- a/apps/host/src/locales/tune-en.json
+++ b/apps/host/src/locales/tune-en.json
@@ -33,7 +33,7 @@
"tune32": "Saved tunings",
"tune33": "In use",
"tune34": "Use",
- "tune35": "Check again (about 2 minutes)",
+ "tune35": "Check again",
"tune36": "Tune again",
"tune37": "Start tuning",
"tune38": "Tuning your model"
diff --git a/apps/host/src/locales/tune-es.json b/apps/host/src/locales/tune-es.json
index 2466e9311..2dd199405 100644
--- a/apps/host/src/locales/tune-es.json
+++ b/apps/host/src/locales/tune-es.json
@@ -33,7 +33,7 @@
"tune32": "Ajustes guardados",
"tune33": "En uso",
"tune34": "Usar",
- "tune35": "Comprobar de nuevo (unos 2 minutos)",
+ "tune35": "Comprobar de nuevo",
"tune36": "Ajustar de nuevo",
"tune37": "Empezar a ajustar",
"tune38": "Ajustando tu modelo"
diff --git a/apps/host/src/locales/tune-ja.json b/apps/host/src/locales/tune-ja.json
index 186a78501..8420fa7ba 100644
--- a/apps/host/src/locales/tune-ja.json
+++ b/apps/host/src/locales/tune-ja.json
@@ -33,7 +33,7 @@
"tune32": "保存済みチューニング",
"tune33": "使用中",
"tune34": "使用する",
- "tune35": "もう一度チェック(約 2 分)",
+ "tune35": "もう一度チェック",
"tune36": "もう一度チューニング",
"tune37": "チューニングを開始",
"tune38": "モデルをチューニング中"
diff --git a/apps/host/src/locales/tune-ko.json b/apps/host/src/locales/tune-ko.json
index 0dfccea96..9b352c298 100644
--- a/apps/host/src/locales/tune-ko.json
+++ b/apps/host/src/locales/tune-ko.json
@@ -33,7 +33,7 @@
"tune32": "저장된 최적화",
"tune33": "사용 중",
"tune34": "사용",
- "tune35": "다시 점검 (약 2분)",
+ "tune35": "다시 점검",
"tune36": "다시 최적화",
"tune37": "최적화 시작",
"tune38": "모델을 최적화하는 중"
diff --git a/apps/host/src/locales/tune-pt.json b/apps/host/src/locales/tune-pt.json
index a5a5ded54..22da20237 100644
--- a/apps/host/src/locales/tune-pt.json
+++ b/apps/host/src/locales/tune-pt.json
@@ -33,7 +33,7 @@
"tune32": "Ajustes salvos",
"tune33": "Em uso",
"tune34": "Usar",
- "tune35": "Verificar de novo (cerca de 2 minutos)",
+ "tune35": "Verificar de novo",
"tune36": "Ajustar de novo",
"tune37": "Iniciar ajuste",
"tune38": "Ajustando o seu modelo"
diff --git a/apps/host/src/locales/tune-ru.json b/apps/host/src/locales/tune-ru.json
index 07b12e500..7bf326d69 100644
--- a/apps/host/src/locales/tune-ru.json
+++ b/apps/host/src/locales/tune-ru.json
@@ -33,7 +33,7 @@
"tune32": "Сохранённые настройки",
"tune33": "Используется",
"tune34": "Использовать",
- "tune35": "Проверить снова (около 2 минут)",
+ "tune35": "Проверить снова",
"tune36": "Настроить снова",
"tune37": "Начать настройку",
"tune38": "Настройка вашей модели"
diff --git a/apps/host/src/locales/tune-zh.json b/apps/host/src/locales/tune-zh.json
index 740e69bfa..6ac7e66ea 100644
--- a/apps/host/src/locales/tune-zh.json
+++ b/apps/host/src/locales/tune-zh.json
@@ -33,7 +33,7 @@
"tune32": "已保存的调优",
"tune33": "使用中",
"tune34": "使用",
- "tune35": "再次检查(约 2 分钟)",
+ "tune35": "再次检查",
"tune36": "再次调优",
"tune37": "开始调优",
"tune38": "正在调优你的模型"
diff --git a/apps/host/tests/fixtures/tune-ui-host.mjs b/apps/host/tests/fixtures/tune-ui-host.mjs
new file mode 100644
index 000000000..8ba9d59a8
--- /dev/null
+++ b/apps/host/tests/fixtures/tune-ui-host.mjs
@@ -0,0 +1,66 @@
+/** Disposable UI fixture for the Tune model dialog: the real native control over fake models, and a pretend `strata` command that
+ * reports progress and a result after a few seconds. No weights, no engine. Needs the demo host on 5161 and a built dist. */
+import http from 'node:http';
+import { readFile, writeFile } from 'node:fs/promises';
+import { writeFileSync } from 'node:fs';
+import { resolve, extname } from 'node:path';
+import { nativeFixture } from '../helpers/native-fixture.mjs';
+
+const arg = (a, n) => { const i = a.indexOf(n); return i < 0 ? undefined : a[i + 1]; };
+let saved = [];
+const slot = 'fixture-slot';
+function status() {
+ const active = saved.find(p => p.active) ?? null;
+ return { ok: true, slot, suggested_name: 'IQ2_XS 32K – Work', active, state: active ? 'soft' : null, reasons: active ? ['the graphics driver changed'] : [], presets: saved, can_undo: saved.length > 0 };
+}
+const stages = [[0, 'Measuring your current settings', 9], [2000, 'Trying: Run the control thread on the last CPU core (round 1 of 2)', 7], [4000, 'Trying: Pin memory only when needed (round 2 of 2)', 3]];
+const handler = (child, args) => {
+ const cmd = args.slice(args.findIndex(a => String(a).endsWith('strata.py')) + 1);
+ const out = json => { child.stdout.emit('data', Buffer.from(JSON.stringify(json))); child.exitCode = 0; child.emit('exit', 0); child.emit('close', 0); };
+ if (cmd[0] === 'presets') {
+ if (cmd[1] === 'status') return out(status());
+ if (cmd[1] === 'list') return out({ ok: true, presets: saved });
+ const id = cmd[2];
+ if (cmd[1] === 'apply') saved = saved.map(p => ({ ...p, active: p.id === id }));
+ if (cmd[1] === 'delete') saved = saved.filter(p => p.id !== id);
+ if (cmd[1] === 'rename') saved = saved.map(p => p.id === id ? { ...p, name: cmd[3] } : p);
+ if (cmd[1] === 'undo') saved = saved.slice(1);
+ return out({ ok: true });
+ }
+ if (cmd[0] === 'tune') {
+ const sf = arg(cmd, '--status-file');
+ stages.forEach(([at, step, left], i) => setTimeout(() => { try { writeFileSync(sf, JSON.stringify({ state: 'running', stage: 'rounds', text: `Finding the fastest settings for your PC… about ${left} min left`, minutes_left: left, runs_done: i * 2 + 1, runs_planned: 8, message: step })); } catch { /* gone */ } }, at));
+ setTimeout(() => {
+ const preset = { id: 'c'.repeat(32), name: 'IQ2_XS 32K – Work', active: true, gain_pct: 11.6, answers: { class: 'exact', fields: [] } };
+ saved = [preset, ...saved.map(p => ({ ...p, active: false }))];
+ out({ ok: true, result: { outcome: 'improved', gain_pct: 11.6, seconds: 1100, preset, answers: { class: 'exact', fields: [] }, base: { decode_tok_s: 54.2 }, chosen: { decode_tok_s: 60.5 }, pairs: 2, faster_pairs: 2 } });
+ }, 7000);
+ }
+};
+const fixture = nativeFixture({ tuneHandler: handler });
+const control = fixture.control, root = resolve(import.meta.dirname, '../../dist'), upstream = 'http://127.0.0.1:5161';
+await control.refresh(true);
+const server = http.createServer(async (req, res) => {
+ try {
+ const url = new URL(req.url, 'http://fixture'), path = url.pathname;
+ let text = ''; if (req.method !== 'GET') for await (const chunk of req) text += chunk;
+ const body = text ? JSON.parse(text) : {};
+ const json = value => { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify(value)); };
+ if (path === '/__fixture/capture' && req.method === 'POST') { await writeFile(process.env.TUNE_SHOT_DIR + '/' + body.name + '.png', Buffer.from(body.data, 'base64')); return json({ ok: true }); }
+ if (path === '/api/native' && req.method === 'GET') return json(await control.refresh());
+ if (path === '/api/native/operations') return json(control.operation(body.kind, body.args));
+ if (path === '/api/native/tune/status') return json(await control.tuneStatus({ model: url.searchParams.get('model'), resourceProfile: url.searchParams.get('resourceProfile') || undefined, vision: url.searchParams.get('vision') || undefined }));
+ if (path === '/api/native/tune/undo') return json(await control.tunePresets.undoFor(body));
+ let m = /^\/api\/native\/tune\/presets\/([0-9a-f]+)\/(apply|rename|delete|undo)$/.exec(path); if (m) return json(await control.tunePresets.action(m[2], m[1], body));
+ m = /^\/api\/native\/operations\/([^/]+)\/cancel$/.exec(path); if (m) return json(await control.cancel(m[1]));
+ if (path === '/api/native/benchmark') return json(control.benchmarkReport());
+ if (path === '/api/hardware') { const v = await (await fetch(upstream + path)).json(); return json({ ...v, gpus: [{ index: 0, id: 'gpu-0', vendor: 'nvidia', name: 'NVIDIA RTX 4090', vramGb: 24, backend: 'cuda', unified: false }] }); }
+ if (path.startsWith('/api/')) { const r = await fetch(upstream + req.url, { method: req.method, headers: text ? { 'content-type': 'application/json' } : {}, body: text || undefined }); res.writeHead(r.status, { 'content-type': r.headers.get('content-type') ?? 'application/json' }); res.end(Buffer.from(await r.arrayBuffer())); return; }
+ const file = path === '/' ? '/index.html' : path; if (file.includes('..')) throw new Error('Invalid fixture path');
+ const content = await readFile(root + file);
+ res.writeHead(200, { 'content-type': ({ '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml', '.woff2': 'font/woff2', '.png': 'image/png' })[extname(file)] ?? 'application/octet-stream' }); res.end(content);
+ } catch (e) { res.writeHead(400, { 'content-type': 'application/json' }); res.end(JSON.stringify({ error: e.message })); }
+});
+server.listen(Number(process.env.TUNE_UI_PORT ?? 5270), '127.0.0.1', () => console.log('Tune UI fixture ready'));
+let stopping = false; async function stop() { if (stopping) return; stopping = true; server.closeAllConnections(); server.close(); await fixture.cleanup(); process.exit(0); }
+process.on('SIGTERM', stop); process.on('SIGINT', stop);