From 4a7422cbc4ca00ad871114631f07f7ce5b92b641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Sun, 11 Jan 2026 15:17:41 +0800 Subject: [PATCH] Add files via upload --- web/static/js/chat.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web/static/js/chat.js b/web/static/js/chat.js index 3d44757f..f3a47254 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -943,6 +943,8 @@ function addMessage(role, content, mcpExecutionIds = null, progressId = null, cr detailBtn.innerHTML = `调用 #${index + 1}`; detailBtn.onclick = () => showMCPDetail(execId); buttonsContainer.appendChild(detailBtn); + // 异步获取工具名称并更新按钮文本 + updateButtonWithToolName(detailBtn, execId, index + 1); }); } @@ -1231,6 +1233,23 @@ window.addEventListener('beforeunload', () => { } }); +// 异步获取工具名称并更新按钮文本 +async function updateButtonWithToolName(button, executionId, index) { + try { + const response = await apiFetch(`/api/monitor/execution/${executionId}`); + if (response.ok) { + const exec = await response.json(); + const toolName = exec.toolName || '未知工具'; + // 格式化工具名称(如果是 name::toolName 格式,只显示 toolName 部分) + const displayToolName = toolName.includes('::') ? toolName.split('::')[1] : toolName; + button.querySelector('span').textContent = `${displayToolName} #${index}`; + } + } catch (error) { + // 如果获取失败,保持原有文本不变 + console.error('获取工具名称失败:', error); + } +} + // 显示MCP调用详情 async function showMCPDetail(executionId) { try {