From 9d9feb40a3af890ca3065714b915bf184004bbda Mon Sep 17 00:00:00 2001 From: thzxx Date: Mon, 6 Apr 2026 21:30:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=90=8E=E6=89=A7=E8=A1=8C=E5=8D=A1=E6=AD=BB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:用户点击确认执行工具(如删除文件)后,页面一直处于'正在思考'loading状态,工具未被执行。 原因:tool-confirm-modal.ts 中 cleanup() 先将 resolveConfirm 设为 null,导致后续 resolveConfirm?.(true) 无法 resolve Promise,await callbacks.onConfirmTool(call) 永远挂起。 修复:在调用 cleanup() 前先保存 resolveConfirm 引用,cleanup 后再调用保存的引用来 resolve Promise。 --- src/renderer/components/tool-confirm-modal.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/tool-confirm-modal.ts b/src/renderer/components/tool-confirm-modal.ts index c408420..63384ba 100644 --- a/src/renderer/components/tool-confirm-modal.ts +++ b/src/renderer/components/tool-confirm-modal.ts @@ -84,15 +84,17 @@ export function showToolConfirm(call: ToolCall): Promise { const onConfirm = (e: Event) => { e.stopPropagation(); + const r = resolveConfirm; cleanup(); logInfo(`已确认: ${call.function.name}`); - resolveConfirm?.(true); + r?.(true); }; const onCancel = (e: Event) => { e.stopPropagation(); + const r = resolveConfirm; cleanup(); logInfo(`已取消: ${call.function.name}`); - resolveConfirm?.(false); + r?.(false); }; const cleanup = () => { confirmBtn.removeEventListener('click', onConfirm);