fix(gui): Ensure all tools are visible in Tool Preset Manager

This commit is contained in:
2026-03-10 01:30:11 -04:00
parent dcc13efaf7
commit f213d37287
3 changed files with 55 additions and 12 deletions

View File

@@ -0,0 +1,12 @@
prompt = """
In src/gui_2.py, modify 'App._render_tool_preset_manager_modal':
1. Instead of iterating over 'self._editing_tool_preset_categories.items()', iterate over 'models.DEFAULT_TOOL_CATEGORIES.items()'.
2. For each category and each tool in that category:
- Check if the tool exists in 'self._editing_tool_preset_categories[cat_name]'.
- Determine the current mode: "disabled" (not present), "auto", or "ask".
- Show three radio buttons: "Disabled", "Auto", "Ask".
- If "Disabled" is selected, remove the tool from 'self._editing_tool_preset_categories[cat_name]'.
- If "Auto" or "Ask" is selected, update 'self._editing_tool_preset_categories[cat_name][tool_name]' accordingly.
- Ensure 'self._editing_tool_preset_categories' is initialized with nested dicts for all categories from 'models.DEFAULT_TOOL_CATEGORIES' when 'New Tool Preset' is clicked or a preset is selected.
Use 1-space indentation.
"""

View File

@@ -997,7 +997,7 @@ class App:
try:
if imgui.button("New Tool Preset", imgui.ImVec2(-1, 0)):
self._editing_tool_preset_name = ""
self._editing_tool_preset_categories = {}
self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
self._editing_tool_preset_scope = "project"
self._selected_tool_preset_idx = -1
if imgui.is_item_hovered():
@@ -1011,7 +1011,9 @@ class App:
self._selected_tool_preset_idx = i
self._editing_tool_preset_name = name
preset = self.controller.tool_presets[name]
self._editing_tool_preset_categories = copy.deepcopy(preset.categories)
self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
for cat, tools in preset.categories.items():
self._editing_tool_preset_categories[cat] = copy.deepcopy(tools)
finally:
imgui.end_child()
@@ -1040,22 +1042,31 @@ class App:
imgui.text("Categories & Tools:")
imgui.begin_child("tp_categories_scroll", imgui.ImVec2(0, -40), True)
try:
for cat_name, tools in self._editing_tool_preset_categories.items():
for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items():
if imgui.tree_node(cat_name):
for tool_name, config in tools.items():
# config can be a string ("auto", "ask") or a dict {"mode": "auto"}
if cat_name not in self._editing_tool_preset_categories:
self._editing_tool_preset_categories[cat_name] = {}
current_cat_tools = self._editing_tool_preset_categories[cat_name]
for tool_name in default_tools:
# Determine current mode: disabled (not present), auto, or ask
if tool_name not in current_cat_tools:
mode = "disabled"
else:
config = current_cat_tools[tool_name]
if isinstance(config, dict):
mode = config.get("mode", "auto")
else:
mode = str(config)
if imgui.radio_button(f"Disabled##{cat_name}_{tool_name}", mode == "disabled"):
if tool_name in current_cat_tools:
del current_cat_tools[tool_name]
imgui.same_line()
if imgui.radio_button(f"Auto##{cat_name}_{tool_name}", mode == "auto"):
if isinstance(config, dict): config["mode"] = "auto"
else: tools[tool_name] = "auto"
current_cat_tools[tool_name] = "auto"
imgui.same_line()
if imgui.radio_button(f"Ask##{cat_name}_{tool_name}", mode == "ask"):
if isinstance(config, dict): config["mode"] = "ask"
else: tools[tool_name] = "ask"
current_cat_tools[tool_name] = "ask"
imgui.same_line()
imgui.text(tool_name)
imgui.tree_pop()

View File

@@ -79,6 +79,26 @@ AGENT_TOOL_NAMES = [
"py_get_hierarchy"
]
DEFAULT_TOOL_CATEGORIES: Dict[str, List[str]] = {
"General": ["read_file", "list_directory", "search_files", "get_tree", "get_file_summary"],
"Python": [
"py_get_skeleton",
"py_get_code_outline",
"py_get_definition",
"py_get_signature",
"py_get_class_summary",
"py_get_var_declaration",
"py_get_docstring",
"py_update_definition",
"py_set_signature",
"py_set_var_declaration"
],
"Surgical": ["get_file_slice", "set_file_slice", "edit_file"],
"Web": ["web_search", "fetch_url"],
"Analysis": ["py_find_usages", "py_get_imports", "py_check_syntax", "py_get_hierarchy"],
"Runtime": ["run_powershell", "get_ui_performance"]
}
def parse_history_entries(history_strings: list[str], roles: list[str]) -> list[dict[str, Any]]:
import re
entries = []