diff --git a/web/app/runs.js b/web/app/runs.js index 9c787dae3..3e21080d4 100644 --- a/web/app/runs.js +++ b/web/app/runs.js @@ -1254,7 +1254,18 @@ function renderRunDetail(r){ const runDescription = ctx.issue?.description || r.input; const descriptionExpanded = host.dataset.runId === r.id && host.querySelector('.run-header-description')?.open; + const previousOutput = host.dataset.runId === r.id && host.dataset.nodeId === selected?.id + ? host.querySelector('.node-output pre') : null; + const outputTop = previousOutput?.scrollTop; + const outputLeft = previousOutput?.scrollLeft; host.innerHTML=`
${issueRef}›${escapeHTML(wf.name)}
${r.executionContext?.parentRunId?``:''}
${issueId?``:''}${!r.pauseRequested?refreshRunSOPButtonHTML(r):''}${['queued','running','waiting'].includes(r.status)?'':''}

${escapeHTML(runTitle)}

${runHeaderDescription(runDescription,ctx.issue?.title,descriptionExpanded)}
${workspaceRestoreButtonHTML()}${runDisplayStatus(r)}${r.status==='failed'&&!gongfengIssueClosed(ctx.issue)?'':''}${canManuallyPassFailedNode(r)&&!gongfengIssueClosed(ctx.issue)?``:''}
Run ${escapeHTML(r.id.slice(-12))}${runModeChipHTML(r,wf)}${runExecutionChipHTML(r)}启动于 ${new Date(r.createdAt).toLocaleString()}执行 ${runElapsed(r)}${runWallNote(r)}
执行详情
${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?'→':''}`}).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=>``).join('')||'
◇

此节点还没有登记交付物

'}
${runIsGroupMode(r)?'
':''}

${telemetrySectionTitle(telAdapter)}

${telPage?`${telemetry.length} 条已加载`:'加载最近 100 条'}
${telemetrySourceTabs(telAdapter,'data-tel-adapter')}${telPage?.hasMore?``:''}
${telPage?([...telemetry].reverse().map(telemetryItemHTML).join('')||`

${telemetryEmptyHint(telAdapter)}

`):'

正在加载轨迹…

'}

Worker 日志

${logPage?`${visibleWorkerLogs(logPage.items).length} 条调用`:(logBusy?'正在接收…':'实时加载最近调用')}
${logPage?.hasMore?``:''}
${logPage?(visibleWorkerLogs(logPage.items).map(logLineHTML).join('')||'

该节点没有日志

'):'

正在加载 Worker 实时日志…

'}
`; host.querySelector('.run-detail-main')?.insertAdjacentHTML('beforeend',`
${workspacePaneHTML(r)}
${previewEnabled?`
${previewPaneHTML(r)}
`:''}
${runEvalPaneHTML(r)}
`); + if (outputTop || outputLeft) { + const output = host.querySelector('.node-output pre'); + if (output && output.textContent === previousOutput.textContent) { + output.scrollTop = outputTop; + output.scrollLeft = outputLeft; + } + } 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',''); diff --git a/webtest/tests/runs-detail.test.mjs b/webtest/tests/runs-detail.test.mjs index 3ca42c077..71d101885 100644 --- a/webtest/tests/runs-detail.test.mjs +++ b/webtest/tests/runs-detail.test.mjs @@ -62,6 +62,33 @@ test('run detail loads logs, telemetry, preview, workspace, evaluation, and chil assert.match(app.document.querySelector('#runsView').textContent, /Implemented|Strong result|Report|2400|2\.4k/i); }); +test('live run redraw keeps the reading position only for the same node output', async (t) => { + const app = await loadApp(); + t.after(app.close); + app.evaluate(` + const report = 'Report line\\n'.repeat(100); + const run = {...state.data.runs[0], status:'running', workflowSnapshot:state.data.workflows[0], + nodes:{'node-1':{status:'succeeded', output:report}, 'node-2':{status:'running', output:report}}}; + state.selectedRun = run.id; + state.selectedRunNode = 'node-1'; + applyRunPayload(run); + `); + const output = () => app.document.querySelector('#runDetail .node-output pre'); + output().scrollTop = 320; + app.evaluate(` + run.nodes['node-2'].status = 'succeeded'; + applyRunPayload({...run, status:'succeeded'}); + `); + assert.equal(output().scrollTop, 320); + + app.evaluate("state.selectedRunNode='node-2'; renderRunDetail(state.activeRun)"); + assert.equal(output().scrollTop, 0, 'switching nodes resets even for identical text'); + + output().scrollTop = 120; + app.evaluate("run.nodes['node-2'].output='Updated report'; applyRunPayload(state.activeRun)"); + assert.equal(output().scrollTop, 0, 'replaced output starts at the top'); +}); + test('run detail node topology renders an icon glyph instead of undefined', async (t) => { const app = await loadApp(); t.after(app.close);