feat: 新增会话压缩命令和上下文显示功能
- ICHelperPanel: 新增 compressConversation 命令处理,支持手动触发会话压缩 - ICHelperPanel: 在加载历史会话时设置 lastTaskId,确保压缩操作可用 - webviewContent: 新增 contextUsage 消息处理,更新上下文使用量显示 - userInteraction: 将用户回答超时时间从 5 分钟延长至 2 小时
This commit is contained in:
@ -12,7 +12,9 @@ import {
|
|||||||
handlePlanAction,
|
handlePlanAction,
|
||||||
setPendingPlanExecution,
|
setPendingPlanExecution,
|
||||||
getCurrentTaskId,
|
getCurrentTaskId,
|
||||||
|
setLastTaskId,
|
||||||
} from "../utils/messageHandler";
|
} from "../utils/messageHandler";
|
||||||
|
import { compactDialog } from "../services/apiClient";
|
||||||
import { VCDViewerPanel } from "./VCDViewerPanel";
|
import { VCDViewerPanel } from "./VCDViewerPanel";
|
||||||
import { ChatHistoryManager } from "../utils/chatHistoryManager";
|
import { ChatHistoryManager } from "../utils/chatHistoryManager";
|
||||||
import { MessageType } from "../types/chatHistory";
|
import { MessageType } from "../types/chatHistory";
|
||||||
@ -195,6 +197,39 @@ export async function showICHelperPanel(
|
|||||||
case "abortDialog":
|
case "abortDialog":
|
||||||
void abortCurrentDialog();
|
void abortCurrentDialog();
|
||||||
break;
|
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 发送)
|
// 处理计划操作(只做模式切换,响应已通过 submitAnswer 发送)
|
||||||
case "planAction":
|
case "planAction":
|
||||||
if (message.action === "confirm") {
|
if (message.action === "confirm") {
|
||||||
@ -528,6 +563,9 @@ async function selectConversation(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置 lastTaskId,用于压缩等操作
|
||||||
|
setLastTaskId(taskId);
|
||||||
|
|
||||||
// 更新面板的任务映射,确保后续对话保存到正确的任务中
|
// 更新面板的任务映射,确保后续对话保存到正确的任务中
|
||||||
const panelId = (panel as any).__uniqueId;
|
const panelId = (panel as any).__uniqueId;
|
||||||
historyManager.setPanelTask(panelId, taskId, workspacePath);
|
historyManager.setPanelTask(panelId, taskId, workspacePath);
|
||||||
|
|||||||
@ -67,13 +67,13 @@ export class UserInteractionManager {
|
|||||||
reject
|
reject
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置超时(5分钟)
|
// 设置超时(2小时)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.pendingQuestions.has(askId)) {
|
if (this.pendingQuestions.has(askId)) {
|
||||||
this.pendingQuestions.delete(askId);
|
this.pendingQuestions.delete(askId);
|
||||||
reject(new Error('用户回答超时'));
|
reject(new Error('用户回答超时'));
|
||||||
}
|
}
|
||||||
}, 300000);
|
}, 7200000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -571,6 +571,13 @@ export function getWebviewContent(iconUri?: string): string {
|
|||||||
currentSegmentedMessage = null;
|
currentSegmentedMessage = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'contextUsage':
|
||||||
|
// 更新上下文使用量显示
|
||||||
|
if (typeof updateContextDisplay === 'function') {
|
||||||
|
updateContextDisplay(message.currentTokens, message.maxTokens);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'hideLoading':
|
case 'hideLoading':
|
||||||
// 隐藏加载指示器
|
// 隐藏加载指示器
|
||||||
hideLoadingIndicator();
|
hideLoadingIndicator();
|
||||||
|
|||||||
Reference in New Issue
Block a user