mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 04:41:16 -05:00
feat: Add auto-approval for mode switching
Implements automatic approval for mode switching operations when enabled, following existing auto-approval patterns in the codebase. Implementation: - Added `alwaysAllowModeSwitch` to state management - Updated `isAutoApproved` function in ChatView to handle mode switch requests - Added mode switch option to AutoApproveMenu with appropriate handler - Integrated with existing auto-approval flow Tests: - Added three test cases in ChatView.auto-approve.test.tsx: 1. Verifies mode switch auto-approval when enabled 2. Verifies no auto-approval when mode switch setting is disabled 3. Verifies no auto-approval when global auto-approval is disabled The implementation follows existing patterns for other auto-approve features (read, write, browser, etc.) to maintain consistency in the codebase.
This commit is contained in:
@@ -28,6 +28,8 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
|
||||
setAlwaysAllowBrowser,
|
||||
alwaysAllowMcp,
|
||||
setAlwaysAllowMcp,
|
||||
alwaysAllowModeSwitch,
|
||||
setAlwaysAllowModeSwitch,
|
||||
alwaysApproveResubmit,
|
||||
setAlwaysApproveResubmit,
|
||||
autoApprovalEnabled,
|
||||
@@ -71,6 +73,13 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
|
||||
enabled: alwaysAllowMcp ?? false,
|
||||
description: "Allows use of configured MCP servers which may modify filesystem or interact with APIs.",
|
||||
},
|
||||
{
|
||||
id: "switchModes",
|
||||
label: "Switch between modes",
|
||||
shortName: "Modes",
|
||||
enabled: alwaysAllowModeSwitch ?? false,
|
||||
description: "Allows automatic switching between different AI modes without requiring approval.",
|
||||
},
|
||||
{
|
||||
id: "retryRequests",
|
||||
label: "Retry failed requests",
|
||||
@@ -120,6 +129,12 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
|
||||
vscode.postMessage({ type: "alwaysAllowMcp", bool: newValue })
|
||||
}, [alwaysAllowMcp, setAlwaysAllowMcp])
|
||||
|
||||
const handleModeSwitchChange = useCallback(() => {
|
||||
const newValue = !(alwaysAllowModeSwitch ?? false)
|
||||
setAlwaysAllowModeSwitch(newValue)
|
||||
vscode.postMessage({ type: "alwaysAllowModeSwitch", bool: newValue })
|
||||
}, [alwaysAllowModeSwitch, setAlwaysAllowModeSwitch])
|
||||
|
||||
const handleRetryChange = useCallback(() => {
|
||||
const newValue = !(alwaysApproveResubmit ?? false)
|
||||
setAlwaysApproveResubmit(newValue)
|
||||
@@ -133,6 +148,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
|
||||
executeCommands: handleExecuteChange,
|
||||
useBrowser: handleBrowserChange,
|
||||
useMcp: handleMcpChange,
|
||||
switchModes: handleModeSwitchChange,
|
||||
retryRequests: handleRetryChange,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user