refactor(vscode-ide-companion): translate Chinese comments to English

- Translate all Chinese comments in TypeScript files to English for better code readability
- Update documentation comments to be in English
- Maintain code functionality while improving internationalization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
yiliang114
2025-11-25 23:41:24 +08:00
parent d5ede56e62
commit 3c09ad46ca
15 changed files with 216 additions and 214 deletions

View File

@@ -52,11 +52,11 @@ export class AcpConnection {
private nextRequestId = { value: 0 };
private backend: AcpBackend | null = null;
// 模块实例
// Module instances
private messageHandler: AcpMessageHandler;
private sessionManager: AcpSessionManager;
// 回调函数
// Callback functions
onSessionUpdate: (data: AcpSessionUpdate) => void = () => {};
onPermissionRequest: (data: AcpPermissionRequest) => Promise<{
optionId: string;
@@ -200,7 +200,7 @@ export class AcpConnection {
}
});
// 初始化协议
// Initialize protocol
const res = await this.sessionManager.initialize(
this.child,
this.pendingRequests,
@@ -249,7 +249,7 @@ export class AcpConnection {
}
});
} else {
// 响应
// Response
this.messageHandler.handleMessage(
message,
this.pendingRequests,

View File

@@ -5,29 +5,29 @@
*/
/**
* ACP文件操作处理器
* ACP File Operation Handler
*
* 负责处理ACP协议中的文件读写操作
* Responsible for handling file read and write operations in the ACP protocol
*/
import { promises as fs } from 'fs';
import * as path from 'path';
/**
* ACP文件操作处理器类
* 提供文件读写功能符合ACP协议规范
* ACP File Operation Handler Class
* Provides file read and write functionality according to ACP protocol specifications
*/
export class AcpFileHandler {
/**
* 处理读取文本文件请求
* Handle read text file request
*
* @param params - 文件读取参数
* @param params.path - 文件路径
* @param params.sessionId - 会话ID
* @param params.line - 起始行号(可选)
* @param params.limit - 读取行数限制(可选)
* @returns 文件内容
* @throws 当文件读取失败时抛出错误
* @param params - File read parameters
* @param params.path - File path
* @param params.sessionId - Session ID
* @param params.line - Starting line number (optional)
* @param params.limit - Read line limit (optional)
* @returns File content
* @throws Error when file reading fails
*/
async handleReadTextFile(params: {
path: string;
@@ -48,7 +48,7 @@ export class AcpFileHandler {
`[ACP] Successfully read file: ${params.path} (${content.length} bytes)`,
);
// 处理行偏移和限制
// Handle line offset and limit
if (params.line !== null || params.limit !== null) {
const lines = content.split('\n');
const startLine = params.line || 0;
@@ -71,14 +71,14 @@ export class AcpFileHandler {
}
/**
* 处理写入文本文件请求
* Handle write text file request
*
* @param params - 文件写入参数
* @param params.path - 文件路径
* @param params.content - 文件内容
* @param params.sessionId - 会话ID
* @returns null表示成功
* @throws 当文件写入失败时抛出错误
* @param params - File write parameters
* @param params.path - File path
* @param params.content - File content
* @param params.sessionId - Session ID
* @returns null indicates success
* @throws Error when file writing fails
*/
async handleWriteTextFile(params: {
path: string;
@@ -91,12 +91,12 @@ export class AcpFileHandler {
console.log(`[ACP] Content size: ${params.content.length} bytes`);
try {
// 确保目录存在
// Ensure directory exists
const dirName = path.dirname(params.path);
console.log(`[ACP] Ensuring directory exists: ${dirName}`);
await fs.mkdir(dirName, { recursive: true });
// 写入文件
// Write file
await fs.writeFile(params.path, params.content, 'utf-8');
console.log(`[ACP] Successfully wrote file: ${params.path}`);

View File

@@ -5,9 +5,9 @@
*/
/**
* ACP消息处理器
* ACP Message Handler
*
* 负责处理ACP协议中的消息接收、解析和分发
* Responsible for receiving, parsing, and distributing messages in the ACP protocol
*/
import type {
@@ -27,8 +27,8 @@ import { AcpFileHandler } from './acpFileHandler.js';
import type { ChildProcess } from 'child_process';
/**
* ACP消息处理器类
* 负责消息的接收、解析和处理
* ACP Message Handler Class
* Responsible for receiving, parsing, and processing messages
*/
export class AcpMessageHandler {
private fileHandler: AcpFileHandler;
@@ -38,10 +38,10 @@ export class AcpMessageHandler {
}
/**
* 发送响应消息到子进程
* Send response message to child process
*
* @param child - 子进程实例
* @param response - 响应消息
* @param child - Child process instance
* @param response - Response message
*/
sendResponseMessage(child: ChildProcess | null, response: AcpResponse): void {
if (child?.stdin) {
@@ -52,11 +52,11 @@ export class AcpMessageHandler {
}
/**
* 处理接收到的消息
* Handle received messages
*
* @param message - ACP消息
* @param pendingRequests - 待处理请求映射表
* @param callbacks - 回调函数集合
* @param message - ACP message
* @param pendingRequests - Pending requests map
* @param callbacks - Callback functions collection
*/
handleMessage(
message: AcpMessage,
@@ -65,14 +65,14 @@ export class AcpMessageHandler {
): void {
try {
if ('method' in message) {
// 请求或通知
// Request or notification
this.handleIncomingRequest(message, callbacks).catch(() => {});
} else if (
'id' in message &&
typeof message.id === 'number' &&
pendingRequests.has(message.id)
) {
// 响应
// Response
this.handleResponse(message, pendingRequests, callbacks);
}
} catch (error) {
@@ -81,11 +81,11 @@ export class AcpMessageHandler {
}
/**
* 处理响应消息
* Handle response message
*
* @param message - 响应消息
* @param pendingRequests - 待处理请求映射表
* @param callbacks - 回调函数集合
* @param message - Response message
* @param pendingRequests - Pending requests map
* @param callbacks - Callback functions collection
*/
private handleResponse(
message: AcpMessage,
@@ -138,11 +138,11 @@ export class AcpMessageHandler {
}
/**
* 处理进入的请求
* Handle incoming requests
*
* @param message - 请求或通知消息
* @param callbacks - 回调函数集合
* @returns 请求处理结果
* @param message - Request or notification message
* @param callbacks - Callback functions collection
* @returns Request processing result
*/
async handleIncomingRequest(
message: AcpRequest | AcpNotification,
@@ -190,11 +190,11 @@ export class AcpMessageHandler {
}
/**
* 处理权限请求
* Handle permission requests
*
* @param params - 权限请求参数
* @param callbacks - 回调函数集合
* @returns 权限请求结果
* @param params - Permission request parameters
* @param callbacks - Callback functions collection
* @returns Permission request result
*/
private async handlePermissionRequest(
params: AcpPermissionRequest,
@@ -206,7 +206,7 @@ export class AcpMessageHandler {
const response = await callbacks.onPermissionRequest(params);
const optionId = response.optionId;
// 处理取消、拒绝或允许
// Handle cancel, deny, or allow
let outcome: string;
if (optionId.includes('reject') || optionId === 'cancel') {
outcome = 'rejected';

View File

@@ -5,9 +5,9 @@
*/
/**
* ACP会话管理器
* ACP Session Manager
*
* 负责管理ACP协议的会话操作包括初始化、认证、会话创建和切换等
* Responsible for managing ACP protocol session operations, including initialization, authentication, session creation, and switching
*/
import { JSONRPC_VERSION } from '../shared/acpTypes.js';
@@ -21,22 +21,22 @@ import type { PendingRequest } from './connectionTypes.js';
import type { ChildProcess } from 'child_process';
/**
* ACP会话管理器类
* 提供会话的初始化、认证、创建、加载和切换功能
* ACP Session Manager Class
* Provides session initialization, authentication, creation, loading, and switching functionality
*/
export class AcpSessionManager {
private sessionId: string | null = null;
private isInitialized = false;
/**
* 发送请求到ACP服务器
* Send request to ACP server
*
* @param method - 请求方法名
* @param params - 请求参数
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 请求响应
* @param method - Request method name
* @param params - Request parameters
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Request response
*/
private sendRequest<T = unknown>(
method: string,
@@ -81,10 +81,10 @@ export class AcpSessionManager {
}
/**
* 发送消息到子进程
* Send message to child process
*
* @param message - 请求或通知消息
* @param child - 子进程实例
* @param message - Request or notification message
* @param child - Child process instance
*/
private sendMessage(
message: AcpRequest | AcpNotification,
@@ -98,12 +98,12 @@ export class AcpSessionManager {
}
/**
* 初始化ACP协议连接
* Initialize ACP protocol connection
*
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 初始化响应
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Initialization response
*/
async initialize(
child: ChildProcess | null,
@@ -135,13 +135,13 @@ export class AcpSessionManager {
}
/**
* 进行认证
* Perform authentication
*
* @param methodId - 认证方法ID
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 认证响应
* @param methodId - Authentication method ID
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Authentication response
*/
async authenticate(
methodId: string | undefined,
@@ -168,13 +168,13 @@ export class AcpSessionManager {
}
/**
* 创建新会话
* Create new session
*
* @param cwd - 工作目录
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 新会话响应
* @param cwd - Working directory
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns New session response
*/
async newSession(
cwd: string,
@@ -202,14 +202,14 @@ export class AcpSessionManager {
}
/**
* 发送提示消息
* Send prompt message
*
* @param prompt - 提示内容
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 响应
* @throws 当没有活动会话时抛出错误
* @param prompt - Prompt content
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Response
* @throws Error when there is no active session
*/
async sendPrompt(
prompt: string,
@@ -234,13 +234,13 @@ export class AcpSessionManager {
}
/**
* 加载已有会话
* Load existing session
*
* @param sessionId - 会话ID
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 加载响应
* @param sessionId - Session ID
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Load response
*/
async loadSession(
sessionId: string,
@@ -291,12 +291,12 @@ export class AcpSessionManager {
}
/**
* 获取会话列表
* Get session list
*
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 会话列表响应
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Session list response
*/
async listSessions(
child: ChildProcess | null,
@@ -324,11 +324,11 @@ export class AcpSessionManager {
}
/**
* 切换到指定会话
* Switch to specified session
*
* @param sessionId - 会话ID
* @param nextRequestId - 请求ID计数器
* @returns 切换响应
* @param sessionId - Session ID
* @param nextRequestId - Request ID counter
* @returns Switch response
*/
async switchSession(
sessionId: string,
@@ -349,9 +349,9 @@ export class AcpSessionManager {
}
/**
* 取消当前会话的提示生成
* Cancel prompt generation for current session
*
* @param child - 子进程实例
* @param child - Child process instance
*/
async cancelSession(child: ChildProcess | null): Promise<void> {
if (!this.sessionId) {
@@ -376,13 +376,13 @@ export class AcpSessionManager {
}
/**
* 保存当前会话
* Save current session
*
* @param tag - 保存标签
* @param child - 子进程实例
* @param pendingRequests - 待处理请求映射表
* @param nextRequestId - 请求ID计数器
* @returns 保存响应
* @param tag - Save tag
* @param child - Child process instance
* @param pendingRequests - Pending requests map
* @param nextRequestId - Request ID counter
* @returns Save response
*/
async saveSession(
tag: string,
@@ -410,7 +410,7 @@ export class AcpSessionManager {
}
/**
* 重置会话管理器状态
* Reset session manager state
*/
reset(): void {
this.sessionId = null;
@@ -418,14 +418,14 @@ export class AcpSessionManager {
}
/**
* 获取当前会话ID
* Get current session ID
*/
getCurrentSessionId(): string | null {
return this.sessionId;
}
/**
* 检查是否已初始化
* Check if initialized
*/
getIsInitialized(): boolean {
return this.isInitialized;

View File

@@ -5,9 +5,9 @@
*/
/**
* ACP连接类型定义
* ACP Connection Type Definitions
*
* 包含了ACP连接所需的所有类型和接口定义
* Contains all types and interface definitions required for ACP connection
*/
import type { ChildProcess } from 'child_process';
@@ -17,47 +17,47 @@ import type {
} from '../shared/acpTypes.js';
/**
* 待处理的请求信息
* Pending Request Information
*/
export interface PendingRequest<T = unknown> {
/** 成功回调 */
/** Success callback */
resolve: (value: T) => void;
/** 失败回调 */
/** Failure callback */
reject: (error: Error) => void;
/** 超时定时器ID */
/** Timeout timer ID */
timeoutId?: NodeJS.Timeout;
/** 请求方法名 */
/** Request method name */
method: string;
}
/**
* ACP连接回调函数类型
* ACP Connection Callback Function Types
*/
export interface AcpConnectionCallbacks {
/** 会话更新回调 */
/** Session update callback */
onSessionUpdate: (data: AcpSessionUpdate) => void;
/** 权限请求回调 */
/** Permission request callback */
onPermissionRequest: (data: AcpPermissionRequest) => Promise<{
optionId: string;
}>;
/** 回合结束回调 */
/** Turn end callback */
onEndTurn: () => void;
}
/**
* ACP连接状态
* ACP Connection State
*/
export interface AcpConnectionState {
/** 子进程实例 */
/** Child process instance */
child: ChildProcess | null;
/** 待处理的请求映射表 */
/** Pending requests map */
pendingRequests: Map<number, PendingRequest<unknown>>;
/** 下一个请求ID */
/** Next request ID */
nextRequestId: number;
/** 当前会话ID */
/** Current session ID */
sessionId: string | null;
/** 是否已初始化 */
/** Whether initialized */
isInitialized: boolean;
/** 后端类型 */
/** Backend type */
backend: string | null;
}

View File

@@ -73,7 +73,8 @@ export class QwenAgentManager {
* Connect to Qwen service
*
* @param workingDir - Working directory
* @param authStateManager - Auth state manager (optional)
* @param authStateManager - Authentication state manager (optional)
* @param cliPath - CLI path (optional, if provided will override the path in configuration)
*/
async connect(
workingDir: string,

View File

@@ -26,7 +26,8 @@ export class QwenConnectionHandler {
* @param connection - ACP connection instance
* @param sessionReader - Session reader instance
* @param workingDir - Working directory
* @param authStateManager - Auth state manager (optional)
* @param authStateManager - Authentication state manager (optional)
* @param cliPath - CLI path (optional, if provided will override the path in configuration)
*/
async connect(
connection: AcpConnection,
@@ -100,7 +101,7 @@ export class QwenConnectionHandler {
'[QwenAgentManager] Found existing sessions:',
sessions.length,
);
const lastSession = sessions[0]; // 已按lastUpdated排序
const lastSession = sessions[0]; // Already sorted by lastUpdated
try {
await connection.switchSession(lastSession.sessionId);

View File

@@ -5,71 +5,71 @@
*/
/**
* Qwen Agent Manager 类型定义
* Qwen Agent Manager Type Definitions
*
* 包含所有相关的接口和类型定义
* Contains all related interfaces and type definitions
*/
import type { AcpPermissionRequest } from '../shared/acpTypes.js';
/**
* 聊天消息
* Chat Message
*/
export interface ChatMessage {
/** 消息角色:用户或助手 */
/** Message role: user or assistant */
role: 'user' | 'assistant';
/** 消息内容 */
/** Message content */
content: string;
/** 时间戳 */
/** Timestamp */
timestamp: number;
}
/**
* 计划条目
* Plan Entry
*/
export interface PlanEntry {
/** 条目内容 */
/** Entry content */
content: string;
/** 优先级 */
/** Priority */
priority: 'high' | 'medium' | 'low';
/** 状态 */
/** Status */
status: 'pending' | 'in_progress' | 'completed';
}
/**
* 工具调用更新数据
* Tool Call Update Data
*/
export interface ToolCallUpdateData {
/** 工具调用ID */
/** Tool call ID */
toolCallId: string;
/** 工具类型 */
/** Tool type */
kind?: string;
/** 工具标题 */
/** Tool title */
title?: string;
/** 状态 */
/** Status */
status?: string;
/** 原始输入 */
/** Raw input */
rawInput?: unknown;
/** 内容 */
/** Content */
content?: Array<Record<string, unknown>>;
/** 位置信息 */
/** Location information */
locations?: Array<{ path: string; line?: number | null }>;
}
/**
* 回调函数集合
* Callback Functions Collection
*/
export interface QwenAgentCallbacks {
/** 消息回调 */
/** Message callback */
onMessage?: (message: ChatMessage) => void;
/** 流式文本块回调 */
/** Stream text chunk callback */
onStreamChunk?: (chunk: string) => void;
/** 思考文本块回调 */
/** Thought text chunk callback */
onThoughtChunk?: (chunk: string) => void;
/** 工具调用回调 */
/** Tool call callback */
onToolCall?: (update: ToolCallUpdateData) => void;
/** 计划回调 */
/** Plan callback */
onPlan?: (entries: PlanEntry[]) => void;
/** 权限请求回调 */
/** Permission request callback */
onPermissionRequest?: (request: AcpPermissionRequest) => Promise<string>;
}

View File

@@ -8,13 +8,13 @@ import * as vscode from 'vscode';
import { CliDetector } from './cliDetector.js';
/**
* CLI 检测和安装处理器
* 负责 Qwen CLI 的检测、安装和提示功能
* CLI Detection and Installation Handler
* Responsible for detecting, installing, and prompting for Qwen CLI
*/
export class CliInstaller {
/**
* 检查 CLI 安装状态并发送结果到 WebView
* @param sendToWebView 发送消息到 WebView 的回调函数
* Check CLI installation status and send results to WebView
* @param sendToWebView Callback function to send messages to WebView
*/
static async checkInstallation(
sendToWebView: (message: unknown) => void,
@@ -50,8 +50,8 @@ export class CliInstaller {
}
/**
* 提示用户安装 CLI
* 显示警告消息,提供安装选项
* Prompt user to install CLI
* Display warning message with installation options
*/
static async promptInstallation(): Promise<void> {
const selection = await vscode.window.showWarningMessage(
@@ -71,8 +71,8 @@ export class CliInstaller {
}
/**
* 安装 Qwen CLI
* 通过 npm 安装全局 CLI 包
* Install Qwen CLI
* Install global CLI package via npm
*/
static async install(): Promise<void> {
try {

View File

@@ -8,13 +8,13 @@ import * as vscode from 'vscode';
import { getFileName } from '../utils/webviewUtils.js';
/**
* 文件操作处理器
* 负责处理文件打开和 diff 查看功能
* File Operations Handler
* Responsible for handling file opening and diff viewing functionality
*/
export class FileOperations {
/**
* 打开文件并可选跳转到指定行和列
* @param filePath 文件路径,可以包含行号和列号(格式:path/to/file.ts:123 path/to/file.ts:123:45
* Open file and optionally navigate to specified line and column
* @param filePath File path, can include line and column numbers (format: path/to/file.ts:123 or path/to/file.ts:123:45)
*/
static async openFile(filePath?: string): Promise<void> {
try {
@@ -73,8 +73,8 @@ export class FileOperations {
}
/**
* 打开 diff 视图比较文件变更
* @param data Diff 数据,包含文件路径、旧内容和新内容
* Open diff view to compare file changes
* @param data Diff data, including file path, old content, and new content
*/
static async openDiff(data?: {
path?: string;

View File

@@ -9,9 +9,9 @@ import type { ConversationStore } from '../storage/conversationStore.js';
import { MessageRouter } from './handlers/MessageRouter.js';
/**
* MessageHandler (重构版)
* 这是一个轻量级的包装类,内部使用 MessageRouter 和各个子处理器
* 保持与原有代码的接口兼容性
* MessageHandler (Refactored Version)
* This is a lightweight wrapper class that internally uses MessageRouter and various sub-handlers
* Maintains interface compatibility with the original code
*/
export class MessageHandler {
private router: MessageRouter;
@@ -31,28 +31,28 @@ export class MessageHandler {
}
/**
* 路由消息到对应的处理器
* Route messages to the corresponding handler
*/
async route(message: { type: string; data?: unknown }): Promise<void> {
await this.router.route(message);
}
/**
* 设置当前会话 ID
* Set current session ID
*/
setCurrentConversationId(id: string | null): void {
this.router.setCurrentConversationId(id);
}
/**
* 获取当前会话 ID
* Get current session ID
*/
getCurrentConversationId(): string | null {
return this.router.getCurrentConversationId();
}
/**
* 设置权限处理器
* Set permission handler
*/
setPermissionHandler(
handler: (message: { type: string; data: { optionId: string } }) => void,
@@ -61,21 +61,21 @@ export class MessageHandler {
}
/**
* 设置登录处理器
* Set login handler
*/
setLoginHandler(handler: () => Promise<void>): void {
this.router.setLoginHandler(handler);
}
/**
* 追加流式内容
* Append stream content
*/
appendStreamContent(chunk: string): void {
this.router.appendStreamContent(chunk);
}
/**
* 检查是否正在保存 checkpoint
* Check if saving checkpoint
*/
getIsSavingCheckpoint(): boolean {
return this.router.getIsSavingCheckpoint();

View File

@@ -7,8 +7,8 @@
import * as vscode from 'vscode';
/**
* Panel Tab 管理器
* 负责管理 WebView Panel 的创建、显示和 Tab 跟踪
* Panel and Tab Manager
* Responsible for managing the creation, display, and tab tracking of WebView Panels
*/
export class PanelManager {
private panel: vscode.WebviewPanel | null = null;
@@ -20,14 +20,14 @@ export class PanelManager {
) {}
/**
* 获取当前的 Panel
* Get the current Panel
*/
getPanel(): vscode.WebviewPanel | null {
return this.panel;
}
/**
* 设置 Panel(用于恢复)
* Set Panel (for restoration)
*/
setPanel(panel: vscode.WebviewPanel): void {
console.log('[PanelManager] Setting panel for restoration');
@@ -35,8 +35,8 @@ export class PanelManager {
}
/**
* 创建新的 WebView Panel
* @returns 是否是新创建的 Panel
* Create new WebView Panel
* @returns Whether it is a newly created Panel
*/
async createPanel(): Promise<boolean> {
if (this.panel) {
@@ -126,8 +126,8 @@ export class PanelManager {
}
/**
* 查找已存在的 Qwen Code webview 所在的 group view column
* @returns 找到的 group view column,如果没有则返回 undefined
* Find the group and view column where the existing Qwen Code webview is located
* @returns The found group and view column, or undefined if not found
*/
private findExistingQwenCodeGroup():
| { group: vscode.TabGroup; viewColumn: vscode.ViewColumn }
@@ -160,8 +160,8 @@ export class PanelManager {
}
/**
* 自动锁定编辑器组(仅在新创建 Panel 时调用)
* 注意:我们不再自动锁定 Qwen Code group以允许用户创建多个 Qwen Code tab
* Auto-lock editor group (only called when creating a new Panel)
* Note: We no longer auto-lock Qwen Code group to allow users to create multiple Qwen Code tabs
*/
async autoLockEditorGroup(): Promise<void> {
if (!this.panel) {
@@ -175,8 +175,8 @@ export class PanelManager {
}
/**
* 显示 Panel(如果存在则 reveal否则什么都不做
* @param preserveFocus 是否保持焦点
* Show Panel (reveal if exists, otherwise do nothing)
* @param preserveFocus Whether to preserve focus
*/
revealPanel(preserveFocus: boolean = true): void {
if (this.panel) {
@@ -185,8 +185,8 @@ export class PanelManager {
}
/**
* 捕获与 WebView Panel 对应的 Tab
* 用于跟踪和管理 Tab 状态
* Capture the Tab corresponding to the WebView Panel
* Used for tracking and managing Tab state
*/
captureTab(): void {
if (!this.panel) {
@@ -211,8 +211,8 @@ export class PanelManager {
}
/**
* 注册 Panel 的 dispose 事件处理器
* @param disposables 用于存储 Disposable 的数组
* Register the dispose event handler for the Panel
* @param disposables Array used to store Disposable objects
*/
registerDisposeHandler(disposables: vscode.Disposable[]): void {
if (!this.panel) {
@@ -231,8 +231,8 @@ export class PanelManager {
}
/**
* 注册视图状态变化事件处理器
* @param disposables 用于存储 Disposable 的数组
* Register the view state change event handler
* @param disposables Array used to store Disposable objects
*/
registerViewStateChangeHandler(disposables: vscode.Disposable[]): void {
if (!this.panel) {
@@ -251,7 +251,7 @@ export class PanelManager {
}
/**
* 销毁 Panel
* Dispose Panel
*/
dispose(): void {
this.panel?.dispose();

View File

@@ -8,15 +8,15 @@ import * as vscode from 'vscode';
import { escapeHtml } from '../utils/webviewUtils.js';
/**
* WebView HTML 内容生成器
* 负责生成 WebView 的 HTML 内容
* WebView HTML Content Generator
* Responsible for generating the HTML content of the WebView
*/
export class WebViewContent {
/**
* 生成 WebView 的 HTML 内容
* Generate HTML content for the WebView
* @param panel WebView Panel
* @param extensionUri 扩展的 URI
* @returns HTML 字符串
* @param extensionUri Extension URI
* @returns HTML string
*/
static generate(
panel: vscode.WebviewPanel,
@@ -29,7 +29,7 @@ export class WebViewContent {
// Convert extension URI for webview access - this allows frontend to construct resource paths
const extensionUriForWebview = panel.webview.asWebviewUri(extensionUri);
// URI 进行 HTML 转义以防止潜在的注入攻击
// Escape URI for HTML to prevent potential injection attacks
const safeExtensionUri = escapeHtml(extensionUriForWebview.toString());
const safeScriptUri = escapeHtml(scriptUri.toString());

View File

@@ -28,11 +28,11 @@ export class WebViewProvider {
constructor(
context: vscode.ExtensionContext,
private extensionUri: vscode.Uri,
authStateManager?: AuthStateManager, // 可选的全局AuthStateManager实例
authStateManager?: AuthStateManager, // Optional global AuthStateManager instance
) {
this.agentManager = new QwenAgentManager();
this.conversationStore = new ConversationStore(context);
// 如果提供了全局的authStateManager,则使用它,否则创建新的实例
// If a global authStateManager is provided, use it, otherwise create a new instance
this.authStateManager = authStateManager || new AuthStateManager(context);
this.panelManager = new PanelManager(extensionUri, () => {
// Panel dispose callback

View File

@@ -90,7 +90,7 @@ export const useSessionManagement = (vscode: VSCodeAPI) => {
);
/**
* 处理Save session响应
* Handle Save session response
*/
const handleSaveSessionResponse = useCallback(
(response: { success: boolean; message?: string }) => {