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:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user