diff --git a/core/tools/definitions/createNewFile.ts b/core/tools/definitions/createNewFile.ts index 1123de217..f0082891c 100644 --- a/core/tools/definitions/createNewFile.ts +++ b/core/tools/definitions/createNewFile.ts @@ -5,6 +5,7 @@ export const createNewFileTool: Tool = { type: "function", displayTitle: "Create New File", wouldLikeTo: "create a new file", + readonly: false, function: { name: BuiltInToolNames.CreateNewFile, description: "Create a new file", diff --git a/core/tools/definitions/exactSearch.ts b/core/tools/definitions/exactSearch.ts index 5e55c8667..2a0266bd5 100644 --- a/core/tools/definitions/exactSearch.ts +++ b/core/tools/definitions/exactSearch.ts @@ -5,6 +5,7 @@ export const exactSearchTool: Tool = { type: "function", displayTitle: "Exact Search", wouldLikeTo: "search for a specific term within the repository", + readonly: true, function: { name: BuiltInToolNames.ExactSearch, description: "Perform an exact search over the repository using ripgrep", diff --git a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx index 232a0cd8e..33e642be2 100644 --- a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx +++ b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx @@ -1,4 +1,4 @@ -import { Listbox } from "@headlessui/react"; +import { Listbox, Transition } from "@headlessui/react"; import { ChevronDownIcon, ChevronUpIcon, @@ -6,7 +6,7 @@ import { } from "@heroicons/react/24/outline"; import { modelSupportsTools } from "core/llm/autodetect"; import { allTools } from "core/tools/index"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import styled from "styled-components"; import { defaultBorderRadius, lightGray, vscForeground } from "../.."; @@ -34,13 +34,35 @@ const BackgroundDiv = styled.div<{ useTools: boolean }>` transition: background-color 200ms; `; -export default function ToolDropdown() { +export default function ToolDropdown({ + +}: { + +}) { const buttonRef = useRef(null); const dispatch = useDispatch(); const [isDropdownOpen, setDropdownOpen] = useState(false); + const useTools = useSelector((store: RootState) => store.uiState.useTools); const defaultModel = useSelector(defaultModelSelector); + + const [showAbove, setShowAbove] = useState(false); + + useEffect(() => { + const checkPosition = () => { + if (buttonRef.current) { + const rect = buttonRef.current.getBoundingClientRect(); + const windowHeight = window.innerHeight; + const spaceBelow = windowHeight - rect.bottom; + setShowAbove(spaceBelow < 250); + } + }; + + if (isDropdownOpen) { + checkPosition(); + } + }, [isDropdownOpen]); if (!modelSupportsTools(defaultModel.model)) { return null; @@ -77,49 +99,53 @@ export default function ToolDropdown() { )} - -
- Tool policies{" "} - -

- Automatic:{" "} - Can be used without asking -

-

- Allowed:{" "} - Will ask before using -

-

- Disabled:{" "} - Cannot be used -

-
- } - /> - - {allTools.map((tool) => ( - + +
- - - ))} - + Tool policies{" "} + +

+ Automatic:{" "} + Can be used without asking +

+

+ Allowed:{" "} + Will ask before using +

+

+ Disabled:{" "} + Cannot be used +

+
+ } + /> + + {allTools.map((tool) => ( + + + + ))} +
+