refactor(vscode-ide-companion): introduce ApprovalMode enum and improve mode handling

- Create new approvalModeTypes.ts with ApprovalMode enum and helper functions
- Replace hardcoded string literals with ApprovalModeValue type
- Consolidate mode mapping logic using new helper functions
This commit is contained in:
yiliang114
2025-12-08 23:12:04 +08:00
parent f146f062cb
commit 7adb9ed7ff
12 changed files with 154 additions and 136 deletions

View File

@@ -15,7 +15,7 @@ import { MessageHandler } from '../webview/MessageHandler.js';
import { WebViewContent } from '../webview/WebViewContent.js';
import { CliInstaller } from '../cli/cliInstaller.js';
import { getFileName } from './utils/webviewUtils.js';
import { authMethod } from '../types/acpTypes.js';
import { authMethod, type ApprovalModeValue } from '../types/acpTypes.js';
export class WebViewProvider {
private panelManager: PanelManager;
@@ -31,8 +31,7 @@ export class WebViewProvider {
private pendingPermissionRequest: AcpPermissionRequest | null = null;
private pendingPermissionResolve: ((optionId: string) => void) | null = null;
// Track current ACP mode id to influence permission/diff behavior
private currentModeId: 'plan' | 'default' | 'auto-edit' | 'yolo' | null =
null;
private currentModeId: ApprovalModeValue | null = null;
constructor(
context: vscode.ExtensionContext,
@@ -885,7 +884,7 @@ export class WebViewProvider {
}
/** Get current ACP mode id (if known). */
getCurrentModeId(): 'plan' | 'default' | 'auto-edit' | 'yolo' | null {
getCurrentModeId(): ApprovalModeValue | null {
return this.currentModeId;
}