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

@@ -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 }) => {