From bbd408f326b0223ff613ae108da10b6c99120ad9 Mon Sep 17 00:00:00 2001 From: thzxx Date: Thu, 23 Apr 2026 16:19:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=85=B7=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=98=BE=E7=A4=BA=E3=80=81?= =?UTF-8?q?=E6=B8=85=E7=90=86=E6=AD=BB=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 工具调用失败时显示错误原因(之前只有状态标签没有具体错误) 2. 删除 formatFileSize 死代码(仅在已移除的结果渲染中使用) 3. 清理 updateLastAssistantMessage 未使用的 stats 参数 --- src/renderer/components/chat-area.ts | 20 ++++++++++---------- src/renderer/styles/style.css | 9 +++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/renderer/components/chat-area.ts b/src/renderer/components/chat-area.ts index c4650d3..725d663 100644 --- a/src/renderer/components/chat-area.ts +++ b/src/renderer/components/chat-area.ts @@ -241,6 +241,14 @@ function renderToolCallCard(tc: ToolCallRecord): string { if (args.selector) paramsHtml += `
选择器: ${escapeHtml(String(args.selector))}
`; if (args.action) paramsHtml += `
操作: ${escapeHtml(String(args.action))}
`; + // 失败/取消时显示错误信息(成功结果在工作空间工具页签查看) + let errorHtml = ''; + if (tc.status === 'error' && tc.result?.error) { + errorHtml = `
❌ ${escapeHtml(String(tc.result.error))}
`; + } else if (tc.status === 'cancelled') { + errorHtml = `
🚫 用户取消了操作
`; + } + return `
${icon} @@ -248,19 +256,11 @@ function renderToolCallCard(tc: ToolCallRecord): string { ${status}
${paramsHtml ? `
${paramsHtml}
` : ''} + ${errorHtml}
`; } -function formatFileSize(bytes: number): string { - if (!bytes) return '0 B'; - const units = ['B', 'KB', 'MB', 'GB']; - let i = 0; - let size = bytes; - while (size >= 1024 && i < units.length - 1) { size /= 1024; i++; } - return `${size.toFixed(1)} ${units[i]}`; -} - -export function updateLastAssistantMessage(content: string, think: string | null, stats: { eval_count?: number; total_duration?: number } | null, model?: string): void { +export function updateLastAssistantMessage(content: string, think: string | null, _stats: unknown, model?: string): void { const lastMsg = currentPlaceholder; if (!lastMsg) return; diff --git a/src/renderer/styles/style.css b/src/renderer/styles/style.css index 1779fa9..ca81401 100644 --- a/src/renderer/styles/style.css +++ b/src/renderer/styles/style.css @@ -2062,6 +2062,15 @@ html, body { color: var(--critical); } +.tool-call-error { + padding: 6px 14px; + font-size: 12px; + color: var(--critical); + border-top: 1px solid var(--border-subtle); + background: rgba(220, 53, 69, 0.04); + word-break: break-all; +} + /* ── 聊天区域工具调用历史(可折叠)── */ .tool-calls-history { margin: 8px 0;