import { tr } from '../lib/i18n'; import { useEffect, useMemo, useRef, useState } from 'react'; import { Screen } from './layout'; import { VersionPicker } from './VersionPicker'; import { FamilySwitch } from './FamilySwitch'; import { PcComputer } from './PcComputer'; import { cardRoomGb, contextCacheGb, fitOn, memoryNeeded, versionFit } from '../lib/native-fit'; import { contextIsTight, defaultContext, DEFAULT_CONTEXT, openingContext } from '../lib/default-context'; import { GpuRoles } from './GpuRoles'; import { fromLegacy, normalize as normalizeRoles, order as roleOrder, recommend as recommendRoles, rows as roleRows, sameRoles, vramOn, type RoleCard, type Roles } from '../lib/gpu-roles'; import { Btn, Dialog, ErrorNotice, Icon, Select } from './ui'; import { installProgress, installStage, stageText, useDownloadEta } from '../lib/download-eta'; import { useKept } from '../lib/kept-state'; import { DownloadParts } from './DownloadParts'; import { EngineWarning } from './EngineWarning'; import { EngineUpdateCard } from './EngineUpdateCard'; import { EngineUpdateDialog } from './EngineUpdateDialog'; import { sizeGb } from '../lib/format'; import { NativeDeleteDialog } from './NativeDelete'; import { plainFailureText } from '../lib/plain-errors'; import { api } from '../lib/client'; import { go, setSettingsSection, selectRemoteModel, pushToast } from '../lib/store'; import { installedListPending, nativeAction, useNative, type NativeJob } from '../lib/native'; import { tuneEffective } from '../lib/native-tune'; import { tunedFields } from '../lib/tune-values'; import { shownVision, steadyNoReader } from '../lib/pictures-choice'; import { draftingChoices as draftingOptions, resolveDrafter } from '../lib/drafting'; import { NativeSettings } from './NativeSettings'; import { NativeSettingsFile } from './NativeSettingsFile'; import { RunImageModel } from './RunImageModel'; import { IMAGE_GENERATION_VISIBLE } from '../lib/features'; import { useStore } from '../lib/store'; import { NativePresets } from './NativePresets'; import { NativeTune } from './NativeTune'; import { NativeTuneBadge } from './NativeTuneBadge'; import { nativeCatalogModels, catalogVersionLabel, fetchesPictures } from '../lib/native-catalog'; export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine }: { onOtherModels: () => void; onImport?: () => void; onConnectEngine?: () => void; onReady?: () => void; }) { const native = useNative(), imageLibrary = useStore(s => s.imageModels), hardware = useStore(s => s.hardware); // The choices are kept while the page is closed (Models -> Monitor -> Models used to start them over and a person lost track of what was downloading). const [family, setFamily] = useKept('models.family', ''), [size, setSize] = useKept('models.size', ''), [context, setContext] = useKept('models.context', DEFAULT_CONTEXT), [contextPicked, setContextPicked] = useKept('models.contextPicked', false), [vision, setVision] = useKept('models.vision', 'yes'); const manual = useStore(s => s.setup?.choices?.onboarding?.manual ?? false); const [expert, setExpert] = useKept('models.expert', manual), [multiple, setMultiple] = useKept('models.multiple', false), [roles, setRoles] = useKept('models.roles', null), [kv, setKv] = useKept('models.kv', 'int8'), [lowRam, setLowRam] = useKept('models.lowRam', 'auto'), [split, setSplit] = useKept('models.split', 'auto'); const [resourceProfile, setResourceProfile] = useKept<'work' | 'performance'>('models.profile', 'work'); const [drafting, setDrafting] = useState('auto'); const [pending, setPending] = useState(false), [error, setError] = useState(''), [plan, setPlan] = useState | null>(null), [drafterGb, setDrafterGb] = useState(null), [loadedError, setLoadedError] = useState(''), [tuneOpen, setTuneOpen] = useState(false), [jobId, setJobId] = useKept('models.job', ''), [manage, setManage] = useState(false); const [toastedJob, setToastedJob] = useKept('models.toasted', ''), [appliedSig, setAppliedSig] = useKept('models.applied', ''); const presetPending = useRef(false), visionPicks = useRef(new Map()); // Read pictures per version: what the person set, or what the version opened with; later reports of the host never overwrite it const [deleting, setDeleting] = useState(null); const families = nativeCatalogModels(native?.catalog?.families ?? []); const expertSection = useRef(null); // The card is inserted above the fold and the browser's scroll anchoring // immediately compensates by scrolling down, which cancelled the smooth // scroll started in the same frame: the page stopped 121px in and clipped // the cards above. Scroll after the layout has settled, and never animate // when motion is reduced. useEffect(() => { if (!expert) return; const frame = requestAnimationFrame(() => expertSection.current?.scrollIntoView({ block: 'start', behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth', })); return () => cancelAnimationFrame(frame); }, [expert]); const selectedFamily = families.find(f => f.family === family || f.sizes.some(size => size.sourceFamily === family)) ?? families[0], selectedSize = selectedFamily?.sizes.find(s => s.id === size) ?? selectedFamily?.sizes[0]; const installed = native?.installed?.models.find(m => m.model === selectedSize?.id), listPending = installedListPending(native); // The sizes this model offers for the conversation context; it opens at 128K (or its largest size when that is smaller). const contextList = native?.catalog?.contexts ?? [8192, 32768, 65536, 131072, 262144]; // The model that is running is shown as running, with Unload: not offered for loading again. const downloaded = native?.installed?.models ?? [], allSizes = families.flatMap(f => f.sizes); // A DeepSeek model of an earlier Strata (Control: no longer run): one line with where its files are, nothing to load or delete here. const retiredModels = downloaded.filter(m => m.retired); // This computer for the fit figures: the biggest usable graphics card, or the ones chosen under Expert settings. const engineVendor = native?.hardware?.engine_vendor ?? null, roleCards: RoleCard[] = roleRows(native?.hardware?.gpus as RoleCard[] | undefined, engineVendor); const pcGpus = (native?.hardware?.gpus ?? []).filter(g => g.usable !== false), pcGpu = [...pcGpus].sort((x, y) => y.vram_gb - x.vram_gb)[0] ?? null; const pcRam = native?.hardware?.ram_gb || hardware?.memory.totalGb || null, pcVram = pcGpu?.vram_gb ?? 0; // What the models that stay loaded (Run multiple models) already take: the fit figures are for what is left. const sizeOf = (id: string) => allSizes.find(s => s.id === id); const keptModels = expert && multiple ? (native?.instances ?? []).filter(i => i.status !== 'error' && i.model !== selectedSize?.id) : []; const keptUse = keptModels.map(i => { const s = sizeOf(i.model); const card = pcGpus.find(g => g.index === i.gpus[0]); const f = s && pcRam ? fitOn(s, { ram_gb: pcRam, vram_gb: card?.vram_gb ?? pcVram }) : null; return { gpus: i.gpus, ram: f?.ramUseGb ?? 0, vram: f?.vramUseGb ?? 0 }; }); const keptRam = keptUse.reduce((n, u) => n + u.ram, 0); const keptVramOn = (cards: number[]) => keptUse.filter(u => u.gpus.some(g => cards.includes(g))).reduce((n, u) => n + u.vram, 0); // The models that are loaded now, with what each takes of graphics memory, RAM and SSD (the app's estimate from the same rule the fit uses: the engine does not report this split). const loadedModels = (native?.instances ?? []).filter(i => i.status === 'ready' || i.status === 'loading').flatMap(i => { const s = sizeOf(i.model); if (!s || !pcRam) return []; const card = pcGpus.find(g => g.index === i.gpus[0]); return [{ id: i.model, label: `${i.label} · ${s.model}`, fit: fitOn(s, { ram_gb: pcRam, vram_gb: cardRoomGb([card ?? pcGpu].filter(c => !!c)) }, true, { context: i.context ?? context, kv }) }]; }); // The versions that are really on this computer: a config whose files are all there (every part of a model in parts). const readyIds = useMemo(() => new Set(downloaded.filter(m => m.ready).map(m => m.model)), [downloaded]); // What a running job works on, by its name in the list: "Qwen3.8-Flash-Next · Gyro · Smallest". const jobLabel = (j: NativeJob) => { const v = allSizes.find(s => s.id === j.model || (s.model === j.model && (!j.family || s.sourceFamily === j.family))); const f = v && families.find(x => x.sizes.includes(v)); return v ? [f?.title, catalogVersionLabel(v)].filter(Boolean).join(' · ') : ''; }; const loadedSelected = native?.instances.find(i => i.model === selectedSize?.id && i.status === 'ready'); // What the running model was really started with is what the page shows: after Load the highlight must still be the profile that was applied. useEffect(() => { if (loadedSelected?.resourceProfile) setResourceProfile(loadedSelected.resourceProfile); }, [loadedSelected?.id, loadedSelected?.resourceProfile]); // After a tuning, Expert mode shows the values the tuning set (the active preset's), not the ones the model was prepared with. const [tunedNow, setTunedNow] = useState<{ name: string; fields: ReturnType } | null>(null); useEffect(() => { if (!selectedSize || !installed?.ready) { setTunedNow(null); return; } let alive = true; tuneEffective(selectedSize.id, resourceProfile, selectedSize.images ? vision : 'no').then(t => { if (alive) setTunedNow(t.applied && t.preset ? { name: t.preset.name, fields: tunedFields(t.changed) } : null); }).catch(() => { if (alive) setTunedNow(null); }); return () => { alive = false; }; }, [selectedSize?.id, installed?.ready, resourceProfile, vision, native?.jobs.filter(j => j.state === 'done').length]); useEffect(() => { if (tunedNow?.fields.kv) setKv(tunedNow.fields.kv as typeof kv); if (tunedNow?.fields.lowRam) setLowRam(tunedNow.fields.lowRam as typeof lowRam); }, [tunedNow]); const active = native?.jobs.find(j => j.state === 'running'); // Catalog groups share quantization names. A remembered job must still belong // to the selected version; another family's failure stays in diagnostics. const selectedJob = (j: NativeJob) => !!selectedSize && (j.model === selectedSize.id || (j.model === selectedSize.model && j.family === selectedSize.sourceFamily)); const job = native?.jobs.find(j => j.id === jobId && selectedJob(j)) ?? native?.jobs.filter(j => ['load', 'install'].includes(j.kind) && selectedJob(j)).at(-1); // This model can read pictures but the installed engine has no picture reader: pictures run off for now, nothing is saved, and the row says nothing wordy. // While a job runs the host is busy and its picture-reader probe can drop out for a moment: the checkbox then keeps what it showed, so the person's choice never flickers. const noReaderNow = !!selectedSize?.imagesCapable && !selectedSize.images, noReaderSeen = useRef({ id: '', value: false }); noReaderSeen.current = steadyNoReader(noReaderNow, !!active, noReaderSeen.current, selectedSize?.id ?? ''); const noReader = noReaderSeen.current.value; // Graphics cards (strata_control/gpu_fit.py: the one rule of the app, the Terminal and setup): the recommended option is pre-selected, the person may pick another // A card a loaded model already uses (a second model on it usually does not fit): said on its row, and not the pre-selected one while another is free. const usedBy = (cards: number[]) => (native?.instances ?? []).filter(i => i.status !== 'error' && i.model !== selectedSize?.id && i.gpus.some(g => cards.includes(g))).map(i => i.label); // Main / Helper / Off per card (src/lib/gpu-roles.ts, strata_control/gpu_roles.py): the recommendation until the person changes a role; a loaded model shows what it was started with. // With Run multiple models, a card another loaded model already uses starts Off for this one (while a free card exists). const busy = (i: number) => expert && multiple && usedBy([i]).length > 0, freeCards = roleCards.filter(c => !busy(c.index)); const recommended = freeCards.length && freeCards.length < roleCards.length ? { ...recommendRoles(freeCards, engineVendor), roles: { ...Object.fromEntries(roleCards.map(c => [c.index, 'off'])), ...recommendRoles(freeCards, engineVendor).roles } as Roles } : recommendRoles(roleCards, engineVendor); const loadedRoles = loadedSelected && roleCards.length > 1 ? fromLegacy(loadedSelected.gpus, roleCards, 'as_given') : null; const effectiveRoles: Roles = roleCards.length > 1 ? (roles ? normalizeRoles(roles, roleCards) : loadedRoles ?? recommended.roles) : recommended.roles; const customRoles = !sameRoles(effectiveRoles, recommended.roles); const changeRoles = (next: Roles) => setRoles(sameRoles(next, recommended.roles) ? null : next); const cardsGpus: number[] = roleCards.length > 1 ? roleOrder(effectiveRoles, roleCards) : []; const chosenCards = cardsGpus; const fitHardware = { ram_gb: pcRam ? Math.max(0, pcRam - keptRam) : pcRam, vram_gb: Math.max(0, (roleCards.length > 1 ? vramOn(effectiveRoles, roleCards) : pcVram) - keptVramOn(chosenCards)) }; // The fit label's own figures (strata_control/fit_label.py): a unified-memory chip counts only its carve-out beside the RAM (lib/native-fit.ts cardRoomGb). const labelHardware = { ram_gb: fitHardware.ram_gb, vram_gb: roleCards.length > 1 ? fitHardware.vram_gb : Math.max(0, cardRoomGb(pcGpu ? [pcGpu] : []) - keptVramOn(chosenCards)) }; // How the chosen version sits on this computer (the same rule as the version list): the page says a word only for "may run slower". const fitState = selectedSize ? versionFit(selectedSize, labelHardware, { context, kv }) : 'unknown'; // A layer split written for another number of cards no longer fits: back to automatic. useEffect(() => { if (cardsGpus.length <= 1 && split !== 'auto') setSplit('auto'); }, [cardsGpus.length]); // Drafting (which drafter guesses ahead): a choice exists only for Qwen3.8-Flash-Next (the qwen and gyro families) on a computer whose engine can run DFlash2; every other model has no dropdown. const draftingChoices = selectedSize ? draftingOptions(selectedSize.sourceFamily ?? selectedFamily?.family, native?.capabilities?.dflash2) : null; // Control's plan says the all-cards split engine takes an Auto start on this computer (it runs the MTP draft layer); it needs two or more cards, so one card chosen in the roles is not it. const splitCards = native?.capabilities?.dflash2Split === true && cardsGpus.length !== 1; // The drafter this run loads (one per run): the fit and the plan use its graphics memory (DFlash2 0.89 GB, MTP 1.08 GB). const nowDrafter = draftingChoices ? resolveDrafter(drafting, selectedSize?.sourceFamily ?? selectedFamily?.family, native?.capabilities?.dflash2, splitCards) : 'mtp'; // DFlash2 with the converted pack (the selector as Q4_0 rows) takes 175 MiB less graphics memory: the fit says the true number (Control's `selq4`, strata_control/drafting.py vram_gb). const fitDrafter = nowDrafter === 'dflash2' && native?.capabilities?.dflash2Selq4 === true ? 'dflash2_selq4' : nowDrafter; const draftingWords: Record = { auto: 'Auto (recommended)', mtp: 'MTP', dflash2: 'DFlash2', off: 'Off' }; const values = useMemo(() => ({ family: selectedSize?.sourceFamily, model: selectedSize?.model, context, vision: selectedSize?.images ? vision : 'no', kv, low_ram: lowRam, resourceProfile, ...(cardsGpus.length > 1 ? { gpus: cardsGpus.join(',') } : cardsGpus.length === 1 ? { gpu: cardsGpus[0] } : {}), loadAfter: true, multiple: expert && multiple }), [selectedSize?.sourceFamily, selectedSize?.model, context, vision, kv, lowRam, resourceProfile, cardsGpus.join(','), expert, multiple]); const downloadValues = { ...values, ...(draftingChoices ? { drafting } : {}), vision: selectedSize?.images && vision !== 'no' ? 'yes' : 'no', loadVision: selectedSize?.images ? vision : 'no', ...(noReader ? { visionUnavailable: true } : {}), ...(contextPicked ? { contextChosen: true } : {}) }; useEffect(() => { if (!native?.catalog || family) return; const current = native.instances.find(i => i.id === native.defaultId); const rec = native.catalog.recommendation ?? { family: null, model: null }; const loadedFamily = families.find(f => f.sizes.some(s => s.id === current?.model)); const have = new Set((native.installed?.models ?? []).filter(m => m.ready).map(m => m.model)); const installedFamily = families.find(f => f.sizes.some(s => have.has(s.id))); const f = loadedFamily ?? installedFamily ?? families.find(f => f.family === rec.family || f.sizes.some(s => s.sourceFamily === rec.family)) ?? families[0]; if (f) { setFamily(f.family); const first = f.sizes.find(s => s.id === current?.model) ?? f.sizes.find(s => have.has(s.id)) ?? f.sizes.find(s => s.model === rec.model) ?? f.sizes[0]; setSize(first?.id ?? ''); // 128K for every configuration (the engine's own recommendation is not what the app opens with). setContext(defaultContext(native.catalog.contexts)); } }, [native?.catalog]); // The version that is selected: a model already on this PC shows the settings it was prepared with (so loading it never asks to download); // a model that is not yet downloaded starts with Read pictures ON (owner rule: pictures on by default). This runs when the SELECTION or the // installed settings change, not when the page opens again: coming back from another tab keeps what was chosen. useEffect(() => { if (presetPending.current) { presetPending.current = false; return; } if (!selectedSize) return; const sig = installed ? ['have', installed.model, installed.ready, installed.context, installed.contextChosen, installed.kv, installed.lowRamMode, installed.drafting, installed.resourceProfile].join('|') : `new|${selectedSize.id}`; if (sig === appliedSig) return; setAppliedSig(sig); if (installed) { // The context it was prepared with when someone chose it; a model that holds the old default (32K) without the marker opens at the new default. if (installed.context) setContext(openingContext(installed.context, contextList, installed.contextChosen === true)); // Off only when the person turned it off (a saved choice on a model that has the picture files); a model prepared without them (images 'off', or an old "off" saved while the engine had no reader) starts with it ON. // The first time this version is seen as installed it opens from its saved settings; from then on that value is the person's (a host report that changes while a job runs never changes it). const known = visionPicks.current.get(selectedSize.id), value = shownVision(known, installed); if (known === undefined) visionPicks.current.set(selectedSize.id, value); setVision(value); setKv(installed.kv ?? 'int8'); setLowRam(installed.lowRamMode ?? 'auto'); setDrafting(installed.drafting ?? 'auto'); // A model never tuned has no saved choice: keep the page's own (Leave room for my work) rather than flipping to Full performance. if (installed.resourceProfile && !loadedSelected?.resourceProfile) setResourceProfile(installed.resourceProfile); } else { setDrafting('auto'); // a model that is not installed has no saved choice: Auto (the page never carries the last model's Drafting over to another one) setVision(shownVision(visionPicks.current.get(selectedSize.id), undefined)); if (!contextPicked) // a context the person picked stays; otherwise 128K setContext(defaultContext(contextList)); } }, [selectedSize?.id, installed?.model, installed?.ready, installed?.context, installed?.contextChosen, installed?.kv, installed?.lowRamMode, installed?.drafting, installed?.resourceProfile]); // drafting too: the saved choice that arrives after the page opened (an app restart) is the one shown, not Auto (0.2.15 release test) const pickVision = (next: string) => { if (selectedSize) visionPicks.current.set(selectedSize.id, next); setVision(next); }; useEffect(() => { if (jobId && job?.state === 'done' && job.id !== toastedJob && (job.kind === 'load' || job.kind === 'install')) { setToastedJob(job.id); selectRemoteModel(null); pushToast('success', 'Model ready', 'Start a new chat when you’re ready.'); } }, [job?.state]); // The picture files came without a load: a model that is loaded right now still runs without pictures until it is loaded again. useEffect(() => { if (jobId && job?.state === 'done' && job.id !== toastedJob && job.kind === 'pictures') { setToastedJob(job.id); pushToast('success', 'Picture files ready', loadedSelected && !loadedSelected.vision ? 'Load the model again to read pictures.' : 'Picture reading is ready.'); } }, [job?.state]); async function perform(action: () => Promise) { setPending(true); setError(''); try { await action(); } catch (e) { setError(e instanceof Error ? e.message : String(e)); } finally { setPending(false); } } /* Load model: no pop-up. The press itself is the yes. The plan is read first (Control checks the free disk space); a disk that is too small is said here, in the page, and nothing starts. Otherwise the download or the apply-and-load starts at once, with its size and notes in the page. */ // The model is on this computer and only its picture files are missing: the Load fetches those files itself (about 0.9 GB, once) and goes on; it does not run the installer again. const picturesByLoad = fetchesPictures(selectedSize, native?.packaged); async function load() { if (!selectedSize) return; setPlan(null); setDrafterGb(null); await perform(async () => { if (installed?.ready && context === installed.context && (!selectedSize?.images || vision === 'no' || picturesByLoad || installed.images && installed.images !== 'off') && (!installed.kv || kv === installed.kv || kv === tunedNow?.fields.kv) && (lowRam === (installed.lowRamMode ?? 'auto') || lowRam === tunedNow?.fields.lowRam)) { const result = await nativeAction('operations', { kind: 'load', args: { model: selectedSize.id, resourceProfile, vision: selectedSize?.images ? vision : 'no', ...(noReader ? { visionUnavailable: true } : {}), ...(contextPicked && !installed.contextChosen ? { contextChosen: true } : {}), multiple: expert && multiple, ...(draftingChoices ? { values: { drafting } } : {}), ...(roleCards.length > 1 ? (roles && customRoles ? { gpuRoles: effectiveRoles, layerSplit: expert && cardsGpus.length > 1 ? split : 'auto' } : cardsGpus.length ? { gpus: cardsGpus, gpusFromRecommendation: true, layerSplit: expert && cardsGpus.length > 1 ? split : 'auto' } : {}) : {}) } }); setJobId(result.id); } else { const planned = await api.post>('/api/native/plan', downloadValues); if (planned?.plan?.disk_short) { setPlan(planned); return; } setDrafterGb(planned?.drafting?.needed ? Number(planned.drafting.gb) || null : null); const result = await nativeAction('operations', { kind: 'install', args: downloadValues }); setJobId(result.id); } }); } /* Unload / Use in chat: a refusal (a chat is still using the model) is said here, beside the button, not far below the page. */ async function loadedAction(path: string) { setLoadedError(''); setPending(true); try { await nativeAction(path); } catch (e) { setLoadedError(e instanceof Error ? e.message : String(e)); } finally { setPending(false); } } // The drafter note belongs to the download that is running; the not-enough-disk message belongs to the version it was said for. useEffect(() => { if (!active) setDrafterGb(null); }, [!!active]); useEffect(() => { setPlan(null); }, [selectedSize?.id]); return {tr("Models")}} titleDetail={ { setFamily(f.family); setSize((f.sizes.find(s => native?.installed?.models.some(m => m.model === s.id && m.ready)) ?? f.sizes[0])?.id ?? ''); setVision('yes'); setError(''); }}/>} actions={ { setExpert(v => !v); setMultiple(false); }}>{tr(expert ? 'Close expert mode' : 'Expert mode')}}>
{tr(retiredModels.length ?
{retiredModels.map(m =>

{m.model_name ?? m.model} {m.retired?.line}

)}
: null)} {tr(native?.instances.length && expert ?

{tr(native.instances.length === 1 ? 'Loaded model' : 'Loaded models')}

{tr(native.instances.map(i =>
{tr(i.label)}{tr(i.gpus.length ? i.gpus.map((g, n) => `GPU ${g + 1}${i.gpus.length > 1 && n === i.gpus.length - 1 ? ' (Main)' : ''}`).join(' + ') : 'Automatic GPU')} · {tr(i.status === 'ready' ? i.phase : i.status)}{tr(native.defaultId === i.id ? ' · Chat default' : '')}{tr(i.error ? {tr(plainFailureText(i.error).message)} : null)}{tr(expert && multiple && native.defaultId !== i.id ? void loadedAction(`instances/${i.id}/default`)}>{tr("Use in chat")} : null)} void loadedAction(`instances/${i.id}/unload`)}>{tr("Unload")}
))}{tr(loadedError ? : null)}
: null)}
{tr(selectedFamily && (!selectedSize || selectedSize.needsNewerEngine) ? <>

{tr("This model needs a newer engine.")}

{tr("Update your engine or import a local GGUF for this model.")}

{ setSettingsSection('Engine'); go('settings'); }}>{tr("Update engine")}{tr("Use a local GGUF\u2026")} : null)}{tr(!selectedFamily && !listPending ? <>

{tr("Set up Strata")}

{tr("Connect your local installation to choose an optimized model.")}

{ setSettingsSection('Engine'); go('settings'); })}>{tr("Connect engine")}{tr(native?.error ?

{tr(native.error)}

: null)}{tr("Other local models")} : null)} {tr(selectedSize ? <>
{tr("Version")} { const f = families.find(f => f.family === v.family || f.sizes.some(s => s.sourceFamily === v.family)); if (!f) return; presetPending.current = true; setFamily(f.family); setSize(f.sizes.find(s => s.model === v.model && (s.sourceFamily === v.family || f.family === v.family))?.id ?? ''); setContext(v.context ?? 32768); setVision(v.vision ?? 'no'); setKv(v.kv ?? 'int8'); setLowRam(v.low_ram ?? 'auto'); }}/> setManage(true)}>{tr("Manage models")}
{ const f = families.find(f => f.sizes.some(s => s.id === id)); if (f) { setFamily(f.family); setSize(id); setError(''); } }} onOwnGguf={() => (onImport ?? onOtherModels)()}/>
{tr(fitState === 'ssd' ?

{tr("may run slower")}

: null)}
{tr("Conversation context")} ({ value: v, label: tr(draftingWords[v]) }))} onChange={v => setDrafting(String(v))}/>
: null)}
{tr("Computer use")}
{tr(contextIsTight(fitHardware.vram_gb, context, kv, selectedSize?.context_fit) ?

{tr("This much context takes about {0} GB of graphics memory and leaves little room for the model on this card. Strata will try it; if it does not start, choose a shorter context.", [contextCacheGb(context, kv, selectedSize?.context_fit).toFixed(1)])}

: null)} {tr(loadedSelected?.metrics?.engine?.drafting_note ?

{tr(String(loadedSelected.metrics.engine.drafting_note))}

: null)} {roleCards.length > 1 ? setRoles(null)} memoryGb={selectedSize ? memoryNeeded(selectedSize) || null : null} ramGb={pcRam} spillGb={selectedSize ? fitOn(selectedSize, fitHardware).spillGb : 0} usedBy={i => usedBy([i])}/> : null} {tr(roleCards.length > 1 && (native?.hardware?.gpus ?? []).length > roleCards.length ?

{tr('Not used: {0} (another make of graphics card than this engine drives).', [(native?.hardware?.gpus ?? []).filter(g => !roleCards.some(r => r.index === g.index && r.vendor === g.vendor)).map(g => g.name).join(', ')])}

: null)} {tr(selectedSize?.images || noReader ? <>
{tr(expert && vision !== 'no' ? setSplit(e.target.value)}/> : null)}
{tr(installed ? <> :

{tr("More engine parameters become available after preparing this version.")}

)}
: null)}
setDeleting(null)}/> setManage(false)} actions={ setManage(false)}>{tr("Done")}}>
{tr(downloaded.some(m => !m.retired && (m.ready || m.diskGb)) ?
{tr(downloaded.filter(m => !m.retired && (m.ready || m.diskGb)).map(m => { const v = allSizes.find(x => x.id === m.model), loaded = native?.instances.some(i => i.model === m.model && i.status === 'ready'); return
{tr(v ? `${catalogVersionLabel(v)}` : m.model_name ?? m.model)}{tr(v ? v.model : m.model)}{tr(m.diskGb ? ` · ${sizeGb(m.diskGb)}` : '')} {tr(loaded ? 'Loaded' : 'Downloaded')} { if (v) setSize(v.id); setManage(false); }}>{tr(selectedSize?.id === m.model ? 'Selected' : 'Use version')} setDeleting(m.model)}>{tr("Delete")}
; }))}
:

{tr("No downloaded models")}

)}
{ setManage(false); (onImport ?? onOtherModels)(); }}>{tr("Use a local GGUF…")}
{selectedSize ? setTuneOpen(false)} model={selectedSize.id} resourceProfile={resourceProfile} vision={selectedSize.images ? vision : 'no'} visionUnavailable={noReader}/> : null}
; } /** setup's "5/7: downloading …" as a sentence a person can read. */ /** The listed context sizes, plus the model's own when it is a size set by hand in its run config (the select would show nothing, and a load would silently pick another). */ export function contextChoices(listed: number[], current: number): number[] { return current > 0 && !listed.includes(current) ? [...listed, current].sort((a, b) => a - b) : listed; } function installStepLabel(step?: string): string { const n = Number(step?.match(/^(\d+)\//)?.[1]); if (!n) return step ? 'Getting things ready…' : 'Downloading and preparing model files…'; return n <= 2 ? 'Checking your computer…' : n <= 4 ? 'Getting things ready…' : n === 5 ? 'Downloading your model…' : n === 6 ? 'Preparing your model for Strata…' : 'Finishing up…'; } /** The formats of the conversation cache and what each costs, in one line (the memory figures are from docs/DETAILS.md: Q4 half of 8-bit, K8/V4 23% less). */ const KV_CHOICES = [ { value: 'int8', label: 'INT8', hint: 'INT8 is the standard: good quality and a medium amount of memory.' }, { value: 'q4_0', label: 'Q4', hint: 'Q4 uses about half the memory of INT8, but is less precise on very long documents.' }, { value: 'k8v4', label: 'K8 / V4', hint: 'K8 / V4 uses about a quarter less memory than INT8 and is more precise than Q4. Prompts are 2 to 5% slower.' }, ]; /** * What a running job is doing, and nothing else: one line with the step, one small line with the numbers when there are any, a thin bar, and Stop as a * plain word. A soft ring breathes beside the step (transform and opacity only; still under reduced motion). The bar fills with the real percent, or * glides while no percent is known. */ export function NativeProgress({ job, label }: { job: NativeJob; label?: string; }) { const download = installProgress(job.result?.install), detailsText = [job.details, job.result?.install?.engine?.details].filter(Boolean).join('\n'); const eta = useDownloadEta(job.kind === 'install' ? download : undefined, job.id); const [stopping, setStopping] = useState(false), [error, setError] = useState(''); async function stop() { setStopping(true); setError(''); try { await nativeAction(`operations/${job.id}/cancel`); } catch (e) { setError(e instanceof Error ? e.message : String(e)); } finally { setStopping(false); } } const running = job.state === 'running', stoppable = ['install', 'load', 'pictures', 'autotune', 'recheck'].includes(job.kind); const kindTitle = job.kind === 'install' ? (label ? tr('Preparing {0}', [label]) : 'Preparing your model') : job.kind === 'load' ? 'Loading model' : job.kind === 'pictures' ? 'Downloading the picture files' : job.kind === 'autotune' || job.kind === 'recheck' ? 'Tuning your model' : 'Engine operation'; const step = job.kind === 'install' ? (job.result?.install?.label ?? (download && /^5\//.test(job.result?.install?.step ?? '') ? stageText(installStage(job.result?.install)) : installStepLabel(job.result?.install?.step))) : job.summary; const percent = download && Number.isFinite(download.percent) ? Math.max(0, Math.min(100, Number(download.percent))) : null; const numbers = [percent !== null ? `${Math.round(percent)}%` : '', download && Number.isFinite(download.done_gb) && Number.isFinite(download.total_gb) ? `${download.done_gb!.toFixed(1)} / ${download.total_gb!.toFixed(1)} GB` : '', eta].filter(Boolean).join(' · '); const words = tr(step || kindTitle); return
{running ?
: null} {detailsText ?
{tr("Details")}
{detailsText}
: null} {error ? : null}
; }