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++
Expert settings: decimals can be typed in sampling and number fields; Ctrl+V of a screenshot reads clipboard items (#3736, #3748)
Niko1221780a69b41b50
diff --git a/apps/host/src/components/DecimalInput.tsx b/apps/host/src/components/DecimalInput.tsxnew file mode 100644index 000000000..e48f96893--- /dev/null+++ b/apps/host/src/components/DecimalInput.tsx@@ -0,0 +1,28 @@+import { useEffect, useState } from 'react';+import { parseDecimal, partialDecimal } from '../lib/decimal';++/** A number field that lets the person type a decimal point: it keeps the text while it is typed and tells the page the number once it is one (#3736). */+export function DecimalInput({ value, onChange, ariaLabel, className = 'st-input', placeholder, disabled }: {+ value: number | null | undefined;+ onChange: (value: number | null) => void;+ ariaLabel: string;+ className?: string;+ placeholder?: string;+ disabled?: boolean;+}) {+ const [text, setText] = useState(value === null || value === undefined ? '' : String(value));+ // A change that came from elsewhere (Restore saved, another tab) replaces the text, but never while the typed text already means this number.+ useEffect(() => {+ const shown = text === '' ? null : parseDecimal(text);+ if ((value ?? null) !== shown) setText(value === null || value === undefined ? '' : String(value));+ }, [value]);+ return <input className={className} aria-label={ariaLabel} inputMode="decimal" disabled={disabled} placeholder={placeholder} value={text}+ onChange={e => {+ const next = e.target.value;+ if (!partialDecimal(next)) return;+ setText(next);+ if (next.trim() === '') onChange(null);+ else { const n = parseDecimal(next); if (n !== null) onChange(n); }+ }}+ onBlur={() => { const n = text.trim() === '' ? null : parseDecimal(text); setText(n === null ? '' : String(n)); }}/>;+}diff --git a/apps/host/src/components/DropZone.tsx b/apps/host/src/components/DropZone.tsxindex c0b1f976a..d9a3ed461 100644--- a/apps/host/src/components/DropZone.tsx+++ b/apps/host/src/components/DropZone.tsx@@ -6,16 +6,7 @@ import { Icon } from './ui';/** Files dropped on the chat go where the attach button would put them: the composer reads the 'strata:drop-files' event. */export const DROP_EVENT = 'strata:drop-files';-/** The pictures on the clipboard, named so each one is told apart in the composer (a pasted screenshot arrives as "image.png"). */-export function pastedFiles(data: DataTransfer | null | undefined): File[] {- const out: File[] = [];- for (const file of Array.from(data?.files ?? [])) {- if (!file.type.startsWith('image/')) continue;- const extension = file.type.split('/')[1]?.replace('jpeg', 'jpg').replace(/[+].*/, '') || 'png';- out.push(new File([file], `Pasted picture ${new Date().toLocaleTimeString().replace(/[^0-9]+/g, '-').replace(/-$/, '')}${out.length ? `-${out.length + 1}` : ''}.${extension}`, { type: file.type }));- }- return out;-}+export { pastedFiles } from '../lib/pasted-files';const hasFiles = (e: React.DragEvent) => Array.from(e.dataTransfer?.types ?? []).includes('Files');/** A file dropped outside the chat must not take the window to that file: the page ignores it (called once at start). */diff --git a/apps/host/src/components/NativeSettings.tsx b/apps/host/src/components/NativeSettings.tsxindex 8b1e39bbf..53eac3e61 100644--- a/apps/host/src/components/NativeSettings.tsx+++ b/apps/host/src/components/NativeSettings.tsx@@ -1,3 +1,4 @@+import { DecimalInput } from './DecimalInput';import { tr } from '../lib/i18n';import {nativeSettingsResponse,nativeSettingsValues} from '../lib/native-settings-response';import { describeChange, type TunedChange } from '../lib/tune-values';@@ -92,14 +93,7 @@ export function NativeSettings({ model }: {</details>;const rows = (native?.fields ?? []).filter(f => `${tr(f.label)} ${f.id} ${tr(f.group)}`.toLowerCase().includes(query.toLowerCase()));return <details className="native-settings"><summary>{tr("Native engine settings")}</summary>{tr(tuned?.changed?.length ? <div className="native-tuned"><p className="small"><strong>{tr("Your tuning '{0}' sets", [tuned.preset?.name ?? ''])}</strong></p><ul>{tuned.changed.map(c => { const d = describeChange(c); return <li key={c.flag}><span>{d.name}</span><b>{d.now || tr('off')}</b>{d.was !== null ? <small className="muted">{tr("was {0}", [d.was])}</small> : null}</li>; })}</ul></div> : null)}<p className="small muted">{tr(!original ? 'Reading saved settings… ' : '')}{tr("Settings for this model. Blank values use Strata\u2019s defaults.")}</p><div className="editor-tabs" role="tablist" aria-label={tr("Native settings editor")}>{tr(['fields', 'json', 'tools'].map(t => <button key={t} role="tab" aria-selected={tab === t} onClick={() => chooseTab(t)}>{tr(t === 'fields' ? 'Parameters' : t === 'json' ? 'JSON' : 'MCP tools')}</button>))}</div>- {tr(tab === 'fields' ? <><input className="st-input" type="search" aria-label={tr("Search native parameters")} placeholder={tr("Search parameters…")} value={query} onChange={e => setQuery(e.target.value)}/>{tr(['Responses', 'GPU & memory', 'Serving', 'Image reading', 'Tools', 'Recovery'].map(group => rows.some(f => f.group === group) ? <section className="native-settings-group" key={group}><h3 className="h4">{tr(group)}</h3>{tr(rows.filter(f => f.group === group).map(f => <label className="native-setting-row" key={f.id}><span><strong>{tr(f.label)}</strong>{tr(f.supported === false ? <small>{tr("Requires a newer Strata installation.")}</small> : f.hint ? <small>{tr(f.hint)}</small> : null)}</span><NativeFieldInput field={f} value={values[f.id]} onChange={v => change(f.id, v)}/></label>))}</section> : null))}<section className="native-settings-group"><h3 className="h4">{tr("Sampling")}</h3>{tr([['temperature', 'Temperature'], ['top_p', 'Top-p'], ['top_k', 'Top-k'], ['min_p', 'Min-p'], ['repetition_penalty', 'Repetition penalty'], ['presence_penalty', 'Presence penalty'], ['frequency_penalty', 'Frequency penalty'], ['penalty_last_n', 'Penalty window'], ['seed', 'Seed']].map(([id, label]) => <label className="native-setting-row" key={id}><span><strong>{tr(label)}</strong></span><input className="st-input" aria-label={tr("Native {0}", [label])} inputMode="decimal" value={values.sampling?.[id] ?? ''} onChange={e => {- const sampling = { ...values.sampling };- if (e.target.value === '')- delete sampling[id];- else- sampling[id] = Number(e.target.value);- change('sampling', sampling);- }}/></label>))}</section></> : tab === 'json' ? <><p className="small muted">{tr("Engine arguments and STRATA environment flags are editable here. Program paths and network access remain managed by the host.")}</p><textarea className="st-input native-json" aria-label={tr("Native configuration JSON")} spellCheck={false} value={text} onChange={e => { setText(e.target.value); setNotice(''); }}/></> : <><p className="small muted">{tr("Add local programs or HTTP MCP servers. Connected tools can read or change the resources you give them access to. Enable tools in chat when you want the model to use them.")}</p><NativeMcpEditor text={mcp} onChange={value => { setMcp(value); setNotice(''); }}/><details><summary className="small">{tr("Configuration example")}</summary><pre className="native-example">{'{\n "files": {\n "command": "npx",\n "args": ["-y", "@modelcontextprotocol/server-filesystem", "/your/folder"],\n "disabled": false\n }\n}'}</pre><p className="xs muted">{tr("Saved credentials are masked. Keep the mask to preserve an existing value; type a new value to replace it.")}</p></details></>)}+ {tr(tab === 'fields' ? <><input className="st-input" type="search" aria-label={tr("Search native parameters")} placeholder={tr("Search parameters…")} value={query} onChange={e => setQuery(e.target.value)}/>{tr(['Responses', 'GPU & memory', 'Serving', 'Image reading', 'Tools', 'Recovery'].map(group => rows.some(f => f.group === group) ? <section className="native-settings-group" key={group}><h3 className="h4">{tr(group)}</h3>{tr(rows.filter(f => f.group === group).map(f => <label className="native-setting-row" key={f.id}><span><strong>{tr(f.label)}</strong>{tr(f.supported === false ? <small>{tr("Requires a newer Strata installation.")}</small> : f.hint ? <small>{tr(f.hint)}</small> : null)}</span><NativeFieldInput field={f} value={values[f.id]} onChange={v => change(f.id, v)}/></label>))}</section> : null))}<section className="native-settings-group"><h3 className="h4">{tr("Sampling")}</h3>{tr([['temperature', 'Temperature'], ['top_p', 'Top-p'], ['top_k', 'Top-k'], ['min_p', 'Min-p'], ['repetition_penalty', 'Repetition penalty'], ['presence_penalty', 'Presence penalty'], ['frequency_penalty', 'Frequency penalty'], ['penalty_last_n', 'Penalty window'], ['seed', 'Seed']].map(([id, label]) => <label className="native-setting-row" key={id}><span><strong>{tr(label)}</strong></span><DecimalInput ariaLabel={tr("Native {0}", [label])} value={values.sampling?.[id] ?? null} onChange={n => { const sampling = { ...values.sampling }; if (n === null) delete sampling[id]; else sampling[id] = n; change('sampling', sampling); }}/></label>))}</section></> : tab === 'json' ? <><p className="small muted">{tr("Engine arguments and STRATA environment flags are editable here. Program paths and network access remain managed by the host.")}</p><textarea className="st-input native-json" aria-label={tr("Native configuration JSON")} spellCheck={false} value={text} onChange={e => { setText(e.target.value); setNotice(''); }}/></> : <><p className="small muted">{tr("Add local programs or HTTP MCP servers. Connected tools can read or change the resources you give them access to. Enable tools in chat when you want the model to use them.")}</p><NativeMcpEditor text={mcp} onChange={value => { setMcp(value); setNotice(''); }}/><details><summary className="small">{tr("Configuration example")}</summary><pre className="native-example">{'{\n "files": {\n "command": "npx",\n "args": ["-y", "@modelcontextprotocol/server-filesystem", "/your/folder"],\n "disabled": false\n }\n}'}</pre><p className="xs muted">{tr("Saved credentials are masked. Keep the mask to preserve an existing value; type a new value to replace it.")}</p></details></>)}<div className="native-settings-actions"><Btn disabled={pending || !original || !dirty} variant="primary" onClick={() => void save()}>{tr(pending ? 'Saving…' : 'Save settings')}</Btn><Btn disabled={pending} onClick={() => { const saved = JSON.parse(original || '{"values":{},"mcp":{}}'); setValues(saved.values); setText(JSON.stringify(saved.values, null, 2)); setMcp(JSON.stringify(saved.mcp, null, 2)); setError(''); }}>{tr("Restore saved")}</Btn></div>{tr(notice ? <p role="status" className="small">{tr(notice)}</p> : null)}{tr(error ? <ErrorNotice message={error} onRetry={() => setRevision(value => value + 1)}/> : null)}</details>;}@@ -114,7 +108,9 @@ function NativeFieldInput({ field, value, onChange }: {return <Select disabled={field.supported === false} ariaLabel={tr(field.label)} value={value === null || value === undefined ? '' : String(value)} options={[{ value: '', label: 'Default' }, { value: 'true', label: 'On' }, { value: 'false', label: 'Off' }]} onChange={v => onChange(v === '' ? null : v === 'true')}/>;if (field.type === 'enum')return <Select disabled={field.supported === false} ariaLabel={tr(field.label)} value={value ?? ''} options={[{ value: '', label: 'Default' }, ...(field.choices ?? []).map(v => ({ value: v, label: v }))]} onChange={v => onChange(v || null)}/>;- return <input disabled={field.supported === false} className="st-input" aria-label={tr(field.label)} inputMode={field.type === 'number' ? 'numeric' : undefined} placeholder={tr("Default")} value={Array.isArray(value) ? value.join(', ') : value ?? ''} onChange={e => onChange(e.target.value === '' ? null : field.type === 'array' ? e.target.value.split(',').map(s => s.trim()).filter(Boolean) : field.type === 'number' ? Number(e.target.value) : e.target.value)}/>;+ if (field.type === 'number')+ return <DecimalInput disabled={field.supported === false} ariaLabel={tr(field.label)} placeholder={tr("Default")} value={value === null || value === undefined || value === '' || !Number.isFinite(Number(value)) ? null : Number(value)} onChange={onChange}/>;+ return <input disabled={field.supported === false} className="st-input" aria-label={tr(field.label)} placeholder={tr("Default")} value={Array.isArray(value) ? value.join(', ') : value ?? ''} onChange={e => onChange(e.target.value === '' ? null : field.type === 'array' ? e.target.value.split(',').map(s => s.trim()).filter(Boolean) : field.type === 'number' ? Number(e.target.value) : e.target.value)}/>;}function NativeAliases({ field, value, onChange }: {field: NativeField;diff --git a/apps/host/src/lib/decimal.ts b/apps/host/src/lib/decimal.tsnew file mode 100644index 000000000..5d918b798--- /dev/null+++ b/apps/host/src/lib/decimal.ts@@ -0,0 +1,9 @@+/** A number typed by a person: "0.95", ".95", "0,95" (a comma is a decimal point in many languages). null while it is not a whole number yet ("", ".", "0.", "-"). */+export function parseDecimal(text: string): number | null {+ const t = String(text ?? '').trim().replace(',', '.');+ if (!/^-?(\d+\.?\d*|\.\d+)$/.test(t) || t.endsWith('.')) return null;+ const n = Number(t);+ return Number.isFinite(n) ? n : null;+}+/** Whether what is typed could still become a number: the field keeps it while the person is in the middle of "0." */+export const partialDecimal = (text: string) => /^-?\d*[.,]?\d*$/.test(String(text ?? '').trim());diff --git a/apps/host/src/lib/pasted-files.ts b/apps/host/src/lib/pasted-files.tsnew file mode 100644index 000000000..373526cec--- /dev/null+++ b/apps/host/src/lib/pasted-files.ts@@ -0,0 +1,19 @@+/** The pictures on the clipboard, named so each one is told apart in the composer (a pasted screenshot arrives as "image.png"). */+export function pastedFiles(data: DataTransfer | null | undefined): File[] {+ const out: File[] = [];+ const found: File[] = Array.from(data?.files ?? []);+ // A screenshot from the clipboard (Win+Shift+S) often comes as an item and not in `files` (#3748).+ if (!found.some(f => f.type.startsWith('image/'))) {+ for (const item of Array.from(data?.items ?? [])) {+ if (item.kind !== 'file' || !item.type.startsWith('image/')) continue;+ const file = item.getAsFile();+ if (file) found.push(file);+ }+ }+ for (const file of found) {+ if (!file.type.startsWith('image/')) continue;+ const extension = file.type.split('/')[1]?.replace('jpeg', 'jpg').replace(/[+].*/, '') || 'png';+ out.push(new File([file], `Pasted picture ${new Date().toLocaleTimeString().replace(/[^0-9]+/g, '-').replace(/-$/, '')}${out.length ? `-${out.length + 1}` : ''}.${extension}`, { type: file.type }));+ }+ return out;+}diff --git a/apps/host/tests/typed-and-pasted.test.mjs b/apps/host/tests/typed-and-pasted.test.mjsnew file mode 100644index 000000000..2ee2ae628--- /dev/null+++ b/apps/host/tests/typed-and-pasted.test.mjs@@ -0,0 +1,24 @@+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 => import(`data:text/javascript;base64,${Buffer.from((await transform(await readFile(new URL(`../src/lib/${name}.ts`, import.meta.url), 'utf8'), { loader: 'ts', format: 'esm' })).code).toString('base64')}`);+const { parseDecimal, partialDecimal } = await load('decimal');+const { pastedFiles } = await load('pasted-files');++test('a decimal point can be typed step by step (#3736)', () => {+ for (const step of ['', '.', '0', '0.', '0.9', '0.95']) assert.equal(partialDecimal(step), true, step);+ assert.equal(parseDecimal('.'), null); assert.equal(parseDecimal('0.'), null);+ assert.equal(parseDecimal('0.95'), 0.95); assert.equal(parseDecimal('.95'), 0.95); assert.equal(parseDecimal('0,95'), 0.95); assert.equal(parseDecimal('20'), 20);+ assert.equal(partialDecimal('0.9x'), false); assert.equal(parseDecimal('1e3'), null);+});++test('a screenshot that is only in clipboard items is attached (#3748)', () => {+ const png = new File(['x'], 'image.png', { type: 'image/png' });+ const data = { files: [], items: [{ kind: 'file', type: 'image/png', getAsFile: () => png }, { kind: 'string', type: 'text/plain', getAsFile: () => null }] };+ const out = pastedFiles(data);+ assert.equal(out.length, 1); assert.equal(out[0].type, 'image/png'); assert.match(out[0].name, /^Pasted picture .*\.png$/);+ assert.equal(pastedFiles({ files: [png], items: [{ kind: 'file', type: 'image/png', getAsFile: () => png }] }).length, 1, 'never twice');+ assert.deepEqual(pastedFiles({ files: [], items: [{ kind: 'string', type: 'text/plain', getAsFile: () => null }] }), []);+});