mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
feat(cli): 添加 CLI 版本检测和会话验证功能
- 新增 CLI 版本检测功能,支持检测 CLI 版本并缓存结果 - 实现会话验证方法,用于检查当前会话是否有效 - 在连接处理中集成 CLI 版本检测和会话验证逻辑 - 优化 WebViewProvider 中的初始化流程,支持背景初始化 - 更新消息处理逻辑,增加与 CLI 相关的错误处理
This commit is contained in:
@@ -99,7 +99,40 @@ export class QwenAgentManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session list
|
||||
* Validate if current session is still active
|
||||
* This is a lightweight check to verify session validity
|
||||
*
|
||||
* @returns True if session is valid, false otherwise
|
||||
*/
|
||||
async validateCurrentSession(): Promise<boolean> {
|
||||
try {
|
||||
// If we don't have a current session, it's definitely not valid
|
||||
if (!this.connection.currentSessionId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to get session list to verify our session still exists
|
||||
const sessions = await this.getSessionList();
|
||||
const currentSessionId = this.connection.currentSessionId;
|
||||
|
||||
// Check if our current session exists in the session list
|
||||
const sessionExists = sessions.some(
|
||||
(session: Record<string, unknown>) =>
|
||||
session.id === currentSessionId ||
|
||||
session.sessionId === currentSessionId,
|
||||
);
|
||||
|
||||
return sessionExists;
|
||||
} catch (error) {
|
||||
console.warn('[QwenAgentManager] Session validation failed:', error);
|
||||
// If we can't validate, assume session is invalid
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session list with version-aware strategy
|
||||
* First tries ACP method if CLI version supports it, falls back to file system method
|
||||
*
|
||||
* @returns Session list
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user