fix: 发送消息后清空上下文文件列表
修复了发送消息后上下文文件仍然显示在输入框中的问题。 - 在 sendMessage() 函数中添加 clearContextItems() 调用 - 调整脚本加载顺序,确保 contextDisplay 在 contextButton 之前初始化
This commit is contained in:
@ -46,7 +46,8 @@ export async function handleUserMessage(
|
|||||||
text: string,
|
text: string,
|
||||||
extensionPath?: string,
|
extensionPath?: string,
|
||||||
mode?: RunMode,
|
mode?: RunMode,
|
||||||
serviceTier?: ServiceTier // 新增:服务等级参数
|
serviceTier?: ServiceTier, // 服务等级参数
|
||||||
|
contextItems?: Array<{ id: number; type: string; path: string }> // 上下文项参数
|
||||||
) {
|
) {
|
||||||
console.log("收到用户消息:", text);
|
console.log("收到用户消息:", text);
|
||||||
|
|
||||||
@ -199,7 +200,8 @@ export async function handleUserMessage(
|
|||||||
extensionPath,
|
extensionPath,
|
||||||
mode,
|
mode,
|
||||||
undefined,
|
undefined,
|
||||||
serviceTier
|
serviceTier,
|
||||||
|
contextItems
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -236,10 +238,19 @@ async function handleUserMessageWithBackend(
|
|||||||
extensionPath: string,
|
extensionPath: string,
|
||||||
mode?: RunMode,
|
mode?: RunMode,
|
||||||
reuseTaskId?: string, // 可选,复用现有 taskId(用于 Plan 模式确认后继续执行)
|
reuseTaskId?: string, // 可选,复用现有 taskId(用于 Plan 模式确认后继续执行)
|
||||||
serviceTier?: ServiceTier // 新增:服务等级参数
|
serviceTier?: ServiceTier, // 服务等级参数
|
||||||
|
contextItems?: Array<{ id: number; type: string; path: string }> // 上下文项参数
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const historyManager = ChatHistoryManager.getInstance();
|
const historyManager = ChatHistoryManager.getInstance();
|
||||||
|
|
||||||
|
// 处理上下文项:在消息前附加文件/文件夹路径
|
||||||
|
let enhancedText = text;
|
||||||
|
if (contextItems && contextItems.length > 0) {
|
||||||
|
console.log("[MessageHandler] 处理上下文项:", contextItems.length);
|
||||||
|
const paths = contextItems.map(item => item.path).join('\n');
|
||||||
|
enhancedText = `${paths}\n\n${text}`;
|
||||||
|
}
|
||||||
|
|
||||||
// 获取 historyManager 中的 taskId(由 ICHelperPanel 创建)
|
// 获取 historyManager 中的 taskId(由 ICHelperPanel 创建)
|
||||||
// 优先使用 reuseTaskId,其次使用 historyManager 的 taskId
|
// 优先使用 reuseTaskId,其次使用 historyManager 的 taskId
|
||||||
const taskIdToUse = reuseTaskId || historyManager.getCurrentTaskId();
|
const taskIdToUse = reuseTaskId || historyManager.getCurrentTaskId();
|
||||||
@ -267,7 +278,7 @@ async function handleUserMessageWithBackend(
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
currentSession!.sendMessage(
|
currentSession!.sendMessage(
|
||||||
text,
|
enhancedText,
|
||||||
{
|
{
|
||||||
onText: (fullText, isStreaming) => {
|
onText: (fullText, isStreaming) => {
|
||||||
// 不再单独处理文本,统一通过 onSegmentUpdate 处理
|
// 不再单独处理文本,统一通过 onSegmentUpdate 处理
|
||||||
|
|||||||
@ -296,8 +296,8 @@ export function getInputAreaScript(): string {
|
|||||||
return `
|
return `
|
||||||
// 注意:getModeSelectorScript() 已在 webviewContent.ts 开头加载,这里不再重复加载
|
// 注意:getModeSelectorScript() 已在 webviewContent.ts 开头加载,这里不再重复加载
|
||||||
${getModelSelectorScript()}
|
${getModelSelectorScript()}
|
||||||
${getContextButtonScript()}
|
|
||||||
${getContextDisplayScript()}
|
${getContextDisplayScript()}
|
||||||
|
${getContextButtonScript()}
|
||||||
${getContextCompressScript()}
|
${getContextCompressScript()}
|
||||||
${getOptimizeButtonScript()}
|
${getOptimizeButtonScript()}
|
||||||
|
|
||||||
@ -438,6 +438,11 @@ export function getInputAreaScript(): string {
|
|||||||
autoResizeTextarea(); // 重置输入框高度
|
autoResizeTextarea(); // 重置输入框高度
|
||||||
messageInput.focus();
|
messageInput.focus();
|
||||||
|
|
||||||
|
// 清空上下文项
|
||||||
|
if (window.clearContextItems) {
|
||||||
|
window.clearContextItems();
|
||||||
|
}
|
||||||
|
|
||||||
// 重置优化状态
|
// 重置优化状态
|
||||||
resetOptimizeButton();
|
resetOptimizeButton();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,16 +26,16 @@ export function getUserInfoComponentContent(): string {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 升级到Pro按钮 (仅BASIC会员显示) -->
|
<!-- 升级到Pro按钮 (仅BASIC会员显示) -->
|
||||||
<div class="upgrade-pro-wrapper" id="upgradeProWrapper" style="display: none;">
|
<!-- <div class="upgrade-pro-wrapper" id="upgradeProWrapper" style="display: none;">
|
||||||
<button class="upgrade-pro-btn" id="upgradeProBtn">升级到 Pro</button>
|
<button class="upgrade-pro-btn" id="upgradeProBtn">升级到 Pro</button>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="user-detail-body">
|
<div class="user-detail-body">
|
||||||
<div class="user-detail-item">
|
<!-- <div class="user-detail-item">
|
||||||
<span class="detail-label">剩余 Credits</span>
|
<span class="detail-label">剩余 Credits</span>
|
||||||
<span class="detail-value" id="creditsDetail">-</span>
|
<span class="detail-value" id="creditsDetail">-</span>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="user-detail-item logout-item" id="logoutItem">
|
<div class="user-detail-item logout-item" id="logoutItem">
|
||||||
<span class="detail-label">账户管理</span>
|
<span class="detail-label">账户管理</span>
|
||||||
<span class="detail-value logout-link">退出登录</span>
|
<span class="detail-value logout-link">退出登录</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user