From 38c5d8c08c15c4efa6e91a3aa8f7a83562c2e202 Mon Sep 17 00:00:00 2001 From: hannesrudolph Date: Mon, 14 Jul 2025 17:03:01 -0600 Subject: [PATCH] fix: address PR review comments - Fix tooltip rendering to conditionally show only when needed - Reuse useAutoApprovalState hook in ChatView to avoid code duplication - Improve code quality and consistency across auto-approve components --- .../src/components/chat/AutoApproveMenu.tsx | 26 ++++++----- webview-ui/src/components/chat/ChatView.tsx | 45 +++++++++++++------ .../settings/AutoApproveSettings.tsx | 25 ++++++----- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/webview-ui/src/components/chat/AutoApproveMenu.tsx b/webview-ui/src/components/chat/AutoApproveMenu.tsx index f5c62df2af..4162b505d9 100644 --- a/webview-ui/src/components/chat/AutoApproveMenu.tsx +++ b/webview-ui/src/components/chat/AutoApproveMenu.tsx @@ -198,26 +198,30 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => { }} onClick={toggleExpanded}>
e.stopPropagation()}> - + {!hasEnabledOptions ? ( + + { + // Show a message or do nothing + return + }} + /> + + ) : ( { - if (!hasEnabledOptions) { - // Show a message or do nothing - return - } const newValue = !(autoApprovalEnabled ?? false) setAutoApprovalEnabled(newValue) vscode.postMessage({ type: "autoApprovalEnabled", bool: newValue }) }} /> - + )}
({ + alwaysAllowReadOnly, + alwaysAllowWrite, + alwaysAllowExecute, + alwaysAllowBrowser, + alwaysAllowMcp, + alwaysAllowModeSwitch, + alwaysAllowSubtasks, + alwaysAllowFollowupQuestions, + alwaysAllowUpdateTodoList, + }), + [ + alwaysAllowReadOnly, + alwaysAllowWrite, + alwaysAllowExecute, + alwaysAllowBrowser, + alwaysAllowMcp, + alwaysAllowModeSwitch, + alwaysAllowSubtasks, + alwaysAllowFollowupQuestions, + alwaysAllowUpdateTodoList, + ], + ) + + const { hasEnabledOptions } = useAutoApprovalState(autoApprovalToggles, autoApprovalEnabled) + const isAutoApproved = useCallback( (message: ClineMessage | undefined) => { // First check if auto-approval is enabled AND we have at least one permission @@ -966,19 +995,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction
- + {!hasEnabledOptions ? ( + + { + // Do nothing when no options are enabled + return + }} + /> + + ) : ( { - if (!hasEnabledOptions) { - return - } const newValue = !(autoApprovalEnabled ?? false) setAutoApprovalEnabled(newValue) vscode.postMessage({ type: "autoApprovalEnabled", bool: newValue }) }} /> - + )}
{t("settings:sections.autoApprove")}