From d4fc87d0a49ff7731922bd3227a7f688aab8ecb3 Mon Sep 17 00:00:00 2001
From: linus-liu-web <395141741@qq.com>
Date: Sun, 22 Nov 2026 03:03:48 +0800
Subject: [PATCH] feat(web): add a run pipeline view for node status, timing,
tokens and failures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On a run detail page the information about "what did this run actually do" is
spread across tabs and interactions: node status lives on the graph, timing and
tokens only show for the selected node, artifacts need a node click, failures
show as a red status without the reason, and events are mixed into the live
trace. On a seven-node SOP this is four places to check before you can answer
"which step failed, how long did each take, how many tokens did it cost".
Add a 流水 (pipeline) tab that aggregates the data already returned by
GET /api/runs/:id:
- a summary strip: run status, completed/failed node counts, wall time, total
tokens, tool calls, retries/rework and artifact count + size;
- one row per node in workflow order: status, duration, attempts/rework,
tokens, tool calls, artifact count + size, plus the current activity or the
failed node's real error;
- expandable per-node detail: full error, current activity, artifacts (opening
the existing artifact preview) and a truncated node output;
- a run event timeline (last 40 events) rendered in one place.
Frontend-only: no API, schema or engine change; it uses the node timing/usage/
error/activity fields, artifact metadata, event list and run usage that the run
endpoint already returns.
---
web/app/run-pipeline.js | 207 +++++++++++++++++++++++++++++++++++++++
web/app/runs.js | 7 +-
web/index.html | 3 +-
web/observability.css | 63 ++++++++++++
web/run_pipeline_test.go | 18 ++++
web/run_pipeline_test.js | 91 +++++++++++++++++
6 files changed, 385 insertions(+), 4 deletions(-)
create mode 100644 web/app/run-pipeline.js
create mode 100644 web/run_pipeline_test.go
create mode 100644 web/run_pipeline_test.js
diff --git a/web/app/run-pipeline.js b/web/app/run-pipeline.js
new file mode 100644
index 00000000..74c75b1f
--- /dev/null
+++ b/web/app/run-pipeline.js
@@ -0,0 +1,207 @@
+// Run 流水视图:把节点状态、耗时、Token、重试、产物与失败原因聚合到一屏。
+// 只读前端聚合,数据来自 GET /api/runs/:id(run.nodes / run.artifacts / run.events / run.usage)。
+
+function formatPipelineDuration(ms) {
+ ms = Math.max(0, Number(ms) || 0);
+ if (ms < 1000) return `${Math.round(ms)}ms`;
+ const seconds = ms / 1000;
+ if (seconds < 60) return `${seconds.toFixed(seconds < 10 ? 1 : 0)}s`;
+ const minutes = Math.floor(seconds / 60);
+ const restSeconds = Math.round(seconds % 60);
+ if (minutes < 60) return restSeconds ? `${minutes}m${restSeconds}s` : `${minutes}m`;
+ const hours = Math.floor(minutes / 60);
+ return `${hours}h${minutes % 60}m`;
+}
+
+function formatPipelineBytes(bytes) {
+ let value = Math.max(0, Number(bytes) || 0);
+ if (value >= 1024 * 1024) return `${(value / (1024 * 1024)).toFixed(value >= 10 * 1024 * 1024 ? 0 : 1)} MB`;
+ if (value >= 1024) return `${(value / 1024).toFixed(value >= 10 * 1024 ? 0 : 1)} KB`;
+ return `${value} B`;
+}
+
+function runPipelineNodeDurationMs(nr) {
+ if (!nr) return 0;
+ const start = nr.startedAt ? Date.parse(nr.startedAt) : NaN;
+ if (!Number.isFinite(start)) return 0;
+ const finished = nr.finishedAt ? Date.parse(nr.finishedAt) : NaN;
+ return Math.max(0, (Number.isFinite(finished) ? finished : Date.now()) - start);
+}
+
+function runPipelineArtifactsByNode(run) {
+ const byNode = {};
+ for (const artifact of run?.artifacts || []) {
+ const key = artifact.nodeId || '';
+ (byNode[key] = byNode[key] || []).push(artifact);
+ }
+ return byNode;
+}
+
+// 节点执行顺序优先跟随 workflow 拓扑(同阶段并行节点按定义顺序),
+// workflow 里找不到的 run 节点(例如历史 run 的已删除节点)追加在末尾。
+function runPipelineOrderedNodes(run, workflowNodes, edges) {
+ const nodes = Array.isArray(workflowNodes) ? workflowNodes.filter(Boolean) : [];
+ const ordered = [];
+ const seen = new Set();
+ const stages = typeof workflowStages === 'function'
+ ? workflowStages({ nodes, edges: Array.isArray(edges) ? edges : [] })
+ : [nodes];
+ for (const stage of stages || []) {
+ for (const node of stage || []) {
+ if (!node || !node.id || seen.has(node.id)) continue;
+ seen.add(node.id);
+ ordered.push(node);
+ }
+ }
+ for (const [id, nr] of Object.entries(run?.nodes || {})) {
+ if (!nr || seen.has(id)) continue;
+ seen.add(id);
+ ordered.push({ id, name: id });
+ }
+ return ordered;
+}
+
+function runPipelineSummary(run, orderedCount) {
+ const nodes = Object.values(run?.nodes || {}).filter(Boolean);
+ const count = (status) => nodes.filter((node) => node.status === status).length;
+ const usage = run?.usage || {};
+ const artifacts = run?.artifacts || [];
+ const artifactBytes = artifacts.reduce((sum, artifact) => sum + Number(artifact.size || 0), 0);
+ const toolCalls = nodes.reduce((sum, node) => sum + Number(node.toolCalls || 0), 0);
+ const retries = nodes.reduce((sum, node) => sum
+ + Math.max(0, Number(node.attempt || 0) - 1)
+ + Math.max(0, Number(node.reworkCount || 0)), 0);
+ const nodeTokens = nodes.reduce((sum, node) => sum + Number(node.usage?.totalTokens || 0), 0);
+ return {
+ total: Math.max(nodes.length, Number(orderedCount) || 0),
+ succeeded: count('succeeded'),
+ failed: count('failed'),
+ running: count('running'),
+ waiting: count('waiting_approval'),
+ cancelled: count('cancelled'),
+ pending: nodes.filter((node) => !node.status || node.status === 'pending').length,
+ tokens: Number(usage.totalTokens || nodeTokens || 0),
+ inputTokens: Number(usage.inputTokens || 0),
+ outputTokens: Number(usage.outputTokens || 0),
+ toolCalls,
+ retries,
+ artifacts: artifacts.length,
+ artifactBytes,
+ };
+}
+
+function runPipelineNodeDetailText(run, nr, artifacts) {
+ if (!nr) return '尚未开始';
+ if (nr.status === 'failed' && nr.error) return nr.error;
+ if (nr.activity) return nr.activity;
+ if (nr.error) return nr.error;
+ if (nr.status === 'waiting_approval') return '等待人工审批';
+ if (nr.status === 'succeeded') {
+ const parts = [];
+ if (artifacts.length) parts.push(`${artifacts.length} 个产物`);
+ if (nr.gateResult?.decision) parts.push(`门禁 ${nr.gateResult.decision}`);
+ return parts.join(' · ') || '已完成';
+ }
+ return '';
+}
+
+function runPipelineRowHTML(run, node, nr, artifacts) {
+ const status = nr?.status || 'pending';
+ const retries = Math.max(0, Number(nr?.attempt || 0) - 1) + Math.max(0, Number(nr?.reworkCount || 0));
+ const tokens = Number(nr?.usage?.totalTokens || 0);
+ const artifactBytes = artifacts.reduce((sum, artifact) => sum + Number(artifact.size || 0), 0);
+ const detail = runPipelineNodeDetailText(run, nr, artifacts);
+ const detailClass = status === 'failed' ? ' is-error' : (status === 'running' ? ' is-running' : '');
+ const duration = status === 'running' ? '进行中' : formatPipelineDuration(runPipelineNodeDurationMs(nr));
+ const artifactsCell = artifacts.length ? `${artifacts.length} 个 · ${formatPipelineBytes(artifactBytes)}` : '—';
+ const artifactItems = artifacts.map((artifact) => `${escapeHTML(artifact.name || 'artifact')} ${escapeHTML(artifact.path || '')} · ${formatPipelineBytes(artifact.size || 0)} `).join('');
+ const output = nr?.output ? `
${escapeHTML(String(nr.output).slice(0, 1200))} ` : '';
+ return `
+
+ ${escapeHTML(node.name || node.id)} ${escapeHTML(node.id)}
+ ${escapeHTML(statusText(status) || '待执行')}
+ ${escapeHTML(duration)}
+ ${nr?.attempt || 0}${retries ? ` / ${retries}` : ' / 0'}
+ ${formatTokens(tokens)}
+ ${Number(nr?.toolCalls || 0)}
+ ${escapeHTML(artifactsCell)}
+ ${escapeHTML(detail)}
+ ›
+
+
+
`;
+}
+
+function runPipelineSummaryHTML(run, summary) {
+ const headline = summary.failed ? `失败 ${summary.failed}`
+ : summary.running ? '运行中'
+ : summary.waiting ? '待审批'
+ : summary.cancelled ? '已取消'
+ : summary.pending ? '等待执行'
+ : '已完成';
+ const cells = [
+ ['状态', headline],
+ ['节点', `${summary.succeeded}/${summary.total} 完成${summary.failed ? ` · ${summary.failed} 失败` : ''}`],
+ ['耗时', typeof runElapsed === 'function' ? runElapsed(run) : '—'],
+ ['Token', formatTokens(summary.tokens)],
+ ['工具调用', String(summary.toolCalls)],
+ ['重试/返工', String(summary.retries)],
+ ['产物', `${summary.artifacts} 个 · ${formatPipelineBytes(summary.artifactBytes)}`],
+ ];
+ return `${cells.map(([label, value]) => `
${escapeHTML(label)} ${escapeHTML(value)}
`).join('')}
`;
+}
+
+function runPipelineTimelineHTML(run) {
+ const events = (run?.events || []).slice(-40);
+ if (!events.length) return '';
+ return events.map((event) => {
+ const time = event.timestamp ? new Date(event.timestamp).toLocaleTimeString() : '';
+ const level = String(event.type || '').includes('fail') || String(event.type || '').includes('exhausted') ? ' is-error' : '';
+ return `
+ ${escapeHTML(time)}
+ ${event.nodeId ? `${escapeHTML(event.nodeId)} ` : ''}
+ ${escapeHTML(event.type || '')}
+ ${escapeHTML(event.message || '')}
+
`;
+ }).join('');
+}
+
+function runPipelinePaneHTML(run, workflowNodes, edges) {
+ const ordered = runPipelineOrderedNodes(run, workflowNodes, edges);
+ const artifactsByNode = runPipelineArtifactsByNode(run);
+ const summary = runPipelineSummary(run, ordered.length);
+ const rows = ordered.map((node) => runPipelineRowHTML(run, node, run?.nodes?.[node.id], artifactsByNode[node.id] || [])).join('');
+ return `
+
运行流水 每个节点的状态、耗时、Token、重试、产物与失败原因 ${summary.retries ? `
${summary.retries} 次重试/返工 ` : ''}
+ ${runPipelineSummaryHTML(run, summary)}
+ 节点 状态 耗时 次数/返工 Token 工具 产物
+
+
+
+
事件时间线 最近 ${Math.min((run?.events || []).length, 40)} 条事件
+ ${runPipelineTimelineHTML(run)}
+ `;
+}
+
+function bindRunPipelinePane(run, host) {
+ const pane = host.querySelector('[data-run-pane="pipeline"]');
+ if (!pane) return;
+ pane.querySelectorAll('[data-run-pipeline-node]').forEach((row) => {
+ row.onclick = () => {
+ const expanded = row.getAttribute('aria-expanded') === 'true';
+ row.setAttribute('aria-expanded', String(!expanded));
+ row.closest('.run-pipeline-item')?.querySelector('.run-pipeline-extra')?.toggleAttribute('hidden', expanded);
+ };
+ });
+ pane.querySelectorAll('[data-run-pipeline-artifact]').forEach((button) => {
+ button.onclick = (event) => {
+ event.stopPropagation();
+ if (typeof previewArtifact === 'function') previewArtifact(run, button.dataset.runPipelineArtifact);
+ };
+ });
+}
diff --git a/web/app/runs.js b/web/app/runs.js
index 51c0e8d2..9854ada4 100644
--- a/web/app/runs.js
+++ b/web/app/runs.js
@@ -1196,13 +1196,13 @@ function renderRunDetail(r){
const alignPanelHTML=r.workflowId==='scheduled-baseline-align'?alignConflictPanelHTML(r):'';
const logBusy=state.runLogs?.runId===pg.runId&&state.runLogs.nodeId===pg.nodeId&&state.runLogs.loading&&!logPage;
const previewEnabled=runPreviewDeclared(r);
- const allowedTabs=['overview','trace','logs','workspace','eval'];
+ const allowedTabs=['overview','pipeline','trace','logs','workspace','eval'];
if(previewEnabled)allowedTabs.splice(4,0,'preview');
const runDetailTab=allowedTabs.includes(state.runDetailTab)?state.runDetailTab:'overview';
- const runTabs=['overview:概览','trace:实时轨迹','logs:Worker日志','workspace:工作区'];
+ const runTabs=['overview:概览','pipeline:流水','trace:实时轨迹','logs:Worker日志','workspace:工作区'];
if(previewEnabled)runTabs.push('preview:前端预览');
runTabs.push('eval:智能评测');
- host.innerHTML=`执行详情 导出全部日志 ${runTabs.map(t=>{const[k,label]=t.split(':');return `${label} `}).join('')}
${runProgressCellHTML(r,wf,progress,graphNodes)}${liveUsageHTML(r)}
交付物 ${(r.artifacts||[]).length} 个不可变快照 按节点和尝试次数保留版本
${alignPanelHTML}${runIsGroupMode(r)?`
已冷冻 SOP 快照 历史协作 · ${graphNodes.length} 个节点可展开审计
`:''}
节点执行拓扑 点击节点查看该节点的输出、产物和执行事件 完成 运行中 待审批 未开始
${graphNodes.map((n,index)=>{const gv=graphNodeView(r,n.id),meta=nodeMeta(n),arts=(r.artifacts||[]).filter(a=>a.nodeId===n.id).length;return `${index?'
→ ':''}
${runNodeIcon(meta.kind)} ${escapeHTML(n.name)} ${escapeHTML(gv.text)}
${arts?`${arts} 产物 `:''}`}).join('')}
${escapeHTML(selected?.name||'节点详情')} 当前活动:${escapeHTML(nr.activity||'')} ${escapeHTML(nr.provider||'未分配')}${nr.model?` · ${escapeHTML(nr.model)}`:''} ${statusText(nr.status)||'待执行'} 执行次数 ${nr.attempt||0}
返工 ${nr.reworkCount||0}
Token ${formatTokens(nr.usage?.totalTokens)}
工具调用 ${nr.toolCalls||0}
${childSOPPanelHTML(r,selected?.id)}${gateResultCardHTML(nr)}${canRerunFromHere(r,selected?.id)?`从这里重跑 保留上游结果,从本节点及下游重跑
`:''}${nr.output?`节点输出 复制
${escapeHTML(displayNodeOutput(nr.output))} `:''}Sandbox ${escapeHTML(nr.sandboxId||'—')} Session ${escapeHTML(nr.sessionId||'—')}
节点交付物 ${nodeArtifacts.length} 个版本 ${nodeArtifacts.map(a=>`
${a.mediaType==='application/json'?'{}':'MD'} ${escapeHTML(a.name)} ${escapeHTML(a.path)} attempt ${a.attempt} · ${Math.max(1,Math.ceil((a.size||0)/1024))} KB · ${(a.sha256||'').slice(0,10)}
预览 › `).join('')||'
'}
${runIsGroupMode(r)?'':''}
${telemetrySectionTitle(telAdapter)} ${telPage?`${telemetry.length} 条已加载`:'加载最近 100 条'} ${telemetrySourceTabs(telAdapter,'data-tel-adapter')}${telPage?.hasMore?`加载更早的 100 条 `:''}
${telPage?([...telemetry].reverse().map(telemetryItemHTML).join('')||`
${telemetryEmptyHint(telAdapter)}
`):'
'}
Worker 日志 ${logPage?`${visibleWorkerLogs(logPage.items).length} 条调用`:(logBusy?'正在接收…':'实时加载最近调用')} ${logPage?.hasMore?`加载更早的 100 条 `:''}
${logPage?(visibleWorkerLogs(logPage.items).map(logLineHTML).join('')||'
'):'
'}
`; host.querySelector('.run-detail-main')?.insertAdjacentHTML('beforeend',`${workspacePaneHTML(r)}
${previewEnabled?`${previewPaneHTML(r)}
`:''}${runEvalPaneHTML(r)}
`);
+ host.innerHTML=`执行详情 导出全部日志 ${runTabs.map(t=>{const[k,label]=t.split(':');return `${label} `}).join('')}
${runProgressCellHTML(r,wf,progress,graphNodes)}${liveUsageHTML(r)}
交付物 ${(r.artifacts||[]).length} 个不可变快照 按节点和尝试次数保留版本
${alignPanelHTML}${runIsGroupMode(r)?`
已冷冻 SOP 快照 历史协作 · ${graphNodes.length} 个节点可展开审计
`:''}
节点执行拓扑 点击节点查看该节点的输出、产物和执行事件 完成 运行中 待审批 未开始
${graphNodes.map((n,index)=>{const gv=graphNodeView(r,n.id),meta=nodeMeta(n),arts=(r.artifacts||[]).filter(a=>a.nodeId===n.id).length;return `${index?'
→ ':''}
${runNodeIcon(meta.kind)} ${escapeHTML(n.name)} ${escapeHTML(gv.text)}
${arts?`${arts} 产物 `:''}`}).join('')}
${escapeHTML(selected?.name||'节点详情')} 当前活动:${escapeHTML(nr.activity||'')} ${escapeHTML(nr.provider||'未分配')}${nr.model?` · ${escapeHTML(nr.model)}`:''} ${statusText(nr.status)||'待执行'} 执行次数 ${nr.attempt||0}
返工 ${nr.reworkCount||0}
Token ${formatTokens(nr.usage?.totalTokens)}
工具调用 ${nr.toolCalls||0}
${childSOPPanelHTML(r,selected?.id)}${gateResultCardHTML(nr)}${canRerunFromHere(r,selected?.id)?`从这里重跑 保留上游结果,从本节点及下游重跑
`:''}${nr.output?`节点输出 复制
${escapeHTML(displayNodeOutput(nr.output))} `:''}Sandbox ${escapeHTML(nr.sandboxId||'—')} Session ${escapeHTML(nr.sessionId||'—')}
节点交付物 ${nodeArtifacts.length} 个版本 ${nodeArtifacts.map(a=>`
${a.mediaType==='application/json'?'{}':'MD'} ${escapeHTML(a.name)} ${escapeHTML(a.path)} attempt ${a.attempt} · ${Math.max(1,Math.ceil((a.size||0)/1024))} KB · ${(a.sha256||'').slice(0,10)}
预览 › `).join('')||'
'}
${runIsGroupMode(r)?'':''}
${runPipelinePaneHTML(r,graphNodes,(wf.edges||[]))}
${telemetrySectionTitle(telAdapter)} ${telPage?`${telemetry.length} 条已加载`:'加载最近 100 条'} ${telemetrySourceTabs(telAdapter,'data-tel-adapter')}${telPage?.hasMore?`加载更早的 100 条 `:''}
${telPage?([...telemetry].reverse().map(telemetryItemHTML).join('')||`
${telemetryEmptyHint(telAdapter)}
`):'
'}
Worker 日志 ${logPage?`${visibleWorkerLogs(logPage.items).length} 条调用`:(logBusy?'正在接收…':'实时加载最近调用')} ${logPage?.hasMore?`加载更早的 100 条 `:''}
${logPage?(visibleWorkerLogs(logPage.items).map(logLineHTML).join('')||'
'):'
'}
`; host.querySelector('.run-detail-main')?.insertAdjacentHTML('beforeend',`${workspacePaneHTML(r)}
${previewEnabled?`${previewPaneHTML(r)}
`:''}${runEvalPaneHTML(r)}
`);
if(keepFrame){const fresh=host.querySelector('iframe[data-vscode-frame]');if(fresh)fresh.replaceWith(existingFrame);}
if(keepPreview){const fresh=host.querySelector('iframe[data-preview-frame]');if(fresh)fresh.replaceWith(existingPreviewFrame);}
const headerActions=host.querySelector('.run-header-actions');if(r.status==='running'&&headerActions)headerActions.querySelector('[data-cancel-run]')?.insertAdjacentHTML('beforebegin','暂停运行 ');
@@ -1235,6 +1235,7 @@ function renderRunDetail(r){
const graph=host.querySelector('.run-graph');if(graph){graph.querySelectorAll('.graph-arrow').forEach(arrow=>arrow.remove());const stages=workflowStages(runIsGroupMode(r)?{...wf,nodes:graphNodes}:wf);graph.classList.add('is-staged');stages.forEach((stage,index)=>{const column=document.createElement('div');column.className='graph-stage'+(stage.length>1?' is-parallel':'');const caption=document.createElement('span');caption.className='graph-stage-label';const captionName=document.createElement('span');captionName.className='graph-stage-name';captionName.textContent=`阶段 ${index+1}${stage.length>1?` · 并行 ${stage.length}`:''}`;caption.append(captionName);const stageTime=stageTimeLabel(r,stage);if(stageTime){const stageTimeEl=document.createElement('em');stageTimeEl.className='graph-stage-time';stageTimeEl.textContent=stageTime;caption.append(stageTimeEl)}column.append(caption);for(const node of stage){const button=graph.querySelector(`[data-run-node="${CSS.escape(node.id)}"]`),parents=(wf.edges||[]).filter(edge=>edge.target===node.id).map(edge=>nodes.find(item=>item.id===edge.source)?.name).filter(Boolean);if(!button)continue;if(parents.length)button.querySelector('small').append(` · 上游 ${parents.join('、')}`);column.append(button)}if(column.children.length>1)graph.append(column)})}
host.querySelector('[data-run-back]')?.addEventListener('click',()=>showRunList());
bindRunDetailTabs(r,host);
+ bindRunPipelinePane(r,host);
host.querySelectorAll('[data-run-node]').forEach(b=>b.onclick=()=>selectRunNode(b.dataset.runNode));host.querySelectorAll('[data-tel-adapter]').forEach(b=>b.onclick=()=>{if((state.runTelemetryAdapter||'live')===b.dataset.telAdapter)return;state.runTelemetryAdapter=b.dataset.telAdapter;state.runTelemetry=null;renderRunDetail(state.activeRun||r)});host.querySelector('[data-logs-load]')?.addEventListener('click',()=>loadRunLogs(pg.runId,pg.nodeId,false));host.querySelector('[data-logs-more]')?.addEventListener('click',()=>loadRunLogs(pg.runId,pg.nodeId,true));host.querySelector('[data-tel-load]')?.addEventListener('click',()=>loadRunTelemetry(pg.runId,pg.nodeId,false));host.querySelector('[data-tel-more]')?.addEventListener('click',()=>loadRunTelemetry(pg.runId,pg.nodeId,true));host.querySelector('[data-open-issue]')?.addEventListener('click',ev=>{ev.preventDefault();ev.stopPropagation();openIssueDetail(ev.currentTarget.dataset.openIssue||issueId,'sop')});host.querySelectorAll('[data-rerun-from-here]').forEach(b=>b.onclick=()=>openRerunFromNode(state.activeRun||r,b.dataset.rerunFromHere));host.querySelector('[data-copy-run]')?.addEventListener('click',()=>copyText(r.id,'Run ID 已复制'));host.querySelector('[data-export-logs]')?.addEventListener('click',()=>downloadRunLogs(r.id));host.querySelector('[data-copy-output]')?.addEventListener('click',()=>copyText(displayNodeOutput(nr.output),'节点输出已复制'));host.querySelector('[data-open-flow]')?.addEventListener('click',()=>{state.workflow=clone(state.data.workflows.find(w=>w.id===r.workflowId)||wf);state.selectedNode=selected?.id||null;switchView('flow');renderAll()});host.querySelector('[data-cancel-run]')?.addEventListener('click',async ()=>{if(await afConfirm({title:'取消运行确认',message:r.status==='queued'?'确定取消排队?此运行将不会启动,之后可删除记录。':'确定取消这次运行?正在执行的节点会被终止。',confirmText:r.status==='queued'?'取消排队':'确认取消',isDanger:true}))runAction(r.id,'cancel',{})});host.querySelector('[data-delete-run]')?.addEventListener('click',()=>deleteRun(r.id));host.querySelectorAll('[data-resume-run]').forEach(b=>b.addEventListener('click',ev=>resumeRun(b.dataset.resumeRun||r.id,ev.currentTarget)));host.querySelectorAll('[data-pass-node]').forEach(b=>b.onclick=()=>passFailedNode(b.dataset.passNode,b.dataset.node,b));host.querySelectorAll('[data-artifact]').forEach(b=>b.onclick=()=>previewArtifact(state.activeRun||r,b.dataset.artifact));host.querySelectorAll('[data-approve]').forEach(b=>b.onclick=()=>runAction(r.id,'approve',withHumanContext({nodeId:b.dataset.approve,context:readHumanContext(b)})));host.querySelectorAll('[data-reject]').forEach(b=>b.onclick=async ()=>{const reason=await afPrompt({title:'打回返工',message:'请输入打回原因:',defaultValue:'验证未通过,请修复后重新提交'});if(reason!==null&&reason!==undefined)runAction(r.id,'reject',withHumanContext({nodeId:b.dataset.reject,targetId:b.dataset.target,reason,context:readHumanContext(b)}))});host.querySelectorAll('[data-retry-node]').forEach(b=>b.onclick=()=>retryWaitingNode(r.id,b.dataset.retryNode,b));host.querySelectorAll('[data-decline-retry]').forEach(b=>b.onclick=()=>declineRetry(r.id,b.dataset.declineRetry));host.querySelectorAll('[data-realign-run]').forEach(b=>b.onclick=()=>realignBaseline(b.dataset.realignRun));
host.querySelector('[data-pause-run]')?.addEventListener('click',()=>pauseRun(r.id));bindPausedResumeActions(host);host.querySelectorAll('[data-refresh-run-sop]').forEach(b=>b.onclick=()=>refreshRunSOP(b.dataset.refreshRunSop));
host.dataset.runId=r.id;host.dataset.nodeId=state.selectedRunNode||'';host.dataset.controlSignature=runControlSignature(r);
diff --git a/web/index.html b/web/index.html
index c5eca185..a633a7d3 100644
--- a/web/index.html
+++ b/web/index.html
@@ -13,7 +13,7 @@
-
+
@@ -1301,6 +1301,7 @@ 确认操作
+
diff --git a/web/observability.css b/web/observability.css
index 66996d5c..3f6c7112 100644
--- a/web/observability.css
+++ b/web/observability.css
@@ -522,3 +522,66 @@ body.obs-expand-open{overflow:hidden}
@media (prefers-reduced-motion:reduce){
.obs-chart-skeleton{animation:none}
}
+
+/* Run 流水视图(web/app/run-pipeline.js) */
+.run-pipeline-section,.run-pipeline-timeline-section{display:flex;flex-direction:column;gap:12px;padding:18px 20px;border-bottom:1px solid var(--line)}
+.run-pipeline-retry-badge{padding:3px 10px;border-radius:999px;border:1px solid color-mix(in srgb,var(--amber) 30%,transparent);background:color-mix(in srgb,var(--amber) 12%,transparent);color:var(--amber);font-size:11.5px;font-weight:700;white-space:nowrap}
+.run-pipeline-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px}
+.run-pipeline-summary-cell{display:flex;flex-direction:column;gap:3px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--panel)}
+.run-pipeline-summary-cell span{font-size:11.5px;color:var(--muted)}
+.run-pipeline-summary-cell b{font-size:15px;font-weight:700;color:var(--text);font-variant-numeric:tabular-nums}
+.run-pipeline-columns{display:grid;grid-template-columns:minmax(180px,2fr) 76px 84px 92px 70px 60px minmax(110px,1fr) 16px;gap:8px;padding:0 12px;font-size:11px;font-weight:600;letter-spacing:.03em;color:var(--muted);text-transform:uppercase}
+.run-pipeline-list{display:flex;flex-direction:column;gap:8px}
+.run-pipeline-item{border:1px solid var(--line);border-radius:12px;background:var(--panel);overflow:hidden}
+.run-pipeline-item.is-failed{border-color:color-mix(in srgb,var(--red) 38%,var(--line))}
+.run-pipeline-item.is-running{border-color:color-mix(in srgb,var(--blue) 38%,var(--line))}
+.run-pipeline-row{display:grid;grid-template-columns:minmax(180px,2fr) 76px 84px 92px 70px 60px minmax(110px,1fr) 16px;gap:8px;align-items:center;width:100%;padding:11px 12px;border:0;background:transparent;color:var(--text);font:inherit;text-align:left;cursor:pointer}
+.run-pipeline-row:hover{background:color-mix(in srgb,var(--text) 3%,transparent)}
+.run-pipeline-node{display:flex;align-items:center;gap:8px;min-width:0}
+.run-pipeline-node b{font-size:13px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.run-pipeline-node small{font-family:var(--mono,ui-monospace,Menlo,monospace);font-size:10.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.run-pipeline-dot{flex:none;width:8px;height:8px;border-radius:999px;background:var(--line-strong)}
+.is-succeeded .run-pipeline-dot{background:var(--green)}
+.is-failed .run-pipeline-dot{background:var(--red)}
+.is-running .run-pipeline-dot{background:var(--blue);box-shadow:0 0 0 3px color-mix(in srgb,var(--blue) 18%,transparent)}
+.is-waiting_approval .run-pipeline-dot{background:var(--amber)}
+.run-pipeline-status{padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;white-space:nowrap;text-align:center;border:1px solid transparent}
+.run-pipeline-status.is-succeeded{background:color-mix(in srgb,var(--green) 12%,transparent);color:var(--green);border-color:color-mix(in srgb,var(--green) 26%,transparent)}
+.run-pipeline-status.is-failed{background:color-mix(in srgb,var(--red) 12%,transparent);color:var(--red);border-color:color-mix(in srgb,var(--red) 26%,transparent)}
+.run-pipeline-status.is-running{background:color-mix(in srgb,var(--blue) 12%,transparent);color:var(--blue);border-color:color-mix(in srgb,var(--blue) 26%,transparent)}
+.run-pipeline-status.is-waiting_approval{background:color-mix(in srgb,var(--amber) 14%,transparent);color:var(--amber);border-color:color-mix(in srgb,var(--amber) 28%,transparent)}
+.run-pipeline-status.is-pending,.run-pipeline-status.is-cancelled{background:color-mix(in srgb,var(--text) 5%,transparent);color:var(--muted);border-color:var(--line)}
+.run-pipeline-metric{font-size:12px;color:var(--text);font-variant-numeric:tabular-nums;white-space:nowrap}
+.run-pipeline-detail{grid-column:1/-1;grid-row:2;font-size:12px;line-height:1.5;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.run-pipeline-detail.is-error{color:var(--red)}
+.run-pipeline-detail.is-running{color:var(--blue)}
+.run-pipeline-chevron{grid-column:8;grid-row:1;color:var(--muted);font-size:16px;line-height:1;transition:transform .15s}
+.run-pipeline-row[aria-expanded="true"] .run-pipeline-chevron{transform:rotate(90deg)}
+.run-pipeline-extra{display:flex;flex-direction:column;gap:10px;padding:0 12px 12px;border-top:1px dashed var(--line)}
+.run-pipeline-extra-block{display:flex;flex-direction:column;gap:6px;padding-top:10px}
+.run-pipeline-extra-block>b{font-size:12px;font-weight:650;color:var(--muted)}
+.run-pipeline-extra-block p{margin:0;font-size:12.5px;line-height:1.55;color:var(--text);overflow-wrap:anywhere}
+.run-pipeline-extra-block pre{margin:0;max-height:220px;overflow:auto;padding:9px 11px;border:1px solid var(--line);border-radius:8px;background:color-mix(in srgb,var(--text) 4%,transparent);font-family:var(--mono,ui-monospace,Menlo,monospace);font-size:11.5px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere}
+.run-pipeline-extra-block.is-error pre{color:var(--red);border-color:color-mix(in srgb,var(--red) 30%,var(--line))}
+.run-pipeline-artifact{display:flex;flex-direction:column;gap:2px;padding:7px 10px;border:1px solid var(--line);border-radius:8px;background:transparent;color:var(--text);font:inherit;text-align:left;cursor:pointer}
+.run-pipeline-artifact:hover{border-color:var(--line-strong);background:color-mix(in srgb,var(--text) 3%,transparent)}
+.run-pipeline-artifact b{font-size:12.5px;font-weight:600}
+.run-pipeline-artifact span{font-size:11.5px;color:var(--muted);overflow-wrap:anywhere}
+.run-pipeline-output{max-height:200px!important}
+.run-pipeline-timeline{display:flex;flex-direction:column;gap:2px;max-height:320px;overflow:auto;border:1px solid var(--line);border-radius:12px;background:var(--panel);padding:8px 10px}
+.run-pipeline-timeline-item{display:grid;grid-template-columns:64px auto auto 1fr;gap:8px;align-items:baseline;padding:5px 4px;border-bottom:1px solid color-mix(in srgb,var(--line) 55%,transparent);font-size:12px}
+.run-pipeline-timeline-item:last-child{border-bottom:0}
+.run-pipeline-timeline-item time{font-family:var(--mono,ui-monospace,Menlo,monospace);font-size:11px;color:var(--muted)}
+.run-pipeline-timeline-node{padding:1px 6px;border-radius:6px;background:color-mix(in srgb,var(--text) 5%,transparent);font-family:var(--mono,ui-monospace,Menlo,monospace);font-size:10.5px;color:var(--muted);white-space:nowrap}
+.run-pipeline-timeline-type{font-size:11px;font-weight:600;color:var(--blue);white-space:nowrap}
+.run-pipeline-timeline-message{color:var(--text);overflow-wrap:anywhere}
+.run-pipeline-timeline-item.is-error .run-pipeline-timeline-type,.run-pipeline-timeline-item.is-error .run-pipeline-timeline-message{color:var(--red)}
+@media (max-width:900px){
+ .run-pipeline-columns{display:none}
+ .run-pipeline-row{grid-template-columns:1fr auto 16px;grid-auto-rows:auto}
+ .run-pipeline-node{grid-column:1;grid-row:1}
+ .run-pipeline-status{grid-column:2;grid-row:1}
+ .run-pipeline-metric{grid-row:2;grid-column:1/-1;display:inline-block;margin-right:12px}
+ .run-pipeline-detail{grid-row:3}
+ .run-pipeline-chevron{grid-column:3;grid-row:1}
+}
diff --git a/web/run_pipeline_test.go b/web/run_pipeline_test.go
new file mode 100644
index 00000000..0a28b719
--- /dev/null
+++ b/web/run_pipeline_test.go
@@ -0,0 +1,18 @@
+package web
+
+import (
+ "os/exec"
+ "testing"
+)
+
+// The run pipeline view is assembled from pure helpers; node asserts ordering,
+// summary math, error rendering and timeline markup against the app bundle.
+func TestRunPipelinePane(t *testing.T) {
+ node, err := exec.LookPath("node")
+ if err != nil {
+ t.Skip("node not installed")
+ }
+ if out, err := exec.Command(node, "run_pipeline_test.js", appBundlePath(t)).CombinedOutput(); err != nil {
+ t.Fatalf("run pipeline pane: %v\n%s", err, out)
+ }
+}
diff --git a/web/run_pipeline_test.js b/web/run_pipeline_test.js
new file mode 100644
index 00000000..9c744977
--- /dev/null
+++ b/web/run_pipeline_test.js
@@ -0,0 +1,91 @@
+const fs = require('node:fs');
+const vm = require('node:vm');
+const assert = require('node:assert/strict');
+const bundle = fs.readFileSync(process.argv[2], 'utf8');
+
+function source(name) {
+ const match = new RegExp('^(?:async )?function ' + name + '\\(', 'm').exec(bundle);
+ assert(match, name + ' not found in the app bundle');
+ const tail = bundle.slice(match.index);
+ const next = /\n(?:async )?function |\n(?:let|const) [A-Za-z]|\n\/\/ /.exec(tail);
+ return next ? tail.slice(0, next.index) : tail;
+}
+
+const context = {
+ escapeHTML: (value) => String(value ?? ''),
+ statusText: (status) => ({ pending: '待执行', running: '运行中', succeeded: '已完成', failed: '失败', waiting_approval: '待审批', cancelled: '已取消' }[status] || ''),
+ formatTokens: (n) => String(n ?? 0),
+ runElapsed: () => '12m',
+};
+vm.createContext(context);
+for (const name of ['workflowStages', 'formatPipelineDuration', 'formatPipelineBytes', 'runPipelineNodeDurationMs', 'runPipelineArtifactsByNode', 'runPipelineOrderedNodes', 'runPipelineSummary', 'runPipelineNodeDetailText', 'runPipelineRowHTML', 'runPipelineSummaryHTML', 'runPipelineTimelineHTML', 'runPipelinePaneHTML']) {
+ vm.runInContext(source(name), context);
+}
+
+assert.equal(context.formatPipelineDuration(0), '0ms');
+assert.equal(context.formatPipelineDuration(1500), '1.5s');
+assert.equal(context.formatPipelineDuration(65000), '1m5s');
+assert.equal(context.formatPipelineDuration(3700000), '1h1m');
+assert.equal(context.formatPipelineBytes(512), '512 B');
+assert.equal(context.formatPipelineBytes(2048), '2.0 KB');
+assert.equal(context.formatPipelineBytes(1572864), '1.5 MB');
+
+const run = {
+ status: 'failed',
+ usage: { totalTokens: 12345, inputTokens: 10000, outputTokens: 2345 },
+ createdAt: '2026-01-01T00:00:00Z',
+ nodes: {
+ clarify: { status: 'succeeded', attempt: 1, toolCalls: 4, usage: { totalTokens: 1000 }, startedAt: '2026-01-01T00:00:00Z', finishedAt: '2026-01-01T00:00:30Z', output: '需求已整理' },
+ design: { status: 'succeeded', attempt: 2, reworkCount: 1, toolCalls: 6, usage: { totalTokens: 4000 }, startedAt: '2026-01-01T00:00:30Z', finishedAt: '2026-01-01T00:05:30Z' },
+ implement: { status: 'failed', attempt: 2, toolCalls: 9, usage: { totalTokens: 7000 }, startedAt: '2026-01-01T00:05:30Z', finishedAt: '2026-01-01T00:15:30Z', error: '写入节点终态失败:Error 1406 Data too long', activity: '运行中' },
+ ghost: { status: 'running', attempt: 1, startedAt: '2026-01-01T00:15:30Z', activity: 'read_image /workspace/refs/a.png' },
+ },
+ artifacts: [
+ { id: 'a1', nodeId: 'clarify', name: 'requirement.md', path: 'requirement.md', size: 84741 },
+ { id: 'a2', nodeId: 'implement', name: 'implementation.md', path: 'implementation.md', size: 2048 },
+ ],
+ events: [
+ { timestamp: '2026-01-01T00:00:30Z', nodeId: 'clarify', type: 'node.succeeded', message: 'clarify 已完成' },
+ { timestamp: '2026-01-01T00:15:30Z', nodeId: 'implement', type: 'agent.loop.exhausted', message: 'Agent 自修正次数已耗尽' },
+ ],
+};
+const workflowNodes = [
+ { id: 'clarify', name: '需求定型' },
+ { id: 'design', name: '方案设计' },
+ { id: 'implement', name: '实现' },
+];
+const ordered = context.runPipelineOrderedNodes(run, workflowNodes, [
+ { source: 'clarify', target: 'design' },
+ { source: 'design', target: 'implement' },
+]);
+assert.deepEqual(Array.from(ordered, (node) => node.id), ['clarify', 'design', 'implement', 'ghost']);
+
+const summary = context.runPipelineSummary(run);
+assert.equal(summary.total, 4);
+assert.equal(summary.succeeded, 2);
+assert.equal(summary.failed, 1);
+assert.equal(summary.running, 1);
+assert.equal(summary.tokens, 12345);
+assert.equal(summary.toolCalls, 19);
+assert.equal(summary.retries, 3);
+assert.equal(summary.artifacts, 2);
+assert.equal(summary.artifactBytes, 84741 + 2048);
+
+const artifactsByNode = context.runPipelineArtifactsByNode(run);
+assert.equal(artifactsByNode.clarify.length, 1);
+const failedRow = context.runPipelineRowHTML(run, workflowNodes[2], run.nodes.implement, artifactsByNode.implement || []);
+assert(failedRow.includes('is-failed'));
+assert(failedRow.includes('Error 1406'), 'failed row carries the real error');
+assert(failedRow.includes('data-run-pipeline-node="implement"'));
+assert(failedRow.includes('实现'));
+assert(failedRow.includes('1 个 · 2.0 KB'));
+const runningRow = context.runPipelineRowHTML(run, ordered[3], run.nodes.ghost, []);
+assert(runningRow.includes('进行中'), 'running node shows progress instead of a duration');
+
+const pane = context.runPipelinePaneHTML(run, workflowNodes, [{ source: 'clarify', target: 'design' }, { source: 'design', target: 'implement' }]);
+assert(pane.includes('运行流水'));
+assert(pane.includes('事件时间线'));
+assert(pane.includes('agent.loop.exhausted'), 'timeline renders run events');
+assert(pane.includes('写入节点终态失败'), 'expanded payload has the error');
+assert(pane.includes('需求定型'), 'rows follow the workflow order');
+assert(pane.includes('retry-badge'), 'retry badge appears when retries exist');