okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
3d9c21509
main
1import type { NativeState } from './native' ; 2 3/** 4* Why a message cannot be sent right now, in plain words, or null when a model can answer. One answer for the composer's Send and for the 5* store, so a run never starts without a model. A model that is still downloading shows its progress instead of "none". 6*/ 7export function noModelNotice ( native :NativeState | null , opts :{ remote ?:boolean ; libraryLoaded ?:boolean } = {}) :{ title :string ; message :string } | null { 8if ( opts . remote || opts . libraryLoaded ) return null ; 9if ( native ?. instances . some ( i => i . status === 'ready' )) return null ; 10const downloading = native ?. jobs ?. find ( j => j . state === 'running' && ( j . result ?. install ?. download || / install|prepare|download|pull|fetch / i . test ( j . kind ))); 11if ( downloading ) { 12const percent = Number ( downloading . result ?. install ?. download ?. percent ); 13return { title :'A model is downloading' , message :Number . isFinite ( percent ) ?`Your model is downloading ( ${ Math . round ( percent )} %). You can chat when it has finished.` :'Your model is downloading. You can chat when it has finished.' }; 14} 15if ( native ?. instances . some ( i => i . status === 'loading' )) return { title :'The model is loading' , message :'Your model is still loading. You can chat in a moment.' }; 16return { title :'No model is loaded' , message :'No model is loaded. Load one in Models first.' }; 17}