Changesets · Branches · Tags · Compare
| Changeset | bd508458c82fdd82f16d6143eada3bcfcc486e2f8263d2a8e56ff9c3ab96b7a7 |
|---|---|
| Author | xiaohuanxiong3 <39520495+xiaohuanxiong3@users.noreply.github.com> · 2025-09-17 03:51 +08:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-16 12:51 -07:00 |
| Parents | b19eeabf8837 |
16 files changed
modified core/index.d.ts +1 −0
| @@ -1099,6 +1099,7 @@ | ||
| 1099 | 1099 | exampleArgs?: Array<[string, string | number]>; |
| 1100 | 1100 | }; |
| 1101 | 1101 | defaultToolPolicy?: ToolPolicy; |
| 1102 | + toolCallIcon?: string; | |
| 1102 | 1103 | evaluateToolCallPolicy?: ( |
| 1103 | 1104 | basePolicy: ToolPolicy, |
| 1104 | 1105 | parsedArgs: Record<string, unknown>, |
modified core/tools/definitions/createRuleBlock.ts +1 −0
| @@ -84,4 +84,5 @@ | ||
| 84 | 84 | ["alwaysApply", "false"], |
| 85 | 85 | ], |
| 86 | 86 | }, |
| 87 | + toolCallIcon: "PencilIcon", | |
| 87 | 88 | }; |
modified core/tools/definitions/fetchUrlContent.ts +1 −0
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | 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:`, |
| 31 | 31 | exampleArgs: [["url", "https://example.com"]], |
| 32 | 32 | }, |
| 33 | + toolCallIcon: "GlobeAltIcon", | |
| 33 | 34 | }; |
modified core/tools/definitions/globSearch.ts +1 −0
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | prefix: `To return a list of files based on a glob search pattern, use the ${BuiltInToolNames.FileGlobSearch} tool`, |
| 31 | 31 | exampleArgs: [["pattern", "*.py"]], |
| 32 | 32 | }, |
| 33 | + toolCallIcon: "MagnifyingGlassIcon", | |
| 33 | 34 | }; |
modified core/tools/definitions/grepSearch.ts +1 −0
| @@ -31,4 +31,5 @@ | ||
| 31 | 31 | prefix: `To perform a grep search within the project, call the ${BuiltInToolNames.GrepSearch} tool with the query pattern to match. For example:`, |
| 32 | 32 | exampleArgs: [["query", ".*main_services.*"]], |
| 33 | 33 | }, |
| 34 | + toolCallIcon: "MagnifyingGlassIcon", | |
| 34 | 35 | }; |
modified core/tools/definitions/ls.ts +1 −0
| @@ -38,4 +38,5 @@ | ||
| 38 | 38 | ["recursive", "false"], |
| 39 | 39 | ], |
| 40 | 40 | }, |
| 41 | + toolCallIcon: "FolderIcon", | |
| 41 | 42 | }; |
modified core/tools/definitions/readCurrentlyOpenFile.ts +1 −0
| @@ -24,4 +24,5 @@ | ||
| 24 | 24 | prefix: `To view the user's currently open file, use the ${BuiltInToolNames.ReadCurrentlyOpenFile} tool. |
| 25 | 25 | If the user is asking about a file and you don't see any code, use this to check the current file`, |
| 26 | 26 | }, |
| 27 | + toolCallIcon: "DocumentTextIcon", | |
| 27 | 28 | }; |
modified core/tools/definitions/readFile.ts +1 −0
| @@ -31,4 +31,5 @@ | ||
| 31 | 31 | exampleArgs: [["filepath", "path/to/the_file.txt"]], |
| 32 | 32 | }, |
| 33 | 33 | defaultToolPolicy: "allowedWithoutPermission", |
| 34 | + toolCallIcon: "DocumentIcon", | |
| 34 | 35 | }; |
modified core/tools/definitions/readFileRange.ts +1 −0
| @@ -48,4 +48,5 @@ | ||
| 48 | 48 | ], |
| 49 | 49 | }, |
| 50 | 50 | defaultToolPolicy: "allowedWithoutPermission", |
| 51 | + toolCallIcon: "DocumentIcon", | |
| 51 | 52 | }; |
modified core/tools/definitions/searchWeb.ts +1 −0
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | 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:`, |
| 31 | 31 | exampleArgs: [["query", "What is the current weather in San Francisco?"]], |
| 32 | 32 | }, |
| 33 | + toolCallIcon: "GlobeAltIcon", | |
| 33 | 34 | }; |
modified core/tools/definitions/viewDiff.ts +1 −0
| @@ -23,4 +23,5 @@ | ||
| 23 | 23 | 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.`, |
| 24 | 24 | }, |
| 25 | 25 | defaultToolPolicy: "allowedWithoutPermission", |
| 26 | + toolCallIcon: "CodeBracketIcon", | |
| 26 | 27 | }; |
modified core/tools/definitions/viewRepoMap.ts +1 −0
| @@ -23,4 +23,5 @@ | ||
| 23 | 23 | prefix: `To view the repository map, use the ${BuiltInToolNames.ViewRepoMap} tool. This will provide a visual representation of the project's structure and organization.`, |
| 24 | 24 | }, |
| 25 | 25 | defaultToolPolicy: "allowedWithPermission", |
| 26 | + toolCallIcon: "MapIcon", | |
| 26 | 27 | }; |
modified core/tools/definitions/viewSubdirectory.ts +1 −0
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | exampleArgs: [["directory_path", "path/to/subdirectory"]], |
| 31 | 31 | }, |
| 32 | 32 | defaultToolPolicy: "allowedWithPermission", |
| 33 | + toolCallIcon: "FolderOpenIcon", | |
| 33 | 34 | }; |
modified gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +0 −13
| @@ -43,18 +43,6 @@ | ||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - function handleToggleClick() { | |
| 47 | - if (isToggleable) { | |
| 48 | - setOpen((prev) => !prev); | |
| 49 | - } | |
| 50 | - } | |
| 51 | - | |
| 52 | - function handleIconClick() { | |
| 53 | - if (isSingleItem) { | |
| 54 | - openContextItem(shownContextItems[0], ideMessenger); | |
| 55 | - } | |
| 56 | - } | |
| 57 | - | |
| 58 | 46 | return ( |
| 59 | 47 | <div className="mt-1 flex flex-col px-4"> |
| 60 | 48 | <div className="flex min-w-0 flex-row items-center justify-between gap-2"> |
| @@ -69,7 +57,6 @@ | ||
| 69 | 57 | icon={Icon} |
| 70 | 58 | isToggleable={isToggleable} |
| 71 | 59 | open={shouldShowContent} |
| 72 | - onClick={isToggleable ? handleToggleClick : handleIconClick} | |
| 73 | 60 | isClickable={isSingleItem} |
| 74 | 61 | /> |
| 75 | 62 | <ToolCallStatusMessage tool={tool} toolCallState={toolCallState} /> |
modified gui/src/pages/gui/ToolCallDiv/index.tsx +9 −3
| @@ -1,4 +1,7 @@ | ||
| 1 | -import { ArrowRightIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { | |
| 2 | + ArrowRightIcon, | |
| 3 | + MagnifyingGlassIcon, | |
| 4 | +} from "@heroicons/react/24/outline"; | |
| 2 | 5 | import { ToolCallState } from "core"; |
| 3 | 6 | import { BuiltInToolNames } from "core/tools/builtIn"; |
| 4 | 7 | import { useState } from "react"; |
| @@ -7,7 +10,7 @@ | ||
| 7 | 10 | import { GroupedToolCallHeader } from "./GroupedToolCallHeader"; |
| 8 | 11 | import { SimpleToolCallUI } from "./SimpleToolCallUI"; |
| 9 | 12 | import { ToolCallDisplay } from "./ToolCallDisplay"; |
| 10 | -import { getStatusIcon, toolCallIcons } from "./utils"; | |
| 13 | +import { getIconByName, getStatusIcon } from "./utils"; | |
| 11 | 14 | |
| 12 | 15 | interface ToolCallDivProps { |
| 13 | 16 | toolCallStates: ToolCallState[]; |
| @@ -37,7 +40,10 @@ | ||
| 37 | 40 | (tool) => toolCallState.toolCall.function?.name === tool.function.name, |
| 38 | 41 | ); |
| 39 | 42 | const functionName = toolCallState.toolCall.function?.name; |
| 40 | - const icon = functionName && toolCallIcons[functionName]; | |
| 43 | + const icon = | |
| 44 | + functionName && tool?.toolCallIcon | |
| 45 | + ? getIconByName(tool.toolCallIcon) | |
| 46 | + : undefined; | |
| 41 | 47 | |
| 42 | 48 | if (icon) { |
| 43 | 49 | return ( |
modified gui/src/pages/gui/ToolCallDiv/utils.tsx +15 −32
| @@ -1,25 +1,11 @@ | ||
| 1 | -import { | |
| 2 | - ArrowRightIcon, | |
| 3 | - CheckIcon, | |
| 4 | - CodeBracketIcon, | |
| 5 | - DocumentIcon, | |
| 6 | - DocumentTextIcon, | |
| 7 | - FolderIcon, | |
| 8 | - FolderOpenIcon, | |
| 9 | - GlobeAltIcon, | |
| 10 | - MagnifyingGlassIcon, | |
| 11 | - MapIcon, | |
| 12 | - PencilIcon, | |
| 13 | - XMarkIcon, | |
| 14 | -} from "@heroicons/react/24/outline"; | |
| 1 | +import * as Icons from "@heroicons/react/24/outline"; | |
| 15 | 2 | import { |
| 16 | 3 | ContextItem, |
| 17 | 4 | ContextItemWithId, |
| 18 | 5 | ToolCallState, |
| 19 | 6 | ToolStatus, |
| 20 | 7 | } from "core"; |
| 21 | -import { BuiltInToolNames } from "core/tools/builtIn"; | |
| 22 | -import { ComponentType } from "react"; | |
| 8 | +import { ComponentType, SVGProps } from "react"; | |
| 23 | 9 | import { vscButtonBackground } from "../../../components"; |
| 24 | 10 | import Spinner from "../../../components/gui/Spinner"; |
| 25 | 11 | |
| @@ -70,19 +56,16 @@ | ||
| 70 | 56 | return "Performing"; |
| 71 | 57 | } |
| 72 | 58 | |
| 73 | -export const toolCallIcons: Record<string, ComponentType> = { | |
| 74 | - [BuiltInToolNames.FileGlobSearch]: MagnifyingGlassIcon, | |
| 75 | - [BuiltInToolNames.GrepSearch]: MagnifyingGlassIcon, | |
| 76 | - [BuiltInToolNames.LSTool]: FolderIcon, | |
| 77 | - [BuiltInToolNames.ReadCurrentlyOpenFile]: DocumentTextIcon, | |
| 78 | - [BuiltInToolNames.ReadFile]: DocumentIcon, | |
| 79 | - [BuiltInToolNames.FetchUrlContent]: GlobeAltIcon, | |
| 80 | - [BuiltInToolNames.SearchWeb]: GlobeAltIcon, | |
| 81 | - [BuiltInToolNames.ViewDiff]: CodeBracketIcon, | |
| 82 | - [BuiltInToolNames.ViewRepoMap]: MapIcon, | |
| 83 | - [BuiltInToolNames.ViewSubdirectory]: FolderOpenIcon, | |
| 84 | - [BuiltInToolNames.CreateRuleBlock]: PencilIcon, | |
| 85 | -}; | |
| 59 | +type IconName = keyof typeof Icons; | |
| 60 | + | |
| 61 | +type Icon = ComponentType<SVGProps<SVGSVGElement>> | undefined; | |
| 62 | + | |
| 63 | +export function getIconByName(name: string): Icon | null { | |
| 64 | + if (name in Icons) { | |
| 65 | + return Icons[name as IconName] as Icon; | |
| 66 | + } | |
| 67 | + return null; | |
| 68 | +} | |
| 86 | 69 | |
| 87 | 70 | export function getStatusIcon(state: ToolStatus) { |
| 88 | 71 | switch (state) { |
| @@ -90,12 +73,12 @@ | ||
| 90 | 73 | case "calling": |
| 91 | 74 | return <Spinner />; |
| 92 | 75 | case "generated": |
| 93 | - return <ArrowRightIcon color={vscButtonBackground} />; | |
| 76 | + return <Icons.ArrowRightIcon color={vscButtonBackground} />; | |
| 94 | 77 | case "done": |
| 95 | - return <CheckIcon className="text-success" />; | |
| 78 | + return <Icons.CheckIcon className="text-success" />; | |
| 96 | 79 | case "canceled": |
| 97 | 80 | case "errored": |
| 98 | - return <XMarkIcon className="text-error" />; | |
| 81 | + return <Icons.XMarkIcon className="text-error" />; | |
| 99 | 82 | } |
| 100 | 83 | } |
| 101 | 84 |