fix: 修复"当前有对话正在进行中"错误

问题:当 currentSession.active 为 true 时,条件判断阻止了
dialogManager.createSession() 的调用,导致无法中止旧会话。

修复:移除条件判断,始终通过 dialogManager 创建会话,
让其内部自动处理旧会话的中止。
This commit is contained in:
XiaoFeng
2026-01-12 09:29:53 +08:00
parent bdc55c727a
commit 772b067202

View File

@ -159,13 +159,11 @@ async function handleUserMessageWithBackend(
// 优先使用 reuseTaskId其次使用 historyManager 的 taskId // 优先使用 reuseTaskId其次使用 historyManager 的 taskId
const taskIdToUse = reuseTaskId || historyManager.getCurrentTaskId(); const taskIdToUse = reuseTaskId || historyManager.getCurrentTaskId();
// 创建或复用会话 // 创建会话dialogManager 会自动处理旧会话的中止)
if (!currentSession || !currentSession.active) {
currentSession = dialogManager.createSession(extensionPath, taskIdToUse || undefined); currentSession = dialogManager.createSession(extensionPath, taskIdToUse || undefined);
// 保存 taskId 用于后续操作(如压缩) // 保存 taskId 用于后续操作(如压缩)
lastTaskId = currentSession.getTaskId(); lastTaskId = currentSession.getTaskId();
console.log("[MessageHandler] 创建会话: taskId=", lastTaskId, "来源=", taskIdToUse ? "historyManager" : "新生成"); console.log("[MessageHandler] 创建会话: taskId=", lastTaskId, "来源=", taskIdToUse ? "historyManager" : "新生成");
}
// 显示状态栏 // 显示状态栏
panel.webview.postMessage({ panel.webview.postMessage({