@@ -735,7 +735,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
735735
736736 const isAutoApproved = useCallback (
737737 ( message : ClineMessage | undefined ) => {
738- if ( ! autoApprovalEnabled || ! message || message . type !== "ask" ) return false
738+ if ( ! autoApprovalEnabled || ! message || message . type !== "ask" ) {
739+ return false
740+ }
739741
740742 if ( message . ask === "browser_action_launch" ) {
741743 return alwaysAllowBrowser
@@ -749,7 +751,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
749751 return alwaysAllowExecute && isAllowedCommand ( message )
750752 }
751753
752- // For read/write operations, check if it's outside workspace and if we have permission for that
754+ // For read/write operations, check if it's outside workspace and if
755+ // we have permission for that.
753756 if ( message . ask === "tool" ) {
754757 let tool : any = { }
755758
@@ -1114,13 +1117,26 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
11141117 }
11151118
11161119 const autoApprove = async ( ) => {
1117- if ( isAutoApproved ( lastMessage ) ) {
1120+ if ( lastMessage ?. ask && isAutoApproved ( lastMessage ) ) {
1121+ // Note that `isAutoApproved` can only return true if
1122+ // lastMessage is an ask of type "browser_action_launch",
1123+ // "use_mcp_server", "command", or "tool".
1124+
11181125 // Add delay for write operations.
1119- if ( lastMessage ? .ask === "tool" && isWriteToolAction ( lastMessage ) ) {
1126+ if ( lastMessage . ask === "tool" && isWriteToolAction ( lastMessage ) ) {
11201127 await new Promise ( ( resolve ) => setTimeout ( resolve , writeDelayMs ) )
11211128 }
11221129
1123- handlePrimaryButtonClick ( )
1130+ vscode . postMessage ( { type : "askResponse" , askResponse : "yesButtonClicked" } )
1131+
1132+ // This is copied from `handlePrimaryButtonClick`, which we used
1133+ // to call from `autoApprove`. I'm not sure how many of these
1134+ // things are actually needed.
1135+ setInputValue ( "" )
1136+ setSelectedImages ( [ ] )
1137+ setTextAreaDisabled ( true )
1138+ setClineAsk ( undefined )
1139+ setEnableButtons ( false )
11241140 }
11251141 }
11261142 autoApprove ( )
0 commit comments