@@ -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,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
79103 setAlwaysAllowModeSwitch ,
80104 setAlwaysAllowSubtasks ,
81105 setAlwaysApproveResubmit ,
106+ setAutoApprovalEnabled , // Added setAutoApprovalEnabled to dependencies
82107 ] ,
83108 )
84109
@@ -107,10 +132,17 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
107132 ] ,
108133 )
109134
110- const enabledActionsList = Object . entries ( toggles )
111- . filter ( ( [ _key , value ] ) => ! ! value )
112- . map ( ( [ key ] ) => t ( autoApproveSettingsConfig [ key as AutoApproveSetting ] . labelKey ) )
113- . join ( ", " )
135+ const hasAnyAutoApprovedAction = useMemo ( ( ) => Object . values ( toggles ) . some ( ( value ) => ! ! value ) , [ toggles ] )
136+
137+ const displayedAutoApproveText = useMemo ( ( ) => {
138+ if ( autoApprovalEnabled && hasAnyAutoApprovedAction ) {
139+ return Object . entries ( toggles )
140+ . filter ( ( [ _key , value ] ) => ! ! value )
141+ . map ( ( [ key ] ) => t ( autoApproveSettingsConfig [ key as AutoApproveSetting ] . labelKey ) )
142+ . join ( ", " )
143+ }
144+ return t ( "chat:autoApprove.none" )
145+ } , [ autoApprovalEnabled , hasAnyAutoApprovedAction , toggles , t ] )
114146
115147 const handleOpenSettings = useCallback (
116148 ( ) =>
@@ -140,9 +172,10 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
140172 onClick = { toggleExpanded } >
141173 < div onClick = { ( e ) => e . stopPropagation ( ) } >
142174 < VSCodeCheckbox
143- checked = { autoApprovalEnabled ?? false }
175+ checked = { autoApprovalEnabled && hasAnyAutoApprovedAction }
176+ disabled = { ! hasAnyAutoApprovedAction }
144177 onChange = { ( ) => {
145- const newValue = ! ( autoApprovalEnabled ?? false )
178+ const newValue = ! ( autoApprovalEnabled && hasAnyAutoApprovedAction )
146179 setAutoApprovalEnabled ( newValue )
147180 vscode . postMessage ( { type : "autoApprovalEnabled" , bool : newValue } )
148181 } }
@@ -172,7 +205,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
172205 flex : 1 ,
173206 minWidth : 0 ,
174207 } } >
175- { enabledActionsList || t ( "chat:autoApprove.none" ) }
208+ { displayedAutoApproveText }
176209 </ span >
177210 < span
178211 className = { `codicon codicon-chevron-${ isExpanded ? "down" : "right" } ` }
@@ -199,7 +232,11 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
199232 />
200233 </ div >
201234
202- < AutoApproveToggle { ...toggles } onToggle = { onAutoApproveToggle } />
235+ < AutoApproveToggle
236+ { ...toggles }
237+ onToggle = { onAutoApproveToggle }
238+ isOverallApprovalEnabled = { autoApprovalEnabled }
239+ />
203240
204241 { /* Auto-approve API request count limit input row inspired by Cline */ }
205242 < div
0 commit comments