Elffuss BraidHub

kikocis/continue public

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>
Changesetbd508458c82fdd82f16d6143eada3bcfcc486e2f8263d2a8e56ff9c3ab96b7a7
Authorxiaohuanxiong3 <39520495+xiaohuanxiong3@users.noreply.github.com> · 2025-09-17 03:51 +08:00
CommitterGitHub <noreply@github.com> · 2025-09-16 12:51 -07:00
Parentsb19eeabf8837

Browse the files at this changeset

16 files changed

modified core/index.d.ts +1 −0
@@ -1099,6 +1099,7 @@
10991099 exampleArgs?: Array<[string, string | number]>;
11001100 };
11011101 defaultToolPolicy?: ToolPolicy;
1102+ toolCallIcon?: string;
11021103 evaluateToolCallPolicy?: (
11031104 basePolicy: ToolPolicy,
11041105 parsedArgs: Record<string, unknown>,
modified core/tools/definitions/createRuleBlock.ts +1 −0
@@ -84,4 +84,5 @@
8484 ["alwaysApply", "false"],
8585 ],
8686 },
87+ toolCallIcon: "PencilIcon",
8788 };
modified core/tools/definitions/fetchUrlContent.ts +1 −0
@@ -30,4 +30,5 @@
3030 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:`,
3131 exampleArgs: [["url", "https://example.com"]],
3232 },
33+ toolCallIcon: "GlobeAltIcon",
3334 };
modified core/tools/definitions/globSearch.ts +1 −0
@@ -30,4 +30,5 @@
3030 prefix: `To return a list of files based on a glob search pattern, use the ${BuiltInToolNames.FileGlobSearch} tool`,
3131 exampleArgs: [["pattern", "*.py"]],
3232 },
33+ toolCallIcon: "MagnifyingGlassIcon",
3334 };
modified core/tools/definitions/grepSearch.ts +1 −0
@@ -31,4 +31,5 @@
3131 prefix: `To perform a grep search within the project, call the ${BuiltInToolNames.GrepSearch} tool with the query pattern to match. For example:`,
3232 exampleArgs: [["query", ".*main_services.*"]],
3333 },
34+ toolCallIcon: "MagnifyingGlassIcon",
3435 };
modified core/tools/definitions/ls.ts +1 −0
@@ -38,4 +38,5 @@
3838 ["recursive", "false"],
3939 ],
4040 },
41+ toolCallIcon: "FolderIcon",
4142 };
modified core/tools/definitions/readCurrentlyOpenFile.ts +1 −0
@@ -24,4 +24,5 @@
2424 prefix: `To view the user's currently open file, use the ${BuiltInToolNames.ReadCurrentlyOpenFile} tool.
2525 If the user is asking about a file and you don't see any code, use this to check the current file`,
2626 },
27+ toolCallIcon: "DocumentTextIcon",
2728 };
modified core/tools/definitions/readFile.ts +1 −0
@@ -31,4 +31,5 @@
3131 exampleArgs: [["filepath", "path/to/the_file.txt"]],
3232 },
3333 defaultToolPolicy: "allowedWithoutPermission",
34+ toolCallIcon: "DocumentIcon",
3435 };
modified core/tools/definitions/readFileRange.ts +1 −0
@@ -48,4 +48,5 @@
4848 ],
4949 },
5050 defaultToolPolicy: "allowedWithoutPermission",
51+ toolCallIcon: "DocumentIcon",
5152 };
modified core/tools/definitions/searchWeb.ts +1 −0
@@ -30,4 +30,5 @@
3030 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:`,
3131 exampleArgs: [["query", "What is the current weather in San Francisco?"]],
3232 },
33+ toolCallIcon: "GlobeAltIcon",
3334 };
modified core/tools/definitions/viewDiff.ts +1 −0
@@ -23,4 +23,5 @@
2323 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.`,
2424 },
2525 defaultToolPolicy: "allowedWithoutPermission",
26+ toolCallIcon: "CodeBracketIcon",
2627 };
modified core/tools/definitions/viewRepoMap.ts +1 −0
@@ -23,4 +23,5 @@
2323 prefix: `To view the repository map, use the ${BuiltInToolNames.ViewRepoMap} tool. This will provide a visual representation of the project's structure and organization.`,
2424 },
2525 defaultToolPolicy: "allowedWithPermission",
26+ toolCallIcon: "MapIcon",
2627 };
modified core/tools/definitions/viewSubdirectory.ts +1 −0
@@ -30,4 +30,5 @@
3030 exampleArgs: [["directory_path", "path/to/subdirectory"]],
3131 },
3232 defaultToolPolicy: "allowedWithPermission",
33+ toolCallIcon: "FolderOpenIcon",
3334 };
modified gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +0 −13
@@ -43,18 +43,6 @@
4343 }
4444 }
4545
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-
5846 return (
5947 <div className="mt-1 flex flex-col px-4">
6048 <div className="flex min-w-0 flex-row items-center justify-between gap-2">
@@ -69,7 +57,6 @@
6957 icon={Icon}
7058 isToggleable={isToggleable}
7159 open={shouldShowContent}
72- onClick={isToggleable ? handleToggleClick : handleIconClick}
7360 isClickable={isSingleItem}
7461 />
7562 <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";
25 import { ToolCallState } from "core";
36 import { BuiltInToolNames } from "core/tools/builtIn";
47 import { useState } from "react";
@@ -7,7 +10,7 @@
710 import { GroupedToolCallHeader } from "./GroupedToolCallHeader";
811 import { SimpleToolCallUI } from "./SimpleToolCallUI";
912 import { ToolCallDisplay } from "./ToolCallDisplay";
10-import { getStatusIcon, toolCallIcons } from "./utils";
13+import { getIconByName, getStatusIcon } from "./utils";
1114
1215 interface ToolCallDivProps {
1316 toolCallStates: ToolCallState[];
@@ -37,7 +40,10 @@
3740 (tool) => toolCallState.toolCall.function?.name === tool.function.name,
3841 );
3942 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;
4147
4248 if (icon) {
4349 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";
152 import {
163 ContextItem,
174 ContextItemWithId,
185 ToolCallState,
196 ToolStatus,
207 } from "core";
21-import { BuiltInToolNames } from "core/tools/builtIn";
22-import { ComponentType } from "react";
8+import { ComponentType, SVGProps } from "react";
239 import { vscButtonBackground } from "../../../components";
2410 import Spinner from "../../../components/gui/Spinner";
2511
@@ -70,19 +56,16 @@
7056 return "Performing";
7157 }
7258
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+}
8669
8770 export function getStatusIcon(state: ToolStatus) {
8871 switch (state) {
@@ -90,12 +73,12 @@
9073 case "calling":
9174 return <Spinner />;
9275 case "generated":
93- return <ArrowRightIcon color={vscButtonBackground} />;
76+ return <Icons.ArrowRightIcon color={vscButtonBackground} />;
9477 case "done":
95- return <CheckIcon className="text-success" />;
78+ return <Icons.CheckIcon className="text-success" />;
9679 case "canceled":
9780 case "errored":
98- return <XMarkIcon className="text-error" />;
81+ return <Icons.XMarkIcon className="text-error" />;
9982 }
10083 }
10184