@@ -19,6 +19,7 @@ import {
19
19
import { useFontSize } from "../../../components/ui/font" ;
20
20
import { useAppSelector } from "../../../redux/hooks" ;
21
21
import { addTool , setToolPolicy } from "../../../redux/slices/uiSlice" ;
22
+ import { isEditTool } from "../../../util/toolCallState" ;
22
23
23
24
interface ToolPolicyItemProps {
24
25
tool : Tool ;
@@ -28,12 +29,22 @@ interface ToolPolicyItemProps {
28
29
29
30
export function ToolPolicyItem ( props : ToolPolicyItemProps ) {
30
31
const dispatch = useDispatch ( ) ;
31
- const policy = useAppSelector (
32
+ const toolPolicy = useAppSelector (
32
33
( state ) => state . ui . toolSettings [ props . tool . function . name ] ,
33
34
) ;
34
35
const [ isExpanded , setIsExpanded ] = useState ( false ) ;
35
36
const mode = useAppSelector ( ( state ) => state . session . mode ) ;
36
37
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
+
37
48
useEffect ( ( ) => {
38
49
if ( ! policy ) {
39
50
dispatch ( addTool ( props . tool ) ) ;
@@ -53,6 +64,7 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
53
64
const fontSize = useFontSize ( - 2 ) ;
54
65
55
66
const disabled =
67
+ isAutoAcceptedToolCall ||
56
68
! props . isGroupEnabled ||
57
69
( mode === "plan" &&
58
70
props . tool . group === BUILT_IN_GROUP_NAME &&
@@ -100,6 +112,19 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
100
112
< InformationCircleIcon className = "h-3 w-3 flex-shrink-0 cursor-help text-yellow-500" />
101
113
</ ToolTip >
102
114
) : 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 }
103
128
{ props . tool . faviconUrl && (
104
129
< img
105
130
src = { props . tool . faviconUrl }
@@ -139,11 +164,13 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
139
164
data-tooltip-id = { disabled ? disabledTooltipId : undefined }
140
165
>
141
166
< 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" }
147
174
</ span >
148
175
< ChevronDownIcon className = "h-3 w-3" />
149
176
</ ListboxButton >
0 commit comments