diff --git a/core/index.d.ts b/core/index.d.ts index 6b0844d02..fe267f766 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1099,6 +1099,7 @@ export interface Tool { exampleArgs?: Array<[string, string | number]>; }; defaultToolPolicy?: ToolPolicy; + toolCallIcon?: string; evaluateToolCallPolicy?: ( basePolicy: ToolPolicy, parsedArgs: Record, diff --git a/core/tools/definitions/createRuleBlock.ts b/core/tools/definitions/createRuleBlock.ts index 7dcb8cd51..2b8f1c4ed 100644 --- a/core/tools/definitions/createRuleBlock.ts +++ b/core/tools/definitions/createRuleBlock.ts @@ -84,4 +84,5 @@ For example:`, ["alwaysApply", "false"], ], }, + toolCallIcon: "PencilIcon", }; diff --git a/core/tools/definitions/fetchUrlContent.ts b/core/tools/definitions/fetchUrlContent.ts index 6927b60bf..2498dcc59 100644 --- a/core/tools/definitions/fetchUrlContent.ts +++ b/core/tools/definitions/fetchUrlContent.ts @@ -30,4 +30,5 @@ export const fetchUrlContentTool: Tool = { prefix: `To fetch the content of a URL, use the ${BuiltInToolNames.FetchUrlContent} tool. For example, to read the contents of a webpage, you might respond with:`, exampleArgs: [["url", "https://example.com"]], }, + toolCallIcon: "GlobeAltIcon", }; diff --git a/core/tools/definitions/globSearch.ts b/core/tools/definitions/globSearch.ts index 6e11f84dd..ddf019cc2 100644 --- a/core/tools/definitions/globSearch.ts +++ b/core/tools/definitions/globSearch.ts @@ -30,4 +30,5 @@ export const globSearchTool: Tool = { prefix: `To return a list of files based on a glob search pattern, use the ${BuiltInToolNames.FileGlobSearch} tool`, exampleArgs: [["pattern", "*.py"]], }, + toolCallIcon: "MagnifyingGlassIcon", }; diff --git a/core/tools/definitions/grepSearch.ts b/core/tools/definitions/grepSearch.ts index 75107d90b..ed9eab756 100644 --- a/core/tools/definitions/grepSearch.ts +++ b/core/tools/definitions/grepSearch.ts @@ -31,4 +31,5 @@ export const grepSearchTool: Tool = { prefix: `To perform a grep search within the project, call the ${BuiltInToolNames.GrepSearch} tool with the query pattern to match. For example:`, exampleArgs: [["query", ".*main_services.*"]], }, + toolCallIcon: "MagnifyingGlassIcon", }; diff --git a/core/tools/definitions/ls.ts b/core/tools/definitions/ls.ts index aefe16302..49ac5b1c6 100644 --- a/core/tools/definitions/ls.ts +++ b/core/tools/definitions/ls.ts @@ -38,4 +38,5 @@ export const lsTool: Tool = { ["recursive", "false"], ], }, + toolCallIcon: "FolderIcon", }; diff --git a/core/tools/definitions/readCurrentlyOpenFile.ts b/core/tools/definitions/readCurrentlyOpenFile.ts index 5afab5ae4..87d1adc22 100644 --- a/core/tools/definitions/readCurrentlyOpenFile.ts +++ b/core/tools/definitions/readCurrentlyOpenFile.ts @@ -24,4 +24,5 @@ export const readCurrentlyOpenFileTool: Tool = { prefix: `To view the user's currently open file, use the ${BuiltInToolNames.ReadCurrentlyOpenFile} tool. If the user is asking about a file and you don't see any code, use this to check the current file`, }, + toolCallIcon: "DocumentTextIcon", }; diff --git a/core/tools/definitions/readFile.ts b/core/tools/definitions/readFile.ts index d63b59b16..ee6c1c91c 100644 --- a/core/tools/definitions/readFile.ts +++ b/core/tools/definitions/readFile.ts @@ -31,4 +31,5 @@ export const readFileTool: Tool = { exampleArgs: [["filepath", "path/to/the_file.txt"]], }, defaultToolPolicy: "allowedWithoutPermission", + toolCallIcon: "DocumentIcon", }; diff --git a/core/tools/definitions/readFileRange.ts b/core/tools/definitions/readFileRange.ts index 672b9f431..41a7bfcfd 100644 --- a/core/tools/definitions/readFileRange.ts +++ b/core/tools/definitions/readFileRange.ts @@ -48,4 +48,5 @@ export const readFileRangeTool: Tool = { ], }, defaultToolPolicy: "allowedWithoutPermission", + toolCallIcon: "DocumentIcon", }; diff --git a/core/tools/definitions/searchWeb.ts b/core/tools/definitions/searchWeb.ts index aa1555e15..7740cb45a 100644 --- a/core/tools/definitions/searchWeb.ts +++ b/core/tools/definitions/searchWeb.ts @@ -30,4 +30,5 @@ export const searchWebTool: Tool = { prefix: `To search the web, use the ${BuiltInToolNames.SearchWeb} tool with a natural language query. For example, to search for the current weather, you would respond with:`, exampleArgs: [["query", "What is the current weather in San Francisco?"]], }, + toolCallIcon: "GlobeAltIcon", }; diff --git a/core/tools/definitions/viewDiff.ts b/core/tools/definitions/viewDiff.ts index 14d6176f2..4c397a04b 100644 --- a/core/tools/definitions/viewDiff.ts +++ b/core/tools/definitions/viewDiff.ts @@ -23,4 +23,5 @@ export const viewDiffTool: Tool = { prefix: `To view the current git diff, use the ${BuiltInToolNames.ViewDiff} tool. This will show you the changes made in the working directory compared to the last commit.`, }, defaultToolPolicy: "allowedWithoutPermission", + toolCallIcon: "CodeBracketIcon", }; diff --git a/core/tools/definitions/viewRepoMap.ts b/core/tools/definitions/viewRepoMap.ts index 0d1d94046..176855e2b 100644 --- a/core/tools/definitions/viewRepoMap.ts +++ b/core/tools/definitions/viewRepoMap.ts @@ -23,4 +23,5 @@ export const viewRepoMapTool: Tool = { prefix: `To view the repository map, use the ${BuiltInToolNames.ViewRepoMap} tool. This will provide a visual representation of the project's structure and organization.`, }, defaultToolPolicy: "allowedWithPermission", + toolCallIcon: "MapIcon", }; diff --git a/core/tools/definitions/viewSubdirectory.ts b/core/tools/definitions/viewSubdirectory.ts index 4ef686445..f8776716f 100644 --- a/core/tools/definitions/viewSubdirectory.ts +++ b/core/tools/definitions/viewSubdirectory.ts @@ -30,4 +30,5 @@ export const viewSubdirectoryTool: Tool = { exampleArgs: [["directory_path", "path/to/subdirectory"]], }, defaultToolPolicy: "allowedWithPermission", + toolCallIcon: "FolderOpenIcon", }; diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index 7f5b7e6e7..b9fa4777d 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -43,18 +43,6 @@ export function SimpleToolCallUI({ } } - function handleToggleClick() { - if (isToggleable) { - setOpen((prev) => !prev); - } - } - - function handleIconClick() { - if (isSingleItem) { - openContextItem(shownContextItems[0], ideMessenger); - } - } - return (
@@ -69,7 +57,6 @@ export function SimpleToolCallUI({ icon={Icon} isToggleable={isToggleable} open={shouldShowContent} - onClick={isToggleable ? handleToggleClick : handleIconClick} isClickable={isSingleItem} /> diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index fc5edf61f..40e5e8cd5 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -1,4 +1,7 @@ -import { ArrowRightIcon } from "@heroicons/react/24/outline"; +import { + ArrowRightIcon, + MagnifyingGlassIcon, +} from "@heroicons/react/24/outline"; import { ToolCallState } from "core"; import { BuiltInToolNames } from "core/tools/builtIn"; import { useState } from "react"; @@ -7,7 +10,7 @@ import FunctionSpecificToolCallDiv from "./FunctionSpecificToolCallDiv"; import { GroupedToolCallHeader } from "./GroupedToolCallHeader"; import { SimpleToolCallUI } from "./SimpleToolCallUI"; import { ToolCallDisplay } from "./ToolCallDisplay"; -import { getStatusIcon, toolCallIcons } from "./utils"; +import { getIconByName, getStatusIcon } from "./utils"; interface ToolCallDivProps { toolCallStates: ToolCallState[]; @@ -37,7 +40,10 @@ export function ToolCallDiv({ (tool) => toolCallState.toolCall.function?.name === tool.function.name, ); const functionName = toolCallState.toolCall.function?.name; - const icon = functionName && toolCallIcons[functionName]; + const icon = + functionName && tool?.toolCallIcon + ? getIconByName(tool.toolCallIcon) + : undefined; if (icon) { return ( diff --git a/gui/src/pages/gui/ToolCallDiv/utils.tsx b/gui/src/pages/gui/ToolCallDiv/utils.tsx index d5648b082..fe18123f4 100644 --- a/gui/src/pages/gui/ToolCallDiv/utils.tsx +++ b/gui/src/pages/gui/ToolCallDiv/utils.tsx @@ -1,25 +1,11 @@ -import { - ArrowRightIcon, - CheckIcon, - CodeBracketIcon, - DocumentIcon, - DocumentTextIcon, - FolderIcon, - FolderOpenIcon, - GlobeAltIcon, - MagnifyingGlassIcon, - MapIcon, - PencilIcon, - XMarkIcon, -} from "@heroicons/react/24/outline"; +import * as Icons from "@heroicons/react/24/outline"; import { ContextItem, ContextItemWithId, ToolCallState, ToolStatus, } from "core"; -import { BuiltInToolNames } from "core/tools/builtIn"; -import { ComponentType } from "react"; +import { ComponentType, SVGProps } from "react"; import { vscButtonBackground } from "../../../components"; import Spinner from "../../../components/gui/Spinner"; @@ -70,19 +56,16 @@ export function getGroupActionVerb(toolCallStates: ToolCallState[]): string { return "Performing"; } -export const toolCallIcons: Record = { - [BuiltInToolNames.FileGlobSearch]: MagnifyingGlassIcon, - [BuiltInToolNames.GrepSearch]: MagnifyingGlassIcon, - [BuiltInToolNames.LSTool]: FolderIcon, - [BuiltInToolNames.ReadCurrentlyOpenFile]: DocumentTextIcon, - [BuiltInToolNames.ReadFile]: DocumentIcon, - [BuiltInToolNames.FetchUrlContent]: GlobeAltIcon, - [BuiltInToolNames.SearchWeb]: GlobeAltIcon, - [BuiltInToolNames.ViewDiff]: CodeBracketIcon, - [BuiltInToolNames.ViewRepoMap]: MapIcon, - [BuiltInToolNames.ViewSubdirectory]: FolderOpenIcon, - [BuiltInToolNames.CreateRuleBlock]: PencilIcon, -}; +type IconName = keyof typeof Icons; + +type Icon = ComponentType> | undefined; + +export function getIconByName(name: string): Icon | null { + if (name in Icons) { + return Icons[name as IconName] as Icon; + } + return null; +} export function getStatusIcon(state: ToolStatus) { switch (state) { @@ -90,12 +73,12 @@ export function getStatusIcon(state: ToolStatus) { case "calling": return ; case "generated": - return ; + return ; case "done": - return ; + return ; case "canceled": case "errored": - return ; + return ; } }