@@ -55,7 +55,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
5555 mcpServers,
5656 alwaysAllowBrowser,
5757 alwaysAllowReadOnly,
58+ alwaysAllowReadOnlyOutsideWorkspace,
5859 alwaysAllowWrite,
60+ alwaysAllowWriteOutsideWorkspace,
5961 alwaysAllowExecute,
6062 alwaysAllowMcp,
6163 allowedCommands,
@@ -649,26 +651,60 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
649651 ( message : ClineMessage | undefined ) => {
650652 if ( ! autoApprovalEnabled || ! message || message . type !== "ask" ) return false
651653
652- return (
653- ( alwaysAllowBrowser && message . ask === "browser_action_launch" ) ||
654- ( alwaysAllowReadOnly && message . ask === "tool" && isReadOnlyToolAction ( message ) ) ||
655- ( alwaysAllowWrite && message . ask === "tool" && isWriteToolAction ( message ) ) ||
656- ( alwaysAllowExecute && message . ask === "command" && isAllowedCommand ( message ) ) ||
657- ( alwaysAllowMcp && message . ask === "use_mcp_server" && isMcpToolAlwaysAllowed ( message ) ) ||
658- ( alwaysAllowModeSwitch &&
659- message . ask === "tool" &&
660- JSON . parse ( message . text || "{}" ) ?. tool === "switchMode" ) ||
661- ( alwaysAllowSubtasks &&
662- message . ask === "tool" &&
663- [ "newTask" , "finishTask" ] . includes ( JSON . parse ( message . text || "{}" ) ?. tool ) )
664- )
654+ if ( message . ask === "browser_action_launch" ) {
655+ return alwaysAllowBrowser
656+ }
657+
658+ if ( message . ask === "use_mcp_server" ) {
659+ return alwaysAllowMcp && isMcpToolAlwaysAllowed ( message )
660+ }
661+
662+ if ( message . ask === "command" ) {
663+ return alwaysAllowExecute && isAllowedCommand ( message )
664+ }
665+
666+ // For read/write operations, check if it's outside workspace and if we have permission for that
667+ if ( message . ask === "tool" ) {
668+ let tool : any = { }
669+ try {
670+ tool = JSON . parse ( message . text || "{}" )
671+ } catch ( error ) {
672+ console . error ( "Failed to parse tool:" , error )
673+ }
674+
675+ if ( ! tool ) {
676+ return false
677+ }
678+
679+ if ( tool ?. tool === "switchMode" ) {
680+ return alwaysAllowModeSwitch
681+ }
682+
683+ if ( [ "newTask" , "finishTask" ] . includes ( tool ?. tool ) ) {
684+ return alwaysAllowSubtasks
685+ }
686+
687+ const isOutsideWorkspace = ! ! tool . isOutsideWorkspace
688+
689+ if ( isReadOnlyToolAction ( message ) ) {
690+ return alwaysAllowReadOnly && ( ! isOutsideWorkspace || alwaysAllowReadOnlyOutsideWorkspace )
691+ }
692+
693+ if ( isWriteToolAction ( message ) ) {
694+ return alwaysAllowWrite && ( ! isOutsideWorkspace || alwaysAllowWriteOutsideWorkspace )
695+ }
696+ }
697+
698+ return false
665699 } ,
666700 [
667701 autoApprovalEnabled ,
668702 alwaysAllowBrowser ,
669703 alwaysAllowReadOnly ,
704+ alwaysAllowReadOnlyOutsideWorkspace ,
670705 isReadOnlyToolAction ,
671706 alwaysAllowWrite ,
707+ alwaysAllowWriteOutsideWorkspace ,
672708 isWriteToolAction ,
673709 alwaysAllowExecute ,
674710 isAllowedCommand ,
@@ -1047,7 +1083,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
10471083 handlePrimaryButtonClick ,
10481084 alwaysAllowBrowser ,
10491085 alwaysAllowReadOnly ,
1086+ alwaysAllowReadOnlyOutsideWorkspace ,
10501087 alwaysAllowWrite ,
1088+ alwaysAllowWriteOutsideWorkspace ,
10511089 alwaysAllowExecute ,
10521090 alwaysAllowMcp ,
10531091 messages ,
0 commit comments