diff --git a/apps/host/src/components/NativeModels.tsx b/apps/host/src/components/NativeModels.tsx index 1ea22472..ec40a713 100644 --- a/apps/host/src/components/NativeModels.tsx +++ b/apps/host/src/components/NativeModels.tsx @@ -84,7 +84,12 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine }, [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'); - const job = native?.jobs.find(j => j.id === jobId) ?? (!jobId ? native?.jobs.filter(j => ['load', 'install'].includes(j.kind)).at(-1) : undefined); + // 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); const noFit = selectedSize?.on_this_pc === 'does not fit'; // 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. diff --git a/apps/host/tests/guided-setup-empty-catalog.test.mjs b/apps/host/tests/guided-setup-empty-catalog.test.mjs index 17c87ca6..b826ce81 100644 --- a/apps/host/tests/guided-setup-empty-catalog.test.mjs +++ b/apps/host/tests/guided-setup-empty-catalog.test.mjs @@ -25,6 +25,7 @@ const stubs={ store:stubFor('store.ts',{useStore:'sel=>sel(globalThis.__store)'}), client:stubFor('client.ts',{}), router:stubFor('router.ts',{}), + 'kept-state':stubFor('kept-state.ts',{useKept:'(key,initial)=>[globalThis.__kept?.[key]??initial,()=>{}]'}), }; let dir,mod; @@ -32,7 +33,7 @@ async function load(){ if(mod)return mod; dir=mkdtempSync(join(tmpdir(),'strata-gs-')); const stubPlugin={name:'stubs',setup(b){ - b.onResolve({filter:/\/lib\/(native|store|client|router)$/},args=>({path:args.path.split('/').pop(),namespace:'stub'})); + b.onResolve({filter:/\/lib\/(native|store|client|router|kept-state)$/},args=>({path:args.path.split('/').pop(),namespace:'stub'})); b.onLoad({filter:/.*/,namespace:'stub'},args=>({contents:stubs[args.path],loader:'js',resolveDir:root})); }}; const entry=join(dir,'entry.tsx'); @@ -82,3 +83,42 @@ test('GuidedSetup lists the real catalog when it has one',async()=>{ const html=m.renderToString(m.createElement(m.GuidedSetup)); assert.match(html,/IQ3_XXS/); }); + +const failedJob=(id,model,family)=>({id,kind:'install',model,family,state:'error', + startedAt:'2026-01-01T00:00:00.000Z',summary:'Previous preparation failed', + error:'Data_dir C:\\Users\\Example\\.strata\\models: a new data folder must be named Strata',result:null}); +async function renderModelJobs(jobs,kept={}){ + const m=await load(); + const size=(id,model)=>({id,model,download_gb:50,ram_needed_gb:48,experts_gb:30,about:'',on_this_pc:'fits',installed:false}); + globalThis.__native={...base,jobs,catalog:{contexts:[32768,65536],families:[ + {family:'qwen',title:'Qwen3.8-Flash-Next',about:'',images:false,experimental:false,sizes:[size('iq3_s','IQ3_S')]}, + {family:'swift',title:'Qwen3.8-Flash-Next (Swift)',about:'',images:false,experimental:false,sizes:[size('swift-iq3_s','IQ3_S')]}, + ]}}; + globalThis.__store=store();globalThis.__kept=kept; + try{return m.renderToString(m.createElement(m.NativeModels));}finally{globalThis.__kept={};} +} + +test('NativeModels does not attach another family’s failed preparation to the selected version',async()=>{ + const job=failedJob('old-swift','IQ3_S','swift'),jobs=[job]; + assert.doesNotMatch(await renderModelJobs(jobs),/Data_dir/); + assert.equal(jobs[0],job,'the job is retained for diagnostics'); +}); + +test('NativeModels ignores a remembered job after selecting a different model',async()=>{ + assert.doesNotMatch(await renderModelJobs([failedJob('old-swift','swift-iq3_s','swift')],{'models.job':'old-swift'}),/Data_dir/); +}); + +test('NativeModels still shows the selected canonical model’s real failure',async()=>{ + assert.match(await renderModelJobs([failedJob('current','iq3_s')]),/Data_dir/); +}); + +test('NativeModels identifies aliases by source family and keeps matching remembered errors',async()=>{ + assert.match(await renderModelJobs([failedJob('current','IQ3_S','qwen')],{'models.job':'current'}),/Data_dir/); + assert.doesNotMatch(await renderModelJobs([failedJob('ambiguous','IQ3_S')]),/Data_dir/); +}); + +test('NativeModels falls back to the latest job for the selected version, not an unrelated remembered job',async()=>{ + const own=failedJob('own','iq3_s'),other={...failedJob('other','swift-iq3_s','swift'),error:'Other model error'}; + const html=await renderModelJobs([own,other],{'models.job':'other'}); + assert.match(html,/Data_dir/);assert.doesNotMatch(html,/Other model error/); +});