mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(vscode-ide-companion): enhance WebViewProvider with force re-login functionality
增强 WebViewProvider 的重新登录功能: - 修复 _lastEditorState 变量声明错误(const -> let) - 在强制重新登录后添加清理等待时间 - 添加登录成功/失败的 WebView 消息通知 - 改进错误处理和日志记录 - 为用户提供更好的登录状态反馈
This commit is contained in:
@@ -201,7 +201,7 @@ export class WebViewProvider {
|
||||
this.panelManager.registerDisposeHandler(this.disposables);
|
||||
|
||||
// Track last known editor state (to preserve when switching to webview)
|
||||
const _lastEditorState: {
|
||||
let _lastEditorState: {
|
||||
fileName: string | null;
|
||||
filePath: string | null;
|
||||
selection: {
|
||||
@@ -233,7 +233,7 @@ export class WebViewProvider {
|
||||
}
|
||||
|
||||
// Update last known state
|
||||
lastEditorState = { fileName, filePath, selection: selectionInfo };
|
||||
_lastEditorState = { fileName, filePath, selection: selectionInfo };
|
||||
|
||||
this.sendMessageToWebView({
|
||||
type: 'activeEditorChanged',
|
||||
@@ -262,7 +262,7 @@ export class WebViewProvider {
|
||||
}
|
||||
|
||||
// Update last known state
|
||||
lastEditorState = { fileName, filePath, selection: selectionInfo };
|
||||
_lastEditorState = { fileName, filePath, selection: selectionInfo };
|
||||
|
||||
this.sendMessageToWebView({
|
||||
type: 'activeEditorChanged',
|
||||
@@ -421,8 +421,30 @@ export class WebViewProvider {
|
||||
this.agentInitialized = false;
|
||||
}
|
||||
|
||||
// Wait a moment for cleanup to complete
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
|
||||
// Reinitialize connection (will trigger fresh authentication)
|
||||
try {
|
||||
await this.initializeAgentConnection();
|
||||
console.log('[WebViewProvider] Force re-login completed successfully');
|
||||
|
||||
// Send success notification to WebView
|
||||
this.sendMessageToWebView({
|
||||
type: 'loginSuccess',
|
||||
data: { message: 'Successfully logged in!' },
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[WebViewProvider] Force re-login failed:', error);
|
||||
|
||||
// Send error notification to WebView
|
||||
this.sendMessageToWebView({
|
||||
type: 'loginError',
|
||||
data: { message: `Login failed: ${error}` },
|
||||
});
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,7 +562,7 @@ export class WebViewProvider {
|
||||
this.panelManager.registerDisposeHandler(this.disposables);
|
||||
|
||||
// Track last known editor state (to preserve when switching to webview)
|
||||
const _lastEditorState: {
|
||||
let _lastEditorState: {
|
||||
fileName: string | null;
|
||||
filePath: string | null;
|
||||
selection: {
|
||||
@@ -572,7 +594,7 @@ export class WebViewProvider {
|
||||
}
|
||||
|
||||
// Update last known state
|
||||
lastEditorState = { fileName, filePath, selection: selectionInfo };
|
||||
_lastEditorState = { fileName, filePath, selection: selectionInfo };
|
||||
|
||||
this.sendMessageToWebView({
|
||||
type: 'activeEditorChanged',
|
||||
|
||||
Reference in New Issue
Block a user