@@ -43,6 +43,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
4343 ( key : AutoApproveSetting , value : boolean ) => {
4444 vscode . postMessage ( { type : key , bool : value } )
4545
46+ // Update the specific setting
4647 switch ( key ) {
4748 case "alwaysAllowReadOnly" :
4849 setAlwaysAllowReadOnly ( value )
@@ -69,6 +70,29 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
6970 setAlwaysApproveResubmit ( value )
7071 break
7172 }
73+
74+ // After updating the specific setting, check if any action is now enabled.
75+ // If so, ensure autoApprovalEnabled is true.
76+ // This needs to be done after the state updates, so we'll use a temporary check
77+ // or re-evaluate the `toggles` object.
78+ // For simplicity, we'll assume the `toggles` state will reflect the change
79+ // in the next render cycle, and we can force autoApprovalEnabled to true
80+ // if any action is being enabled.
81+ if ( value === true ) {
82+ setAutoApprovalEnabled ( true )
83+ vscode . postMessage ( { type : "autoApprovalEnabled" , bool : true } )
84+ } else {
85+ // If an action is being disabled, check if all are now disabled.
86+ // If so, set autoApprovalEnabled to false.
87+ // This requires re-evaluating the state of all toggles *after* the current one is set.
88+ // A more robust solution would involve passing the updated `toggles` object
89+ // or re-calculating `hasAnyAutoApprovedAction` here.
90+ // For now, let's rely on the `hasAnyAutoApprovedAction` memoized value
91+ // which will update on the next render.
92+ // If the user unchecks the last enabled option, autoApprovalEnabled should become false.
93+ // This logic is already handled by the main checkbox's disabled state in the collapsed view.
94+ // So, we only need to ensure it turns ON when an individual is turned ON.
95+ }
7296 } ,
7397 [
7498 setAlwaysAllowReadOnly ,
@@ -79,6 +103,8 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
79103 setAlwaysAllowModeSwitch ,
80104 setAlwaysAllowSubtasks ,
81105 setAlwaysApproveResubmit ,
106+ setAutoApprovalEnabled , // Added setAutoApprovalEnabled to dependencies
107+ vscode , // Added vscode to dependencies
82108 ] ,
83109 )
84110
@@ -107,10 +133,20 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
107133 ] ,
108134 )
109135
110- const enabledActionsList = Object . entries ( toggles )
111- . filter ( ( [ _key , value ] ) => ! ! value )
112- . map ( ( [ key ] ) => t ( autoApproveSettingsConfig [ key as AutoApproveSetting ] . labelKey ) )
113- . join ( ", " )
136+ const hasAnyAutoApprovedAction = useMemo (
137+ ( ) => Object . values ( toggles ) . some ( ( value ) => ! ! value ) ,
138+ [ toggles ] ,
139+ )
140+
141+ const displayedAutoApproveText = useMemo ( ( ) => {
142+ if ( autoApprovalEnabled && hasAnyAutoApprovedAction ) {
143+ return Object . entries ( toggles )
144+ . filter ( ( [ _key , value ] ) => ! ! value )
145+ . map ( ( [ key ] ) => t ( autoApproveSettingsConfig [ key as AutoApproveSetting ] . labelKey ) )
146+ . join ( ", " )
147+ }
148+ return t ( "chat:autoApprove.none" )
149+ } , [ autoApprovalEnabled , hasAnyAutoApprovedAction , toggles , t ] )
114150
115151 const handleOpenSettings = useCallback (
116152 ( ) =>
@@ -140,9 +176,10 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
140176 onClick = { toggleExpanded } >
141177 < div onClick = { ( e ) => e . stopPropagation ( ) } >
142178 < VSCodeCheckbox
143- checked = { autoApprovalEnabled ?? false }
179+ checked = { autoApprovalEnabled && hasAnyAutoApprovedAction }
180+ disabled = { ! hasAnyAutoApprovedAction }
144181 onChange = { ( ) => {
145- const newValue = ! ( autoApprovalEnabled ?? false )
182+ const newValue = ! ( autoApprovalEnabled && hasAnyAutoApprovedAction )
146183 setAutoApprovalEnabled ( newValue )
147184 vscode . postMessage ( { type : "autoApprovalEnabled" , bool : newValue } )
148185 } }
@@ -172,7 +209,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
172209 flex : 1 ,
173210 minWidth : 0 ,
174211 } } >
175- { enabledActionsList || t ( "chat:autoApprove.none" ) }
212+ { displayedAutoApproveText }
176213 </ span >
177214 < span
178215 className = { `codicon codicon-chevron-${ isExpanded ? "down" : "right" } ` }
@@ -199,7 +236,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
199236 />
200237 </ div >
201238
202- < AutoApproveToggle { ...toggles } onToggle = { onAutoApproveToggle } />
239+ < AutoApproveToggle { ...toggles } onToggle = { onAutoApproveToggle } isOverallApprovalEnabled = { autoApprovalEnabled } />
203240
204241 { /* Auto-approve API request count limit input row inspired by Cline */ }
205242 < div
0 commit comments