stage-progress.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // Render the backend's boot-scoped projection. No browser-side phase reducer.
  2. (() => {
  3. const $ = id => document.getElementById(id);
  4. const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
  5. const states = {running:'执行中',waiting_input:'等待输入',observed:'已观测',completed:'已观察到结束',skipped:'已跳过',failed:'失败 / 被阻断',interrupted:'已中断',unknown:'结束未确认'};
  6. const planStates = {idle:'尚未启动计划',running:'计划自动运行',waiting_boot:'等待真实新启动',waiting_user:'等待人工操作',paused:'计划已暂停',completed:'计划已完成',blocked:'计划被阻断',failed:'计划执行失败',stopped:'自动执行已停止',amt_preparing:'正在准备 AMT',amt_running:'AMT 执行中'};
  7. const terminalStates = new Set(['completed','skipped','failed','interrupted']);
  8. const closeReasons = {console_offline:'控制台离线,当前执行状态未知',later_stage_observed_without_end:'已观察到后续阶段,未收到此步骤的结束回显'};
  9. let api, currentScope = '', rowLimit = 80;
  10. const list = value => Array.isArray(value) ? value : [];
  11. const count = value => Number.isFinite(Number(value)) ? Math.max(0, Number(value)) : 0;
  12. const time = value => Number(value) > 0 ? api.time(value) : '—';
  13. const duration = value => typeof value === 'number' && Number.isFinite(value) ? value.toLocaleString() + ' ms' : '未报告';
  14. const cpuName = value => value !== null && value !== undefined && value !== '' ? 'CPU' + value : '全局';
  15. const stateName = (row, live) => {
  16. if (row.state === 'unknown' && row.closed_reason === 'console_offline') return '离线 · 最后' + (states[row.last_observed_state] || '状态未知');
  17. const name = states[row.state] || '已观测';
  18. return !live && !terminalStates.has(row.state) ? '最后观测:' + name : name;
  19. };
  20. function stateBadge(row, live) {
  21. const state = Object.hasOwn(states, row.state) ? row.state : 'observed';
  22. return `<span class="stage-task-state ${live || terminalStates.has(state) ? 'is-' + state : 'is-historical'}" data-state="${state}">${esc(stateName(row, live))}</span>`;
  23. }
  24. function mainLabel(progress) {
  25. return progress.main?.label || '等待阶段数据';
  26. }
  27. function renderSummary(control, progress, firmware, station, live) {
  28. const main = progress.main || {}, stages = list(progress.stages), prompt = firmware.console_prompt || {};
  29. $('boot-title').textContent = live || !main.id || main.id === 'unknown' ? '本轮启动主进度' : '启动主进度 · 最后观测';
  30. $('boot-identity').textContent = firmware.boot_pending ? '已请求复位,等待真实新启动证据' : progress.boot_id ? `第 ${count(progress.boot_sequence)} 次已确认启动 · ${progress.boot_id}` : progress.main?.id && progress.main.id !== 'unknown' ? '当前会话未捕获启动边界;已记录实际观察到的阶段' : '等待真实启动边界;重新连接不会创建一次启动';
  31. $('boot-current').textContent = main.id && main.id !== 'unknown' ? `${live ? '本轮已推进到' : '最后推进到'}:${mainLabel(progress)}` : '等待当前启动的阶段证据';
  32. const container = $('boot-stages');
  33. Object.assign(container.dataset, {source:station.run_id ? 'run' : 'diagnostic',runId:station.run_id || '',context:live ? 'current' : 'historical_session',bootId:progress.boot_id || '',mainPhase:main.id || 'unknown'});
  34. const stageErrors = firmware.stage_errors || {};
  35. container.innerHTML = stages.map(row => {
  36. const isSkipped = row.state === 'skipped';
  37. const observed = row.state !== 'unobserved' && !isSkipped, current = row.state === 'current';
  38. const status = isSkipped ? '已跳过 (未启用)' : current ? (live ? '已到此阶段' : '最后到达') : observed ? '已观测' : '未观测';
  39. const details = isSkipped ? '本轮未执行 RMT 扫描' : (count(row.step_count) ? `${count(row.step_count)} 个步骤 · 结束 ${count(row.completed_count)}` : '尚无步骤记录');
  40. const errRecords = list(stageErrors[row.id]).length;
  41. const issues = (count(row.failed_count) || errRecords) ? ` · 异常 ${Math.max(count(row.failed_count), errRecords)}` : '';
  42. return `<div class="boot-stage ${observed ? 'observed' : ''} ${current && live ? 'current' : ''}" data-phase="${esc(row.id)}" data-stage-state="${esc(row.state)}"><div class="boot-stage-name">${esc(row.label || row.id)}<span class="boot-stage-state">${status}</span></div><div class="boot-stage-time">${details}${issues}</div></div>`;
  43. }).join('') || '<p class="stage-empty">等待后端阶段数据。</p>';
  44. const plan = control.boot_execution || {};
  45. const oldPlan = plan.boot_id && progress.boot_id && plan.boot_id !== progress.boot_id;
  46. $('stage-plan-state').textContent = (oldPlan ? '上次计划:' : plan.boot_id && !progress.boot_id ? '计划记录:' : '') + (planStates[plan.state] || (plan.state ? plan.state : '尚未启动计划'));
  47. $('stage-plan-state').classList.toggle('is-attention', ['waiting_user','paused','blocked','failed'].includes(plan.state));
  48. $('stage-plan-state').title = [plan.boot_id && !progress.boot_id ? '当前会话尚未捕获启动边界,计划与本轮启动的归属未确认。' : '',plan.waiting_reason || plan.error || ''].filter(Boolean).join(' ');
  49. const input = prompt.kind === 'uip' ? `ICT${prompt.uip_stage ?? ''}` : prompt.kind === 'amt' ? 'AMT 菜单' : prompt.kind === 'uefi' ? 'UEFI Shell' : prompt.kind || '';
  50. $('stage-input-context').textContent = prompt.ready ? `${live && prompt.live !== false ? '当前输入位置' : '最后输入位置'}:${cpuName(prompt.cpu)} · ${input}` : live ? '当前没有等待输入的菜单' : '控制台未实时在线,显示最后观测';
  51. $('boot-evidence').textContent = api.terminalText(main.evidence || '尚无主阶段证据');
  52. $('boot-evidence').title = main.evidence || '';
  53. // Render 7 distinct stage completion badges
  54. const sc = control.stage_completions || firmware.stage_completions || {};
  55. const compStrip = $('stage-completions-strip');
  56. if (compStrip) {
  57. const compDefs = [
  58. ['ict_stage1_complete', '1. ICT1 完成'],
  59. ['training_complete', '2. Training 完成'],
  60. ['rmt_complete', '3. RMT 完成'],
  61. ['amt_complete', '4. AMT 完成'],
  62. ['ict_stage2_complete', '5. ICT2 完成'],
  63. ['uefi_complete', '6. UEFI 到达'],
  64. ['mt_pass_complete', '7. MT PASS 完成'],
  65. ];
  66. compStrip.innerHTML = '<strong style="color:#475569">7 阶段独立完成判定:</strong>' + compDefs.map(([key, labelText]) => {
  67. const isMtFail = key === 'mt_pass_complete' && sc.mt_fail_complete === true && sc[key] !== true;
  68. const isRmtSkipped = key === 'rmt_complete' && (sc.rmt_status === 'skipped' || firmware.rmt_status === 'skipped') && sc[key] !== true;
  69. const done = sc[key] === true;
  70. if (isMtFail) {
  71. return `<span class="badge error" data-completion-flag="mt_fail_complete" style="background:#fee2e2;color:#991b1b;border-color:#fca5a5">✗ 7. MT FAIL</span>`;
  72. }
  73. if (isRmtSkipped) {
  74. return `<span class="badge" data-completion-flag="rmt_skipped" style="background:#f1f5f9;color:#64748b;border-color:#cbd5e1">— 3. RMT 已跳过</span>`;
  75. }
  76. return `<span class="badge ${done ? 'connected' : ''}" data-completion-flag="${esc(key)}" style="${done ? 'background:#dcfce7;color:#166534;border-color:#86efac' : 'opacity:0.75'}">${done ? '✓ ' : '○ '}${esc(labelText)}</span>`;
  77. }).join('');
  78. }
  79. // Render firmware family & task_status badges
  80. const fwFam = firmware.firmware_family || 'unknown';
  81. if ($('station-fw-family-badge')) {
  82. $('station-fw-family-badge').textContent = fwFam === 'vd012' ? '固件: 107_VD012 (24算子)' : fwFam === 'cxmt' ? '固件: CxmtDdrTest (19算子)' : '固件待识别';
  83. }
  84. const tStatus = control.task_status || station.task_status || 'not_started';
  85. if ($('station-task-status-badge')) {
  86. $('station-task-status-badge').textContent = `任务状态: ${tStatus}`;
  87. $('station-task-status-badge').classList.toggle('connected', tStatus === 'completed');
  88. $('station-task-status-badge').classList.toggle('error', tStatus === 'failed');
  89. }
  90. // Render awaiting_dimm_replacement or stage_errors banner (G27 fix: never hide when task_status==='failed' or fault_code set!)
  91. const awaitingRep = !!(control.awaiting_dimm_replacement || station.awaiting_dimm_replacement);
  92. const hasStageErrs = Object.values(stageErrors).some(arr => Array.isArray(arr) && arr.length > 0);
  93. const wd = control.watchdog || {};
  94. const faultCode = wd.fault_code || firmware.fault_code || station.fault_code || '';
  95. const hasFailState = tStatus === 'failed' || control.verdict === 'fail' || station.verdict === 'fail' || !!faultCode;
  96. if ($('dimm-replacement-banner')) {
  97. $('dimm-replacement-banner').classList.toggle('hidden', !awaitingRep && !hasStageErrs && !hasFailState);
  98. }
  99. // Render dedicated Dual-Link Offline / Stage-Hang Watchdog / Serial-Gap alert banner
  100. const wdBanner = $('watchdog-alert-banner');
  101. if (wdBanner) {
  102. const obsDetail = firmware.observed_detail || station.observed_detail || '';
  103. const isLinkWaiting = obsDetail === 'link_offline_waiting' || wd.link_offline_waiting === true;
  104. const serialGap = !!(wd.serial_gap_detected || firmware.serial_gap_detected || station.serial_gap_detected);
  105. const gapCount = Number(wd.serial_gap_count || firmware.serial_gap_count || 1);
  106. const gapSec = Math.max(1, Math.round(Number(wd.serial_gap_total_ms || firmware.serial_gap_total_ms || 0) / 1000));
  107. if (isLinkWaiting) {
  108. const offSec = Math.max(5, Math.round(Number(wd.link_offline_elapsed_ms || 0) / 1000));
  109. const limSec = Math.round(Number(wd.link_lost_timeout_ms || 240000) / 1000);
  110. wdBanner.className = '';
  111. wdBanner.style.cssText = 'display:flex;justify-content:space-between;align-items:center;gap:10px;padding:8px 12px;margin-bottom:8px;background:#fffbeb;border:1px solid #f59e0b;border-radius:6px;color:#92400e;font-size:13px';
  112. wdBanner.dataset.alertKind = 'link_offline_waiting';
  113. wdBanner.innerHTML = `<div><strong>⚠️ BMC 与 2200 串口同时断联保护中 (link_offline_waiting · 已持续 ${offSec}s / 超时上限 ${limSec}s):</strong>当前测试未清空、计时器未重置,正在等待管理网或 BMC 恢复;若持续超过 ${limSec}s 将自动判 <code>link_lost_timeout</code> 并联动高温罩吹风降温。</div>`;
  114. } else if (faultCode) {
  115. const preserved = !!(wd.hang_scene_preserved || firmware.hang_scene_preserved || station.hang_scene_preserved);
  116. const faultMsg = wd.fault_message || firmware.fault_message || station.fault_message || plan.error || faultCode;
  117. const faultTitles = {
  118. stage_hang_timeout: '🛑 阶段无输出卡死看门狗触发 (stage_hang_timeout)',
  119. mt_duration_timeout: '🛑 MT 阶段总运行时长超限 (mt_duration_timeout)',
  120. amt_duration_timeout: '🛑 AMT 阶段总运行时长超限 (amt_duration_timeout)',
  121. link_lost_timeout: '🛑 BMC 与 2200 串口持续双断超时 (link_lost_timeout)',
  122. reconnect_power_off: '🛑 链路重连后核验主板已掉电关机 (reconnect_power_off)',
  123. consecutive_hang_limit_exceeded: '🛑 连续死机达到熔断阈值 · 已停止自动重启 (consecutive_hang_limit_exceeded)',
  124. };
  125. wdBanner.className = '';
  126. wdBanner.style.cssText = 'display:flex;justify-content:space-between;align-items:center;gap:10px;padding:8px 12px;margin-bottom:8px;background:#fef2f2;border:1px solid #dc2626;border-radius:6px;color:#991b1b;font-size:13px;flex-wrap:wrap';
  127. wdBanner.dataset.alertKind = faultCode;
  128. const hangAct = wd.hang_action || (wd.reboot_on_hang ? 'retry_current_task' : 'stop');
  129. const hangActBadge = preserved
  130. ? '🔒 已停机保留死机现场(未自动重启,可查最后串口/SEL)'
  131. : hangAct === 'restart_full_plan'
  132. ? '🔄 已触发自动重启 · 从头重做整个测试计划'
  133. : '🔄 已触发自动重启 · 重新执行当前未完成的完整任务';
  134. wdBanner.innerHTML = `<div>
  135. <strong>${esc(faultTitles[faultCode] || ('🛑 保护规则触发 (' + faultCode + ')'))}</strong>
  136. <div style="margin-top:3px;font-size:12px">${esc(faultMsg)}</div>
  137. <div style="margin-top:4px;display:flex;gap:6px;flex-wrap:wrap;font-size:12px">
  138. <span class="badge error" style="background:#fee2e2;color:#991b1b;border-color:#fca5a5">${hangActBadge}</span>
  139. <span class="badge" style="background:#eff6ff;color:#1d4ed8;border-color:#93c5fd">❄️ 已推送 task_complete 联动高温罩停热吹扫 (0x08 00)</span>
  140. ${serialGap ? `<span class="badge" style="background:#fef3c7;color:#92400e;border-color:#fcd34d">⚠️ 期间曾发生 ${gapCount} 次串口断联 (${gapSec}s)</span>` : ''}
  141. </div>
  142. </div>`;
  143. } else if (serialGap) {
  144. wdBanner.className = '';
  145. wdBanner.style.cssText = 'display:flex;justify-content:space-between;align-items:center;gap:10px;padding:8px 12px;margin-bottom:8px;background:#fffbeb;border:1px solid #fbbf24;border-radius:6px;color:#92400e;font-size:13px';
  146. wdBanner.dataset.alertKind = 'serial_gap_detected';
  147. wdBanner.innerHTML = `<div><strong>⚠️ 串口断联丢字提醒 (serial_gap_detected):</strong>本轮测试期间 2200 串口曾断联 ${gapCount} 次(累计约 ${gapSec}s)并已自动恢复${obsDetail === 'link_recovered' ? ' (link_recovered)' : ''}。归档报告已打标,若最终结果 PASS 建议人工复核串口日志或重跑确认。</div>`;
  148. } else {
  149. wdBanner.className = 'hidden';
  150. wdBanner.dataset.alertKind = '';
  151. wdBanner.innerHTML = '';
  152. }
  153. }
  154. // Render live pending StageIntents (last-write-wins)
  155. const intents = control.stage_intents || {};
  156. if ($('stage-intent-summary')) {
  157. const parts = [];
  158. for (const [stg, obj] of Object.entries(intents)) {
  159. if (obj && typeof obj === 'object' && obj.action) {
  160. const stgName = stg === 'uip1' ? 'ICT1' : stg === 'uip2' ? 'ICT2' : stg === 'uip' ? 'ICT' : stg.toUpperCase();
  161. parts.push(`${stgName}→${obj.action}(rev#${obj.revision || 1})`);
  162. }
  163. }
  164. $('stage-intent-summary').textContent = parts.length ? `待消费预置: ${parts.join(' · ')}` : '当前待消费预置: 无';
  165. }
  166. }
  167. function updateOptions(id, values, allLabel) {
  168. const select = $(id), selected = select.value;
  169. const signature = JSON.stringify(values);
  170. if (select.dataset.signature === signature) return;
  171. select.dataset.signature = signature;
  172. select.innerHTML = `<option value="">${allLabel}</option>` + values.map(([value,label]) => `<option value="${esc(value)}">${esc(label)}</option>`).join('');
  173. select.value = values.some(([value]) => String(value) === selected) ? selected : '';
  174. }
  175. function renderCpus(progress, live) {
  176. const rows = list(progress.per_cpu);
  177. $('stage-cpu-cards').innerHTML = rows.map(row => {
  178. const current = row.current || {}, active = list(row.active_steps);
  179. const activity = active.length ? active : current.step_id || current.name ? [current] : [];
  180. return `<section class="stage-cpu-card" data-cpu="${esc(row.cpu)}"><div class="stage-cpu-heading"><strong>${esc(cpuName(row.cpu))}</strong><span>${live ? '已推进到' : '最后到达'} ${esc(row.main?.label || '未确认')}</span></div><div class="stage-cpu-activity"><span class="stage-task-category">${live && active.length ? '当前活动' : '最近记录'}</span>${activity.map(step => `<div class="stage-active-step" data-step-id="${esc(step.step_id || '')}"><div>${stateBadge(step,live)}<span class="stage-task-category">${esc(step.stage_label || step.stage || '')} · ${esc(step.detail_label || '')}</span></div><strong>${esc(step.name || step.detail_label || '尚无任务名称')}</strong><small>最近观测 ${time(step.observed_unix_ms)}${typeof step.duration_ms === 'number' ? ' · 固件用时 ' + duration(step.duration_ms) : ''}</small><code title="${esc(step.evidence || '')}">${esc(api.terminalText(step.evidence || '没有附带原始行'))}</code></div>`).join('') || '<p class="stage-empty">尚无本次启动的 CPU 步骤。</p>'}</div></section>`;
  181. }).join('') || '<p class="stage-empty">尚未收到本次启动的 CPU 步骤;后端收到可归属 CPU 的固件输出后显示。</p>';
  182. }
  183. function renderSteps(progress, live) {
  184. const steps = [...list(progress.steps)].sort((a,b) => count(a.observed_unix_ms)-count(b.observed_unix_ms) || count(a.sequence)-count(b.sequence)), stages = list(progress.stages);
  185. updateOptions('stage-filter-phase', stages.map(row => [row.id,row.label || row.id]), '全部阶段');
  186. const cpus = new Set([...list(progress.per_cpu).map(row => row.cpu), ...steps.map(row => row.cpu)].filter(cpu => cpu !== null && cpu !== undefined && cpu !== ''));
  187. const cpuOptions = [...cpus].sort((a,b) => Number(a)-Number(b)).map(cpu => [String(cpu),cpuName(cpu)]);
  188. if (steps.some(row => row.cpu === null || row.cpu === undefined || row.cpu === '')) cpuOptions.push(['global','全局步骤']);
  189. updateOptions('stage-filter-cpu', cpuOptions, '全部 CPU / 全局');
  190. const stage = $('stage-filter-phase').value, cpu = $('stage-filter-cpu').value;
  191. const isGlobal = row => row.cpu === null || row.cpu === undefined || row.cpu === '';
  192. const filtered = steps.filter(row => (!stage || row.stage === stage) && (!cpu || (cpu === 'global' ? isGlobal(row) : String(row.cpu) === cpu)));
  193. const visible = filtered.slice(-rowLimit).reverse(), body = $('stage-steps-body');
  194. $('stage-step-count').textContent = `当前启动 ${count(progress.step_count)} 个步骤 · 匹配 ${filtered.length} 个 · 显示 ${visible.length} 个`;
  195. $('stage-retention-note').textContent = (count(progress.truncated_count) ? `另有 ${count(progress.truncated_count)} 条较早记录不在当前快照中。` : '') + '按最近观测排列;完成数量只计实际结束回显,不估算百分比。';
  196. $('btn-stage-more').hidden = visible.length >= filtered.length;
  197. const signature = JSON.stringify([progress.boot_id,live,visible]);
  198. if (body.dataset.signature === signature) return;
  199. const open = new Set([...body.querySelectorAll('details[open]')].map(node => node.dataset.stepId));
  200. body.dataset.signature = signature;
  201. body.innerHTML = visible.map(row => {
  202. const metadata = [row.detail_label && row.detail_label !== row.name ? row.detail_label : '',row.firmware_step !== null && row.firmware_step !== undefined ? `固件步骤 ${row.firmware_step}` : '',count(row.attempt) > 1 ? `第 ${row.attempt} 次` : ''].filter(Boolean).join(' · ');
  203. const lines = [row.first_evidence && row.first_evidence !== row.evidence ? '首次:\n' + row.first_evidence : '',row.evidence || '没有附带原始行',row.closed_reason ? '记录状态说明:' + (closeReasons[row.closed_reason] || row.closed_reason) : ''].filter(Boolean).join('\n\n');
  204. return `<tr data-step-id="${esc(row.step_id)}" data-stage="${esc(row.stage)}" data-cpu="${row.cpu === null || row.cpu === undefined ? 'global' : esc(row.cpu)}"><td><strong>${esc(row.stage_label || row.stage || '未分类')}</strong><small>${esc(cpuName(row.cpu))}</small></td><td><strong class="stage-step-name">${esc(row.name || row.detail_label || '已观测步骤')}</strong><small>${esc(metadata)}</small></td><td>${stateBadge(row,live)}</td><td><span>最近 ${time(row.observed_unix_ms)}</span><small>开始 ${time(row.started_unix_ms)}</small><small>结束 ${time(row.ended_unix_ms)}</small></td><td>${duration(row.duration_ms)}</td><td><details class="stage-step-evidence" data-step-id="${esc(row.step_id)}" ${open.has(String(row.step_id)) ? 'open' : ''}><summary>${esc(api.terminalText(row.evidence || '查看原始依据'))}</summary><pre>${esc(api.terminalText(lines))}</pre></details></td></tr>`;
  205. }).join('') || '<tr><td colspan="6">当前筛选下尚无步骤记录。未观测不代表跳过。</td></tr>';
  206. }
  207. function renderHistory(firmware) {
  208. const entries = list(firmware.phase_transitions).slice(-100).reverse();
  209. const dispPhase = p => (p === 'uip' ? 'ICT' : p === 'uip1' ? 'ICT1' : p === 'uip2' ? 'ICT2' : (p || ''));
  210. $('observation-count').textContent = `本次启动 ${entries.length} 条`;
  211. $('boot-observations').innerHTML = entries.map(row => `<li><time>${time(row.observed_unix_ms)}</time><span>${esc(dispPhase(row.phase))}${row.cpu != null ? ' · ' + esc(cpuName(row.cpu)) : ''}${row.uip_stage != null ? ' · ICT' + esc(row.uip_stage) : ''}</span><code>${esc(api.terminalText(row.evidence || ''))}</code></li>`).join('') || '<li>尚无本次启动的阶段变化记录。</li>';
  212. $('boot-history').innerHTML = list(firmware.boot_history).slice(-12).reverse().map(row => `<li><time>${time(row.started_unix_ms)}</time><span>第 ${esc(row.boot_sequence)} 次 · ${esc(dispPhase(row.last_phase) || '未确认')}</span><code>${esc(row.evidence || row.boot_id || '')}</code></li>`).join('') || '<li>尚无此前启动记录。实际的新启动证据才建立新一轮。</li>';
  213. }
  214. function render(control, context = {}) {
  215. if (!api) return;
  216. const c = control || window.stlFirmware.snapshot(api.stationId()) || {};
  217. const firmware = c.firmware || {}, progress = firmware.stage_progress || {};
  218. const station = context.station || api.station() || {}, diagnostic = context.diagnostic || api.diagnostic() || {};
  219. const live = !!api.connected() && progress.live === true && (station.run_id ? station.sol_state === 'online' : diagnostic.state === 'online');
  220. const scope = (station.station_id || api.stationId()) + ':' + (progress.boot_id || '');
  221. if (scope !== currentScope) {
  222. currentScope = scope; rowLimit = 80; $('stage-filter-phase').value = '';
  223. $('stage-steps-body').dataset.signature = ''; $('stage-steps-body').innerHTML = '';
  224. }
  225. renderSummary(c,progress,firmware,station,live);
  226. $('stage-detail-panel').dataset.bootId = progress.boot_id || '';
  227. $('stage-detail-panel').dataset.live = String(live);
  228. $('stage-detail-live').textContent = !count(progress.step_count) ? '等待阶段数据' : !live ? '最后观测 · 非实时' : progress.boot_observed === false ? '当前会话 · 启动边界未捕获' : '本次启动 · 持续观测';
  229. renderCpus(progress,live); renderSteps(progress,live); renderHistory(firmware);
  230. }
  231. function init(services) {
  232. api = services;
  233. $('btn-stage-details').onclick = () => { window.stlNavigation.show('testing'); $('stage-detail-panel').scrollIntoView({block:'start',behavior:'smooth'}); };
  234. for (const id of ['stage-filter-phase','stage-filter-cpu']) $(id).onchange = () => { rowLimit = 80; render(); };
  235. $('btn-stage-filter-reset').onclick = () => { $('stage-filter-phase').value = ''; $('stage-filter-cpu').value = ''; rowLimit = 80; render(); };
  236. $('btn-stage-more').onclick = () => { rowLimit += 80; render(); };
  237. window.addEventListener('stl:page-change', () => render());
  238. }
  239. window.stlStages = {init,render};
  240. })();