mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
test(vscode-ide-companion): 尝试通过 session/load 旧会话
- 修改了 WebViewProvider 中的逻辑,先尝试通过 ACP 加载旧会话 - 如果加载失败,则创建新会话作为回退方案 - 在 AcpConnection 中添加了初始化响应的日志输出 - 在 QwenAgentManager 中添加了新的 loadSessionViaAcp 方法,用于测试 ACP 的 session/load 功能
This commit is contained in:
@@ -754,11 +754,29 @@ export class WebViewProvider {
|
|||||||
console.log('[WebViewProvider] Could not get session details:', err);
|
console.log('[WebViewProvider] Could not get session details:', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMPORTANT: CLI doesn't support loading old sessions
|
// TESTING: Try to load session via ACP first, fallback to creating new session
|
||||||
// So we always create a NEW ACP session for continuation
|
|
||||||
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
|
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
|
||||||
const workingDir = workspaceFolder?.uri.fsPath || process.cwd();
|
const workingDir = workspaceFolder?.uri.fsPath || process.cwd();
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log('[WebViewProvider] Testing session/load via ACP...');
|
||||||
|
const loadResponse =
|
||||||
|
await this.agentManager.loadSessionViaAcp(sessionId);
|
||||||
|
console.log('[WebViewProvider] session/load succeeded:', loadResponse);
|
||||||
|
|
||||||
|
// If load succeeded, use the loaded session
|
||||||
|
this.currentConversationId = sessionId;
|
||||||
|
console.log(
|
||||||
|
'[WebViewProvider] Set currentConversationId to loaded session:',
|
||||||
|
sessionId,
|
||||||
|
);
|
||||||
|
} catch (_loadError) {
|
||||||
|
console.log(
|
||||||
|
'[WebViewProvider] session/load not supported, creating new session',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Fallback: CLI doesn't support loading old sessions
|
||||||
|
// So we create a NEW ACP session for continuation
|
||||||
try {
|
try {
|
||||||
const newAcpSessionId =
|
const newAcpSessionId =
|
||||||
await this.agentManager.createNewSession(workingDir);
|
await this.agentManager.createNewSession(workingDir);
|
||||||
@@ -783,6 +801,7 @@ export class WebViewProvider {
|
|||||||
);
|
);
|
||||||
throw createError;
|
throw createError;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send messages and session details to WebView
|
// Send messages and session details to WebView
|
||||||
// The historical messages are display-only, not sent to CLI
|
// The historical messages are display-only, not sent to CLI
|
||||||
|
|||||||
@@ -193,11 +193,13 @@ export class AcpConnection {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 初始化协议
|
// 初始化协议
|
||||||
await this.sessionManager.initialize(
|
const res = await this.sessionManager.initialize(
|
||||||
this.child,
|
this.child,
|
||||||
this.pendingRequests,
|
this.pendingRequests,
|
||||||
this.nextRequestId,
|
this.nextRequestId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('[ACP] Initialization response:', res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ export class QwenAgentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会话消息
|
* 获取会话消息(从磁盘读取)
|
||||||
*
|
*
|
||||||
* @param sessionId - 会话ID
|
* @param sessionId - 会话ID
|
||||||
* @returns 消息列表
|
* @returns 消息列表
|
||||||
@@ -159,6 +159,28 @@ export class QwenAgentManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试通过 ACP session/load 方法加载会话
|
||||||
|
* 这是一个测试方法,用于验证 CLI 是否支持 session/load
|
||||||
|
*
|
||||||
|
* @param sessionId - 会话ID
|
||||||
|
* @returns 加载响应或错误
|
||||||
|
*/
|
||||||
|
async loadSessionViaAcp(sessionId: string): Promise<unknown> {
|
||||||
|
try {
|
||||||
|
console.log(
|
||||||
|
'[QwenAgentManager] Testing session/load via ACP for:',
|
||||||
|
sessionId,
|
||||||
|
);
|
||||||
|
const response = await this.connection.loadSession(sessionId);
|
||||||
|
console.log('[QwenAgentManager] Session load response:', response);
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[QwenAgentManager] Session load via ACP failed:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建新会话
|
* 创建新会话
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user