function statusClass(status){status=String(status||'unknown');if(status.includes('success'))return'success';if(status.includes('manual'))return'warn';if(status.includes('blocker')||status.includes('failed'))return'error';if(status.includes('running')||status==='RUNNING')return'running';return''} function shortText(value,max=42){value=String(value||'—');return value.length>max?value.slice(0,max-1)+'…':value} function inferredJobUrl(summary={}, detail={}){ if(summary.job_url)return summary.job_url; const launch=detail.launch||{}; if(launch.job_url)return launch.job_url; const jobId=summary.job_id||launch.job_id||detail.state?.job_id; const owner=launch.created_by||detail.state?.created_by||state.user?.username; return jobId&&owner?`https://huggingface.co/jobs/${owner}/${jobId}`:''; } function runMatchesStatus(run,status){ const s=String(run.status||'unknown').toLowerCase(); if(!status||status==='all')return true; if(status==='running')return s.includes('running')||s==='queued'||s==='pending'; if(status==='full_inference_success')return s.includes('success'); if(status==='manual_hardware_required')return s.includes('manual')||s.includes('hardware'); if(status==='technical_blocker')return s.includes('blocker'); if(status==='failed')return s.includes('failed')||s.includes('error'); return s===String(status).toLowerCase(); } function runMatchesQuery(run,query){ if(!query)return true; const haystack=[run.run_id,run.model_id,run.target_space,run.status,run.kind,run.selected_hardware].map(x=>String(x||'').toLowerCase()).join(' '); return haystack.includes(String(query).toLowerCase()); } function filteredRuns(){ const query=document.getElementById('runSearch')?.value||''; const status=state.runStatusFilter||'all'; return (state.runsCache||[]).filter(r=>runMatchesStatus(r,status)&&runMatchesQuery(r,query)); } function renderRunStats(){ const counts={all:state.runsCache.length,running:0,full_inference_success:0,manual_hardware_required:0,failed:0}; for(const r of state.runsCache){ if(runMatchesStatus(r,'running'))counts.running+=1; if(runMatchesStatus(r,'full_inference_success'))counts.full_inference_success+=1; if(runMatchesStatus(r,'manual_hardware_required'))counts.manual_hardware_required+=1; if(runMatchesStatus(r,'failed'))counts.failed+=1; } document.querySelectorAll('.filter[data-status]').forEach(btn=>{ const status=btn.dataset.status||'all'; const label={all:'All',running:'Running',full_inference_success:'Success',manual_hardware_required:'Manual',failed:'Failed',technical_blocker:'Blockers'}[status]||status; const count=counts[status]; btn.textContent=typeof count==='number'?`${label} ${count}`:label; }); } function renderSelectedLinks(summary={}){ const detail=state.selectedRunDetail||{}; const runId=summary.run_id||detail.run_id; const bucket=summary.bucket_source||detail.bucket_source||state.bucketSource; const artifacts=summary.artifacts_url||(typeof artifactUrl==='function'?artifactUrl(runId,bucket):''); const jobUrl=inferredJobUrl(summary,detail); setLink('selectedOpenJob',jobUrl); setLink('selectedOpenSpace',summary.target_space_url); setLink('selectedOpenSettings',summary.target_space_url?summary.target_space_url+'/settings':''); setLink('selectedOpenArtifacts',artifacts); const btn=document.getElementById('selectedValidateBtn'); if(btn){btn.disabled=!summary.target_space;btn.onclick=()=>{state.selectedRunDetail=state.selectedRunDetail||{summary};prepareValidationFromActiveRun();}} } function renderBlockers(detail={}){ const root=document.getElementById('selectedBlockers');if(!root)return; const summary=detail.summary||{};const blockers=detail.technical_blockers||{}; const manual=summary.manual_hardware_required||String(summary.status||'').includes('manual_hardware_required'); const blockerItems=Array.isArray(blockers.blockers)?blockers.blockers:[]; if(!manual&&!blockerItems.length){root.hidden=true;root.innerHTML='';return;} root.hidden=false;const parts=[]; if(manual)parts.push('Manual hardware required
Open Space settings, choose the recommended GPU, then run validation.
'); for(const b of blockerItems.slice(0,4)){parts.push(`${shortText(b.type||b.name||'Technical blocker',32)}${shortText(b.claim||b.reason||b.message||'',120)}
`)} root.innerHTML=parts.join(''); } function renderRunRows(runs,compact=false){ return (runs||[]).map(r=>``).join('') } function renderRunsFromCache(){ const runs=filteredRuns(); const roots=[['runsTable',false],['runsTableHome',true]]; for(const [id,compact] of roots){ const root=document.getElementById(id); if(root)root.innerHTML=renderRunRows(runs,compact)||'${escapeHtml(e.message)}
`; } } function renderRunDetail(detail){ state.selectedRunDetail=detail; const summary=detail.summary||{};const smoke=detail.generation_smoke||{};const files=detail.files||[]; setText('selectedRunId',detail.run_id||summary.run_id||'—');setText('selectedModelId',summary.model_id||'—');setText('selectedTargetSpace',summary.target_space||'—');setText('selectedHardware',summary.selected_hardware||'—'); setText('runDetailStatus',summary.status||'unknown');setText('homeRunDetailStatus',summary.status||'unknown');setText('detailRunId',summary.run_id||detail.run_id);setText('detailJobStatus',summary.status||'—');setText('detailGateStatus',(detail.inference_gate||{}).status||summary.status||'—');setText('detailSpace',summary.target_space||'—');setText('detailHardware',summary.selected_hardware||summary.hardware||'—');setText('detailTraces',Array.isArray(detail.events)?String(detail.events.length)+' events':summary.traces_count||'—'); const statusEl=document.getElementById('runDetailStatus');if(statusEl)statusEl.className='badge '+statusClass(summary.status);const homeStatus=document.getElementById('homeRunDetailStatus');if(homeStatus)homeStatus.className='badge '+statusClass(summary.status); const validation=document.getElementById('selectedValidation');if(validation){validation.innerHTML=`${escapeHtml(shortText(firstLine,180))}
`} setQuickLinks({job_url:inferredJobUrl(summary,detail),target_space_url:summary.target_space_url,target_space_settings_url:summary.target_space_url?summary.target_space_url+'/settings':'',artifacts_url:summary.artifacts_url,bucket_source:detail.bucket_source,run_id:summary.run_id||detail.run_id}); renderSelectedLinks({...summary,bucket_source:detail.bucket_source});renderBlockers(detail); const homeBtn=document.getElementById('homeValidateBtn');if(homeBtn){homeBtn.disabled=!summary.target_space;homeBtn.onclick=prepareValidationFromActiveRun} } let runSearchTimer=null; document.getElementById('runSearch')?.addEventListener('input',()=>{clearTimeout(runSearchTimer);runSearchTimer=setTimeout(renderRunsFromCache,90)});