@@ -37,7 +37,7 @@ interface ChatViewProps {
3737export const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images
3838
3939const ChatView = ( { isHidden, showAnnouncement, hideAnnouncement, showHistoryView } : ChatViewProps ) => {
40- const { version, clineMessages : messages , taskHistory, apiConfiguration, mcpServers, alwaysAllowBrowser, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute, alwaysAllowMcp, allowedCommands } = useExtensionState ( )
40+ const { version, clineMessages : messages , taskHistory, apiConfiguration, mcpServers, alwaysAllowBrowser, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute, alwaysAllowMcp, allowedCommands, writeDelayMs } = useExtensionState ( )
4141
4242 //const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
4343 const task = useMemo ( ( ) => messages . at ( 0 ) , [ messages ] ) // leaving this less safe version here since if the first message is not a task, then the extension is in a bad state and needs to be debugged (see Cline.abort)
@@ -831,10 +831,17 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
831831 // Only proceed if we have an ask and buttons are enabled
832832 if ( ! clineAsk || ! enableButtons ) return
833833
834- if ( isAutoApproved ( lastMessage ) ) {
835- handlePrimaryButtonClick ( )
834+ const autoApprove = async ( ) => {
835+ if ( isAutoApproved ( lastMessage ) ) {
836+ // Add delay for write operations
837+ if ( alwaysAllowWrite && isWriteToolAction ( lastMessage ) ) {
838+ await new Promise ( resolve => setTimeout ( resolve , writeDelayMs ) )
839+ }
840+ handlePrimaryButtonClick ( )
841+ }
836842 }
837- } , [ clineAsk , enableButtons , handlePrimaryButtonClick , alwaysAllowBrowser , alwaysAllowReadOnly , alwaysAllowWrite , alwaysAllowExecute , alwaysAllowMcp , messages , allowedCommands , mcpServers , isAutoApproved , lastMessage ] )
843+ autoApprove ( )
844+ } , [ clineAsk , enableButtons , handlePrimaryButtonClick , alwaysAllowBrowser , alwaysAllowReadOnly , alwaysAllowWrite , alwaysAllowExecute , alwaysAllowMcp , messages , allowedCommands , mcpServers , isAutoApproved , lastMessage , writeDelayMs , isWriteToolAction ] )
838845
839846 return (
840847 < div
0 commit comments