diff --git a/src/panels/ICHelperPanel.ts b/src/panels/ICHelperPanel.ts index daeeaef..df0a0b0 100644 --- a/src/panels/ICHelperPanel.ts +++ b/src/panels/ICHelperPanel.ts @@ -12,7 +12,9 @@ import { handlePlanAction, setPendingPlanExecution, getCurrentTaskId, + setLastTaskId, } from "../utils/messageHandler"; +import { compactDialog } from "../services/apiClient"; import { VCDViewerPanel } from "./VCDViewerPanel"; import { ChatHistoryManager } from "../utils/chatHistoryManager"; import { MessageType } from "../types/chatHistory"; @@ -195,6 +197,39 @@ export async function showICHelperPanel( case "abortDialog": void abortCurrentDialog(); break; + // 新增:压缩会话 + case "compressConversation": + { + const taskId = getCurrentTaskId(); + if (taskId) { + compactDialog(taskId) + .then((result) => { + if (result.success) { + panel.webview.postMessage({ + command: "receiveMessage", + text: "✅ 会话压缩完成", + }); + } else { + panel.webview.postMessage({ + command: "receiveMessage", + text: `❌ 压缩失败: ${result.error || "未知错误"}`, + }); + } + }) + .catch((err) => { + panel.webview.postMessage({ + command: "receiveMessage", + text: `❌ 压缩失败: ${err.message || "网络错误"}`, + }); + }); + } else { + panel.webview.postMessage({ + command: "receiveMessage", + text: "❌ 没有活跃的会话", + }); + } + } + break; // 处理计划操作(只做模式切换,响应已通过 submitAnswer 发送) case "planAction": if (message.action === "confirm") { @@ -528,6 +563,9 @@ async function selectConversation( return; } + // 设置 lastTaskId,用于压缩等操作 + setLastTaskId(taskId); + // 更新面板的任务映射,确保后续对话保存到正确的任务中 const panelId = (panel as any).__uniqueId; historyManager.setPanelTask(panelId, taskId, workspacePath); diff --git a/src/services/userInteraction.ts b/src/services/userInteraction.ts index e14d192..a5fea5a 100644 --- a/src/services/userInteraction.ts +++ b/src/services/userInteraction.ts @@ -67,13 +67,13 @@ export class UserInteractionManager { reject }); - // 设置超时(5分钟) + // 设置超时(2小时) setTimeout(() => { if (this.pendingQuestions.has(askId)) { this.pendingQuestions.delete(askId); reject(new Error('用户回答超时')); } - }, 300000); + }, 7200000); }); } diff --git a/src/views/webviewContent.ts b/src/views/webviewContent.ts index 25bc90f..a75ae93 100644 --- a/src/views/webviewContent.ts +++ b/src/views/webviewContent.ts @@ -571,6 +571,13 @@ export function getWebviewContent(iconUri?: string): string { currentSegmentedMessage = null; break; + case 'contextUsage': + // 更新上下文使用量显示 + if (typeof updateContextDisplay === 'function') { + updateContextDisplay(message.currentTokens, message.maxTokens); + } + break; + case 'hideLoading': // 隐藏加载指示器 hideLoadingIndicator();