Upload 8 files
Browse files- web/static/app.js +45 -2
web/static/app.js
CHANGED
|
@@ -31,6 +31,49 @@ function runPassedSpaceCreation(payload={}){
|
|
| 31 |
const passedSteps=new Set(['create_space','create_space_hardware','upload_files','runtime_upload_epoch']);
|
| 32 |
return Array.isArray(events)&&events.some(e=>passedSteps.has(String(e.step||''))&&String(e.status||'').toLowerCase()==='success');
|
| 33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
function isValidationRunDetail(detail={}){
|
| 36 |
const summary=detail.summary||{};
|
|
@@ -317,7 +360,7 @@ function setGeneratedSpaceLinksEnabled(links={},enabled=false){
|
|
| 317 |
for(const id of ['activeOpenSpace','openSpace','launchOpenSpace'])setLink(id,space);
|
| 318 |
for(const id of ['activeOpenSettings','openSettings','manualOpenSettings','launchOpenSettings'])setLink(id,settings);
|
| 319 |
}
|
| 320 |
-
function setQuickLinks(links={},context={}){links=normalizeLinks(links||{});state.activeLinks=links;for(const id of ['activeOpenJob','openJob','launchOpenJob'])setLink(id,links.job_url);const runForLinks=links.run_id||context.run_id||context.summary?.run_id||state.runId;let spaceReady=Boolean(links.target_space_url&&(
|
| 321 |
let operationTimer=null;function toastDuration(type='info'){if(type==='loading')return 12000;if(type==='error')return 7000;if(type==='warning'||type==='warn')return 6000;return 3500}
|
| 322 |
function setOperation(message,type='info',opts={}){const el=$('operationStatus');if(!el)return;if(operationTimer){clearTimeout(operationTimer);operationTimer=null}if(!message){el.hidden=true;el.textContent='';el.className='operation-status floating-toast';return}el.hidden=false;el.className='operation-status floating-toast '+type;el.textContent=message;const duration=opts.duration??toastDuration(type);if(duration>0)operationTimer=setTimeout(()=>{setOperation('')},duration)}
|
| 323 |
function showMessage(msg,isError=false){const type=isError===true?'error':(typeof isError==='string'?isError:'info');setOperation(msg,type);const el=$('eventsPanel');if(el&&!state.runId)el.textContent=(isError?'Error: ':'')+msg}
|
|
@@ -1535,7 +1578,7 @@ async function refreshRunReportPreview(runId){
|
|
| 1535 |
console.warn('report refresh failed',e);
|
| 1536 |
}
|
| 1537 |
}
|
| 1538 |
-
async function refreshProgress(){if(!state.runId||state.progressPollInFlight)return;state.progressPollInFlight=true;try{const now=Date.now();const includeLogs=!state.lastJobLogPoll||now-state.lastJobLogPoll>8000;if(includeLogs)state.lastJobLogPoll=now;const requestedRunId=state.runId;const p=await apiGet(`/api/runs/${encodeURIComponent(requestedRunId)}/progress?bucket_name=${encodeURIComponent(state.bucketName)}${includeLogs?'&include_job_logs=1':''}`);if(requestedRunId!==state.runId)return;if((p.run_id||p.summary?.run_id)&&state.runId&&(p.run_id||p.summary?.run_id)!==state.runId)return;state.activeRunProgress=p;state.pollErrors=0;if(p.bucket_source)state.bucketSource=p.bucket_source;try{if(typeof renderRunViewSnapshot==='function')renderRunViewSnapshot(p);else renderProgress(p);}catch(renderErr){console.warn('renderRunViewSnapshot failed; keeping events visible',renderErr);try{renderProgress(p)}catch(_){}}renderEvents(p.view?.activity||p.events_recent||p.events||[]);renderMetrics(p);if(typeof upsertRunExplorerFromProgress==='function')upsertRunExplorerFromProgress(p);if(typeof renderRunStats==='function')renderRunStats();if(typeof renderActiveRunActions==='function')renderActiveRunActions({...p.summary,bucket_source:p.bucket_source},p);if(typeof renderRunDocuments==='function')renderRunDocuments({...p,summary:{...p.summary,bucket_source:p.bucket_source}});if(typeof renderAgentRecovery==='function')renderAgentRecovery(p);if(typeof renderBlockers==='function')renderBlockers(p);if(p.view){setText('detailRunId',p.view.run_id||p.run_id);setText('selectedModelId',p.view.header?.model||p.summary?.model_id||'β')}else{setText('detailRunId',p.run_id||state.runId)}renderActiveRunMeta(p);if(p.state){setText('detailSpace',p.state.target_space||p.summary?.target_space||'β');const mode=runImplementationMode(p.summary||{},p);setText('detailImplementationMode',mode?implementationModeLabel(mode):'β');const modeEl=$('detailImplementationMode');if(modeEl&&mode)modeEl.title=implementationModeDescription(mode);setText('detailHardware',p.state.selected_hardware||p.summary?.selected_hardware||'β')}const canonicalUi=typeof canonicalRunUiState==='function'?canonicalRunUiState(p):{label:badgeLabel(p.view?.header?.status||p.status||p.state?.status||'running'),status:p.view?.header?.status||p.status||p.state?.status||'running'};setText('detailJobStatus',canonicalUi.label||badgeLabel(canonicalUi.status||'running'));setText('detailGateStatus',p.inference_gate?.status||p.summary?.gate_status||'β');setText('detailTraces',Array.isArray(p.events)?String(p.events.length)+' events':'β');setText('homeRunDetailStatus',canonicalUi.label||badgeLabel(canonicalUi.status||'running'));setQuickLinks({...p.links,...p.view?.links,...p.space_link_state,...p.view?.space_link_state,bucket_source:p.bucket_source,run_id:p.run_id},{...p,space_identity:p.space_identity||p.view?.space_link_state||p.space_link_state||{},events:p.events||[]});saveActiveRun();const modelProgress=p.view?.timeline_model?.progress||{};const terminalSnapshot=modelProgress.terminal===true||p.view?.status_model?.is_terminal===true;const canonicalForTerminal=typeof canonicalRunUiState==='function'?canonicalRunUiState(p):null;const status=String(canonicalForTerminal?.status||p.view?.header?.status||p.status||p.state?.status||'').toLowerCase();if((terminalSnapshot||TERMINAL_STATUSES.has(status))&&state.poll){clearInterval(state.poll);state.poll=null;if(state.lastReportRefreshRunId!==state.runId){
|
| 1539 |
state.lastReportRefreshRunId=state.runId;
|
| 1540 |
const finalRunId=state.runId;
|
| 1541 |
setTimeout(()=>{if(state.runId===finalRunId)refreshRunReportPreview(finalRunId)},120);
|
|
|
|
| 31 |
const passedSteps=new Set(['create_space','create_space_hardware','upload_files','runtime_upload_epoch']);
|
| 32 |
return Array.isArray(events)&&events.some(e=>passedSteps.has(String(e.step||''))&&String(e.status||'').toLowerCase()==='success');
|
| 33 |
}
|
| 34 |
+
function contextTargetSpaceUrl(context={},links={}){
|
| 35 |
+
const summary=context.summary||context.detail?.summary||{};
|
| 36 |
+
const stateObj=context.state||context.detail?.state||{};
|
| 37 |
+
const launch=context.launch||context.detail?.launch||{};
|
| 38 |
+
const view=context.view||{};
|
| 39 |
+
const linkState=context.space_link_state||view.space_link_state||context.detail?.space_link_state||{};
|
| 40 |
+
const identity=context.space_identity||context.detail?.space_identity||{};
|
| 41 |
+
const candidates=[
|
| 42 |
+
links.target_space_url,links.space_url,
|
| 43 |
+
summary.target_space_url,stateObj.target_space_url,launch.target_space_url,
|
| 44 |
+
view.links?.target_space_url,view.links?.space_url,
|
| 45 |
+
linkState.target_space_url,identity.target_space_url,
|
| 46 |
+
context.target_space_url
|
| 47 |
+
];
|
| 48 |
+
for(const value of candidates){if(value&&String(value).trim())return String(value).trim()}
|
| 49 |
+
const target=firstNonEmpty(
|
| 50 |
+
links.target_space,links.target_space_id,links.space_id,links.space,
|
| 51 |
+
summary.target_space,summary.target_space_id,stateObj.target_space,stateObj.target_space_id,
|
| 52 |
+
launch.target_space,launch.target_space_id,linkState.target_space,linkState.target_space_id,
|
| 53 |
+
identity.target_space,identity.target_space_id,context.target_space,context.target_space_id
|
| 54 |
+
).replace(/^https:\/\/huggingface.co\/spaces\//,'').replace(/\/$/,'');
|
| 55 |
+
return target&&target.includes('/')?`https://huggingface.co/spaces/${target}`:'';
|
| 56 |
+
}
|
| 57 |
+
function contextIndicatesSpaceLinksReady(context={},links={}){
|
| 58 |
+
const summary=context.summary||context.detail?.summary||{};
|
| 59 |
+
const stateObj=context.state||context.detail?.state||{};
|
| 60 |
+
const view=context.view||{};
|
| 61 |
+
const linkState=context.space_link_state||view.space_link_state||context.detail?.space_link_state||{};
|
| 62 |
+
const identity=context.space_identity||context.detail?.space_identity||{};
|
| 63 |
+
if(links.links_ready||links.space_created||links.space_uploaded||links.runtime_uploaded||links.space_runtime_known)return true;
|
| 64 |
+
if(linkState.links_ready||linkState.space_created||linkState.space_uploaded||linkState.runtime_uploaded||linkState.space_runtime_known)return true;
|
| 65 |
+
if(identity.links_ready||identity.space_created||identity.space_uploaded||identity.runtime_uploaded||identity.space_runtime_known)return true;
|
| 66 |
+
if(runPassedSpaceCreation(context))return true;
|
| 67 |
+
const statusText=[
|
| 68 |
+
links.status,links.verdict,links.effective_status,
|
| 69 |
+
context.status,context.verdict,context.effective_status,
|
| 70 |
+
summary.status,summary.verdict,summary.effective_status,summary.gate_status,
|
| 71 |
+
stateObj.status,stateObj.verdict,stateObj.effective_status,
|
| 72 |
+
view.header?.status,view.status_model?.global_status,view.status_model?.display_status,
|
| 73 |
+
context.inference_gate?.status,summary.inference_gate?.status,stateObj.inference_gate?.status
|
| 74 |
+
].map(x=>String(x||'').toLowerCase()).join(' ');
|
| 75 |
+
return Boolean(statusText.match(/full_inference_success|repair_success|validated_after_space_test|validated_after_manual_space_test|manual_validation_passed|manual_validated|recovered_by_space_test|recovered_by_manual_validation|full_inference_candidate_health_passed|partial_validation|completed_with_warnings|demo_usable_full_promise_not_verified|interactive_app_available_smoke_failed|manual_test_required_smoke_failed|manual_hardware_required|generated_needs_manual_hardware|waiting_manual_action|placeholder_scaffold_deployed|health_only/));
|
| 76 |
+
}
|
| 77 |
|
| 78 |
function isValidationRunDetail(detail={}){
|
| 79 |
const summary=detail.summary||{};
|
|
|
|
| 360 |
for(const id of ['activeOpenSpace','openSpace','launchOpenSpace'])setLink(id,space);
|
| 361 |
for(const id of ['activeOpenSettings','openSettings','manualOpenSettings','launchOpenSettings'])setLink(id,settings);
|
| 362 |
}
|
| 363 |
+
function setQuickLinks(links={},context={}){links=normalizeLinks(links||{});const resolvedSpaceUrl=contextTargetSpaceUrl(context,links);if(resolvedSpaceUrl&&!links.target_space_url)links.target_space_url=resolvedSpaceUrl;if(!links.target_space_settings_url&&links.target_space_url)links.target_space_settings_url=links.target_space_url+'/settings';state.activeLinks=links;for(const id of ['activeOpenJob','openJob','launchOpenJob'])setLink(id,links.job_url);const runForLinks=links.run_id||context.run_id||context.summary?.run_id||state.runId;let spaceReady=Boolean(links.target_space_url&&contextIndicatesSpaceLinksReady(context,links));if(spaceReady&&links.target_space_url)state.spaceLinksUnlockedFor=runForLinks;if(!spaceReady&&state.spaceLinksUnlockedFor&&state.spaceLinksUnlockedFor===runForLinks&&links.target_space_url)spaceReady=true;setGeneratedSpaceLinksEnabled(links,spaceReady);for(const id of ['activeOpenArtifacts','openArtifacts','launchOpenArtifacts'])setLink(id,links.artifacts_url);renderManualAction({links:{...links,target_space_url:spaceReady?links.target_space_url:'',target_space_settings_url:spaceReady?links.target_space_settings_url:''}})}
|
| 364 |
let operationTimer=null;function toastDuration(type='info'){if(type==='loading')return 12000;if(type==='error')return 7000;if(type==='warning'||type==='warn')return 6000;return 3500}
|
| 365 |
function setOperation(message,type='info',opts={}){const el=$('operationStatus');if(!el)return;if(operationTimer){clearTimeout(operationTimer);operationTimer=null}if(!message){el.hidden=true;el.textContent='';el.className='operation-status floating-toast';return}el.hidden=false;el.className='operation-status floating-toast '+type;el.textContent=message;const duration=opts.duration??toastDuration(type);if(duration>0)operationTimer=setTimeout(()=>{setOperation('')},duration)}
|
| 366 |
function showMessage(msg,isError=false){const type=isError===true?'error':(typeof isError==='string'?isError:'info');setOperation(msg,type);const el=$('eventsPanel');if(el&&!state.runId)el.textContent=(isError?'Error: ':'')+msg}
|
|
|
|
| 1578 |
console.warn('report refresh failed',e);
|
| 1579 |
}
|
| 1580 |
}
|
| 1581 |
+
async function refreshProgress(){if(!state.runId||state.progressPollInFlight)return;state.progressPollInFlight=true;try{const now=Date.now();const includeLogs=!state.lastJobLogPoll||now-state.lastJobLogPoll>8000;if(includeLogs)state.lastJobLogPoll=now;const requestedRunId=state.runId;const p=await apiGet(`/api/runs/${encodeURIComponent(requestedRunId)}/progress?bucket_name=${encodeURIComponent(state.bucketName)}${includeLogs?'&include_job_logs=1':''}`);if(requestedRunId!==state.runId)return;if((p.run_id||p.summary?.run_id)&&state.runId&&(p.run_id||p.summary?.run_id)!==state.runId)return;state.activeRunProgress=p;state.pollErrors=0;if(p.bucket_source)state.bucketSource=p.bucket_source;try{if(typeof renderRunViewSnapshot==='function')renderRunViewSnapshot(p);else renderProgress(p);}catch(renderErr){console.warn('renderRunViewSnapshot failed; keeping events visible',renderErr);try{renderProgress(p)}catch(_){}}renderEvents(p.view?.activity||p.events_recent||p.events||[]);renderMetrics(p);if(typeof upsertRunExplorerFromProgress==='function')upsertRunExplorerFromProgress(p);if(typeof renderRunStats==='function')renderRunStats();if(typeof renderActiveRunActions==='function')renderActiveRunActions({...p.summary,bucket_source:p.bucket_source},p);if(typeof renderRunDocuments==='function')renderRunDocuments({...p,summary:{...p.summary,bucket_source:p.bucket_source}});if(typeof renderAgentRecovery==='function')renderAgentRecovery(p);if(typeof renderBlockers==='function')renderBlockers(p);if(p.view){setText('detailRunId',p.view.run_id||p.run_id);setText('selectedModelId',p.view.header?.model||p.summary?.model_id||'β')}else{setText('detailRunId',p.run_id||state.runId)}renderActiveRunMeta(p);if(p.state){setText('detailSpace',p.state.target_space||p.summary?.target_space||'β');const mode=runImplementationMode(p.summary||{},p);setText('detailImplementationMode',mode?implementationModeLabel(mode):'β');const modeEl=$('detailImplementationMode');if(modeEl&&mode)modeEl.title=implementationModeDescription(mode);setText('detailHardware',p.state.selected_hardware||p.summary?.selected_hardware||'β')}const canonicalUi=typeof canonicalRunUiState==='function'?canonicalRunUiState(p):{label:badgeLabel(p.view?.header?.status||p.status||p.state?.status||'running'),status:p.view?.header?.status||p.status||p.state?.status||'running'};setText('detailJobStatus',canonicalUi.label||badgeLabel(canonicalUi.status||'running'));setText('detailGateStatus',p.inference_gate?.status||p.summary?.gate_status||'β');setText('detailTraces',Array.isArray(p.events)?String(p.events.length)+' events':'β');setText('homeRunDetailStatus',canonicalUi.label||badgeLabel(canonicalUi.status||'running'));setQuickLinks({...p.links,...p.view?.links,...p.space_link_state,...p.view?.space_link_state,target_space_url:p.summary?.target_space_url||p.state?.target_space_url||p.links?.target_space_url||p.view?.links?.target_space_url,target_space:p.summary?.target_space||p.state?.target_space||p.links?.target_space||p.view?.links?.target_space,bucket_source:p.bucket_source,run_id:p.run_id},{...p,space_identity:p.space_identity||p.view?.space_link_state||p.space_link_state||{},space_link_state:p.space_link_state||p.view?.space_link_state||{},events:p.events||[]});saveActiveRun();const modelProgress=p.view?.timeline_model?.progress||{};const terminalSnapshot=modelProgress.terminal===true||p.view?.status_model?.is_terminal===true;const canonicalForTerminal=typeof canonicalRunUiState==='function'?canonicalRunUiState(p):null;const status=String(canonicalForTerminal?.status||p.view?.header?.status||p.status||p.state?.status||'').toLowerCase();if((terminalSnapshot||TERMINAL_STATUSES.has(status))&&state.poll){clearInterval(state.poll);state.poll=null;if(state.lastReportRefreshRunId!==state.runId){
|
| 1582 |
state.lastReportRefreshRunId=state.runId;
|
| 1583 |
const finalRunId=state.runId;
|
| 1584 |
setTimeout(()=>{if(state.runId===finalRunId)refreshRunReportPreview(finalRunId)},120);
|