@@ -19,6 +19,7 @@ import {
1919import { useFontSize } from "../../../components/ui/font" ;
2020import { useAppSelector } from "../../../redux/hooks" ;
2121import { addTool , setToolPolicy } from "../../../redux/slices/uiSlice" ;
22+ import { isEditTool } from "../../../util/toolCallState" ;
2223
2324interface ToolPolicyItemProps {
2425 tool : Tool ;
@@ -28,12 +29,22 @@ interface ToolPolicyItemProps {
2829
2930export function ToolPolicyItem ( props : ToolPolicyItemProps ) {
3031 const dispatch = useDispatch ( ) ;
31- const policy = useAppSelector (
32+ const toolPolicy = useAppSelector (
3233 ( state ) => state . ui . toolSettings [ props . tool . function . name ] ,
3334 ) ;
3435 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
3536 const mode = useAppSelector ( ( state ) => state . session . mode ) ;
3637
38+ const autoAcceptEditToolDiffs = useAppSelector (
39+ ( state ) => state . config . config . ui ?. autoAcceptEditToolDiffs ,
40+ ) ;
41+ const isAutoAcceptedToolCall =
42+ isEditTool ( props . tool . function . name ) && autoAcceptEditToolDiffs ;
43+
44+ const policy = isAutoAcceptedToolCall
45+ ? "allowedWithoutPermission"
46+ : toolPolicy ;
47+
3748 useEffect ( ( ) => {
3849 if ( ! policy ) {
3950 dispatch ( addTool ( props . tool ) ) ;
@@ -53,6 +64,7 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
5364 const fontSize = useFontSize ( - 2 ) ;
5465
5566 const disabled =
67+ isAutoAcceptedToolCall ||
5668 ! props . isGroupEnabled ||
5769 ( mode === "plan" &&
5870 props . tool . group === BUILT_IN_GROUP_NAME &&
@@ -100,6 +112,19 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
100112 < InformationCircleIcon className = "h-3 w-3 flex-shrink-0 cursor-help text-yellow-500" />
101113 </ ToolTip >
102114 ) : null }
115+ { isAutoAcceptedToolCall ? (
116+ < ToolTip
117+ place = "bottom"
118+ className = "flex flex-wrap items-center"
119+ content = {
120+ < p className = "m-0 p-0" >
121+ Auto-Accept Agent Edits setting is on
122+ </ p >
123+ }
124+ >
125+ < InformationCircleIcon className = "h-3 w-3 flex-shrink-0 cursor-help text-yellow-500" />
126+ </ ToolTip >
127+ ) : null }
103128 { props . tool . faviconUrl && (
104129 < img
105130 src = { props . tool . faviconUrl }
@@ -139,11 +164,13 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
139164 data-tooltip-id = { disabled ? disabledTooltipId : undefined }
140165 >
141166 < span className = "text-xs" >
142- { disabled || policy === "disabled"
143- ? "Excluded"
144- : policy === "allowedWithoutPermission"
145- ? "Automatic"
146- : "Ask First" }
167+ { isAutoAcceptedToolCall
168+ ? "Automatic"
169+ : disabled || policy === "disabled"
170+ ? "Excluded"
171+ : policy === "allowedWithoutPermission"
172+ ? "Automatic"
173+ : "Ask First" }
147174 </ span >
148175 < ChevronDownIcon className = "h-3 w-3" />
149176 </ ListboxButton >
0 commit comments