fix: 修复工具确认后执行卡死问题

问题:用户点击确认执行工具(如删除文件)后,页面一直处于'正在思考'loading状态,工具未被执行。
原因:tool-confirm-modal.ts 中 cleanup() 先将 resolveConfirm 设为 null,导致后续 resolveConfirm?.(true) 无法 resolve Promise,await callbacks.onConfirmTool(call) 永远挂起。
修复:在调用 cleanup() 前先保存 resolveConfirm 引用,cleanup 后再调用保存的引用来 resolve Promise。
This commit is contained in:
thzxx
2026-04-06 21:30:00 +08:00
parent 6d17817ce4
commit 9d9feb40a3
@@ -84,15 +84,17 @@ export function showToolConfirm(call: ToolCall): Promise<boolean> {
const onConfirm = (e: Event) => { const onConfirm = (e: Event) => {
e.stopPropagation(); e.stopPropagation();
const r = resolveConfirm;
cleanup(); cleanup();
logInfo(`已确认: ${call.function.name}`); logInfo(`已确认: ${call.function.name}`);
resolveConfirm?.(true); r?.(true);
}; };
const onCancel = (e: Event) => { const onCancel = (e: Event) => {
e.stopPropagation(); e.stopPropagation();
const r = resolveConfirm;
cleanup(); cleanup();
logInfo(`已取消: ${call.function.name}`); logInfo(`已取消: ${call.function.name}`);
resolveConfirm?.(false); r?.(false);
}; };
const cleanup = () => { const cleanup = () => {
confirmBtn.removeEventListener('click', onConfirm); confirmBtn.removeEventListener('click', onConfirm);