mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
feat(cli): 添加 CLI 版本检测和会话验证功能
- 新增 CLI 版本检测功能,支持检测 CLI 版本并缓存结果 - 实现会话验证方法,用于检查当前会话是否有效 - 在连接处理中集成 CLI 版本检测和会话验证逻辑 - 优化 WebViewProvider 中的初始化流程,支持背景初始化 - 更新消息处理逻辑,增加与 CLI 相关的错误处理
This commit is contained in:
@@ -260,6 +260,32 @@ export class SessionMessageHandler extends BaseMessageHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// // Validate current session before sending message
|
||||
// const isSessionValid = await this.agentManager.validateCurrentSession();
|
||||
// if (!isSessionValid) {
|
||||
// console.warn('[SessionMessageHandler] Current session is not valid');
|
||||
|
||||
// // Show non-modal notification with Login button
|
||||
// const result = await vscode.window.showWarningMessage(
|
||||
// 'Your session has expired. Please login again to continue using Qwen Code.',
|
||||
// 'Login Now',
|
||||
// );
|
||||
|
||||
// if (result === 'Login Now') {
|
||||
// // Use login handler directly
|
||||
// if (this.loginHandler) {
|
||||
// await this.loginHandler();
|
||||
// } else {
|
||||
// // Fallback to command
|
||||
// vscode.window.showInformationMessage(
|
||||
// 'Please wait while we connect to Qwen Code...',
|
||||
// );
|
||||
// await vscode.commands.executeCommand('qwenCode.login');
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Send to agent
|
||||
try {
|
||||
this.resetStreamContent();
|
||||
@@ -327,9 +353,15 @@ export class SessionMessageHandler extends BaseMessageHandler {
|
||||
console.error('[SessionMessageHandler] Error sending message:', error);
|
||||
|
||||
const errorMsg = String(error);
|
||||
if (errorMsg.includes('No active ACP session')) {
|
||||
// Check for session not found error and handle it appropriately
|
||||
if (
|
||||
errorMsg.includes('Session not found') ||
|
||||
errorMsg.includes('No active ACP session')
|
||||
) {
|
||||
// Clear auth cache since session is invalid
|
||||
// Note: We would need access to authStateManager for this, but for now we'll just show login prompt
|
||||
const result = await vscode.window.showWarningMessage(
|
||||
'You need to login first to use Qwen Code.',
|
||||
'Your session has expired. Please login again to continue using Qwen Code.',
|
||||
'Login Now',
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user