From 7ed75415a3a1b1907601e5d6c5dd3ded9e9327c3 Mon Sep 17 00:00:00 2001 From: thzxx Date: Thu, 23 Apr 2026 12:36:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=85=B7=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8D=B3=E6=97=B6?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=B6=88=E6=81=AF=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updateMessageToolRecord 更新 state 后缺少 renderMessages() 调用, 导致消息中的工具卡片状态不会实时更新(始终显示 running)。 添加 renderMessages() 调用,确保工具执行完成后消息中的卡片 立即显示正确状态(✅/❌)。 --- src/renderer/components/input-area.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/input-area.ts b/src/renderer/components/input-area.ts index 00ff423..b881194 100644 --- a/src/renderer/components/input-area.ts +++ b/src/renderer/components/input-area.ts @@ -851,6 +851,7 @@ export async function sendMessage(): Promise { /** 更新当前会话消息中最近一个 'running' 状态的同名工具记录 */ function updateMessageToolRecord(toolName: string, status: 'success' | 'error', result: Record): void { + let updated = false; state.update(KEYS.CURRENT_SESSION, (session: ChatSession | null) => { if (!session) return session; const messages = [...session.messages]; @@ -860,14 +861,17 @@ function updateMessageToolRecord(toolName: string, status: 'success' | 'error', if (!msg.toolCalls) continue; const idx = msg.toolCalls.findIndex(tc => tc.name === toolName && tc.status === 'running'); if (idx !== -1) { - const updated = [...msg.toolCalls]; - updated[idx] = { ...updated[idx], status, result }; - messages[i] = { ...msg, toolCalls: updated }; + const updatedRecords = [...msg.toolCalls]; + updatedRecords[idx] = { ...updatedRecords[idx], status, result }; + messages[i] = { ...msg, toolCalls: updatedRecords }; + updated = true; return { ...session, messages, updatedAt: Date.now() }; } } return session; }); + // 状态更新后重新渲染消息,使工具卡片状态即时生效 + if (updated) renderMessages(); } async function sendMessageWithAgentLoop(text: string, currentSession: ChatSession, model: string): Promise {