fix(gui): fix tool presets and biases panel and cache analytics section layout
This commit is contained in:
110
src/gui_2.py
110
src/gui_2.py
@@ -2483,9 +2483,7 @@ def hello():
|
|||||||
if self.current_provider != "gemini":
|
if self.current_provider != "gemini":
|
||||||
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_cache_panel")
|
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_cache_panel")
|
||||||
return
|
return
|
||||||
if not imgui.collapsing_header("Cache Analytics"):
|
imgui.text_colored(C_LBL, 'Cache Analytics')
|
||||||
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_cache_panel")
|
|
||||||
return
|
|
||||||
stats = getattr(self.controller, '_cached_cache_stats', {})
|
stats = getattr(self.controller, '_cached_cache_stats', {})
|
||||||
if not stats.get("cache_exists"):
|
if not stats.get("cache_exists"):
|
||||||
imgui.text_disabled("No active cache")
|
imgui.text_disabled("No active cache")
|
||||||
@@ -3664,58 +3662,70 @@ def hello():
|
|||||||
def _render_agent_tools_panel(self) -> None:
|
def _render_agent_tools_panel(self) -> None:
|
||||||
if imgui.collapsing_header("Active Tool Presets & Biases", imgui.TreeNodeFlags_.default_open):
|
if imgui.collapsing_header("Active Tool Presets & Biases", imgui.TreeNodeFlags_.default_open):
|
||||||
imgui.text("Tool Preset")
|
imgui.text("Tool Preset")
|
||||||
presets = self.controller.tool_presets
|
presets = self.controller.tool_presets
|
||||||
preset_names = [""] + sorted(list(presets.keys()))
|
preset_names = [""] + sorted(list(presets.keys()))
|
||||||
|
|
||||||
# Gracefully handle None or missing preset
|
active = getattr(self, "ui_active_tool_preset", "")
|
||||||
active = getattr(self, "ui_active_tool_preset", "")
|
if active is None: active = ""
|
||||||
if active is None: active = ""
|
try:
|
||||||
try:
|
idx = preset_names.index(active)
|
||||||
idx = preset_names.index(active)
|
except ValueError:
|
||||||
except ValueError:
|
idx = 0
|
||||||
idx = 0
|
|
||||||
|
|
||||||
ch, new_idx = imgui.combo("##tool_preset_select", idx, preset_names)
|
ch, new_idx = imgui.combo("##tool_preset_select", idx, preset_names)
|
||||||
if ch:
|
if ch:
|
||||||
self.ui_active_tool_preset = preset_names[new_idx]
|
self.ui_active_tool_preset = preset_names[new_idx]
|
||||||
|
|
||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
if imgui.button("Manage Presets##tools"):
|
if imgui.button("Manage Presets##tools"):
|
||||||
self.show_tool_preset_manager_window = True
|
self.show_tool_preset_manager_window = True
|
||||||
if imgui.is_item_hovered():
|
if imgui.is_item_hovered():
|
||||||
imgui.set_tooltip("Configure tool availability and default modes.")
|
imgui.set_tooltip("Configure tool availability and default modes.")
|
||||||
|
|
||||||
imgui.dummy(imgui.ImVec2(0, 8))
|
imgui.dummy(imgui.ImVec2(0, 4))
|
||||||
active_name = self.ui_active_tool_preset
|
imgui.text("Bias Profile")
|
||||||
if active_name and active_name in presets:
|
if imgui.begin_combo("##bias", getattr(self, 'ui_active_bias_profile', "") or "None"):
|
||||||
preset = presets[active_name]
|
if imgui.selectable("None", not getattr(self, 'ui_active_bias_profile', ""))[0]:
|
||||||
for cat_name, tools in preset.categories.items():
|
self.ui_active_bias_profile = ""
|
||||||
if imgui.tree_node(cat_name):
|
from src import ai_client
|
||||||
for tool in tools:
|
ai_client.set_bias_profile(None)
|
||||||
if tool.weight >= 5:
|
for bname in sorted(self.controller.bias_profiles.keys()):
|
||||||
imgui.text_colored(vec4(255, 100, 100), "[HIGH]")
|
if imgui.selectable(bname, bname == getattr(self, 'ui_active_bias_profile', ""))[0]:
|
||||||
|
self.ui_active_bias_profile = bname
|
||||||
|
from src import ai_client
|
||||||
|
ai_client.set_bias_profile(bname)
|
||||||
|
imgui.end_combo()
|
||||||
|
|
||||||
|
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 imgui.tree_node(cat_name):
|
||||||
|
for tool in tools:
|
||||||
|
if tool.weight >= 5:
|
||||||
|
imgui.text_colored(vec4(255, 100, 100), "[HIGH]")
|
||||||
|
imgui.same_line()
|
||||||
|
elif tool.weight == 4:
|
||||||
|
imgui.text_colored(vec4(255, 255, 100), "[PREF]")
|
||||||
|
imgui.same_line()
|
||||||
|
elif tool.weight == 2:
|
||||||
|
imgui.text_colored(vec4(255, 150, 50), "[REJECT]")
|
||||||
|
imgui.same_line()
|
||||||
|
elif tool.weight <= 1:
|
||||||
|
imgui.text_colored(vec4(180, 180, 180), "[LOW]")
|
||||||
|
imgui.same_line()
|
||||||
|
|
||||||
|
imgui.text(tool.name)
|
||||||
|
imgui.same_line(180)
|
||||||
|
|
||||||
|
mode = tool.approval
|
||||||
|
if imgui.radio_button(f"Auto##{cat_name}_{tool.name}", mode == "auto"):
|
||||||
|
tool.approval = "auto"
|
||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
elif tool.weight == 4:
|
if imgui.radio_button(f"Ask##{cat_name}_{tool.name}", mode == "ask"):
|
||||||
imgui.text_colored(vec4(255, 255, 100), "[PREF]")
|
tool.approval = "ask"
|
||||||
imgui.same_line()
|
imgui.tree_pop()
|
||||||
elif tool.weight == 2:
|
|
||||||
imgui.text_colored(vec4(255, 150, 50), "[REJECT]")
|
|
||||||
imgui.same_line()
|
|
||||||
elif tool.weight <= 1:
|
|
||||||
imgui.text_colored(vec4(180, 180, 180), "[LOW]")
|
|
||||||
imgui.same_line()
|
|
||||||
|
|
||||||
imgui.text(tool.name)
|
|
||||||
imgui.same_line(180)
|
|
||||||
|
|
||||||
mode = tool.approval
|
|
||||||
if imgui.radio_button(f"Auto##{cat_name}_{tool.name}", mode == "auto"):
|
|
||||||
tool.approval = "auto"
|
|
||||||
imgui.same_line()
|
|
||||||
if imgui.radio_button(f"Ask##{cat_name}_{tool.name}", mode == "ask"):
|
|
||||||
tool.approval = "ask"
|
|
||||||
imgui.tree_pop()
|
|
||||||
|
|
||||||
def _render_theme_panel(self) -> None:
|
def _render_theme_panel(self) -> None:
|
||||||
if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_theme_panel")
|
if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_theme_panel")
|
||||||
exp, opened = imgui.begin("Theme", self.show_windows["Theme"])
|
exp, opened = imgui.begin("Theme", self.show_windows["Theme"])
|
||||||
|
|||||||
Reference in New Issue
Block a user