From f5f28ca1bfbec2d09318b8396119155154a2554d Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sun, 20 Jul 2025 02:20:27 +0000 Subject: [PATCH] feat: update tool settings to show individual toggles dynamically - Remove grouped display of tools - Show all tools as individual toggles in a flat list - Make tool list dynamic based on global TOOL_GROUPS configuration - Separate disableable tools from always-available tools - Add translation for "Always available tools" section --- .../src/components/settings/ToolSettings.tsx | 111 +++++++++++++----- webview-ui/src/i18n/locales/en/settings.json | 3 +- 2 files changed, 81 insertions(+), 33 deletions(-) diff --git a/webview-ui/src/components/settings/ToolSettings.tsx b/webview-ui/src/components/settings/ToolSettings.tsx index 8899b0c2e6..cf5be5aaa1 100644 --- a/webview-ui/src/components/settings/ToolSettings.tsx +++ b/webview-ui/src/components/settings/ToolSettings.tsx @@ -13,6 +13,7 @@ type ToolSettingsProps = HTMLAttributes & { setCachedStateField: SetCachedStateField<"disabledTools"> } +// Import the constants from shared/tools.ts // Tool display names mapping const TOOL_DISPLAY_NAMES: Record = { execute_command: "Run commands", @@ -45,20 +46,30 @@ const ALWAYS_AVAILABLE_TOOLS = [ "update_todo_list", ] -// Tool groups for better organization -const TOOL_GROUPS = { - "File Operations": [ - "read_file", - "write_to_file", - "search_files", - "list_files", - "list_code_definition_names", - "codebase_search", - ], - "Code Editing": ["apply_diff", "insert_content", "search_and_replace"], - System: ["execute_command", "browser_action"], - MCP: ["use_mcp_tool", "access_mcp_resource"], - Other: ["fetch_instructions"], +// Tool groups configuration +const TOOL_GROUPS: Record = { + read: { + tools: [ + "read_file", + "fetch_instructions", + "search_files", + "list_files", + "list_code_definition_names", + "codebase_search", + ], + }, + edit: { + tools: ["apply_diff", "write_to_file", "insert_content", "search_and_replace"], + }, + browser: { + tools: ["browser_action"], + }, + command: { + tools: ["execute_command"], + }, + mcp: { + tools: ["use_mcp_tool", "access_mcp_resource"], + }, } export const ToolSettings = ({ disabledTools = [], setCachedStateField, ...props }: ToolSettingsProps) => { @@ -79,13 +90,35 @@ export const ToolSettings = ({ disabledTools = [], setCachedStateField, ...props const isToolEnabled = (toolName: string) => !disabledTools.includes(toolName) - const toolGroups = useMemo(() => { - return Object.entries(TOOL_GROUPS).map(([groupName, tools]) => ({ - name: groupName, - tools: tools.filter((tool) => !ALWAYS_AVAILABLE_TOOLS.includes(tool)), - })) + // Get all available tools dynamically from the global tools configuration + const allTools = useMemo(() => { + const tools = new Set() + + // Add all tools from tool groups + Object.values(TOOL_GROUPS).forEach((group) => { + group.tools.forEach((tool) => tools.add(tool)) + }) + + // Add always available tools + ALWAYS_AVAILABLE_TOOLS.forEach((tool) => tools.add(tool)) + + // Convert to array and sort alphabetically + return Array.from(tools).sort((a, b) => { + const nameA = TOOL_DISPLAY_NAMES[a as keyof typeof TOOL_DISPLAY_NAMES] || a + const nameB = TOOL_DISPLAY_NAMES[b as keyof typeof TOOL_DISPLAY_NAMES] || b + return nameA.localeCompare(nameB) + }) }, []) + // Separate tools into disableable and always-available + const disableableTools = useMemo(() => { + return allTools.filter((tool) => !ALWAYS_AVAILABLE_TOOLS.includes(tool as any)) + }, [allTools]) + + const alwaysAvailableTools = useMemo(() => { + return allTools.filter((tool) => ALWAYS_AVAILABLE_TOOLS.includes(tool as any)) + }, [allTools]) + return (
@@ -98,21 +131,35 @@ export const ToolSettings = ({ disabledTools = [], setCachedStateField, ...props
{t("settings:tools.description")}
-
- {toolGroups.map(({ name, tools }) => ( -
-

{name}

-
- {tools.map((tool) => ( - handleToolToggle(tool, e.target.checked)}> - {TOOL_DISPLAY_NAMES[tool] || tool} - - ))} +
+ {/* Disableable tools */} + {disableableTools.map((tool) => ( + handleToolToggle(tool, e.target.checked)}> + + {TOOL_DISPLAY_NAMES[tool as keyof typeof TOOL_DISPLAY_NAMES] || tool} + + + ))} + + {/* Separator */} + {alwaysAvailableTools.length > 0 && ( +
+
+ {t("settings:tools.alwaysAvailable")}
+ )} + + {/* Always available tools (disabled checkboxes) */} + {alwaysAvailableTools.map((tool) => ( + + + {TOOL_DISPLAY_NAMES[tool as keyof typeof TOOL_DISPLAY_NAMES] || tool} + + ))}
diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index 84ca8e79e1..cada31a2f7 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -722,6 +722,7 @@ "includeMaxOutputTokensDescription": "Send max output tokens parameter in API requests. Some providers may not support this.", "tools": { "description": "Disable specific tools to reduce token usage. Disabled tools won't be included in the system prompt.", - "note": "Note: Some tools are always available and cannot be disabled (ask questions, complete tasks, switch modes, create new task, update todo list)." + "note": "Note: Some tools are always available and cannot be disabled (ask questions, complete tasks, switch modes, create new task, update todo list).", + "alwaysAvailable": "Always available tools" } }