From 5978fadc1d40b2fa025af5e81c276843591a38ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:34:53 +0800 Subject: [PATCH] Add files via upload --- web/static/i18n/en-US.json | 1 + web/static/i18n/zh-CN.json | 1 + web/static/js/monitor.js | 53 ++++++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json index 4d6ec5bb..94ce2e9d 100644 --- a/web/static/i18n/en-US.json +++ b/web/static/i18n/en-US.json @@ -146,6 +146,7 @@ "callNumber": "Call #{{n}}", "iterationRound": "Iteration {{n}}", "aiThinking": "AI thinking", + "planning": "Planning", "toolCallsDetected": "Detected {{count}} tool call(s)", "callTool": "Call tool: {{name}} ({{index}}/{{total}})", "toolExecComplete": "Tool {{name}} completed", diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json index e3374a7e..b8bb4f87 100644 --- a/web/static/i18n/zh-CN.json +++ b/web/static/i18n/zh-CN.json @@ -146,6 +146,7 @@ "callNumber": "调用 #{{n}}", "iterationRound": "第 {{n}} 轮迭代", "aiThinking": "AI思考", + "planning": "规划中", "toolCallsDetected": "检测到 {{count}} 个工具调用", "callTool": "调用工具: {{name}} ({{index}}/{{total}})", "toolExecComplete": "工具 {{name}} 执行完成", diff --git a/web/static/js/monitor.js b/web/static/js/monitor.js index 04d09505..23bbd1d5 100644 --- a/web/static/js/monitor.js +++ b/web/static/js/monitor.js @@ -1101,16 +1101,16 @@ function handleStreamEvent(event, progressElement, progressId, loadActiveTasks(); } - // 主回复开始流式输出时隐藏整条进度卡片(迭代阶段默认展开;最终回复时不再占屏) - hideProgressMessageForFinalReply(progressId); - - // 已存在则复用;否则创建空助手消息占位,用于增量追加 - const existing = responseStreamStateByProgressId.get(progressId); - if (existing && existing.assistantId) break; - - const assistantId = addMessage('assistant', '', mcpIds, progressId); - setAssistantId(assistantId); - responseStreamStateByProgressId.set(progressId, { assistantId, buffer: '' }); + // 多代理模式下,迭代过程中的输出只显示在时间线中,不创建助手消息气泡 + // 创建时间线条目用于显示迭代过程中的输出 + const agentPrefix = timelineAgentBracketPrefix(responseData); + const title = agentPrefix + '📝 ' + (typeof window.t === 'function' ? window.t('chat.planning') : '规划中'); + const itemId = addTimelineItem(timeline, 'thinking', { + title: title, + message: ' ', + data: responseData + }); + responseStreamStateByProgressId.set(progressId, { itemId: itemId, buffer: '' }); break; } @@ -1126,19 +1126,31 @@ function handleStreamEvent(event, progressElement, progressId, } } - hideProgressMessageForFinalReply(progressId); - + // 多代理模式下,迭代过程中的输出只显示在时间线中 + // 更新时间线条目内容 let state = responseStreamStateByProgressId.get(progressId); - if (!state || !state.assistantId) { - const mcpIds = responseData.mcpExecutionIds || []; - const assistantId = addMessage('assistant', '', mcpIds, progressId); - setAssistantId(assistantId); - state = { assistantId, buffer: '' }; + if (!state) { + state = { itemId: null, buffer: '' }; responseStreamStateByProgressId.set(progressId, state); } - state.buffer += (event.message || ''); - updateAssistantBubbleContent(state.assistantId, state.buffer, false); + const deltaContent = event.message || ''; + state.buffer += deltaContent; + + // 更新时间线条目内容 + if (state.itemId) { + const item = document.getElementById(state.itemId); + if (item) { + const contentEl = item.querySelector('.timeline-item-content'); + if (contentEl) { + if (typeof formatMarkdown === 'function') { + contentEl.innerHTML = formatMarkdown(state.buffer); + } else { + contentEl.textContent = state.buffer; + } + } + } + } break; } @@ -1179,6 +1191,9 @@ function handleStreamEvent(event, progressElement, progressId, updateAssistantBubbleContent(assistantIdFinal, event.message, true); } + // 最终回复时隐藏进度卡片(多代理模式下,迭代过程已完整展示) + hideProgressMessageForFinalReply(progressId); + // 将进度详情集成到工具调用区域(放在最终 response 之后,保证时间线已完整) integrateProgressToMCPSection(progressId, assistantIdFinal, mcpIds); responseStreamStateByProgressId.delete(progressId);