feat(ui): Improved resize policies and added dual controls for Preset windows
This commit is contained in:
48
src/gui_2.py
48
src/gui_2.py
@@ -925,7 +925,7 @@ class App:
|
||||
|
||||
def _render_preset_manager_content(self, is_embedded: bool = False) -> None:
|
||||
avail = imgui.get_content_region_avail()
|
||||
imgui.begin_child("preset_list_area", imgui.ImVec2(250, avail.y), True)
|
||||
imgui.begin_child("preset_list_area", imgui.ImVec2(avail.x * 0.25, avail.y), True)
|
||||
try:
|
||||
preset_names = sorted(self.controller.presets.keys())
|
||||
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
|
||||
@@ -949,17 +949,22 @@ class App:
|
||||
p_name = self._editing_preset_name or "(New Preset)"
|
||||
imgui.text_colored(C_IN, f"Editing Preset: {p_name}")
|
||||
imgui.separator()
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
imgui.text("Name:")
|
||||
imgui.set_next_item_width(-1)
|
||||
_, self._editing_preset_name = imgui.input_text("##edit_name", self._editing_preset_name)
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
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.dummy(imgui.ImVec2(0, 8))
|
||||
imgui.text("Content:")
|
||||
_, self._editing_preset_content = imgui.input_text_multiline("##edit_content", self._editing_preset_content, imgui.ImVec2(-1, -40))
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
if imgui.button("Save", imgui.ImVec2(120, 0)):
|
||||
if self._editing_preset_name.strip():
|
||||
self.controller._cb_save_preset(
|
||||
@@ -1006,7 +1011,7 @@ class App:
|
||||
def _render_tool_preset_manager_content(self, is_embedded: bool = False) -> None:
|
||||
avail = imgui.get_content_region_avail()
|
||||
# Left Column: Listbox
|
||||
imgui.begin_child("tool_preset_list_area", imgui.ImVec2(250, avail.y), True)
|
||||
imgui.begin_child("tool_preset_list_area", imgui.ImVec2(avail.x * 0.25, avail.y), True)
|
||||
try:
|
||||
if imgui.button("New Tool Preset", imgui.ImVec2(-1, 0)):
|
||||
self._editing_tool_preset_name = ""
|
||||
@@ -1041,6 +1046,7 @@ class App:
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.text("Name:")
|
||||
imgui.set_next_item_width(-1)
|
||||
_, self._editing_tool_preset_name = imgui.input_text("##edit_tp_name", self._editing_tool_preset_name)
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
@@ -1100,12 +1106,13 @@ class App:
|
||||
finally:
|
||||
imgui.end_child()
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
imgui.separator()
|
||||
imgui.text_colored(C_SUB, "Bias Profiles")
|
||||
imgui.begin_child("bias_profiles_area", imgui.ImVec2(0, 300), True)
|
||||
try:
|
||||
avail_bias = imgui.get_content_region_avail()
|
||||
imgui.begin_child("bias_list", imgui.ImVec2(200, avail_bias.y), False)
|
||||
imgui.begin_child("bias_list", imgui.ImVec2(avail_bias.x * 0.3, avail_bias.y), False)
|
||||
if imgui.button("New Profile", imgui.ImVec2(-1, 0)):
|
||||
self._editing_bias_profile_name = ""
|
||||
self._editing_bias_profile_tool_weights = {}
|
||||
@@ -1125,6 +1132,7 @@ class App:
|
||||
imgui.same_line()
|
||||
imgui.begin_child("bias_edit", imgui.ImVec2(0, avail_bias.y), False)
|
||||
imgui.text("Name:")
|
||||
imgui.set_next_item_width(-1)
|
||||
_, self._editing_bias_profile_name = imgui.input_text("##b_name", self._editing_bias_profile_name)
|
||||
|
||||
imgui.text_colored(C_KEY, "Tool Weights:")
|
||||
@@ -1260,7 +1268,7 @@ class App:
|
||||
try:
|
||||
avail = imgui.get_content_region_avail()
|
||||
# Left Pane: List of Personas
|
||||
imgui.begin_child("persona_list_area", imgui.ImVec2(250, avail.y), True)
|
||||
imgui.begin_child("persona_list_area", imgui.ImVec2(avail.x * 0.25, avail.y), True)
|
||||
try:
|
||||
if imgui.button("New Persona", imgui.ImVec2(-1, 0)):
|
||||
self._editing_persona_name = ""
|
||||
@@ -1301,10 +1309,12 @@ class App:
|
||||
header = "New Persona" if getattr(self, '_editing_persona_is_new', True) else f"Editing Persona: {self._editing_persona_name}"
|
||||
imgui.text_colored(C_IN, header)
|
||||
imgui.separator()
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.text("Name:")
|
||||
imgui.same_line()
|
||||
imgui.set_next_item_width(-1)
|
||||
_, self._editing_persona_name = imgui.input_text("##pname", self._editing_persona_name, 128)
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.text("Scope:")
|
||||
if imgui.radio_button("Global##pscope", getattr(self, '_editing_persona_scope', 'project') == "global"):
|
||||
@@ -1312,8 +1322,10 @@ class App:
|
||||
imgui.same_line()
|
||||
if imgui.radio_button("Project##pscope", getattr(self, '_editing_persona_scope', 'project') == "project"):
|
||||
self._editing_persona_scope = "project"
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.separator()
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.text("Preferred Models:")
|
||||
providers = self.controller.PROVIDERS
|
||||
@@ -1321,6 +1333,7 @@ class App:
|
||||
self._persona_pref_models_expanded = {}
|
||||
imgui.begin_child("pref_models_list", imgui.ImVec2(0, 200), True)
|
||||
to_remove = []
|
||||
avail_edit = imgui.get_content_region_avail()
|
||||
for i, entry in enumerate(self._editing_persona_preferred_models_list):
|
||||
imgui.push_id(f"pref_model_{i}")
|
||||
|
||||
@@ -1361,8 +1374,11 @@ class App:
|
||||
|
||||
imgui.text("Temperature:")
|
||||
imgui.same_line()
|
||||
imgui.set_next_item_width(100)
|
||||
_, entry["temperature"] = imgui.input_float("##temp", entry.get("temperature", 0.7), 0.1, 0.1, "%.1f")
|
||||
imgui.set_next_item_width(avail_edit.x * 0.3)
|
||||
_, entry["temperature"] = imgui.slider_float("##temp_slider", entry.get("temperature", 0.7), 0.0, 2.0, "%.1f")
|
||||
imgui.same_line()
|
||||
imgui.set_next_item_width(80)
|
||||
_, entry["temperature"] = imgui.input_float("##temp_input", entry.get("temperature", 0.7), 0.1, 0.1, "%.1f")
|
||||
|
||||
imgui.same_line()
|
||||
imgui.text("Max Output Tokens:")
|
||||
@@ -1395,40 +1411,43 @@ class App:
|
||||
})
|
||||
self._persona_pref_models_expanded[idx] = True
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
imgui.separator()
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.text("Tool Preset:")
|
||||
imgui.same_line()
|
||||
t_preset_names = ["None"] + sorted(self.controller.tool_presets.keys())
|
||||
t_idx = t_preset_names.index(self._editing_persona_tool_preset_id) if getattr(self, '_editing_persona_tool_preset_id', '') in t_preset_names else 0
|
||||
imgui.push_item_width(200)
|
||||
imgui.set_next_item_width(200)
|
||||
_, t_idx = imgui.combo("##ptoolpreset", t_idx, t_preset_names)
|
||||
self._editing_persona_tool_preset_id = t_preset_names[t_idx] if t_idx > 0 else ""
|
||||
imgui.pop_item_width()
|
||||
|
||||
imgui.same_line()
|
||||
imgui.text("Bias Profile:")
|
||||
imgui.same_line()
|
||||
bias_names = ["None"] + sorted(self.controller.bias_profiles.keys())
|
||||
b_idx = bias_names.index(self._editing_persona_bias_profile_id) if getattr(self, '_editing_persona_bias_profile_id', '') in bias_names else 0
|
||||
imgui.push_item_width(200)
|
||||
imgui.set_next_item_width(200)
|
||||
_, b_idx = imgui.combo("##pbiasprofile", b_idx, bias_names)
|
||||
self._editing_persona_bias_profile_id = bias_names[b_idx] if b_idx > 0 else ""
|
||||
imgui.pop_item_width()
|
||||
|
||||
imgui.same_line()
|
||||
if imgui.button("Manage Tools##p_tools"):
|
||||
self.show_tool_preset_manager_window = True
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
imgui.separator()
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
imgui.text("System Prompt:")
|
||||
|
||||
imgui.text("Load from Preset:")
|
||||
imgui.same_line()
|
||||
prompt_presets = ["Select..."] + sorted(self.controller.presets.keys())
|
||||
if not hasattr(self, "_load_preset_idx"): self._load_preset_idx = 0
|
||||
imgui.push_item_width(150)
|
||||
imgui.set_next_item_width(150)
|
||||
_, self._load_preset_idx = imgui.combo("##load_preset", self._load_preset_idx, prompt_presets)
|
||||
imgui.pop_item_width()
|
||||
imgui.same_line()
|
||||
if imgui.button("Apply##apply_p"):
|
||||
if self._load_preset_idx > 0:
|
||||
@@ -1444,7 +1463,10 @@ class App:
|
||||
|
||||
_, self._editing_persona_system_prompt = imgui.input_text_multiline("##pprompt", self._editing_persona_system_prompt, imgui.ImVec2(-1, 150))
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
imgui.separator()
|
||||
imgui.dummy(imgui.ImVec2(0, 8))
|
||||
|
||||
if imgui.button("Save Persona", imgui.ImVec2(120, 0)):
|
||||
if self._editing_persona_name.strip():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user