wip(vscode-ide-companion): OnboardingPage

This commit is contained in:
yiliang114
2025-12-13 16:28:58 +08:00
parent 5841370b1a
commit bca288e742
12 changed files with 235 additions and 138 deletions

View File

@@ -17,6 +17,19 @@ import { getFileName } from './utils/webviewUtils.js';
import { type ApprovalModeValue } from '../types/acpTypes.js';
import { isAuthenticationRequiredError } from '../utils/authErrors.js';
/**
* WebView Provider Class
*
* Manages the WebView panel lifecycle, agent connection, and message handling.
* Acts as the central coordinator between VS Code extension and WebView UI.
*
* Key responsibilities:
* - WebView panel creation and management
* - Qwen agent connection and session management
* - Message routing between extension and WebView
* - Authentication state handling
* - Permission request processing
*/
export class WebViewProvider {
private panelManager: PanelManager;
private messageHandler: MessageHandler;
@@ -122,7 +135,6 @@ export class WebViewProvider {
// Setup end-turn handler from ACP stopReason notifications
this.agentManager.onEndTurn((reason) => {
console.log(' ============== ', reason);
// Ensure WebView exits streaming state even if no explicit streamEnd was emitted elsewhere
this.sendMessageToWebView({
type: 'streamEnd',
@@ -521,6 +533,12 @@ export class WebViewProvider {
/**
* Attempt to restore authentication state and initialize connection
* This is called when the webview is first shown
*
* This method tries to establish a connection without forcing authentication,
* allowing detection of existing authentication state. If connection fails,
* initializes an empty conversation to allow browsing history.
*
* @returns Promise<void> - Resolves when auth state restoration attempt is complete
*/
private async attemptAuthStateRestoration(): Promise<void> {
try {
@@ -550,6 +568,16 @@ export class WebViewProvider {
/**
* Internal: perform actual connection/initialization (no auth locking).
*
* This method handles the complete agent connection and initialization workflow:
* 1. Detects if Qwen CLI is installed
* 2. If CLI is not installed, prompts user for installation
* 3. If CLI is installed, attempts to connect to the agent
* 4. Handles authentication requirements and session creation
* 5. Notifies WebView of connection status
*
* @param options - Connection options including auto-authentication setting
* @returns Promise<void> - Resolves when initialization is complete
*/
private async doInitializeAgentConnection(options?: {
autoAuthenticate?: boolean;