From 1be22da9b9452d7bdfe893cf655361f36d5d255d Mon Sep 17 00:00:00 2001 From: nang-dev Date: Fri, 21 Feb 2025 17:29:31 -0500 Subject: [PATCH] Added auto-approve --- src/core/webview/ClineProvider.ts | 30 +++++++++---------- .../src/components/chat/AutoApproveMenu.tsx | 4 +-- .../chat/__tests__/AutoApproveMenu.test.tsx | 16 +++++----- .../src/context/ExtensionStateContext.tsx | 12 ++++++-- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 304c968622f..f70a19bd477 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -2044,11 +2044,11 @@ export class ClineProvider implements vscode.WebviewViewProvider { version: this.context.extension?.packageJSON?.version ?? "", apiConfiguration, customInstructions, - alwaysAllowReadOnly: alwaysAllowReadOnly ?? false, - alwaysAllowWrite: alwaysAllowWrite ?? false, - alwaysAllowExecute: alwaysAllowExecute ?? false, - alwaysAllowBrowser: alwaysAllowBrowser ?? false, - alwaysAllowMcp: alwaysAllowMcp ?? false, + alwaysAllowReadOnly: alwaysAllowReadOnly ?? true, + alwaysAllowWrite: alwaysAllowWrite ?? true, + alwaysAllowExecute: alwaysAllowExecute ?? true, + alwaysAllowBrowser: alwaysAllowBrowser ?? true, + alwaysAllowMcp: alwaysAllowMcp ?? true, alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false, uriScheme: vscode.env.uriScheme, clineMessages: this.cline?.clineMessages || [], @@ -2067,7 +2067,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { terminalOutputLineLimit: terminalOutputLineLimit ?? 500, fuzzyMatchThreshold: fuzzyMatchThreshold ?? 1.0, mcpEnabled: mcpEnabled ?? true, - alwaysApproveResubmit: alwaysApproveResubmit ?? false, + alwaysApproveResubmit: alwaysApproveResubmit ?? true, requestDelaySeconds: requestDelaySeconds ?? 10, rateLimitSeconds: rateLimitSeconds ?? 0, currentApiConfigName: currentApiConfigName ?? "default", @@ -2076,7 +2076,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { customModePrompts: customModePrompts ?? {}, customSupportPrompts: customSupportPrompts ?? {}, enhancementApiConfigId, - autoApprovalEnabled: autoApprovalEnabled ?? false, + autoApprovalEnabled: autoApprovalEnabled ?? true, customModes: await this.customModesManager.getCustomModes(), experiments: experiments ?? experimentDefault, } @@ -2354,12 +2354,12 @@ export class ClineProvider implements vscode.WebviewViewProvider { }, lastShownAnnouncementId, customInstructions, - alwaysAllowReadOnly: alwaysAllowReadOnly ?? false, - alwaysAllowWrite: alwaysAllowWrite ?? false, - alwaysAllowExecute: alwaysAllowExecute ?? false, - alwaysAllowBrowser: alwaysAllowBrowser ?? false, - alwaysAllowMcp: alwaysAllowMcp ?? false, - alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false, + alwaysAllowReadOnly: alwaysAllowReadOnly ?? true, + alwaysAllowWrite: alwaysAllowWrite ?? true, + alwaysAllowExecute: alwaysAllowExecute ?? true, + alwaysAllowBrowser: alwaysAllowBrowser ?? true, + alwaysAllowMcp: alwaysAllowMcp ?? true, + alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? true, taskHistory, allowedCommands, soundEnabled: soundEnabled ?? false, @@ -2401,7 +2401,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { return langMap[vscodeLang.split("-")[0]] ?? "English" })(), mcpEnabled: mcpEnabled ?? true, - alwaysApproveResubmit: alwaysApproveResubmit ?? false, + alwaysApproveResubmit: alwaysApproveResubmit ?? true, requestDelaySeconds: Math.max(5, requestDelaySeconds ?? 10), rateLimitSeconds: rateLimitSeconds ?? 0, currentApiConfigName: currentApiConfigName ?? "default", @@ -2411,7 +2411,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { customSupportPrompts: customSupportPrompts ?? {}, enhancementApiConfigId, experiments: experiments ?? experimentDefault, - autoApprovalEnabled: autoApprovalEnabled ?? false, + autoApprovalEnabled: autoApprovalEnabled ?? true, customModes, } } diff --git a/webview-ui/src/components/chat/AutoApproveMenu.tsx b/webview-ui/src/components/chat/AutoApproveMenu.tsx index 386c2d6f2bb..e28fdbcc5b9 100644 --- a/webview-ui/src/components/chat/AutoApproveMenu.tsx +++ b/webview-ui/src/components/chat/AutoApproveMenu.tsx @@ -174,9 +174,9 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => { onClick={toggleExpanded}>
e.stopPropagation()}> { - const newValue = !(autoApprovalEnabled ?? false) + const newValue = !(autoApprovalEnabled ?? true) setAutoApprovalEnabled(newValue) vscode.postMessage({ type: "autoApprovalEnabled", bool: newValue }) }} diff --git a/webview-ui/src/components/chat/__tests__/AutoApproveMenu.test.tsx b/webview-ui/src/components/chat/__tests__/AutoApproveMenu.test.tsx index 491a9173482..8eeb95f0838 100644 --- a/webview-ui/src/components/chat/__tests__/AutoApproveMenu.test.tsx +++ b/webview-ui/src/components/chat/__tests__/AutoApproveMenu.test.tsx @@ -47,14 +47,14 @@ describe("AutoApproveMenu", () => { customModes: [], // Auto-approve specific properties - alwaysAllowReadOnly: false, - alwaysAllowWrite: false, - alwaysAllowExecute: false, - alwaysAllowBrowser: false, - alwaysAllowMcp: false, - alwaysApproveResubmit: false, - alwaysAllowModeSwitch: false, - autoApprovalEnabled: false, + alwaysAllowReadOnly: true, + alwaysAllowWrite: true, + alwaysAllowExecute: true, + alwaysAllowBrowser: true, + alwaysAllowMcp: true, + alwaysApproveResubmit: true, + alwaysAllowModeSwitch: true, + autoApprovalEnabled: true, // Required setter functions setApiConfiguration: jest.fn(), diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index f1f71d3261e..0a92ae860b9 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -83,9 +83,15 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode taskHistory: [], shouldShowAnnouncement: false, allowedCommands: [], + alwaysAllowReadOnly: true, + alwaysAllowWrite: true, + alwaysAllowExecute: true, + alwaysAllowBrowser: true, + alwaysAllowMcp: true, + alwaysAllowModeSwitch: true, soundEnabled: false, soundVolume: 0.5, - diffEnabled: false, + diffEnabled: true, fuzzyMatchThreshold: 1.0, preferredLanguage: "English", writeDelayMs: 1000, @@ -93,7 +99,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode screenshotQuality: 75, terminalOutputLineLimit: 500, mcpEnabled: true, - alwaysApproveResubmit: false, + alwaysApproveResubmit: true, requestDelaySeconds: 5, rateLimitSeconds: 0, // Minimum time between successive requests (0 = disabled) currentApiConfigName: "default", @@ -103,7 +109,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode customSupportPrompts: {}, experiments: experimentDefault, enhancementApiConfigId: "", - autoApprovalEnabled: false, + autoApprovalEnabled: true, customModes: [], })