feat: move tool icon names to tool definitions (#7322)

* feat: Adding the isExecutionResultSearchable property to the Tool indicates whether the tool indicates whether the result is inspectable
fix: 移除 SimpleToolCallUI 中 ToggleWithIcon 重复的 onClick 函数

* feat: Adding the isExecutionResultSearchable property to the Tool indicates whether the tool's execution results are checkable
fix: 移除 SimpleToolCallUI 中 ToggleWithIcon 重复的 onClick 函数

* fix: cleanup file security pr

* fix: ignore .idea etc.

* fix: move .continue from security to indexing ignore

* fix: move ide dirs and venv dirs to indexing not security ignores

* feat: remove isExecutionResultSearchable from Tool

* feat: prettier

---------

Co-authored-by: Dallin Romney <dallinromney@gmail.com>
This commit is contained in:
xiaohuanxiong3 2025-09-17 03:51:41 +08:00 • committed by GitHub
parent 5852de31b4
commit acbba9c6d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 37 additions and 48 deletions

1
core/index.d.ts vendored
View file

@ -1099,6 +1099,7 @@ export interface Tool {
exampleArgs?: Array<[string, string | number]>;
};
defaultToolPolicy?: ToolPolicy;
toolCallIcon?: string;
evaluateToolCallPolicy?: (
basePolicy: ToolPolicy,
parsedArgs: Record<string, unknown>,

View file

@ -84,4 +84,5 @@ For example:`,
["alwaysApply", "false"],
],
},
toolCallIcon: "PencilIcon",
};

View file

@ -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",
};

View file

@ -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",
};

View file

@ -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",
};

View file

@ -38,4 +38,5 @@ export const lsTool: Tool = {
["recursive", "false"],
],
},
toolCallIcon: "FolderIcon",
};

View file

@ -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",
};

View file

@ -31,4 +31,5 @@ export const readFileTool: Tool = {
exampleArgs: [["filepath", "path/to/the_file.txt"]],
},
defaultToolPolicy: "allowedWithoutPermission",
toolCallIcon: "DocumentIcon",
};

View file

@ -48,4 +48,5 @@ export const readFileRangeTool: Tool = {
],
},
defaultToolPolicy: "allowedWithoutPermission",
toolCallIcon: "DocumentIcon",
};

View file

@ -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",
};

View file

@ -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",
};

View file

@ -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",
};

View file

@ -30,4 +30,5 @@ export const viewSubdirectoryTool: Tool = {
exampleArgs: [["directory_path", "path/to/subdirectory"]],
},
defaultToolPolicy: "allowedWithPermission",
toolCallIcon: "FolderOpenIcon",
};

View file

@ -43,18 +43,6 @@ export function SimpleToolCallUI({
}
}
function handleToggleClick() {
if (isToggleable) {
setOpen((prev) => !prev);
}
}
function handleIconClick() {
if (isSingleItem) {
openContextItem(shownContextItems[0], ideMessenger);
}
}
return (
<div className="mt-1 flex flex-col px-4">
<div className="flex min-w-0 flex-row items-center justify-between gap-2">
@ -69,7 +57,6 @@ export function SimpleToolCallUI({
icon={Icon}
isToggleable={isToggleable}
open={shouldShowContent}
onClick={isToggleable ? handleToggleClick : handleIconClick}
isClickable={isSingleItem}
/>
<ToolCallStatusMessage tool={tool} toolCallState={toolCallState} />

View file

@ -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 (

View file

@ -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<string, ComponentType> = {
[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<SVGProps<SVGSVGElement>> | 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 <Spinner />;
case "generated":
return <ArrowRightIcon color={vscButtonBackground} />;
return <Icons.ArrowRightIcon color={vscButtonBackground} />;
case "done":
return <CheckIcon className="text-success" />;
return <Icons.CheckIcon className="text-success" />;
case "canceled":
case "errored":
return <XMarkIcon className="text-error" />;
return <Icons.XMarkIcon className="text-error" />;
}
}