From 27de07ceff3e3d2e6e3292c1922b86c72910871a Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sun, 1 Nov 2026 00:25:32 +0100 Subject: [PATCH] App: one card tells a person with an older engine that a newer one is available, with one button (Update engine); #4848 After an app or Control update the engine is never touched, and the app said nothing. Strata Control keeps what the last update or check found newer (update_available of 'strata components engine', Qwen engine and DeepSeek engine; read without the network); the host passes it to the app as engine.updateAvailable and the Models screen shows one card in plain words with the existing Update engine job as its button (disabled while a job runs or a model is loaded). A DeepSeek engine update is reported as an engine update, not as 'Strata is updated'. JavaScript only; the Control side is on f-0291-keepcurrent. --- apps/host/server/native-control.mjs | 4 +- apps/host/src/components/EngineUpdateCard.tsx | 40 +++++++++++++++++++ apps/host/src/components/NativeModels.tsx | 2 + apps/host/src/lib/native.ts | 2 +- apps/host/src/locales/fix-de.json | 4 +- apps/host/src/locales/fix-en.json | 4 +- apps/host/src/locales/fix-es.json | 4 +- apps/host/src/locales/fix-fr.json | 4 +- apps/host/src/locales/fix-ja.json | 4 +- apps/host/src/locales/fix-ko.json | 4 +- apps/host/src/locales/fix-pt.json | 4 +- apps/host/src/locales/fix-ru.json | 4 +- apps/host/src/locales/fix-zh.json | 4 +- apps/host/src/styles/onboarding.css | 2 + apps/host/tests/engine-update-card.test.mjs | 33 +++++++++++++++ 15 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 apps/host/src/components/EngineUpdateCard.tsx create mode 100644 apps/host/tests/engine-update-card.test.mjs diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjs index 4b56261cbc..7ffa3da277 100644 --- a/apps/host/server/native-control.mjs +++ b/apps/host/server/native-control.mjs @@ -125,7 +125,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp 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),missing:missingNames(m.missing,disk[m.id]?.missingFiles),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,wrongMake:engine.wrongMake===true,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}, + installDir:list.install_dir,engine:{usable:engine.usable,notice:engine.notice,wrongMake:engine.wrongMake===true,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,updateAvailable:engine.update_available??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,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}; @@ -446,7 +446,7 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};} } return {summary:notes.filter(Boolean).join(' '),result:done}; } - function updateSummary(done){const r=(done.results??[]).filter(x=>x.status==='updated').map(x=>x.component==='engine'?'The engine is updated and ready.':'Strata is updated. It takes effect the next time you open the app.');return r.length?r.join(' '):'Everything is already up to date.';} + function updateSummary(done){const r=(done.results??[]).filter(x=>x.status==='updated').map(x=>x.component==='engine'||x.component==='dsv41'?'The engine is updated and ready.':'Strata is updated. It takes effect the next time you open the app.');return r.length?r.join(' '):'Everything is already up to date.';} function execute(cmd,args,cwd){return new Promise((resolve,reject)=>{let output='';const process=spawnProcess(cmd,args,{cwd,stdio:['ignore','pipe','pipe']});process.stdout.on('data',c=>{output+=c;if(output.length>100000)process.kill();});process.stderr.on('data',c=>append('update',c.toString()));process.on('error',reject);process.on('exit',code=>code===0?resolve(output):reject(new Error('Git could not update this installation. Open diagnostics.')));});} /* Every write of a model's run config keeps the person's options: those they wrote into "args" or "user_args" since the file was last written are read from the file itself, go over what the caller built, and "args_written" is refreshed. */ function writeModelConfig(path,next){const mine=mergeUserArgs(captureUserArgs(readJson(path)),next[USER_KEY]??[]);next=stampedUserArgs(next,mine);copyFileSync(path,path+'.bak');chmodSync(path+'.bak',0o600);const temp=path+'.ui-tmp';writeFileSync(temp,JSON.stringify(next,null,2)+'\n',{mode:0o600});renameSync(temp,path);} diff --git a/apps/host/src/components/EngineUpdateCard.tsx b/apps/host/src/components/EngineUpdateCard.tsx new file mode 100644 index 0000000000..ee8d007351 --- /dev/null +++ b/apps/host/src/components/EngineUpdateCard.tsx @@ -0,0 +1,40 @@ +import { useState } from 'react'; +import { tr } from '../lib/i18n'; +import { Btn, Icon } from './ui'; +import { nativeAction, type NativeState } from '../lib/native'; + +/** Strata Control's last check found a newer engine than the one installed (the Qwen engine, the DeepSeek engine, or both): its numbers come from the + * check kept on this PC (`update_available` of `strata components engine`), so showing the card reads no network. After an app or Control update this is how a + * person with an older engine is told (#4848). */ +export const engineUpdateOffered = (native: NativeState | null | undefined) => { + const offer = native?.engine?.updateAvailable; + return !!(offer && (offer.engine || offer.dsv41)); +}; + +/** One card, plain words, one button. The update itself is the existing "Update engine" job (its progress shows where every job's does); models are not touched. */ +export function EngineUpdateCard({ native, busy }: { native: NativeState | null | undefined; busy: boolean }) { + const [pending, setPending] = useState(false); + const [error, setError] = useState(''); + if (!engineUpdateOffered(native)) return null; + const running = (native?.instances.length ?? 0) > 0; + async function update() { + setPending(true); + setError(''); + try { + await nativeAction('operations', { kind: 'update-engine' }); + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + } finally { + setPending(false); + } + } + return
+ +
+

{tr("A newer engine is available for this computer. Your models and settings stay as they are.")}

+ {running ? {tr("Unload your running models first.")} : null} + {error ? {error} : null} +
+ void update()}>{tr("Update engine")} +
; +} diff --git a/apps/host/src/components/NativeModels.tsx b/apps/host/src/components/NativeModels.tsx index 1cdcb1119d..e6dfaab2a3 100644 --- a/apps/host/src/components/NativeModels.tsx +++ b/apps/host/src/components/NativeModels.tsx @@ -12,6 +12,7 @@ import { installProgress, installStage, stageText, useDownloadEta } from '../lib import { useKept } from '../lib/kept-state'; import { DownloadParts } from './DownloadParts'; import { EngineWarning } from './EngineWarning'; +import { EngineUpdateCard } from './EngineUpdateCard'; import { sizeGb } from '../lib/format'; import { NativeDeleteDialog } from './NativeDelete'; import { plainFailureText } from '../lib/plain-errors'; @@ -205,6 +206,7 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine {tr(selectedSize?.images ? <>
{tr(expert && vision !== 'no' ?