diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCallButtonsDiv.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallButtonsDiv.tsx index a2c69cbed..42f9d9204 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCallButtonsDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCallButtonsDiv.tsx @@ -1,4 +1,4 @@ -import { useContext } from "react"; +import { useContext, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import styled from "styled-components"; import { @@ -55,8 +55,22 @@ export function ToolCallButtons(props: ToolCallButtonsProps) { const toolCallState = useSelector( (store: RootState) => store.state.currentToolCallState, ); + const toolSetting = useSelector( + (store: RootState) => + store.uiState.toolSettings[toolCallState.toolCall.function.name], + ); + const ideMessenger = useContext(IdeMessengerContext); + useEffect(() => { + if ( + toolCallState.currentToolCallState === "generated" && + toolSetting === "allowedWithoutPermission" + ) { + callTool(); + } + }, [toolCallState.currentToolCallState, toolSetting]); + const { streamResponseAfterToolCall } = useChatHandler( dispatch, ideMessenger, diff --git a/gui/src/redux/slices/uiStateSlice.ts b/gui/src/redux/slices/uiStateSlice.ts index 3d88c5435..268815ae4 100644 --- a/gui/src/redux/slices/uiStateSlice.ts +++ b/gui/src/redux/slices/uiStateSlice.ts @@ -1,4 +1,5 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; +import { BuiltInToolNames } from "core/tools/builtIn"; import { defaultOnboardingCardState, OnboardingCardState, @@ -31,7 +32,15 @@ export const uiStateSlice = createSlice({ shouldAddFileForEditing: false, useTools: false, - toolSettings: {}, + toolSettings: { + [BuiltInToolNames.CreateNewFile]: "allowedWithPermission", + [BuiltInToolNames.RunTerminalCommand]: "allowedWithPermission", + [BuiltInToolNames.ViewSubdirectory]: "allowedWithoutPermission", + [BuiltInToolNames.ViewRepoMap]: "allowedWithoutPermission", + [BuiltInToolNames.ExactSearch]: "allowedWithoutPermission", + [BuiltInToolNames.SearchWeb]: "allowedWithoutPermission", + [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", + }, } as UiState, reducers: { setOnboardingCard: (