Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
feat(web): animate running SOP node activity (#178)
汪聪588483253433
diff --git a/design.md b/design.mdindex 2105ec36..9e9b4519 100644--- a/design.md+++ b/design.md@@ -330,6 +330,10 @@ Logo 默认 64px,小屏或短屏为 52px;标题为 36px,小屏为 30px。行首图标块为中性灰:SOP 运行用 `workflow`,自由协作(`collaborationMode==='group'`)用 `chat`;自由协作行的进度显示「—」,不显示耗时。查看(`eye`)和删除(`trash`)图标按钮在悬停或键盘聚焦到行时显示,删除悬停变红;不可删除的行不输出删除按钮也不留占位。整行点击或按 Enter 进入详情。列表周期刷新时保留行或按钮上的键盘焦点。+### 节点当前活动++运行详情中,选中节点实际执行时,状态文字旁显示转圈,当前活动文字以约 2.4 秒一轮从左向右扫过高光。标签、模型信息与布局保持静止;实时日志只更新文本与状态类,避免重建元素打断动效。已完成、失败、取消、暂停、等待人工确认及子 SOP 待确认时均为静态。明暗主题沿用 Harness 文字令牌,长活动文字省略;减少动态效果或强制颜色模式下关闭两种动画,保留可读文字与静态状态图形。+## Bot 管理Bot 管理页(`#botsView`)按需求列表与运行记录列表的 Harness 先例绘制,接口、权限、三步引导和表单字段不变。令牌与共享组件见「设计规范」;动效只引用 `--bot-*` 时长与曲线令牌,曲线不在令牌以外重复声明。diff --git a/docs/assets/node-activity-live-dark.png b/docs/assets/node-activity-live-dark.pngnew file mode 100644index 00000000..b5a6f765Binary files /dev/null and b/docs/assets/node-activity-live-dark.png differdiff --git a/docs/assets/node-activity-live-light.png b/docs/assets/node-activity-live-light.pngnew file mode 100644index 00000000..52fc16f1Binary files /dev/null and b/docs/assets/node-activity-live-light.png differdiff --git a/docs/node-activity-validation.md b/docs/node-activity-validation.mdnew file mode 100644index 00000000..ae5f70b2--- /dev/null+++ b/docs/node-activity-validation.md@@ -0,0 +1,61 @@+# Node activity UI acceptance++This evidence uses the real platform built from the animation contribution,+a dedicated local test installation, a password session and a synthetic shell+SOP. No model service, production run or organization data is involved.++## Asset cache upgrade++The literal query in `web/index.html` is not the URL sent to a browser.+`studioFileServer` calls `stampStudioIndex` on each HTML request. Every CSS and+JavaScript reference is rewritten with the first eight bytes of the asset's+SHA-256 hash. HTML is served with `Cache-Control: no-cache`; the resulting+versioned assets use `public, max-age=31536000, immutable`.++The Chromium check kept the same browser context and its HTTP cache enabled:++1. A same-origin HTTP proxy presented the prior stylesheet and its content-hash+ URL while forwarding authentication, run APIs, streaming and other assets to+ the real platform. The baseline was the stylesheet before this contribution.+2. A second normal document navigation reused that old stylesheet. Chromium's+ DevTools Protocol reported a cache hit; the proxy received only one request+ for the old asset across both navigations.+3. The proxy then forwarded the platform's current HTML unchanged. A normal+ navigation fetched the new stylesheet URL, and the existing cached stylesheet+ did not prevent either animation from appearing. No cache clear, hard refresh,+ Playwright request routing or mocked run response was used.++| Asset | Served URL | Network requests |+| --- | --- | --- |+| Previous CSS | `/observability.css?v=b5623289d4bd5745` | 1, then reused from cache |+| Animation CSS | `/observability.css?v=e10036f176cdcba1` | 1 after the upgrade |++The stylesheet hash follows its bytes and will change with later edits. The+handwritten `v=20261031metrics2` was unchanged throughout this check. Regression+tests in `internal/httpapi/studio_test.go` also verify that changing only CSS+changes the served URL without editing HTML or recreating the handler.++## Real-service visual checks++The selected node came from a real running shell SOP. Computed styles and timed+samples confirmed spinner rotation and moving text highlights in both themes.+Reduced-motion preferences disabled both animations. The inspector was also+checked at a 390px viewport, and requesting cancellation stopped its animations+through the real run update path.++The following screenshots are fresh captures of that live inspector. They are+cropped to exclude unrelated installation controls and are static images of the+animated states.++Light theme:++++Dark theme:++++Validation completed on 2026-11-11: the ten node-inspector tests, the stylesheet+hash/upgrade and cache-header Go tests, JavaScript syntax checks, and the live+Chromium checks described above passed. These checks do not claim approval on+behalf of a maintainer or execution of the entire deployed acceptance suite.diff --git a/internal/httpapi/studio_test.go b/internal/httpapi/studio_test.goindex 670772c1..4bed9cf1 100644--- a/internal/httpapi/studio_test.go+++ b/internal/httpapi/studio_test.go@@ -10,6 +10,7 @@ import ("path/filepath""strings""testing"+ "testing/fstest""agentflow/internal/engine""agentflow/internal/repo"@@ -50,6 +51,50 @@ func TestStudioIndexStampsAssetsWithContentHash(t *testing.T) {if strings.Contains(html, "/app.js?v=20260820s6") || strings.Contains(html, "/app.js?v=20260820s5") {t.Fatal("hand-edited cache-bust versions should be replaced")}+ css, err := fs.ReadFile(static, "observability.css")+ if err != nil {+ t.Fatal(err)+ }+ cssHash := sha256.Sum256(css)+ if want := `/observability.css?v=` + hex.EncodeToString(cssHash[:8]) + `"`; !strings.Contains(html, want) {+ t.Fatalf("served index must use the activity stylesheet's content hash: want %s, got %s", want, snippet(html, "observability.css"))+ }+}++func TestStudioStylesheetChangesInvalidateURLWithoutEditingIndex(t *testing.T) {+ const index = `<html><head><link rel="stylesheet" href="/observability.css?v=20261031metrics2"></head></html>`+ static := fstest.MapFS{+ "index.html": {Data: []byte(index)},+ "observability.css": {Data: []byte(`.node-activity-inline{color:gray}`)},+ }+ h := studioFileServer(static)+ previousURL := ""+ for _, css := range []string{+ `.node-activity-inline{color:gray}`,+ `.node-activity-inline.is-running{animation:shimmer 2.4s infinite}`,+ } {+ // The deployment changes only the stylesheet; keep the same HTML and handler.+ static["observability.css"].Data = []byte(css)+ sum := sha256.Sum256([]byte(css))+ url := "/observability.css?v=" + hex.EncodeToString(sum[:8])+ rec := httptest.NewRecorder()+ h.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/", nil))+ if rec.Code != http.StatusOK || rec.Header().Get("Cache-Control") != "no-cache" {+ t.Fatalf("index must be revalidated: status=%d cache=%q", rec.Code, rec.Header().Get("Cache-Control"))+ }+ if !strings.Contains(rec.Body.String(), `href="`+url+`"`) || strings.Contains(rec.Body.String(), "20261031metrics2") {+ t.Fatalf("handwritten version must be replaced by the current stylesheet hash: %s", rec.Body.String())+ }+ if url == previousURL {+ t.Fatal("changed stylesheet reused its immutable URL")+ }+ asset := httptest.NewRecorder()+ h.ServeHTTP(asset, httptest.NewRequest(http.MethodGet, url, nil))+ if asset.Code != http.StatusOK || asset.Body.String() != css {+ t.Fatalf("stamped URL must serve the matching stylesheet: status=%d body=%q", asset.Code, asset.Body.String())+ }+ previousURL = url+ }}func TestStudioVscodePageStampsAssetsWithContentHash(t *testing.T) {diff --git a/web/app/runs.js b/web/app/runs.jsindex f3d1d4e1..4be62f1b 100644--- a/web/app/runs.js+++ b/web/app/runs.js@@ -559,6 +559,13 @@ function selectRunNode(nodeId){renderRunDetail(run);if(!same){const pg=runPageTarget(run,nodeId);ensureRunPages(pg.runId,pg.nodeId)}}+/** 仅为实际执行中的节点显示动效,排除暂停、取消与子流程待确认。 */+function nodeInspectorIsRunning(run,nodeId){+ if(run.status!=='running'||run.pauseRequested||run.cancelRequested||run.nodes?.[nodeId]?.status!=='running')return false;+ /** 已加载的子流程用于校正父节点仍为运行中的过渡状态。 */+ const child=childRunState(run.nodes[nodeId].childRunId);+ return (!child||(child.status==='running'&&!child.pauseRequested&&!child.cancelRequested))&&graphNodeView(run,nodeId).cls==='running';+}function patchRunLive(r){const host=$('#runDetail');if(!host||host.dataset.runId!==r.id||host.dataset.controlSignature!==runControlSignature(r)){renderRunDetail(r);return}const usageHost=host.querySelector('[data-run-usage]');@@ -577,7 +584,9 @@ function patchRunLive(r){if(count){if(!em){em=document.createElement('em');btn.appendChild(em)}em.textContent=`${count} 产物`}else if(em)em.remove();});const selected=state.selectedRunNode,nr=r.nodes?.[selected]||{};- const inspectorStatus=host.querySelector('.node-inspector .status');if(inspectorStatus){inspectorStatus.className=`status ${nr.status||'pending'}`;inspectorStatus.textContent=statusText(nr.status)||'待执行'}+ /** 保留现有元素,让连续日志更新不重启动效。 */+ const inspectorRunning=nodeInspectorIsRunning(r,selected);+ const inspectorStatus=host.querySelector('.node-inspector .status');if(inspectorStatus){inspectorStatus.className=`status node-inspector-status ${nr.status||'pending'}${inspectorRunning?' is-running':''}`;inspectorStatus.textContent=statusText(nr.status)||'待执行'}const facts=host.querySelectorAll('.node-facts b');if(facts[0])facts[0].textContent=String(nr.attempt||0);if(facts[1])facts[1].textContent=String(nr.reworkCount||0);@@ -585,7 +594,7 @@ function patchRunLive(r){if(facts[3])facts[3].textContent=String(nr.toolCalls||0);const artifactTotal=host.querySelector('.run-context-grid > div:last-child b');if(artifactTotal)artifactTotal.textContent=`${(r.artifacts||[]).length} 个不可变快照`;- const activity=host.querySelector('.node-activity-inline');if(activity){if(nr.activity){activity.hidden=false;const b=activity.querySelector('b');if(b)b.textContent=nr.activity}else{activity.hidden=true}}+ const activity=host.querySelector('.node-activity-inline');if(activity){activity.classList.toggle('is-running',inspectorRunning);if(nr.activity){activity.hidden=false;const b=activity.querySelector('b');if(b&&b.textContent!==nr.activity)b.textContent=nr.activity}else{activity.hidden=true}}const feed=host.querySelector('.worker-log-feed'),tel=host.querySelector('.telemetry-feed');const pg=runPageTarget(r,selected);const logPage=state.runLogs?.runId===pg.runId&&state.runLogs.nodeId===pg.nodeId&&state.runLogs.loaded?state.runLogs:null;@@ -953,7 +962,8 @@ function runPageTarget(r,nodeId){return child?{runId:child,nodeId:'',child:true}:{runId:r?.id||'',nodeId:nodeId||'',child:false};}function childRunState(id){return state.childRuns?.[id]?.run||null}-function childRunSignature(run){return `${run?.status}|${Object.entries(run?.nodes||{}).map(([k,v])=>`${k}:${v?.status}`).sort().join(',')}`}+/** 子流程控制标记变化也要刷新父节点,及时停止或恢复活动动效。 */+function childRunSignature(run){return `${run?.status}:${Boolean(run?.pauseRequested)}:${Boolean(run?.cancelRequested)}|${Object.entries(run?.nodes||{}).map(([k,v])=>`${k}:${v?.status}`).sort().join(',')}`}// Where the child SOP needs attention: a pending human decision first, then a failure, then the running node.function childRunFocus(child){if(!child)return null;@@ -1103,6 +1113,8 @@ function renderRunDetail(r){const wf=r.workflowSnapshot?.id?r.workflowSnapshot:((state.data.workflows||[]).find(w=>w.id===r.workflowId)||state.workflow||{id:r.workflowId||'',name:r.workflowId||'流程',nodes:[],edges:[],version:1}),nodes=wf.nodes||[],graphNodes=runIsGroupMode(r)?runFrozenSopNodes(r,wf):nodes,progress=runProgress(r),ctx=runContext(r),usage=r.usage||{};const issueId=ctx.issue?.id||r.executionContext?.issueId||'';const pickNodes=runIsGroupMode(r)?(graphNodes.length?graphNodes:nodes):nodes;if(!state.selectedRunNode||!pickNodes.some(n=>n.id===state.selectedRunNode)){state.selectedRunNode=pickNodes.find(n=>['running','waiting_approval','failed','cancelled'].includes(r.nodes?.[n.id]?.status))?.id||pickNodes.find(n=>r.nodes?.[n.id]?.status==='succeeded')?.id||pickNodes[0]?.id}const pg=runPageTarget(r,state.selectedRunNode);const selected=pickNodes.find(n=>n.id===state.selectedRunNode)||nodes.find(n=>n.id===state.selectedRunNode),nr=r.nodes?.[selected?.id]||{},nodeArtifacts=(r.artifacts||[]).filter(a=>a.nodeId===selected?.id),logPage=state.runLogs?.runId===pg.runId&&state.runLogs.nodeId===pg.nodeId&&state.runLogs.loaded?state.runLogs:null,telAdapter=state.runTelemetryAdapter||'live',telPage=state.runTelemetry?.runId===pg.runId&&state.runTelemetry.nodeId===pg.nodeId&&state.runTelemetry.adapter===telAdapter&&state.runTelemetry.loaded?state.runTelemetry:null,telemetry=compactTelemetry(telPage?.items||[]);+ /** 首次渲染与实时更新使用同一节点活动判断。 */+ const inspectorRunning=nodeInspectorIsRunning(r,selected?.id);const issueRef=ctx.issue?`${escapeHTML(ctx.project?.key||'TASK')}-${ctx.issue.number}`:'独立运行';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;@@ -1113,7 +1125,7 @@ function renderRunDetail(r){const runTabs=['overview:概览','trace:实时轨迹','logs:Worker日志','workspace:工作区'];if(previewEnabled)runTabs.push('preview:前端预览');runTabs.push('eval:智能评测');- host.innerHTML=`<div class="run-detail-main"><header class="run-detail-header"><div class="run-detail-topbar"><button class="button ghost small run-back-inline" data-run-back>← 返回运行列表</button><div class="run-breadcrumb"><span>${issueRef}</span><i>›</i><span>${escapeHTML(wf.name)}</span></div>${r.executionContext?.parentRunId?`<button class="button ghost small" data-open-parent-run="${escapeHTML(r.executionContext.parentRunId)}">↑ 返回父 SOP 运行</button>`:''}<div class="run-header-actions">${issueId?`<button class="button primary small" data-open-issue="${escapeHTML(issueId)}">打开需求</button>`:''}${!r.pauseRequested?refreshRunSOPButtonHTML(r):''}<button class="button ghost small" data-open-flow>查看流程定义</button>${['queued','running','waiting'].includes(r.status)?'<button class="button danger-outline small" data-cancel-run>取消运行</button>':'<button class="button danger-outline small" data-delete-run>删除记录</button>'}</div></div><div class="run-header-main"><div><h2>${escapeHTML(ctx.issue?.title||wf.name)}</h2><p>${escapeHTML(r.input||'无运行输入')}</p></div><div class="run-status-wrap"><span class="status ${runDisplayStatusClass(r)}">${runDisplayStatus(r)}</span>${r.status==='failed'&&!gongfengIssueClosed(ctx.issue)?'<button class="button primary small" data-resume-run>↻ 重试运行</button>':''}${canManuallyPassFailedNode(r)&&!gongfengIssueClosed(ctx.issue)?`<button class="button ghost small" data-pass-node="${escapeHTML(r.id)}" data-node="${escapeHTML(failedNodeId(r))}">手动通过</button>`:''}</div></div><div class="run-header-meta"><span class="run-meta-chip run-id-chip" title="${escapeHTML(r.id)}">Run <code>${escapeHTML(r.id.slice(-12))}</code><button type="button" class="run-id-copy" data-copy-run title="复制完整 Run ID" aria-label="复制 Run ID"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 5.5V3.5A1.5 1.5 0 0 0 9 2H3.5A1.5 1.5 0 0 0 2 3.5V9A1.5 1.5 0 0 0 3.5 10.5H5.5"/></svg></button></span>${runModeChipHTML(r,wf)}${runExecutionChipHTML(r)}<span class="run-meta-chip"><svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" style="vertical-align:-1px;margin-right:4px;"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>启动于 ${new Date(r.createdAt).toLocaleString()}</span><span class="run-meta-chip" title="${escapeHTML(runTimingTitle(r))}"><svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" style="vertical-align:-1px;margin-right:4px;"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>执行 ${runElapsed(r)}${runWallNote(r)}</span></div></header><div class="run-section-label"><b>执行详情</b><div class="run-section-label-actions"><button class="button ghost small" data-export-logs title="下载本次运行全部节点的 Worker 日志">导出全部日志</button><div class="run-tabs" role="tablist">${runTabs.map(t=>{const[k,label]=t.split(':');return `<button class="run-tab ${runDetailTab===k?'active':''}" data-run-tab="${k}">${label}</button>`}).join('')}</div></div></div><div class="run-pane" data-run-pane="overview" ${runDetailTab==='overview'?'':'hidden'}><section class="run-context-grid">${runProgressCellHTML(r,wf,progress,graphNodes)}<div data-run-usage>${liveUsageHTML(r)}</div><div><span>交付物</span><b>${(r.artifacts||[]).length} 个不可变快照</b><small>按节点和尝试次数保留版本</small></div></section></section>${alignPanelHTML}${runIsGroupMode(r)?`<details class="run-sop-snapshot"><summary><div><b>已冷冻 SOP 快照</b><span>历史协作 · ${graphNodes.length} 个节点可展开审计</span></div></summary>`:''}<section class="run-graph-section"><div class="section-heading"><div><h3>节点执行拓扑</h3><span>点击节点查看该节点的输出、产物和执行事件</span></div><div class="graph-legend"><span><i class="succeeded"></i>完成</span><span><i class="running"></i>运行中</span><span><i class="waiting_approval"></i>待审批</span><span><i></i>未开始</span></div></div><div class="run-graph">${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?'<span class="graph-arrow">→</span>':''}<button class="graph-node ${gv.cls} ${state.selectedRunNode===n.id?'selected':''}" data-run-node="${escapeHTML(n.id)}"><span class="node-icon ${meta.kind}">${runNodeIcon(meta.kind)}</span><div><b>${escapeHTML(n.name)}</b><small>${escapeHTML(gv.text)}</small></div>${arts?`<em>${arts} 产物</em>`:''}</button>`}).join('')}</div></section><div class="node-drilldown"><section class="node-inspector"><div class="section-heading"><div class="node-inspector-title"><h3>${escapeHTML(selected?.name||'节点详情')}</h3><span class="node-activity-inline" ${nr.activity?'':'hidden'}>当前活动:<b>${escapeHTML(nr.activity||'')}</b></span><span class="node-inspector-model">${escapeHTML(nr.provider||'未分配')}${nr.model?` · ${escapeHTML(nr.model)}`:''}</span></div><span class="status ${nr.status||'pending'}">${statusText(nr.status)||'待执行'}</span></div><div class="node-facts"><div><span>执行次数</span><b>${nr.attempt||0}</b></div><div><span>返工</span><b>${nr.reworkCount||0}</b></div><div><span>Token</span><b>${formatTokens(nr.usage?.totalTokens)}</b></div><div><span>工具调用</span><b>${nr.toolCalls||0}</b></div></div>${childSOPPanelHTML(r,selected?.id)}${gateResultCardHTML(nr)}${canRerunFromHere(r,selected?.id)?`<div class="node-rerun-row"><button type="button" class="button ghost small" data-rerun-from-here="${escapeHTML(selected.id)}">从这里重跑</button><small>保留上游结果,从本节点及下游重跑</small></div>`:''}${nr.output?`<div class="node-output"><div><b>节点输出</b><button data-copy-output>复制</button></div><pre>${escapeHTML(displayNodeOutput(nr.output))}</pre></div>`:'<div class="node-output empty"><b>节点输出</b><p>节点完成后,结构化输出会显示在这里。</p></div>'}<div class="runtime-details"><span>Sandbox <code>${escapeHTML(nr.sandboxId||'—')}</code></span><span>Session <code>${escapeHTML(nr.sessionId||'—')}</code></span></div></section><section class="node-artifacts"><div class="section-heading"><div><h3>节点交付物</h3><span>${nodeArtifacts.length} 个版本</span></div></div><div class="node-artifact-list">${nodeArtifacts.map(a=>`<button class="node-artifact-card" data-artifact="${escapeHTML(a.id)}"><span class="artifact-file-icon">${a.mediaType==='application/json'?'{}':'MD'}</span><div><b>${escapeHTML(a.name)}</b><span>${escapeHTML(a.path)}</span><small>attempt ${a.attempt} · ${Math.max(1,Math.ceil((a.size||0)/1024))} KB · ${(a.sha256||'').slice(0,10)}</small></div><i>预览 ›</i></button>`).join('')||'<div class="empty-inline"><span>◇</span><p>此节点还没有登记交付物</p></div>'}</div></section></div>${runIsGroupMode(r)?'</details>':''}</div><div class="run-pane" data-run-pane="trace" ${runDetailTab==='trace'?'':'hidden'}><section class="trace-section"><div class="section-heading"><div><h3>${telemetrySectionTitle(telAdapter)}</h3><span>${telPage?`${telemetry.length} 条已加载`:'加载最近 100 条'}</span></div><div class="trace-heading-actions">${telemetrySourceTabs(telAdapter,'data-tel-adapter')}${telPage?.hasMore?`<button class="button ghost small" data-tel-more>加载更早的 100 条</button>`:''}</div></div><div class="telemetry-feed">${telPage?([...telemetry].reverse().map(telemetryItemHTML).join('')||`<div class="empty-inline"><p>${telemetryEmptyHint(telAdapter)}</p></div>`):'<div class="empty-inline"><p>正在加载轨迹…</p></div>'}</div></section></div><div class="run-pane" data-run-pane="logs" ${runDetailTab==='logs'?'':'hidden'}><section class="worker-log-section"><div class="section-heading"><div><h3>Worker 日志</h3><span>${logPage?`${visibleWorkerLogs(logPage.items).length} 条调用`:(logBusy?'正在接收…':'实时加载最近调用')}</span></div><div class="worker-log-heading-actions">${logPage?.hasMore?`<button class="button ghost small" data-logs-more>加载更早的 100 条</button>`:''}</div></div><div class="worker-log-feed">${logPage?(visibleWorkerLogs(logPage.items).map(logLineHTML).join('')||'<div class="empty-inline"><p>该节点没有日志</p></div>'):'<div class="empty-inline"><p>正在加载 Worker 实时日志…</p></div>'}</div></section></div></div>`; host.querySelector('.run-detail-main')?.insertAdjacentHTML('beforeend',`<div class="run-pane" data-run-pane="workspace" ${runDetailTab==='workspace'?'':'hidden'}>${workspacePaneHTML(r)}</div>${previewEnabled?`<div class="run-pane" data-run-pane="preview" ${runDetailTab==='preview'?'':'hidden'}>${previewPaneHTML(r)}</div>`:''}<div class="run-pane" data-run-pane="eval" ${runDetailTab==='eval'?'':'hidden'}>${runEvalPaneHTML(r)}</div>`);+ host.innerHTML=`<div class="run-detail-main"><header class="run-detail-header"><div class="run-detail-topbar"><button class="button ghost small run-back-inline" data-run-back>← 返回运行列表</button><div class="run-breadcrumb"><span>${issueRef}</span><i>›</i><span>${escapeHTML(wf.name)}</span></div>${r.executionContext?.parentRunId?`<button class="button ghost small" data-open-parent-run="${escapeHTML(r.executionContext.parentRunId)}">↑ 返回父 SOP 运行</button>`:''}<div class="run-header-actions">${issueId?`<button class="button primary small" data-open-issue="${escapeHTML(issueId)}">打开需求</button>`:''}${!r.pauseRequested?refreshRunSOPButtonHTML(r):''}<button class="button ghost small" data-open-flow>查看流程定义</button>${['queued','running','waiting'].includes(r.status)?'<button class="button danger-outline small" data-cancel-run>取消运行</button>':'<button class="button danger-outline small" data-delete-run>删除记录</button>'}</div></div><div class="run-header-main"><div><h2>${escapeHTML(ctx.issue?.title||wf.name)}</h2><p>${escapeHTML(r.input||'无运行输入')}</p></div><div class="run-status-wrap"><span class="status ${runDisplayStatusClass(r)}">${runDisplayStatus(r)}</span>${r.status==='failed'&&!gongfengIssueClosed(ctx.issue)?'<button class="button primary small" data-resume-run>↻ 重试运行</button>':''}${canManuallyPassFailedNode(r)&&!gongfengIssueClosed(ctx.issue)?`<button class="button ghost small" data-pass-node="${escapeHTML(r.id)}" data-node="${escapeHTML(failedNodeId(r))}">手动通过</button>`:''}</div></div><div class="run-header-meta"><span class="run-meta-chip run-id-chip" title="${escapeHTML(r.id)}">Run <code>${escapeHTML(r.id.slice(-12))}</code><button type="button" class="run-id-copy" data-copy-run title="复制完整 Run ID" aria-label="复制 Run ID"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 5.5V3.5A1.5 1.5 0 0 0 9 2H3.5A1.5 1.5 0 0 0 2 3.5V9A1.5 1.5 0 0 0 3.5 10.5H5.5"/></svg></button></span>${runModeChipHTML(r,wf)}${runExecutionChipHTML(r)}<span class="run-meta-chip"><svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" style="vertical-align:-1px;margin-right:4px;"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>启动于 ${new Date(r.createdAt).toLocaleString()}</span><span class="run-meta-chip" title="${escapeHTML(runTimingTitle(r))}"><svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" style="vertical-align:-1px;margin-right:4px;"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>执行 ${runElapsed(r)}${runWallNote(r)}</span></div></header><div class="run-section-label"><b>执行详情</b><div class="run-section-label-actions"><button class="button ghost small" data-export-logs title="下载本次运行全部节点的 Worker 日志">导出全部日志</button><div class="run-tabs" role="tablist">${runTabs.map(t=>{const[k,label]=t.split(':');return `<button class="run-tab ${runDetailTab===k?'active':''}" data-run-tab="${k}">${label}</button>`}).join('')}</div></div></div><div class="run-pane" data-run-pane="overview" ${runDetailTab==='overview'?'':'hidden'}><section class="run-context-grid">${runProgressCellHTML(r,wf,progress,graphNodes)}<div data-run-usage>${liveUsageHTML(r)}</div><div><span>交付物</span><b>${(r.artifacts||[]).length} 个不可变快照</b><small>按节点和尝试次数保留版本</small></div></section></section>${alignPanelHTML}${runIsGroupMode(r)?`<details class="run-sop-snapshot"><summary><div><b>已冷冻 SOP 快照</b><span>历史协作 · ${graphNodes.length} 个节点可展开审计</span></div></summary>`:''}<section class="run-graph-section"><div class="section-heading"><div><h3>节点执行拓扑</h3><span>点击节点查看该节点的输出、产物和执行事件</span></div><div class="graph-legend"><span><i class="succeeded"></i>完成</span><span><i class="running"></i>运行中</span><span><i class="waiting_approval"></i>待审批</span><span><i></i>未开始</span></div></div><div class="run-graph">${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?'<span class="graph-arrow">→</span>':''}<button class="graph-node ${gv.cls} ${state.selectedRunNode===n.id?'selected':''}" data-run-node="${escapeHTML(n.id)}"><span class="node-icon ${meta.kind}">${runNodeIcon(meta.kind)}</span><div><b>${escapeHTML(n.name)}</b><small>${escapeHTML(gv.text)}</small></div>${arts?`<em>${arts} 产物</em>`:''}</button>`}).join('')}</div></section><div class="node-drilldown"><section class="node-inspector"><div class="section-heading"><div class="node-inspector-title"><h3>${escapeHTML(selected?.name||'节点详情')}</h3><span class="node-activity-inline${inspectorRunning?' is-running':''}" ${nr.activity?'':'hidden'}>当前活动:<b>${escapeHTML(nr.activity||'')}</b></span><span class="node-inspector-model">${escapeHTML(nr.provider||'未分配')}${nr.model?` · ${escapeHTML(nr.model)}`:''}</span></div><span class="status node-inspector-status ${nr.status||'pending'}${inspectorRunning?' is-running':''}">${statusText(nr.status)||'待执行'}</span></div><div class="node-facts"><div><span>执行次数</span><b>${nr.attempt||0}</b></div><div><span>返工</span><b>${nr.reworkCount||0}</b></div><div><span>Token</span><b>${formatTokens(nr.usage?.totalTokens)}</b></div><div><span>工具调用</span><b>${nr.toolCalls||0}</b></div></div>${childSOPPanelHTML(r,selected?.id)}${gateResultCardHTML(nr)}${canRerunFromHere(r,selected?.id)?`<div class="node-rerun-row"><button type="button" class="button ghost small" data-rerun-from-here="${escapeHTML(selected.id)}">从这里重跑</button><small>保留上游结果,从本节点及下游重跑</small></div>`:''}${nr.output?`<div class="node-output"><div><b>节点输出</b><button data-copy-output>复制</button></div><pre>${escapeHTML(displayNodeOutput(nr.output))}</pre></div>`:'<div class="node-output empty"><b>节点输出</b><p>节点完成后,结构化输出会显示在这里。</p></div>'}<div class="runtime-details"><span>Sandbox <code>${escapeHTML(nr.sandboxId||'—')}</code></span><span>Session <code>${escapeHTML(nr.sessionId||'—')}</code></span></div></section><section class="node-artifacts"><div class="section-heading"><div><h3>节点交付物</h3><span>${nodeArtifacts.length} 个版本</span></div></div><div class="node-artifact-list">${nodeArtifacts.map(a=>`<button class="node-artifact-card" data-artifact="${escapeHTML(a.id)}"><span class="artifact-file-icon">${a.mediaType==='application/json'?'{}':'MD'}</span><div><b>${escapeHTML(a.name)}</b><span>${escapeHTML(a.path)}</span><small>attempt ${a.attempt} · ${Math.max(1,Math.ceil((a.size||0)/1024))} KB · ${(a.sha256||'').slice(0,10)}</small></div><i>预览 ›</i></button>`).join('')||'<div class="empty-inline"><span>◇</span><p>此节点还没有登记交付物</p></div>'}</div></section></div>${runIsGroupMode(r)?'</details>':''}</div><div class="run-pane" data-run-pane="trace" ${runDetailTab==='trace'?'':'hidden'}><section class="trace-section"><div class="section-heading"><div><h3>${telemetrySectionTitle(telAdapter)}</h3><span>${telPage?`${telemetry.length} 条已加载`:'加载最近 100 条'}</span></div><div class="trace-heading-actions">${telemetrySourceTabs(telAdapter,'data-tel-adapter')}${telPage?.hasMore?`<button class="button ghost small" data-tel-more>加载更早的 100 条</button>`:''}</div></div><div class="telemetry-feed">${telPage?([...telemetry].reverse().map(telemetryItemHTML).join('')||`<div class="empty-inline"><p>${telemetryEmptyHint(telAdapter)}</p></div>`):'<div class="empty-inline"><p>正在加载轨迹…</p></div>'}</div></section></div><div class="run-pane" data-run-pane="logs" ${runDetailTab==='logs'?'':'hidden'}><section class="worker-log-section"><div class="section-heading"><div><h3>Worker 日志</h3><span>${logPage?`${visibleWorkerLogs(logPage.items).length} 条调用`:(logBusy?'正在接收…':'实时加载最近调用')}</span></div><div class="worker-log-heading-actions">${logPage?.hasMore?`<button class="button ghost small" data-logs-more>加载更早的 100 条</button>`:''}</div></div><div class="worker-log-feed">${logPage?(visibleWorkerLogs(logPage.items).map(logLineHTML).join('')||'<div class="empty-inline"><p>该节点没有日志</p></div>'):'<div class="empty-inline"><p>正在加载 Worker 实时日志…</p></div>'}</div></section></div></div>`; host.querySelector('.run-detail-main')?.insertAdjacentHTML('beforeend',`<div class="run-pane" data-run-pane="workspace" ${runDetailTab==='workspace'?'':'hidden'}>${workspacePaneHTML(r)}</div>${previewEnabled?`<div class="run-pane" data-run-pane="preview" ${runDetailTab==='preview'?'':'hidden'}>${previewPaneHTML(r)}</div>`:''}<div class="run-pane" data-run-pane="eval" ${runDetailTab==='eval'?'':'hidden'}>${runEvalPaneHTML(r)}</div>`);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','<button class="button ghost small" data-pause-run>暂停运行</button>');diff --git a/web/observability.css b/web/observability.cssindex 44999cd4..66996d5c 100644--- a/web/observability.css+++ b/web/observability.css@@ -99,8 +99,20 @@.node-inspector-title h3{flex:0 0 auto}.node-inspector-title .node-inspector-model{display:block;margin-top:0;color:var(--muted-2);font-size:11px}.node-inspector-title .node-activity-inline{display:inline-flex;align-items:baseline;gap:4px;margin-top:0;padding:2px 8px;border:1px solid var(--line);border-radius:999px;background:var(--bg-soft);color:var(--muted-2);font-size:10px;white-space:nowrap;max-width:100%;overflow:hidden}-.node-inspector-title .node-activity-inline b{font-weight:650;color:var(--text);overflow:hidden;text-overflow:ellipsis}+.node-inspector-title .node-activity-inline b{min-width:0;font-weight:650;color:var(--hui-text);overflow:hidden;text-overflow:ellipsis}.node-inspector-title .node-activity-inline[hidden]{display:none}+/* 运行状态转圈与活动文字高光共享真实执行状态,不影响历史日志。 */+.node-inspector .node-inspector-status{display:inline-flex;align-items:center;gap:6px;flex-shrink:0}+.node-inspector-status.is-running::before{content:"";width:12px;height:12px;box-sizing:border-box;border:1.5px solid currentColor;border-right-color:transparent;border-radius:50%;animation:node-status-spin .85s linear infinite}+@keyframes node-status-spin{to{transform:rotate(360deg)}}+@supports ((background-clip:text) or (-webkit-background-clip:text)){+ .node-inspector-title .node-activity-inline.is-running b{color:transparent;background-image:linear-gradient(100deg,var(--hui-secondary) 40%,var(--hui-text) 50%,var(--hui-secondary) 60%);background-size:250% 100%;background-position:100% 0;background-clip:text;-webkit-background-clip:text;animation:node-activity-shimmer 2.4s ease-in-out infinite}+}+@keyframes node-activity-shimmer{from{background-position:100% 0}to{background-position:0 0}}+@media (prefers-reduced-motion:reduce),(forced-colors:active){+ .node-inspector-status.is-running::before{animation:none}+ .node-inspector-title .node-activity-inline.is-running b{animation:none;background:none;color:var(--hui-text)}+}.node-error,.node-output{margin-top:10px;border:1px solid var(--line);border-radius:9px;overflow:hidden}.node-output>div{height:35px;display:flex;align-items:center;justify-content:space-between;padding:0 10px;border-bottom:1px solid var(--line);background:var(--bg-soft)}.node-output b{font-size:10px}diff --git a/webtest/tests/runs-detail.test.mjs b/webtest/tests/runs-detail.test.mjsindex 2dd40ca3..56fcf961 100644--- a/webtest/tests/runs-detail.test.mjs+++ b/webtest/tests/runs-detail.test.mjs@@ -196,3 +196,107 @@ test('a stage that has not started or finished hides the zero default time', asyassert.ok(times.some((text) => text.includes('现在') && !text.includes('0001')), `an open stage shows now, not year 1: ${times.join(' | ')}`);assert.ok(times.every((text) => !text.includes('0001')), times.join(' | '));});++/** 渲染正在执行的节点,保留真实详情页与实时更新入口。 */+function renderActivityFixture(app) {+ app.evaluate(`+ state.activeRun={...state.data.runs[0],status:'running',pauseRequested:false,cancelRequested:false,+ workflowSnapshot:structuredClone(state.data.workflows[0]),artifacts:[],+ nodes:{'node-1':{status:'running',attempt:1,activity:'正在分析需求'},'node-2':{status:'pending'}}};+ state.selectedRun=state.activeRun.id;state.selectedRunNode='node-1';+ renderRunDetail(state.activeRun);+ `);+}++/** 同时检查活动文字与节点状态的动态反馈。 */+function assertInspectorMotion(app, active, message) {+ for (const selector of ['.node-activity-inline', '.node-inspector-status']) {+ const element = app.document.querySelector(`#runDetail ${selector}`);+ assert.ok(element, selector);+ assert.equal(element.classList.contains('is-running'), active, `${message}: ${selector}`);+ }+}++test('running node activity keeps its DOM and motion across streamed text updates', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ renderActivityFixture(app);+ assertInspectorMotion(app, true, 'initial running node');+ const activity = app.document.querySelector('#runDetail .node-activity-inline');+ const text = activity.querySelector('b');+ const status = app.document.querySelector('#runDetail .node-inspector-status');+ assert.equal(activity.hidden, false);+ app.evaluate(`startLiveRun(state.activeRun.id)`);+ const stream = app.evaluate('state.runStream');+ const next = '正在读取 <component> & 接口规范';+ stream.emit({ run: { id: 'run-1', status: 'running', nodes: { 'node-1': { activity: next } } } }, 'run');+ assert.equal(app.document.querySelector('#runDetail .node-activity-inline'), activity);+ assert.equal(activity.querySelector('b'), text, 'streamed text should not replace the animated element');+ assert.equal(app.document.querySelector('#runDetail .node-inspector-status'), status);+ assert.equal(text.textContent, next);+ assert.equal(text.children.length, 0, 'activity stays escaped text');+ assertInspectorMotion(app, true, 'streamed activity');+ stream.emit({ run: { id: 'run-1', status: 'running', nodes: {+ 'node-1': { status: 'succeeded' }, 'node-2': { status: 'running' },+ } } }, 'run');+ assertInspectorMotion(app, false, 'selected completed node while another node runs');+ assert.equal(activity.querySelector('b').textContent, next, 'completed activity remains readable');+});++test('terminal, human-waiting, paused and cancelling runs stop inspector motion', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ for (const [label, runPatch, nodeStatus] of [+ ['completed', { status: 'succeeded' }, 'succeeded'],+ ['failed', { status: 'failed' }, 'failed'],+ ['cancelled', { status: 'cancelled' }, 'cancelled'],+ ['human approval', { status: 'waiting' }, 'waiting_approval'],+ ['paused', { status: 'paused' }, 'running'],+ ['pause requested', { pauseRequested: true }, 'running'],+ ['cancel requested', { cancelRequested: true }, 'running'],+ ]) {+ renderActivityFixture(app);+ app.evaluate(`Object.assign(state.activeRun,${JSON.stringify(runPatch)});+ state.activeRun.nodes['node-1'].status=${JSON.stringify(nodeStatus)};patchRunLive(state.activeRun)`);+ assertInspectorMotion(app, false, label);+ assert.equal(app.document.querySelector('#runDetail .node-activity-inline b').textContent, '正在分析需求', label);+ }+});++test('a parent node only animates while its child SOP is executing', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ renderActivityFixture(app);+ app.evaluate(`+ state.activeRun.nodes['node-1'].childRunId='child-activity';+ state.childRuns={'child-activity':{at:Date.now(),run:{id:'child-activity',status:'waiting',+ workflowSnapshot:{nodes:[{id:'review',name:'Review'}]},nodes:{review:{status:'waiting_approval'}}}}};+ renderRunDetail(state.activeRun);+ `);+ assertInspectorMotion(app, false, 'child waits for human approval on first render');+ app.evaluate(`state.childRuns['child-activity'].run.status='running';+ state.childRuns['child-activity'].run.nodes.review.status='running';patchRunLive(state.activeRun)`);+ assertInspectorMotion(app, true, 'child resumes execution');+ app.evaluate(`state.childRuns['child-activity'].run.nodes.review.status='waiting_approval';patchRunLive(state.activeRun)`);+ assertInspectorMotion(app, false, 'child approval node overrides its stale running status');+});++test('child pause and cancellation polling refreshes motion without parent stream events', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ renderActivityFixture(app);+ const child = { id: 'child-activity', status: 'running', pauseRequested: false, cancelRequested: false,+ workflowSnapshot: { nodes: [{ id: 'work', name: 'Work' }] }, nodes: { work: { status: 'running' } } };+ app.evaluate(`state.activeRun.nodes['node-1'].childRunId='child-activity';+ state.childRuns={'child-activity':{at:Date.now(),run:${JSON.stringify(child)}}};renderRunDetail(state.activeRun)`);+ assertInspectorMotion(app, true, 'initial child execution');+ for (const flag of ['pauseRequested', 'cancelRequested']) {+ for (const requested of [true, false]) {+ app.router.get('/api/runs/child-activity', { ...child, [flag]: requested });+ app.evaluate(`state.childRuns['child-activity'].at=0;refreshChildRuns(state.activeRun)`);+ await settle(3);+ assert.equal(app.evaluate(`state.childRuns['child-activity'].run.${flag}`), requested);+ assertInspectorMotion(app, !requested, `${flag}=${requested} from child polling`);+ }+ }+});