okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-dl99-fixes: the Qwen3.6 first-run download (no engine-race stop, no cancelled engine download, progress to 100%, the picture reader's real figure, the engine-not-ready sentence)361c8d94a

main
2.5 KiB27 linesraw
1export interface DownloadProgress {percent?:number;done_gb?:number;total_gb?:number;remaining_gb?:number;file?:string}
2/** The native installer reports each shard, not whole-model progress. */
3export function downloadCounter(size:number|undefined,progress:DownloadProgress|undefined,running:boolean){
4 if(running&&progress?.file==='checking files')return {value:undefined,label:'Preparing files…',key:'preparing'};   // nothing is downloaded while setup checks the files (DL99)
5 if(running&&progress){
6  if(Number.isFinite(progress.remaining_gb))return {value:Math.max(0,progress.remaining_gb!),label:'GB left to download',key:'total'};
7  if(Number.isFinite(progress.total_gb)&&Number.isFinite(progress.done_gb))return {value:Math.max(0,progress.total_gb!-progress.done_gb!),label:'GB left in this file',key:progress.file??'file'};
8  if(Number.isFinite(progress.total_gb)&&Number.isFinite(progress.percent))return {value:Math.max(0,progress.total_gb!*(1-Math.min(100,Math.max(0,progress.percent!))/100)),label:'GB left in this file',key:progress.file??'file'};
9 }
10 return running?{value:undefined,label:progress?'Downloading…':'Preparing files…',key:'preparing'}:{value:size,label:'GB to download',key:'size'};
11}
12/** The setup wizard moves on from its download page only when the model is ready. An install that ended with every file in, for a model that is not ready
13 *  because the engine for this PC is missing or can't be used, left the page at its last figure (99%) with no word (DL99): it then says so, with the next step. */
14export function engineNotReadyAfterInstall(installState:string|undefined,modelReady:boolean|undefined,engineUsable:boolean|undefined){
15 return installState==='done'&&modelReady!==true&&engineUsable===false;
16}
17export function onboardingError(message:string){
18 if(/(?:not enough.*(?:disk|storage)|disk.*(?:space|full)|ENOSPC)/i.test(message)){
19  const needed=message.match(/(?:about\s+)?([\d.]+)\s*GB\s+(?:needed|required)/i)?.[1];
20  const free=message.match(/([\d.]+)\s*GB\s+(?:free|available)/i)?.[1];
21  return {title:'You need more storage.',message:needed?`This model needs about ${needed} GB.${free?` You have ${free} GB free.`:''}`:'There isn’t enough free space to download this model.',next:'Choose another folder or a smaller model.',storage:true};
22 }
23 return {title:'Something needs your attention.',message,next:undefined,storage:false};
24}
25export function modelFolderLabel(path:string){
26 return /[\\/]Documents[\\/]Strata[\\/]Models[\\/]?$/i.test(path)?'Documents / Strata / Models':path;
27}