fix(conductor): Resolve FileExistsError and harden Preset Manager modal

This commit is contained in:
2026-03-09 22:59:22 -04:00
parent 451d19126f
commit 178a694e2a
7 changed files with 110 additions and 84 deletions

View File

@@ -409,13 +409,13 @@ class App:
if exp:
if imgui.collapsing_header("Provider & Model"):
self._render_provider_panel()
if imgui.collapsing_header("System Prompts"):
self._render_system_prompts_panel()
if imgui.collapsing_header("Token Budget"):
self._render_token_budget_panel()
self._render_cache_panel()
self._render_tool_analytics_panel()
self._render_session_insights_panel()
if imgui.collapsing_header("System Prompts"):
self._render_system_prompts_panel()
imgui.end()
if self.show_windows.get("MMA Dashboard", False):
@@ -864,81 +864,89 @@ class App:
def _render_preset_manager_modal(self) -> None:
if not self.show_preset_manager_modal: return
imgui.open_popup("Preset Manager")
if imgui.begin_popup_modal("Preset Manager", True, imgui.WindowFlags_.always_auto_resize)[0]:
imgui.begin_child("preset_list_area", imgui.ImVec2(250, 600), True)
preset_names = sorted(self.controller.presets.keys())
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
self._editing_preset_name = ""
self._editing_preset_content = ""
self._editing_preset_temperature = 0.0
self._editing_preset_top_p = 1.0
self._editing_preset_max_output_tokens = 4096
self._editing_preset_scope = "project"
self._editing_preset_is_new = True
imgui.separator()
for name in preset_names:
p = self.controller.presets[name]
is_sel = (name == self._editing_preset_name)
if imgui.selectable(name, is_sel)[0]:
self._editing_preset_name = name
self._editing_preset_content = p.system_prompt
self._editing_preset_temperature = p.temperature if p.temperature is not None else 0.0
self._editing_preset_top_p = p.top_p if p.top_p is not None else 1.0
self._editing_preset_max_output_tokens = p.max_output_tokens if p.max_output_tokens is not None else 4096
self._editing_preset_is_new = False
imgui.end_child()
imgui.same_line()
imgui.begin_child("preset_edit_area", imgui.ImVec2(500, 600), False)
p_name = self._editing_preset_name or "(New Preset)"
imgui.text_colored(C_IN, f"Editing Preset: {p_name}")
imgui.separator()
imgui.text("Name:")
_, self._editing_preset_name = imgui.input_text("##edit_name", self._editing_preset_name)
imgui.text("Scope:")
if imgui.radio_button("Global", self._editing_preset_scope == "global"):
self._editing_preset_scope = "global"
imgui.same_line()
if imgui.radio_button("Project", self._editing_preset_scope == "project"):
self._editing_preset_scope = "project"
imgui.text("Content:")
_, self._editing_preset_content = imgui.input_text_multiline("##edit_content", self._editing_preset_content, imgui.ImVec2(-1, 280))
imgui.text("Temperature:")
_, self._editing_preset_temperature = imgui.input_float("##edit_temp", self._editing_preset_temperature, 0.1, 1.0, "%.2f")
imgui.text("Top P:")
_, self._editing_preset_top_p = imgui.input_float("##edit_top_p", self._editing_preset_top_p, 0.1, 1.0, "%.2f")
imgui.text("Max Output Tokens:")
_, self._editing_preset_max_output_tokens = imgui.input_int("##edit_max_tokens", self._editing_preset_max_output_tokens)
if imgui.button("Save", imgui.ImVec2(120, 0)):
if self._editing_preset_name.strip():
self.controller._cb_save_preset(
self._editing_preset_name.strip(),
self._editing_preset_content,
self._editing_preset_temperature,
self._editing_preset_top_p,
self._editing_preset_max_output_tokens,
self._editing_preset_scope
)
self.ai_status = f"Preset '{self._editing_preset_name.strip()}' saved to {self._editing_preset_scope}"
imgui.set_item_tooltip("Save the current preset settings")
imgui.same_line()
if imgui.button("Delete", imgui.ImVec2(120, 0)):
if self._editing_preset_name.strip():
try:
self.controller._cb_delete_preset(self._editing_preset_name.strip(), self._editing_preset_scope)
self.ai_status = f"Preset '{self._editing_preset_name}' deleted from {self._editing_preset_scope}"
opened, self.show_preset_manager_modal = imgui.begin_popup_modal("Preset Manager", self.show_preset_manager_modal)
if opened:
try:
avail = imgui.get_content_region_avail()
imgui.begin_child("preset_list_area", imgui.ImVec2(250, avail.y), True)
try:
preset_names = sorted(self.controller.presets.keys())
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
self._editing_preset_name = ""
self._editing_preset_content = ""
except Exception as e:
self.ai_status = f"Error deleting: {e}"
imgui.set_item_tooltip("Delete the selected preset")
imgui.same_line()
if imgui.button("Close", imgui.ImVec2(120, 0)):
self.show_preset_manager_modal = False
imgui.close_current_popup()
imgui.end_child()
imgui.end_popup()
self._editing_preset_temperature = 0.0
self._editing_preset_top_p = 1.0
self._editing_preset_max_output_tokens = 4096
self._editing_preset_scope = "project"
self._editing_preset_is_new = True
imgui.separator()
for name in preset_names:
p = self.controller.presets[name]
is_sel = (name == self._editing_preset_name)
if imgui.selectable(name, is_sel)[0]:
self._editing_preset_name = name
self._editing_preset_content = p.system_prompt
self._editing_preset_temperature = p.temperature if p.temperature is not None else 0.0
self._editing_preset_top_p = p.top_p if p.top_p is not None else 1.0
self._editing_preset_max_output_tokens = p.max_output_tokens if p.max_output_tokens is not None else 4096
self._editing_preset_is_new = False
finally:
imgui.end_child()
imgui.same_line()
imgui.begin_child("preset_edit_area", imgui.ImVec2(0, avail.y), False)
try:
p_name = self._editing_preset_name or "(New Preset)"
imgui.text_colored(C_IN, f"Editing Preset: {p_name}")
imgui.separator()
imgui.text("Name:")
_, self._editing_preset_name = imgui.input_text("##edit_name", self._editing_preset_name)
imgui.text("Scope:")
if imgui.radio_button("Global", self._editing_preset_scope == "global"):
self._editing_preset_scope = "global"
imgui.same_line()
if imgui.radio_button("Project", self._editing_preset_scope == "project"):
self._editing_preset_scope = "project"
imgui.text("Content:")
_, self._editing_preset_content = imgui.input_text_multiline("##edit_content", self._editing_preset_content, imgui.ImVec2(-1, 280))
imgui.text("Temperature:")
_, self._editing_preset_temperature = imgui.input_float("##edit_temp", self._editing_preset_temperature, 0.1, 1.0, "%.2f")
imgui.text("Top P:")
_, self._editing_preset_top_p = imgui.input_float("##edit_top_p", self._editing_preset_top_p, 0.1, 1.0, "%.2f")
imgui.text("Max Output Tokens:")
_, self._editing_preset_max_output_tokens = imgui.input_int("##edit_max_tokens", self._editing_preset_max_output_tokens)
if imgui.button("Save", imgui.ImVec2(120, 0)):
if self._editing_preset_name.strip():
self.controller._cb_save_preset(
self._editing_preset_name.strip(),
self._editing_preset_content,
self._editing_preset_temperature,
self._editing_preset_top_p,
self._editing_preset_max_output_tokens,
self._editing_preset_scope
)
self.ai_status = f"Preset '{self._editing_preset_name.strip()}' saved to {self._editing_preset_scope}"
imgui.set_item_tooltip("Save the current preset settings")
imgui.same_line()
if imgui.button("Delete", imgui.ImVec2(120, 0)):
if self._editing_preset_name.strip():
try:
self.controller._cb_delete_preset(self._editing_preset_name.strip(), self._editing_preset_scope)
self.ai_status = f"Preset '{self._editing_preset_name}' deleted from {self._editing_preset_scope}"
self._editing_preset_name = ""
self._editing_preset_content = ""
except Exception as e:
self.ai_status = f"Error deleting: {e}"
imgui.set_item_tooltip("Delete the selected preset")
imgui.same_line()
if imgui.button("Close", imgui.ImVec2(120, 0)):
self.show_preset_manager_modal = False
imgui.close_current_popup()
finally:
imgui.end_child()
finally:
imgui.end_popup()
def _render_projects_panel(self) -> None:
if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_projects_panel")