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++
Models folder: Finish or leave an interrupted move from the Storage card (host routes, card notice, 6 strings in 8 languages)
Niko12216c688faf2277
diff --git a/apps/host/server/control-runtime.mjs b/apps/host/server/control-runtime.mjsindex 0447572de..3e02f8b19 100644--- a/apps/host/server/control-runtime.mjs+++ b/apps/host/server/control-runtime.mjs@@ -224,6 +224,26 @@ export function createControl({ control = findControl(), env = process.env, runconst error = result.json?.error;throw Object.assign(new ControlError(error?.message ?? (result.stderr.split(/\r?\n/).filter(Boolean).pop() || 'The models could not be moved.'), { exitCode: result.code, output: result.json }), { code: error?.code ?? 'move_failed', details: error?.details ?? '' });},+ /** A move of the models folder that the last run left unfinished (`strata models move --status`): null, or {state, from, to, bytes}. */+ async interruptedModelsMove(dataFolder) {+ const result = await call(['models', 'move', '--status', ...(dataFolder ? ['--from', dataFolder] : []), '--output', 'json'], { timeoutMs: 30_000 });+ if (result.json?.ok) return result.json.interrupted ?? null;+ throw failure(result, 'The models folder could not be checked.');+ },+ /** "Finish it": the same move again, from where it stopped. Same events and result as moveModels. */+ async resumeModelsMove(dataFolder, { installDir = null, cancelFile = null, onEvent = null } = {}) {+ const args = ['models', 'move', '--resume', ...(dataFolder ? ['--from', dataFolder] : []), ...(installDir ? ['--install-dir', installDir] : []), ...(cancelFile ? ['--cancel-file', cancelFile] : []), '--output', 'jsonl'];+ const result = await call(args, { timeoutMs: 24 * 3600_000, onLine: onEvent ?? (() => {}) });+ if (result.json?.ok && result.json.event === 'result') return result.json;+ const error = result.json?.error;+ throw Object.assign(new ControlError(error?.message ?? (result.stderr.split(/\r?\n/).filter(Boolean).pop() || 'The models could not be moved.'), { exitCode: result.code, output: result.json }), { code: error?.code ?? 'move_failed', details: error?.details ?? '' });+ },+ /** "Leave it": keep the old folder, remove the partial copies in the new one. */+ async leaveModelsMove(dataFolder, { installDir = null } = {}) {+ const result = await call(['models', 'move', '--leave', ...(dataFolder ? ['--from', dataFolder] : []), ...(installDir ? ['--install-dir', installDir] : []), '--output', 'json'], { timeoutMs: 24 * 3600_000 });+ if (result.json?.ok) return result.json;+ throw Object.assign(failure(result, 'The partial copies could not be removed.'), { code: result.json?.error?.code ?? 'leave_failed', details: result.json?.error?.details ?? '' });+ },async saveProfile(name, configPath) {const listed = await call(['profile', 'list', '--output', 'json'], { timeoutMs: 20_000 });const known = (listed.json?.profiles ?? []).some(p => p.id === name);diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjsindex eb454cb4f..f8d638ad7 100644--- a/apps/host/server/index.mjs+++ b/apps/host/server/index.mjs@@ -974,6 +974,9 @@ async function api(req, res, path, method, url) {if(picked.cancelled)return json(res,200,{cancelled:true});return json(res,200,{plan:await native.planModelsFolder(picked.path)});}if(path==='/api/native/models-folder/start'&&method==='POST'){const body=await readBody(req);const result=await native.startModelsFolder({folder:body.path,choice:body.choice,stopRunning:body.stopRunning===true});return json(res,result.id?202:200,result);}+ if(path==='/api/native/models-folder/interrupted'&&method==='GET')return json(res,200,{interrupted:await native.interruptedMove()});+ if(path==='/api/native/models-folder/resume'&&method==='POST'){const body=await readBody(req);return json(res,202,await native.finishInterruptedMove({stopRunning:body.stopRunning===true}));}+ if(path==='/api/native/models-folder/leave'&&method==='POST')return json(res,200,await native.leaveInterruptedMove());if(path==='/api/native/plan'&&method==='POST')return json(res,200,await native.plan(await readBody(req)));if(path==='/api/native/operations'&&method==='POST'){if(storageChanging)return error(res,409,'Wait for the model folder check to finish.');const body=await readBody(req);return json(res,202,native.operation(body.kind,body.args));}if(path==='/api/native/logs'&&method==='GET')return json(res,200,{logs:native.logs()});diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjsindex 75f7c0ced..7ec4a440d 100644--- a/apps/host/server/native-control.mjs+++ b/apps/host/server/native-control.mjs@@ -424,11 +424,15 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}setDownloadDirectory(target);lastRead=0;await refresh(true);return {done:true,choice,folder:target,oldFolder:old,setAside:aside};}+ return runModelsMove(old,target,(from,to,options)=>control.moveModels(from,to,options));+ }+ /* The move as a job (the progress dialog reads it). `run` is moveModels for a new move, resumeModelsMove for "Finish it". */+ function runModelsMove(old,target,run){rmSync(moveFile(),{force:true});return begin('models-move',async job=>{job.cancelFile=moveFile();job.summary='Starting…';try{- const result=await control.moveModels(old,target,{installDir:repo(),cancelFile:moveFile(),onEvent:event=>{+ const result=await run(old,target,{installDir:repo(),cancelFile:moveFile(),onEvent:event=>{if(event.event!=='progress')return;job.progress={done:event.done,total:event.total,file:event.file,group:event.group,index:event.index,count:event.count,secondsLeft:event.seconds_left||0,sameDrive:!!event.same_drive};job.summary=`${Math.round(event.done/1e8)/10} of ${Math.round(event.total/1e8)/10} GB`;emit();}});@@ -445,10 +449,33 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}}finally{rmSync(moveFile(),{force:true});}},{family:undefined});}+ /* "A move was interrupted. Finish it or leave it": the next start finds the unfinished move (Control keeps a note in the models folder in use). */+ async function interruptedMove(){+ if(!packaged)return null;+ const now=currentModelsFolder();if(!now)return null;+ if([...jobs.values()].some(j=>j.kind==='models-move'&&j.state==='running'))return null;+ try{return await control.interruptedModelsMove(now);}catch{return null;}+ }+ async function finishInterruptedMove({stopRunning=false}={}){+ const st=await interruptedMove();if(!st)throw new Error('No move was interrupted.');+ if([...jobs.values()].some(j=>j.state==='running'))throw new Error('Finish or stop the download to change the folder.');+ if(instances.size){+ if(!stopRunning)throw Object.assign(new Error('A model is running. Stop it first, then change the folder.'),{code:'running'});+ for(const id of [...instances.keys()])await unload(id);+ }+ return runModelsMove(st.from,st.to,(from,to,options)=>control.resumeModelsMove(from,options));+ }+ async function leaveInterruptedMove(){+ const st=await interruptedMove();if(!st)throw new Error('No move was interrupted.');+ if([...jobs.values()].some(j=>j.state==='running'))throw new Error('Finish or stop the download to change the folder.');+ const result=await control.leaveModelsMove(st.from,{installDir:repo()});+ lastRead=0;await refresh(true);+ return {done:true,folder:st.from,partial:st.to,removed:result.removed??0,restored:result.restored??0};+ }async function cancel(id){const job=jobs.get(id);if(!job||job.state!=='running')throw new Error('This operation is no longer running.');if(job.kind==='install'){job.engineAbort?.abort();await tool('strata_install',{cancel:true});}else if(job.kind==='models-move'){/* a safe stop: the copy in flight is dropped, files already moved stay */try{writeFileSync(job.cancelFile,'stop');}catch{/* the run ends anyway */}job.summary='Stopping…';emit();return state();}else if(job.abort)job.abort.abort();else if(job.process){if(!['tune','calibrate','autotune','recheck'].includes(job.kind))throw new Error('File updates cannot be cancelled safely while files are being replaced.');job.state='cancelled';await stopProcess(job.process);}job.state='cancelled';job.summary=job.kind==='install'?'Stopped. Completed downloads are kept.':'Stopped.';emit();return state();}async function close(){closing=true;clearInterval(timer);const installing=packaged&&child&&[...jobs.values()].some(j=>j.kind==='install'&&j.state==='running');if(installing)await send('tools/call',{name:'strata_install',arguments:{cancel:true}},15000).catch(()=>{});const operations=[];for(const job of jobs.values()){job.abort?.abort();if(job.process)operations.push(stopProcess(job.process));if(job.state==='running')job.state='cancelled';}await Promise.all(operations);await Promise.all([...instances.keys()].map(id=>unload(id,true).catch(()=>{})));disconnect();}// Remove nonserializable process references from public jobs.const publicState=()=>{const value=state();value.jobs=value.jobs.map(({process,engineAbort,rawResult,...job})=>job);return value;};async function localPreview(path){if(!packaged)throw new Error('Checking local model files is part of the Strata app.');if(typeof path!=='string'||!path.trim()||[...path].some(c=>c.charCodeAt(0)<32))throw new Error('Choose a folder.');return control.importPlan(path.trim());}- return {state:publicState,tuneStatus,tuneEffective,tuneOff,tunePresets:{list:()=>autotuner.list(),action:(kind,id,extra)=>autotuner.action(kind,id,extra),undoFor:async args=>autotuner.undoFor(tuneConfig(args).path)},refresh,localPreview,configure,setDownloadDirectory,planModelsFolder,startModelsFolder,plan,settings,save,settingsFile,openSettingsFile,operation,cancel,unload,resolveInstance,poll,logs:()=>logs.slice(),benchmarkReport:()=>readJson(join(directory,'native-benchmark.json'),null),setDefault(id){defaultId=resolveInstance(id).id;emit();return publicState();},hasLive:()=>[...instances.values()].some(i=>i.status==='ready'),readyInstances:()=>[...instances.values()].filter(i=>i.status==='ready'),close};+ return {state:publicState,tuneStatus,tuneEffective,tuneOff,tunePresets:{list:()=>autotuner.list(),action:(kind,id,extra)=>autotuner.action(kind,id,extra),undoFor:async args=>autotuner.undoFor(tuneConfig(args).path)},refresh,localPreview,configure,setDownloadDirectory,planModelsFolder,startModelsFolder,interruptedMove,finishInterruptedMove,leaveInterruptedMove,plan,settings,save,settingsFile,openSettingsFile,operation,cancel,unload,resolveInstance,poll,logs:()=>logs.slice(),benchmarkReport:()=>readJson(join(directory,'native-benchmark.json'),null),setDefault(id){defaultId=resolveInstance(id).id;emit();return publicState();},hasLive:()=>[...instances.values()].some(i=>i.status==='ready'),readyInstances:()=>[...instances.values()].filter(i=>i.status==='ready'),close};}diff --git a/apps/host/src/components/ModelsFolderDialog.tsx b/apps/host/src/components/ModelsFolderDialog.tsxindex 8d9ba884d..4111effe9 100644--- a/apps/host/src/components/ModelsFolderDialog.tsx+++ b/apps/host/src/components/ModelsFolderDialog.tsx@@ -54,6 +54,8 @@ export function ModelsFolderCard({ blocked }: { blocked: boolean }) {const [outcome, setOutcome] = useState<{ job: NativeJob } | null>(null);const [notice, setNotice] = useState('');const [stopping, setStopping] = useState(false);+ const [unfinished, setUnfinished] = useState<{ from: string; to: string } | null>(null);+ const [resumed, setResumed] = useState<{ from: string; to: string } | null>(null);const folder = native?.downloadDirectory ?? '';const free = native?.downloadFreeBytes ?? null;const usage = native?.installed?.usage?.total_bytes ?? 0;@@ -64,6 +66,41 @@ export function ModelsFolderCard({ blocked }: { blocked: boolean }) {const used = free !== null && total ? Math.min(100, Math.max(1, ((total - free) / total) * 100)) : 0;useEffect(() => { if (moving && !jobId) setJobId(moving.id); }, [moving, jobId]);+ /* A move that a crash or a stop left half done: found again at the next start, with its two choices. */+ useEffect(() => {+ if (moving || outcome) return;+ let live = true;+ api.get<{ interrupted: { from: string; to: string } | null }>('/api/native/models-folder/interrupted')+ .then(r => { if (live) setUnfinished(r.interrupted); }).catch(() => { if (live) setUnfinished(null); });+ return () => { live = false; };+ }, [moving, outcome, folder]);+ async function finishMove() {+ if (!unfinished) return;+ setPending(true);+ setError(null);+ try {+ const result = await api.post<NativeJob>('/api/native/models-folder/resume', { stopRunning: true });+ setResumed(unfinished);+ setUnfinished(null);+ if (result.id) { setJobId(result.id); setOutcome(null); await refreshNative(true); }+ }+ catch (e) { setError({ message: (e as Error).message, details: ((e as ApiError).body as { details?: string } | undefined)?.details }); }+ finally { setPending(false); }+ }+ async function leaveMove() {+ if (!unfinished) return;+ setPending(true);+ setError(null);+ try {+ await api.post('/api/native/models-folder/leave', {});+ setNotice(tr('The partial copies were removed. Your models are in {0}.', [unfinished.from]));+ setUnfinished(null);+ await refreshNative(true);+ }+ catch (e) { setError({ message: (e as Error).message, details: ((e as ApiError).body as { details?: string } | undefined)?.details }); }+ finally { setPending(false); }+ }+function leave() { setPlan(null); setStage(null); setError(null); setTyping(false); }async function pick(path = '') {setPending(true);@@ -106,7 +143,7 @@ export function ModelsFolderCard({ blocked }: { blocked: boolean }) {try { await nativeAction(`operations/${moving.id}/cancel`); }catch (e) { setError({ message: (e as Error).message }); }}- function closeResult() { setOutcome(null); setJobId(null); leave(); setNotice(''); }+ function closeResult() { setOutcome(null); setJobId(null); setResumed(null); leave(); setNotice(''); }const progress = moving?.progress as { done: number; total: number; file: string; group: string; index: number; count: number; secondsLeft: number; sameDrive: boolean } | null | undefined;const percent = progress && progress.total > 0 ? Math.round((progress.done / progress.total) * 100) : 0;@@ -125,6 +162,12 @@ export function ModelsFolderCard({ blocked }: { blocked: boolean }) {<input id="models-folder-path" className="st-input" value={typed} onChange={e => setTyped(e.target.value)} placeholder={tr('Full path to an existing folder')} spellCheck={false} autoFocus/><div className="row"><Btn variant="primary" type="submit" disabled={pending || !typed.trim()}>{tr('Use this directory')}</Btn></div></form> : null}+ {unfinished && !moving ? <div className="models-notice models-notice--info" role="alert"><Icon name="info" size={18}/><div>+ <strong>{tr('A move was interrupted. Finish it or leave it.')}</strong><br/>+ {tr('Strata was moving your models from {0} to {1} when it stopped. Nothing is lost.', [unfinished.from, unfinished.to])}+ <p className="small muted">{tr('Finishing puts all your models in {1}. Leaving it keeps them in {0} and removes the partial copies from {1}.', [unfinished.from, unfinished.to])}</p>+ <div className="row"><Btn variant="primary" size="sm" disabled={pending || blocked} onClick={() => void finishMove()}>{tr('Finish the move')}</Btn><Btn size="sm" disabled={pending || blocked} onClick={() => void leaveMove()}>{tr('Leave it')}</Btn></div>+ </div></div> : null}{notice ? <p className="small storage-directory__notice" role="status"><Icon name="check" size={15}/>{notice}</p> : null}{error && !stage ? <Failure message={error.message} details={error.details}/> : null}</section>@@ -155,7 +198,7 @@ export function ModelsFolderCard({ blocked }: { blocked: boolean }) {<p className="small">{tr('Keep Strata open. You can keep using other apps. Your models cannot be loaded until the move is done.')}</p>{progress ? <details className="models-details"><summary>{tr('Details')}</summary><ul><li>{tr('Now copying: {0}, file {1} of {2}', [modelName(progress.group, native) ?? progress.group, progress.index, progress.count])}</li>- <li>{tr('From {0} to {1}', [savedPlan?.current ?? '', savedPlan?.folder ?? ''])}</li></ul></details> : null}+ <li>{tr('From {0} to {1}', [savedPlan?.current ?? resumed?.from ?? '', savedPlan?.folder ?? resumed?.to ?? ''])}</li></ul></details> : null}</Dialog><ResultDialog outcome={outcome?.job ?? null} plan={savedPlan} native={native} onClose={closeResult} onAgain={() => { closeResult(); void pick(); }}/>@@ -199,7 +242,7 @@ function ChooseBody({ plan, choice, setChoice, names, error }: { plan: Plan; chofunction ResultDialog({ outcome, plan, native, onClose, onAgain }: { outcome: NativeJob | null; plan: Plan | null; native: NativeState | null; onClose: () => void; onAgain: () => void }) {if (!outcome) return null;const result = (outcome.result ?? {}) as Outcome;- const sized = (groups: string[]) => list(groups.map(g => { const m = plan?.models.find(x => x.group === g); const name = modelName(g, native); return name ? `${name} (${gb(m?.bytes ?? 0)})` : null; }).filter((x): x is string => !!x));+ const sized = (groups: string[]) => list(groups.map(g => { const m = plan?.models.find(x => x.group === g); const name = modelName(g, native); return name ? (m ? `${name} (${gb(m.bytes)})` : name) : null; }).filter((x): x is string => !!x));if (outcome.state === 'error') {const full = result.code === 'disk_full';const where = driveOf(result.to ?? '');diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.jsonindex 09f832941..8b0b25ca2 100644--- a/apps/host/src/locales/de.json+++ b/apps/host/src/locales/de.json@@ -3437,5 +3437,11 @@"s8413": "Ein Modell läuft. Stoppen Sie es zuerst und ändern Sie dann den Ordner.","s8414": "Wählen Sie einen Modellordner.","s8415": "Wählen Sie, was mit Ihren Modellen geschehen soll.",- "s8416": "Diese Möglichkeit gibt es hier nicht."+ "s8416": "Diese Möglichkeit gibt es hier nicht.",+ "s8417": "Ein Verschieben wurde unterbrochen. Beenden Sie es oder lassen Sie es sein.",+ "s8418": "Strata hat Ihre Modelle von {0} nach {1} verschoben, als es angehalten wurde. Es ist nichts verloren.",+ "s8419": "Verschieben beenden",+ "s8420": "Belassen",+ "s8421": "Beenden legt alle Ihre Modelle in {1} ab. Belassen lässt sie in {0} und entfernt die unvollständigen Kopien aus {1}.",+ "s8422": "Die unvollständigen Kopien wurden entfernt. Ihre Modelle liegen in {0}."}diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.jsonindex 59b543fe7..2f0c9903b 100644--- a/apps/host/src/locales/en.json+++ b/apps/host/src/locales/en.json@@ -3437,5 +3437,11 @@"s8413": "A model is running. Stop it first, then change the folder.","s8414": "Choose a models folder.","s8415": "Choose what to do with your models.",- "s8416": "That choice is not possible here."+ "s8416": "That choice is not possible here.",+ "s8417": "A move was interrupted. Finish it or leave it.",+ "s8418": "Strata was moving your models from {0} to {1} when it stopped. Nothing is lost.",+ "s8419": "Finish the move",+ "s8420": "Leave it",+ "s8421": "Finishing puts all your models in {1}. Leaving it keeps them in {0} and removes the partial copies from {1}.",+ "s8422": "The partial copies were removed. Your models are in {0}."}diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.jsonindex ff46ecd48..af4f2cd7f 100644--- a/apps/host/src/locales/es.json+++ b/apps/host/src/locales/es.json@@ -3437,5 +3437,11 @@"s8413": "Hay un modelo en ejecución. Deténlo primero y después cambia la carpeta.","s8414": "Elige una carpeta de modelos.","s8415": "Elige qué hacer con tus modelos.",- "s8416": "Esa opción no es posible aquí."+ "s8416": "Esa opción no es posible aquí.",+ "s8417": "Se interrumpió un traslado. Termínelo o déjelo como estaba.",+ "s8418": "Strata estaba trasladando sus modelos de {0} a {1} cuando se detuvo. No se ha perdido nada.",+ "s8419": "Terminar el traslado",+ "s8420": "Dejarlo",+ "s8421": "Terminar pone todos sus modelos en {1}. Dejarlo los mantiene en {0} y elimina las copias parciales de {1}.",+ "s8422": "Se eliminaron las copias parciales. Sus modelos están en {0}."}diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.jsonindex adc211355..1b29a58bc 100644--- a/apps/host/src/locales/ja.json+++ b/apps/host/src/locales/ja.json@@ -3437,5 +3437,11 @@"s8413": "モデルが実行中です。先に停止してから、フォルダを変更してください。","s8414": "モデルフォルダを選んでください。","s8415": "モデルをどうするか選んでください。",- "s8416": "この選択肢はここでは使えません。"+ "s8416": "この選択肢はここでは使えません。",+ "s8417": "移動が中断されました。完了するか、中止してください。",+ "s8418": "Strata がモデルを {0} から {1} へ移動している途中で止まりました。失われたものはありません。",+ "s8419": "移動を完了する",+ "s8420": "中止する",+ "s8421": "完了すると、すべてのモデルが {1} に入ります。中止すると、モデルは {0} に残り、{1} の不完全なコピーが削除されます。",+ "s8422": "不完全なコピーを削除しました。モデルは {0} にあります。"}diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.jsonindex 77bd09ad1..4d6f84108 100644--- a/apps/host/src/locales/ko.json+++ b/apps/host/src/locales/ko.json@@ -3437,5 +3437,11 @@"s8413": "모델이 실행 중입니다. 먼저 중지한 뒤 폴더를 변경하세요.","s8414": "모델 폴더를 선택하세요.","s8415": "모델을 어떻게 할지 선택하세요.",- "s8416": "여기서는 해당 선택지를 사용할 수 없습니다."+ "s8416": "여기서는 해당 선택지를 사용할 수 없습니다.",+ "s8417": "이동이 중단되었습니다. 마무리하거나 그대로 두세요.",+ "s8418": "Strata가 모델을 {0}에서 {1}(으)로 옮기던 중 멈췄습니다. 잃어버린 것은 없습니다.",+ "s8419": "이동 마무리",+ "s8420": "그대로 두기",+ "s8421": "마무리하면 모든 모델이 {1}에 들어갑니다. 그대로 두면 모델은 {0}에 남고 {1}의 불완전한 복사본이 삭제됩니다.",+ "s8422": "불완전한 복사본을 삭제했습니다. 모델은 {0}에 있습니다."}diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.jsonindex 91ba5cb16..181b64944 100644--- a/apps/host/src/locales/pt.json+++ b/apps/host/src/locales/pt.json@@ -3437,5 +3437,11 @@"s8413": "Há um modelo em execução. Pare-o primeiro e depois altere a pasta.","s8414": "Escolha uma pasta de modelos.","s8415": "Escolha o que fazer com seus modelos.",- "s8416": "Essa opção não é possível aqui."+ "s8416": "Essa opção não é possível aqui.",+ "s8417": "Uma mudança foi interrompida. Termine-a ou deixe como estava.",+ "s8418": "O Strata estava mudando seus modelos de {0} para {1} quando parou. Nada foi perdido.",+ "s8419": "Terminar a mudança",+ "s8420": "Deixar como está",+ "s8421": "Terminar coloca todos os seus modelos em {1}. Deixar como está mantém os modelos em {0} e remove as cópias parciais de {1}.",+ "s8422": "As cópias parciais foram removidas. Seus modelos estão em {0}."}diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.jsonindex 02b7e2f69..e8a597f77 100644--- a/apps/host/src/locales/ru.json+++ b/apps/host/src/locales/ru.json@@ -3437,5 +3437,11 @@"s8413": "Модель запущена. Сначала остановите её, затем смените папку.","s8414": "Выберите папку моделей.","s8415": "Выберите, что сделать с моделями.",- "s8416": "Этот вариант здесь невозможен."+ "s8416": "Этот вариант здесь невозможен.",+ "s8417": "Перенос был прерван. Завершите его или оставьте как есть.",+ "s8418": "Strata переносил ваши модели из {0} в {1}, когда остановился. Ничего не потеряно.",+ "s8419": "Завершить перенос",+ "s8420": "Оставить как есть",+ "s8421": "Если завершить, все модели окажутся в {1}. Если оставить, модели останутся в {0}, а неполные копии в {1} будут удалены.",+ "s8422": "Неполные копии удалены. Ваши модели находятся в {0}."}diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.jsonindex d7a75e9cf..8cb479656 100644--- a/apps/host/src/locales/zh.json+++ b/apps/host/src/locales/zh.json@@ -3437,5 +3437,11 @@"s8413": "有模型正在运行。请先停止它,再更改文件夹。","s8414": "请选择模型文件夹。","s8415": "请选择如何处理你的模型。",- "s8416": "此处无法使用该选项。"+ "s8416": "此处无法使用该选项。",+ "s8417": "移动被中断了。请完成它,或保持原样。",+ "s8418": "Strata 正在把你的模型从 {0} 移到 {1} 时停止了。没有任何内容丢失。",+ "s8419": "完成移动",+ "s8420": "保持原样",+ "s8421": "完成后,所有模型都会放到 {1}。保持原样则模型留在 {0},并删除 {1} 中不完整的副本。",+ "s8422": "已删除不完整的副本。你的模型在 {0}。"}diff --git a/apps/host/tests/models-folder.test.mjs b/apps/host/tests/models-folder.test.mjsindex ef2769bc8..e3b4b0e1d 100644--- a/apps/host/tests/models-folder.test.mjs+++ b/apps/host/tests/models-folder.test.mjs@@ -8,7 +8,7 @@ import { createNativeControl } from '../server/native-control.mjs';import { createControl } from '../server/control-runtime.mjs';/** The host in the packaged app with a stand-in for Strata Control: the move itself is Control's (tests/terminal/test_models_move.py). */-function fixture(t, { plan = {}, move = null } = {}) {+function fixture(t, { plan = {}, move = null, unfinished = null } = {}) {const root = realpathSync(mkdtempSync(join(tmpdir(), 'strata-mfolder-')));const install = join(root, 'install'), data = join(root, 'host'), oldFolder = join(root, 'old'), newFolder = join(root, 'new');for (const d of [install, data, oldFolder, newFolder]) mkdirSync(d, { recursive: true });@@ -34,6 +34,13 @@ function fixture(t, { plan = {}, move = null } = {}) {options.onEvent({ event: 'progress', done: 5e9, total: 74e9, file: 'models/gyro-s/a.gguf', group: 'gyro-s', index: 1, count: 3, seconds_left: 300, same_drive: false });return { ok: true, event: 'result', done: true, stopped: false, moved: ['gyro-s', 'coder'], remaining: [], bytes_moved: 74e9, total_bytes: 74e9, files_moved: 3, same_drive: false };},+ async interruptedModelsMove(from) { calls.push(['status', from]); return unfinished; },+ async resumeModelsMove(from, options) {+ calls.push(['resume', from, options.installDir]);+ options.onEvent({ event: 'progress', done: 20e9, total: 74e9, file: 'models/coder/c.gguf', group: 'coder', index: 2, count: 3, seconds_left: 120, same_drive: false });+ return { ok: true, event: 'result', done: true, stopped: false, moved: ['coder'], remaining: [], bytes_moved: 74e9, total_bytes: 74e9, files_moved: 2, same_drive: false };+ },+ async leaveModelsMove(from, options) { calls.push(['leave', from, options.installDir]); return { ok: true, removed: 1, restored: 1, bytes_removed: 5 }; },async stop() { return { ok: true }; },};const spawnProcess = () => { throw new Error('the host starts no process here'); };@@ -160,11 +167,45 @@ test('a move needs the app: the Control command line is built from the plan andawait assert.rejects(failing.moveModels('/o', '/n'), e => e.code === 'disk_full' && e.details === 'ENOSPC' && /ran out of space/.test(e.message));});+test('an unfinished move is found at the next start, and Finish resumes it as a job that changes the folder only when done', async t => {+ const f = fixture(t);+ f.control.interruptedModelsMove = async from => { f.calls.push(['status', from]); return { state: 'failed', from: f.oldFolder, to: f.newFolder, bytes: 74e9 }; };+ assert.equal((await f.native.interruptedMove()).to, f.newFolder);+ assert.deepEqual(f.calls[0], ['status', f.oldFolder]);+ const job = await f.native.finishInterruptedMove({ stopRunning: true });+ const done = await finish(f.native, job.id);+ assert.equal(done.state, 'done');+ assert.equal(f.calls.find(c => c[0] === 'resume')[1], f.oldFolder);+ assert.equal(f.native.state().downloadDirectory, f.newFolder);+});++test('Leave it keeps the old folder and asks Control to remove the partial copies; nothing interrupted means nothing to do', async t => {+ const f = fixture(t);+ assert.equal(await f.native.interruptedMove(), null);+ await assert.rejects(f.native.leaveInterruptedMove(), /No move was interrupted/);+ f.control.interruptedModelsMove = async () => ({ state: 'running', from: f.oldFolder, to: f.newFolder, bytes: 1 });+ const result = await f.native.leaveInterruptedMove();+ assert.equal(result.folder, f.oldFolder);+ assert.deepEqual(f.calls.find(c => c[0] === 'leave').slice(0, 2), ['leave', f.oldFolder]);+ assert.equal(f.native.state().downloadDirectory, f.oldFolder);+});++test('the Control command lines for status, resume and leave', async () => {+ const seen = [];+ const control = createControl({ control: { dir: '/c', python: '/c/py', cli: '/c/strata.py' }, run: async args => { seen.push(args); return args.includes('--status') ? { code: 0, json: { ok: true, interrupted: { from: '/o', to: '/n' } }, text: '', stderr: '' } : args.includes('--leave') ? { code: 0, json: { ok: true, removed: 0 }, text: '', stderr: '' } : { code: 0, json: { ok: true, event: 'result', done: true }, text: '', stderr: '' }; } });+ assert.equal((await control.interruptedModelsMove('/o')).to, '/n');+ await control.resumeModelsMove('/o', { installDir: '/i', cancelFile: '/c.cancel' });+ await control.leaveModelsMove('/o', { installDir: '/i' });+ assert.deepEqual(seen[0], ['models', 'move', '--status', '--from', '/o', '--output', 'json']);+ assert.deepEqual(seen[1], ['models', 'move', '--resume', '--from', '/o', '--install-dir', '/i', '--cancel-file', '/c.cancel', '--output', 'jsonl']);+ assert.deepEqual(seen[2], ['models', 'move', '--leave', '--from', '/o', '--install-dir', '/i', '--output', 'json']);+});+test('the models folder strings exist in all 8 languages with the same placeholders', () => {const read = lang => JSON.parse(readFileSync(new URL(`../src/locales/${lang}.json`, import.meta.url), 'utf8'));const en = read('en');- const ours = Object.keys(en).filter(k => Number(k.slice(1)) >= 8339 && Number(k.slice(1)) <= 8416);- assert.equal(ours.length, 78);+ const ours = Object.keys(en).filter(k => Number(k.slice(1)) >= 8339 && Number(k.slice(1)) <= 8422);+ assert.equal(ours.length, 84);for (const lang of ['de', 'es', 'ja', 'ko', 'pt', 'ru', 'zh']) {const text = read(lang);for (const key of ours) {