feat(ui): Improved tool list rendering and added category filtering
This commit is contained in:
35
src/gui_2.py
35
src/gui_2.py
@@ -89,7 +89,7 @@ class App:
|
|||||||
"""The main ImGui interface orchestrator for Manual Slop."""
|
"""The main ImGui interface orchestrator for Manual Slop."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Initialize controller and delegate state
|
# Initialize controller and delegate state
|
||||||
self.controller = app_controller.AppController()
|
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)
|
# 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'):
|
if not hasattr(self.controller, 'PROVIDERS'):
|
||||||
@@ -189,6 +189,7 @@ class App:
|
|||||||
self.ui_crt_filter = True
|
self.ui_crt_filter = True
|
||||||
self._nerv_alert = theme_fx.AlertPulsing()
|
self._nerv_alert = theme_fx.AlertPulsing()
|
||||||
self._nerv_flicker = theme_fx.StatusFlicker()
|
self._nerv_flicker = theme_fx.StatusFlicker()
|
||||||
|
self.ui_tool_filter_category = "All"
|
||||||
|
|
||||||
def _handle_approve_tool(self, user_data=None) -> None:
|
def _handle_approve_tool(self, user_data=None) -> None:
|
||||||
"""UI-level wrapper for approving a pending tool execution ask."""
|
"""UI-level wrapper for approving a pending tool execution ask."""
|
||||||
@@ -1061,9 +1062,21 @@ class App:
|
|||||||
imgui.dummy(imgui.ImVec2(0, 8))
|
imgui.dummy(imgui.ImVec2(0, 8))
|
||||||
|
|
||||||
imgui.text("Categories & Tools:")
|
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)
|
imgui.begin_child("tp_categories_scroll", imgui.ImVec2(0, 300), True)
|
||||||
try:
|
try:
|
||||||
for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items():
|
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 imgui.tree_node(cat_name):
|
||||||
if cat_name not in self._editing_tool_preset_categories:
|
if cat_name not in self._editing_tool_preset_categories:
|
||||||
self._editing_tool_preset_categories[cat_name] = []
|
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)
|
tool = next((t for t in current_cat_tools if t.name == tool_name), None)
|
||||||
mode = "disabled" if tool is None else tool.approval
|
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 imgui.radio_button(f"Off##{cat_name}_{tool_name}", mode == "disabled"):
|
||||||
if tool: current_cat_tools.remove(tool)
|
if tool: current_cat_tools.remove(tool)
|
||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
@@ -1090,11 +1106,9 @@ class App:
|
|||||||
current_cat_tools.append(tool)
|
current_cat_tools.append(tool)
|
||||||
else:
|
else:
|
||||||
tool.approval = "ask"
|
tool.approval = "ask"
|
||||||
imgui.same_line()
|
|
||||||
imgui.text(tool_name)
|
|
||||||
|
|
||||||
if tool:
|
if tool:
|
||||||
imgui.same_line(250)
|
imgui.same_line(350)
|
||||||
imgui.set_next_item_width(100)
|
imgui.set_next_item_width(100)
|
||||||
_, tool.weight = imgui.slider_int(f"Weight##{cat_name}_{tool_name}", tool.weight, 1, 5)
|
_, tool.weight = imgui.slider_int(f"Weight##{cat_name}_{tool_name}", tool.weight, 1, 5)
|
||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
@@ -3752,11 +3766,24 @@ def hello():
|
|||||||
ai_client.set_bias_profile(bname)
|
ai_client.set_bias_profile(bname)
|
||||||
imgui.end_combo()
|
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))
|
imgui.dummy(imgui.ImVec2(0, 8))
|
||||||
active_name = self.ui_active_tool_preset
|
active_name = self.ui_active_tool_preset
|
||||||
if active_name and active_name in presets:
|
if active_name and active_name in presets:
|
||||||
preset = presets[active_name]
|
preset = presets[active_name]
|
||||||
for cat_name, tools in preset.categories.items():
|
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):
|
if imgui.tree_node(cat_name):
|
||||||
for tool in tools:
|
for tool in tools:
|
||||||
if tool.weight >= 5:
|
if tool.weight >= 5:
|
||||||
|
|||||||
Reference in New Issue
Block a user