From 61b164eec299c5b232ca07657f26225c6f57384e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Wed, 20 May 2026 11:03:38 +0800 Subject: [PATCH] Add files via upload --- web/static/js/chat.js | 5 +---- web/static/js/monitor.js | 43 +++++---------------------------------- web/static/js/webshell.js | 10 ++------- 3 files changed, 8 insertions(+), 50 deletions(-) diff --git a/web/static/js/chat.js b/web/static/js/chat.js index 73e41388..8fcb357b 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -2424,11 +2424,8 @@ function renderProcessDetails(messageId, processDetails) { const toolName = data.toolName || (typeof window.t === 'function' ? window.t('chat.unknownTool') : '未知工具'); const index = data.index || 0; const total = data.total || 0; - const argsHint = typeof window.toolCallArgHint === 'function' - ? window.toolCallArgHint(typeof window.parseToolCallArgsFromData === 'function' ? window.parseToolCallArgsFromData(data) : {}) - : ''; const callTitle = typeof window.formatToolCallTimelineTitle === 'function' - ? window.formatToolCallTimelineTitle(toolName, index, total, argsHint) + ? window.formatToolCallTimelineTitle(toolName, index, total) : (typeof window.t === 'function' ? window.t('chat.callTool', { name: escapeHtml(toolName), index: index, total: total }) : '调用工具: ' + escapeHtml(toolName) + ' (' + index + '/' + total + ')'); itemTitle = agPx + '🔧 ' + callTitle; } else if (eventType === 'tool_result') { diff --git a/web/static/js/monitor.js b/web/static/js/monitor.js index fbea849e..5d121883 100644 --- a/web/static/js/monitor.js +++ b/web/static/js/monitor.js @@ -1592,9 +1592,7 @@ function handleStreamEvent(event, progressElement, progressId, const index = toolInfo.index || 0; const total = toolInfo.total || 0; const toolCallId = toolInfo.toolCallId || null; - const toolCallArgs = parseToolCallArgsFromData(toolInfo); - const toolCallHint = toolCallArgHint(toolCallArgs); - const toolCallTitle = formatToolCallTimelineTitle(toolName, index, total, toolCallHint); + const toolCallTitle = formatToolCallTimelineTitle(toolName, index, total); const toolCallItemId = addTimelineItem(timeline, 'tool_call', { title: timelineAgentBracketPrefix(toolInfo) + '🔧 ' + toolCallTitle, message: event.message, @@ -2531,38 +2529,14 @@ function parseToolCallArgsFromData(data) { return args; } -function toolCallArgHint(args) { - if (!args || typeof args !== 'object') return ''; - const method = args.method != null ? String(args.method).trim().toUpperCase() : ''; - const url = args.url || args.URL || args.target || args.uri; - if (url != null && String(url).trim() !== '') { - let s = String(url).trim(); - if (method) s = method + ' ' + s; - return s.length > 56 ? s.slice(0, 53) + '...' : s; - } - if (method) { - return method; - } - const cmd = args.command || args.cmd || args.script; - if (cmd != null && String(cmd).trim() !== '') { - const s = String(cmd).trim(); - return s.length > 48 ? s.slice(0, 45) + '...' : s; - } - return ''; -} - -function formatToolCallTimelineTitle(toolName, index, total, argsHint) { +function formatToolCallTimelineTitle(toolName, index, total) { const name = toolName || (typeof window.t === 'function' ? window.t('chat.unknownTool') : '未知工具'); const idx = index || 0; const tot = total || 0; - let base; if (typeof window.t === 'function') { - base = window.t('chat.callTool', { name: name, index: idx, total: tot }); - } else { - base = '调用工具: ' + name + (tot ? ' (' + idx + '/' + tot + ')' : ''); + return window.t('chat.callTool', { name: name, index: idx, total: tot }); } - const hint = (argsHint && String(argsHint).trim()) ? String(argsHint).trim() : ''; - return hint ? (base + ' · ' + hint) : base; + return '调用工具: ' + name + (tot ? ' (' + idx + '/' + tot + ')' : ''); } function buildToolResultSectionHtml(data, opts) { @@ -2741,7 +2715,6 @@ window.attachToolResultToCall = attachToolResultToCall; window.mergeToolResultIntoCallItem = mergeToolResultIntoCallItem; window.formatToolCallTimelineTitle = formatToolCallTimelineTitle; window.parseToolCallArgsFromData = parseToolCallArgsFromData; -window.toolCallArgHint = toolCallArgHint; window.buildToolResultSectionHtml = buildToolResultSectionHtml; // 更新工具调用状态 @@ -2810,11 +2783,6 @@ function addTimelineItem(timeline, type, options) { if (d.toolCallId != null && String(d.toolCallId).trim() !== '') { item.dataset.toolCallId = String(d.toolCallId).trim(); } - const callArgs = parseToolCallArgsFromData(d); - const argHint = toolCallArgHint(callArgs); - if (argHint) { - item.dataset.toolArgHint = argHint; - } const merged = options.mergedResult || d._mergedResult; if (merged) { item.dataset.toolResultMerged = '1'; @@ -4320,9 +4288,8 @@ function refreshProgressAndTimelineI18n() { const name = (item.dataset.toolName != null && item.dataset.toolName !== '') ? item.dataset.toolName : _t('chat.unknownTool'); const index = parseInt(item.dataset.toolIndex, 10) || 0; const total = parseInt(item.dataset.toolTotal, 10) || 0; - const hint = item.dataset.toolArgHint || ''; const callTitle = typeof formatToolCallTimelineTitle === 'function' - ? formatToolCallTimelineTitle(name, index, total, hint) + ? formatToolCallTimelineTitle(name, index, total) : _t('chat.callTool', { name: name, index: index, total: total }); titleSpan.textContent = ap + '\uD83D\uDD27 ' + callTitle; } else if (type === 'tool_result' && (item.dataset.toolName !== undefined || item.dataset.toolSuccess !== undefined)) { diff --git a/web/static/js/webshell.js b/web/static/js/webshell.js index 1ea4fdc8..a54ba187 100644 --- a/web/static/js/webshell.js +++ b/web/static/js/webshell.js @@ -1666,11 +1666,8 @@ function buildWebshellTimelineItemFromDetail(detail) { var tn = data.toolName || ((typeof window.t === 'function') ? window.t('chat.unknownTool') : '未知工具'); var idx = data.index || 0; var total = data.total || 0; - var wsHint = typeof window.toolCallArgHint === 'function' - ? window.toolCallArgHint(typeof window.parseToolCallArgsFromData === 'function' ? window.parseToolCallArgsFromData(data) : {}) - : ''; var wsCallTitle = typeof window.formatToolCallTimelineTitle === 'function' - ? window.formatToolCallTimelineTitle(tn, idx, total, wsHint) + ? window.formatToolCallTimelineTitle(tn, idx, total) : ((typeof window.t === 'function') ? window.t('chat.callTool', { name: tn, index: idx, total: total }) : ('调用: ' + tn + (total ? ' (' + idx + '/' + total + ')' : ''))); title = ap + '🔧 ' + wsCallTitle; } else if (eventType === 'tool_result') { @@ -3064,11 +3061,8 @@ function runWebshellAiSend(conn, inputEl, sendBtn, messagesContainer) { var tn = _ed.toolName || '未知工具'; var idx = _ed.index || 0; var total = _ed.total || 0; - var wsHintLive = typeof window.toolCallArgHint === 'function' - ? window.toolCallArgHint(typeof window.parseToolCallArgsFromData === 'function' ? window.parseToolCallArgsFromData(_ed) : {}) - : ''; var callTitle = typeof window.formatToolCallTimelineTitle === 'function' - ? window.formatToolCallTimelineTitle(tn, idx, total, wsHintLive) + ? window.formatToolCallTimelineTitle(tn, idx, total) : (wsTOr('chat.callTool', '') || ('调用工具: ' + tn + (total ? ' (' + idx + '/' + total + ')' : ''))); var callItem = appendTimelineItem('tool_call', webshellAgentPx(_ed) + '🔧 ' + callTitle, _em || '', _ed); if (_ed.toolCallId && callItem) {