diff --git a/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue b/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue index 49837de..080b980 100644 --- a/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue +++ b/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue @@ -54,6 +54,64 @@ const activeLogNames = ref([]); const dialogTitle = computed(() => run.value?.workflow_name || $t('ai-platform.workflowRuns.detail.runId')); const executionLogs = computed(() => run.value?.execution_log || []); +const taskSummary = computed(() => { + const inputs = run.value?.inputs || {}; + const issueId = inputs.issue_id || inputs.issueId; + const request = + inputs.request || + inputs.user_input || + inputs.query || + inputs.task || + inputs.prompt || + inputs.message; + if (issueId && request) return `${issueId}: ${request}`; + return previewValue(request || inputs); +}); +const finalOutput = computed(() => { + const outputs = run.value?.outputs || {}; + const direct = + outputs.output || + outputs.final_result || + outputs.result || + outputs.answer || + outputs.summary; + if (direct) return previewValue(direct); + + const nodeValues = Object.entries(outputs) + .filter(([key]) => key.startsWith('_node_')) + .map(([, value]) => (value as any)?.output || value) + .filter(Boolean); + return previewValue(nodeValues.at(-1) || outputs); +}); +const agentSummaries = computed(() => { + const agents = new Map< + string, + { code: string; model: string; name: string; steps: number; tokens: number } + >(); + + for (const log of executionLogs.value) { + const meta = getLogMeta(log); + const code = meta.agent_code; + if (!code) continue; + + const current = agents.get(code) || { + code, + model: meta.model || meta.model_id || '-', + name: meta.agent_name || code, + steps: 0, + tokens: 0, + }; + current.steps += 1; + current.tokens += + log.tokens_used || + meta.total_tokens || + meta.prompt_tokens + meta.completion_tokens || + 0; + agents.set(code, current); + } + + return [...agents.values()]; +}); async function loadDetail() { if (!runId.value) return; @@ -240,6 +298,46 @@ defineExpose({ open }); +
+
+
任务输入
+
{{ taskSummary }}
+
+
+
最终输出
+
{{ run.error_message || finalOutput }}
+
+
+
+ 协作智能体 + {{ agentSummaries.length }} +
+
+
+
+ {{ agent.name }} + + {{ agent.steps }} 步 / {{ agent.tokens }} Token + +
+
+ {{ agent.code }} · {{ agent.model }} +
+
+
+
+ 暂无智能体协作记录 +
+
+
+
>({}); +const runFinalOutputs = ref>({}); const runEvents = ref< Array<{ detail?: string; @@ -286,6 +288,32 @@ function formatRunDuration(ms?: number) { return `${(ms / 1000).toFixed(2)}s`; } +function previewRunValue(value: any, maxLength = 500) { + if (value === undefined || value === null || value === '') return '-'; + const text = + typeof value === 'string' + ? value + : JSON.stringify(value, null, 2); + return text.length > maxLength ? `${text.slice(0, maxLength)}...` : text; +} + +function getWorkflowFinalOutput(outputs?: Record) { + if (!outputs) return ''; + const direct = + outputs.output || + outputs.final_result || + outputs.result || + outputs.answer || + outputs.summary; + if (direct) return previewRunValue(direct, 800); + + const nodeValues = Object.entries(outputs) + .filter(([key]) => key.startsWith('_node_')) + .map(([, value]) => (value as any)?.output || value) + .filter(Boolean); + return previewRunValue(nodeValues.at(-1) || outputs, 800); +} + function pushRunEvent( title: string, status: 'failed' | 'info' | 'running' | 'success' | 'warning' = 'info', @@ -305,6 +333,8 @@ function resetRunState() { runStatus.value = 'running'; runError.value = ''; runElapsedTime.value = 0; + runSubmittedInputs.value = {}; + runFinalOutputs.value = {}; runEvents.value = []; } @@ -406,10 +436,13 @@ function handleWorkflowRunEvent(event: WorkflowStreamEvent) { case 'complete': { runStatus.value = 'completed'; runElapsedTime.value = event.elapsed_time || 0; + runFinalOutputs.value = event.outputs || {}; + const finalOutput = getWorkflowFinalOutput(event.outputs); pushRunEvent( '流程运行完成', 'success', - `耗时 ${formatRunDuration(event.elapsed_time)},Token ${event.total_tokens || 0}`, + finalOutput || + `耗时 ${formatRunDuration(event.elapsed_time)},Token ${event.total_tokens || 0}`, ); ElMessage.success('流程运行完成'); cancelWorkflowRunStream = null; @@ -434,6 +467,7 @@ function handleRunWorkflow(inputs: Record) { cancelWorkflowRunStream?.(); resetRunState(); + runSubmittedInputs.value = inputs; runStatusDialogVisible.value = true; pushRunEvent('已提交运行请求', 'info', runWorkflowTarget.value.name); @@ -905,7 +939,23 @@ onUnmounted(() => { {{ runError }}
- +
+
+
本次任务
+
{{ previewRunValue(runSubmittedInputs) }}
+
+
+
+ 最终输出 + + {{ formatRunDuration(runElapsedTime) }} + +
+
{{ getWorkflowFinalOutput(runFinalOutputs) || '-' }}
+
+
+ +
{
+ +