feat(ui): Improved tool list rendering and added category filtering

This commit is contained in:
2026-03-11 20:27:33 -04:00
parent 97ecd709a9
commit f21f22e48f

View File

@@ -89,7 +89,7 @@ class App:
"""The main ImGui interface orchestrator for Manual Slop."""
def __init__(self) -> None:
# Initialize controller and delegate state
# Initialize controller and delegate state
self.controller = app_controller.AppController()
# Restore legacy PROVIDERS to controller if needed (it already has it via delegation if set on class level, but let's be explicit)
if not hasattr(self.controller, 'PROVIDERS'):
@@ -189,6 +189,7 @@ class App:
self.ui_crt_filter = True
self._nerv_alert = theme_fx.AlertPulsing()
self._nerv_flicker = theme_fx.StatusFlicker()
self.ui_tool_filter_category = "All"
def _handle_approve_tool(self, user_data=None) -> None:
"""UI-level wrapper for approving a pending tool execution ask."""
@@ -1061,9 +1062,21 @@ class App:
imgui.dummy(imgui.ImVec2(0, 8))
imgui.text("Categories & Tools:")
cat_options = ["All"] + sorted(list(models.DEFAULT_TOOL_CATEGORIES.keys()))
try:
f_idx = cat_options.index(self.ui_tool_filter_category)
except ValueError:
f_idx = 0
imgui.set_next_item_width(200)
ch_cat, next_f_idx = imgui.combo("Filter Category##tp", f_idx, cat_options)
if ch_cat:
self.ui_tool_filter_category = cat_options[next_f_idx]
imgui.begin_child("tp_categories_scroll", imgui.ImVec2(0, 300), True)
try:
for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items():
if self.ui_tool_filter_category != "All" and self.ui_tool_filter_category != cat_name:
continue
if imgui.tree_node(cat_name):
if cat_name not in self._editing_tool_preset_categories:
self._editing_tool_preset_categories[cat_name] = []
@@ -1074,6 +1087,9 @@ class App:
tool = next((t for t in current_cat_tools if t.name == tool_name), None)
mode = "disabled" if tool is None else tool.approval
imgui.text(tool_name)
imgui.same_line(180)
if imgui.radio_button(f"Off##{cat_name}_{tool_name}", mode == "disabled"):
if tool: current_cat_tools.remove(tool)
imgui.same_line()
@@ -1090,11 +1106,9 @@ class App:
current_cat_tools.append(tool)
else:
tool.approval = "ask"
imgui.same_line()
imgui.text(tool_name)
if tool:
imgui.same_line(250)
imgui.same_line(350)
imgui.set_next_item_width(100)
_, tool.weight = imgui.slider_int(f"Weight##{cat_name}_{tool_name}", tool.weight, 1, 5)
imgui.same_line()
@@ -3752,11 +3766,24 @@ def hello():
ai_client.set_bias_profile(bname)
imgui.end_combo()
imgui.dummy(imgui.ImVec2(0, 8))
cat_options = ["All"] + sorted(list(models.DEFAULT_TOOL_CATEGORIES.keys()))
try:
f_idx = cat_options.index(self.ui_tool_filter_category)
except ValueError:
f_idx = 0
imgui.set_next_item_width(200)
ch_cat, next_f_idx = imgui.combo("Filter Category##agent", f_idx, cat_options)
if ch_cat:
self.ui_tool_filter_category = cat_options[next_f_idx]
imgui.dummy(imgui.ImVec2(0, 8))
active_name = self.ui_active_tool_preset
if active_name and active_name in presets:
preset = presets[active_name]
for cat_name, tools in preset.categories.items():
if self.ui_tool_filter_category != "All" and self.ui_tool_filter_category != cat_name:
continue
if imgui.tree_node(cat_name):
for tool in tools:
if tool.weight >= 5: