checkpoitn before the ai yeets ita again

This commit is contained in:
2026-03-11 22:06:34 -04:00
parent 4dee0e6f69
commit 1541e7f9fd

View File

@@ -940,18 +940,15 @@ class App:
def _render_preset_manager_content(self, is_embedded: bool = False) -> None: def _render_preset_manager_content(self, is_embedded: bool = False) -> None:
avail = imgui.get_content_region_avail() avail = imgui.get_content_region_avail()
if not hasattr(self, "_prompt_md_preview"): self._prompt_md_preview = False
if imgui.begin_table("prompt_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v): if imgui.begin_table("prompt_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
try:
imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200) imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200)
imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row() imgui.table_next_row()
# Left Column: Presets # Left Sidebar
imgui.table_next_column() imgui.table_next_column()
imgui.begin_child("prompt_list_pane", imgui.ImVec2(0, 0), False) if imgui.begin_child("prompt_list_pane", imgui.ImVec2(0, 0), False):
try:
if imgui.button("New Preset", imgui.ImVec2(-1, 0)): if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
self._editing_preset_name = "" self._editing_preset_name = ""
self._editing_preset_system_prompt = "" self._editing_preset_system_prompt = ""
@@ -966,21 +963,18 @@ class App:
p = self.controller.presets[name] p = self.controller.presets[name]
self._editing_preset_system_prompt = p.system_prompt self._editing_preset_system_prompt = p.system_prompt
self._editing_preset_scope = self.controller.preset_manager.get_preset_scope(name) self._editing_preset_scope = self.controller.preset_manager.get_preset_scope(name)
finally:
imgui.end_child() imgui.end_child()
# Right Column: Editor # Right Editor
imgui.table_next_column() imgui.table_next_column()
avail_r = imgui.get_content_region_avail() avail_r = imgui.get_content_region_avail()
# Subtract space for bottom buttons # Reserve 45px for footer buttons
imgui.begin_child("prompt_edit_pane", imgui.ImVec2(0, avail_r.y - 45), False) if imgui.begin_child("prompt_edit_pane", imgui.ImVec2(0, avail_r.y - 45), False):
try:
p_disp = self._editing_preset_name or "(New Preset)" p_disp = self._editing_preset_name or "(New Preset)"
imgui.text_colored(C_IN, f"Editing Prompt Preset: {p_disp}") imgui.text_colored(C_IN, f"Editing Prompt Preset: {p_disp}")
imgui.separator() imgui.separator()
if imgui.begin_table("p_meta", 2): if imgui.begin_table("p_meta", 2):
try:
imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80) imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80)
imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row() imgui.table_next_row()
@@ -990,10 +984,9 @@ class App:
imgui.table_next_row() imgui.table_next_row()
imgui.table_next_column(); imgui.text("Scope:") imgui.table_next_column(); imgui.text("Scope:")
imgui.table_next_column() imgui.table_next_column()
if imgui.radio_button("Global", self._editing_preset_scope == "global"): self._editing_preset_scope = "global" if imgui.radio_button("Global##ps", self._editing_preset_scope == "global"): self._editing_preset_scope = "global"
imgui.same_line() imgui.same_line()
if imgui.radio_button("Project", self._editing_preset_scope == "project"): self._editing_preset_scope = "project" if imgui.radio_button("Project##ps", self._editing_preset_scope == "project"): self._editing_preset_scope = "project"
finally:
imgui.end_table() imgui.end_table()
imgui.dummy(imgui.ImVec2(0, 4)) imgui.dummy(imgui.ImVec2(0, 4))
@@ -1003,18 +996,16 @@ class App:
if imgui.button("MD Preview" if not self._prompt_md_preview else "Edit Mode"): if imgui.button("MD Preview" if not self._prompt_md_preview else "Edit Mode"):
self._prompt_md_preview = not self._prompt_md_preview self._prompt_md_preview = not self._prompt_md_preview
rem_y = imgui.get_content_region_avail().y
if self._prompt_md_preview: if self._prompt_md_preview:
imgui.begin_child("prompt_preview", imgui.ImVec2(-1, imgui.get_content_region_avail().y), True) if imgui.begin_child("prompt_preview", imgui.ImVec2(-1, rem_y), True):
try:
markdown_helper.render(self._editing_preset_system_prompt, context_id="prompt_preset_preview") markdown_helper.render(self._editing_preset_system_prompt, context_id="prompt_preset_preview")
finally:
imgui.end_child() imgui.end_child()
else: else:
_, self._editing_preset_system_prompt = imgui.input_text_multiline("##pcont", self._editing_preset_system_prompt, imgui.ImVec2(-1, imgui.get_content_region_avail().y)) _, self._editing_preset_system_prompt = imgui.input_text_multiline("##pcont", self._editing_preset_system_prompt, imgui.ImVec2(-1, rem_y))
finally:
imgui.end_child() imgui.end_child()
# Bottom Buttons # Footer Buttons
imgui.separator() imgui.separator()
imgui.dummy(imgui.ImVec2(0, 4)) imgui.dummy(imgui.ImVec2(0, 4))
if imgui.button("Save", imgui.ImVec2(100, 0)): if imgui.button("Save", imgui.ImVec2(100, 0)):
@@ -1032,7 +1023,6 @@ class App:
imgui.same_line() imgui.same_line()
if imgui.button("Close", imgui.ImVec2(100, 0)): if imgui.button("Close", imgui.ImVec2(100, 0)):
self.show_preset_manager_window = False self.show_preset_manager_window = False
finally:
imgui.end_table() imgui.end_table()
def _render_preset_manager_window(self, is_embedded: bool = False) -> None: def _render_preset_manager_window(self, is_embedded: bool = False) -> None:
@@ -1057,57 +1047,43 @@ class App:
def _render_tool_preset_manager_content(self, is_embedded: bool = False) -> None: def _render_tool_preset_manager_content(self, is_embedded: bool = False) -> None:
avail = imgui.get_content_region_avail() avail = imgui.get_content_region_avail()
if not hasattr(self, "_tool_split_v"): self._tool_split_v = 0.4
if not hasattr(self, "_bias_split_v"): self._bias_split_v = 0.6
if not hasattr(self, "_tool_list_open"): self._tool_list_open = True
if not hasattr(self, "_bias_list_open"): self._bias_list_open = True
if not hasattr(self, "_bias_weights_open"): self._bias_weights_open = True
if not hasattr(self, "_bias_cats_open"): self._bias_cats_open = True
if imgui.begin_table("tp_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v): if imgui.begin_table("tp_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
try:
imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200) imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200)
imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row() imgui.table_next_row()
# Left Sidebar # Left Sidebar
imgui.table_next_column() imgui.table_next_column()
imgui.begin_child("tp_list_pane", imgui.ImVec2(0, 0), False) if imgui.begin_child("tp_list_pane", imgui.ImVec2(0, 0), False):
try:
if imgui.button("New Preset", imgui.ImVec2(-1, 0)): if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
self._editing_tool_preset_name = ""; self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES} self._editing_tool_preset_name = ""; self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
self._editing_tool_preset_scope = "project"; self._selected_tool_preset_idx = -1 self._editing_tool_preset_scope = "project"; self._selected_tool_preset_idx = -1
imgui.separator() imgui.separator()
preset_names = sorted(self.controller.tool_presets.keys()) preset_names = sorted(self.controller.tool_presets.keys())
for i, name in enumerate(preset_names): for i, name in enumerate(preset_names):
if imgui.selectable(f"{name}##tp_{i}", self._selected_tool_preset_idx == i)[0]: if name and imgui.selectable(f"{name}##tp_{i}", self._selected_tool_preset_idx == i)[0]:
self._selected_tool_preset_idx = i; self._editing_tool_preset_name = name self._selected_tool_preset_idx = i; self._editing_tool_preset_name = name
preset = self.controller.tool_presets[name] preset = self.controller.tool_presets[name]
self._editing_tool_preset_categories = {cat: copy.deepcopy(tools) for cat, tools in preset.categories.items()} self._editing_tool_preset_categories = {cat: copy.deepcopy(tools) for cat, tools in preset.categories.items()}
finally:
imgui.end_child() imgui.end_child()
# Right Editor # Right Editor
imgui.table_next_column() imgui.table_next_column()
avail_r = imgui.get_content_region_avail() avail_r = imgui.get_content_region_avail()
# Bottom buttons reserved space if imgui.begin_child("tp_editor_content", imgui.ImVec2(0, avail_r.y - 45), False):
imgui.begin_child("tp_editor_content", imgui.ImVec2(0, avail_r.y - 45), False)
try:
p_name = self._editing_tool_preset_name or "(New Tool Preset)" p_name = self._editing_tool_preset_name or "(New Tool Preset)"
imgui.text_colored(C_IN, f"Editing Tool Preset: {p_name}"); imgui.separator() imgui.text_colored(C_IN, f"Editing Tool Preset: {p_name}"); imgui.separator()
if imgui.begin_table("tp_meta", 2): if imgui.begin_table("tp_meta", 2):
try:
imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80); imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80); imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row(); imgui.table_next_column(); imgui.text("Name:"); imgui.table_next_column(); imgui.set_next_item_width(-1); _, self._editing_tool_preset_name = imgui.input_text("##etpn", self._editing_tool_preset_name) imgui.table_next_row(); imgui.table_next_column(); imgui.text("Name:"); imgui.table_next_column(); imgui.set_next_item_width(-1); _, self._editing_tool_preset_name = imgui.input_text("##etpn", self._editing_tool_preset_name)
imgui.table_next_row(); imgui.table_next_column(); imgui.text("Scope:"); imgui.table_next_column() imgui.table_next_row(); imgui.table_next_column(); imgui.text("Scope:"); imgui.table_next_column()
if imgui.radio_button("Global", self._editing_tool_preset_scope == "global"): self._editing_tool_preset_scope = "global" if imgui.radio_button("Global##tps", self._editing_tool_preset_scope == "global"): self._editing_tool_preset_scope = "global"
imgui.same_line(); imgui.same_line();
if imgui.radio_button("Project", self._editing_tool_preset_scope == "project"): self._editing_tool_preset_scope = "project" if imgui.radio_button("Project##tps", self._editing_tool_preset_scope == "project"): self._editing_tool_preset_scope = "project"
finally:
imgui.end_table() imgui.end_table()
# Vertical split calculation
rem_y = imgui.get_content_region_avail().y - 80 rem_y = imgui.get_content_region_avail().y - 80
if self._tool_list_open and self._bias_list_open: if self._tool_list_open and self._bias_list_open:
h1 = rem_y * self._tool_split_v; h2 = rem_y - h1 - 10 h1 = rem_y * self._tool_split_v; h2 = rem_y - h1 - 10
@@ -1116,9 +1092,8 @@ class App:
else: h1, h2 = 0, 0 else: h1, h2 = 0, 0
imgui.dummy(imgui.ImVec2(0, 4)) imgui.dummy(imgui.ImVec2(0, 4))
opened_tools = imgui.collapsing_header("Categories & Tools", imgui.TreeNodeFlags_.default_open) opened_t = imgui.collapsing_header("Categories & Tools", imgui.TreeNodeFlags_.default_open)
if opened_tools != self._tool_list_open: self._tool_list_open = opened_tools if opened_t != self._tool_list_open: self._tool_list_open = opened_t
if self._tool_list_open: if self._tool_list_open:
imgui.text("Filter:"); imgui.same_line() imgui.text("Filter:"); imgui.same_line()
cat_opts = ["All"] + sorted(list(models.DEFAULT_TOOL_CATEGORIES.keys())) cat_opts = ["All"] + sorted(list(models.DEFAULT_TOOL_CATEGORIES.keys()))
@@ -1126,15 +1101,13 @@ class App:
imgui.set_next_item_width(200); ch_cat, next_f_idx = imgui.combo("##tp_filter", f_idx, cat_opts) imgui.set_next_item_width(200); ch_cat, next_f_idx = imgui.combo("##tp_filter", f_idx, cat_opts)
if ch_cat: self.ui_tool_filter_category = cat_opts[next_f_idx] if ch_cat: self.ui_tool_filter_category = cat_opts[next_f_idx]
imgui.begin_child("tp_scroll", imgui.ImVec2(0, h1), True) if imgui.begin_child("tp_scroll", imgui.ImVec2(0, h1), True):
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 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: self._editing_tool_preset_categories[cat_name] = [] if cat_name not in self._editing_tool_preset_categories: self._editing_tool_preset_categories[cat_name] = []
curr_cat_tools = self._editing_tool_preset_categories[cat_name] curr_cat_tools = self._editing_tool_preset_categories[cat_name]
if imgui.begin_table(f"tt_{cat_name}", 2, imgui.TableFlags_.borders_inner_v): if imgui.begin_table(f"tt_{cat_name}", 2, imgui.TableFlags_.borders_inner_v):
try:
imgui.table_setup_column("Tool", imgui.TableColumnFlags_.width_fixed, 250); imgui.table_setup_column("Ctrls", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("Tool", imgui.TableColumnFlags_.width_fixed, 250); imgui.table_setup_column("Ctrls", imgui.TableColumnFlags_.width_stretch)
for tool_name in default_tools: for tool_name in default_tools:
tool = next((t for t in curr_cat_tools if t.name == tool_name), None) tool = next((t for t in curr_cat_tools if t.name == tool_name), None)
@@ -1150,44 +1123,36 @@ class App:
if imgui.radio_button(f"Ask##{cat_name}_{tool_name}", mode == "ask"): if imgui.radio_button(f"Ask##{cat_name}_{tool_name}", mode == "ask"):
if not tool: tool = models.Tool(name=tool_name, approval="ask"); current_cat_tools.append(tool) if not tool: tool = models.Tool(name=tool_name, approval="ask"); current_cat_tools.append(tool)
else: tool.approval = "ask" else: tool.approval = "ask"
finally:
imgui.end_table() imgui.end_table()
imgui.tree_pop() imgui.tree_pop()
finally:
imgui.end_child() imgui.end_child()
if self._bias_list_open: if self._bias_list_open:
imgui.button("###tool_splitter", imgui.ImVec2(-1, 4)) imgui.button("###tool_splitter", imgui.ImVec2(-1, 4))
if imgui.is_item_active(): self._tool_split_v = max(0.1, min(0.9, self._tool_split_v + imgui.get_io().mouse_delta.y / rem_y)) if imgui.is_item_active(): self._tool_split_v = max(0.1, min(0.9, self._tool_split_v + imgui.get_io().mouse_delta.y / rem_y))
imgui.dummy(imgui.ImVec2(0, 4)) imgui.dummy(imgui.ImVec2(0, 4))
opened_bias = imgui.collapsing_header("Bias Profiles", imgui.TreeNodeFlags_.default_open) opened_b = imgui.collapsing_header("Bias Profiles", imgui.TreeNodeFlags_.default_open)
if opened_bias != self._bias_list_open: self._bias_list_open = opened_bias if opened_b != self._bias_list_open: self._bias_list_open = opened_b
if self._bias_list_open: if self._bias_list_open:
imgui.begin_child("bias_area", imgui.ImVec2(0, h2), True) if imgui.begin_child("bias_area", imgui.ImVec2(0, h2), True):
try:
if imgui.begin_table("bias_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v): if imgui.begin_table("bias_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
try:
imgui.table_setup_column("BList", imgui.TableColumnFlags_.width_fixed, 150); imgui.table_setup_column("BEdit", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("BList", imgui.TableColumnFlags_.width_fixed, 150); imgui.table_setup_column("BEdit", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row(); imgui.table_next_column() imgui.table_next_row(); imgui.table_next_column()
imgui.begin_child("blist_pane", imgui.ImVec2(0, 0), False) if imgui.begin_child("blist_pane", imgui.ImVec2(0, 0), False):
try:
if imgui.button("New Profile", imgui.ImVec2(-1, 0)): if imgui.button("New Profile", imgui.ImVec2(-1, 0)):
self._editing_bias_profile_name = ""; self._editing_bias_profile_tool_weights = {} self._editing_bias_profile_name = ""; self._editing_bias_profile_tool_weights = {}
self._editing_bias_profile_category_multipliers = {}; self._selected_bias_profile_idx = -1 self._editing_bias_profile_category_multipliers = {}; self._selected_bias_profile_idx = -1
imgui.separator(); bnames = sorted(self.bias_profiles.keys()) imgui.separator(); bnames = sorted(self.bias_profiles.keys())
for i, bname in enumerate(bnames): for i, bname in enumerate(bnames):
if imgui.selectable(f"{bname}##b_{i}", self._selected_bias_profile_idx == i)[0]: if bname and imgui.selectable(f"{bname}##b_{i}", self._selected_bias_profile_idx == i)[0]:
self._selected_bias_profile_idx = i; self._editing_bias_profile_name = bname; prof = self.bias_profiles[bname] self._selected_bias_profile_idx = i; self._editing_bias_profile_name = bname; prof = self.bias_profiles[bname]
self._editing_bias_profile_tool_weights = copy.deepcopy(prof.tool_weights); self._editing_bias_profile_category_multipliers = copy.deepcopy(prof.category_multipliers) self._editing_bias_profile_tool_weights = copy.deepcopy(prof.tool_weights); self._editing_bias_profile_category_multipliers = copy.deepcopy(prof.category_multipliers)
finally:
imgui.end_child() imgui.end_child()
imgui.table_next_column()
imgui.begin_child("bedit_pane", imgui.ImVec2(0, 0), False)
try:
imgui.text("Name:"); imgui.same_line(); imgui.set_next_item_width(-1); _, self._editing_bias_profile_name = imgui.input_text("##bname", self._editing_bias_profile_name)
rem_bias_y = imgui.get_content_region_avail().y - 45 # Save button space imgui.table_next_column()
if imgui.begin_child("bedit_pane", imgui.ImVec2(0, 0), False):
imgui.text("Name:"); imgui.same_line(); imgui.set_next_item_width(-1); _, self._editing_bias_profile_name = imgui.input_text("##bname", self._editing_bias_profile_name)
rem_bias_y = imgui.get_content_region_avail().y - 45
if self._bias_weights_open and self._bias_cats_open: if self._bias_weights_open and self._bias_cats_open:
bh1 = rem_bias_y * self._bias_split_v; bh2 = rem_bias_y - bh1 - 10 bh1 = rem_bias_y * self._bias_split_v; bh2 = rem_bias_y - bh1 - 10
elif self._bias_weights_open: bh1, bh2 = rem_bias_y, 0 elif self._bias_weights_open: bh1, bh2 = rem_bias_y, 0
@@ -1197,22 +1162,18 @@ class App:
opened_bw = imgui.collapsing_header("Tool Weights", imgui.TreeNodeFlags_.default_open) opened_bw = imgui.collapsing_header("Tool Weights", imgui.TreeNodeFlags_.default_open)
if opened_bw != self._bias_weights_open: self._bias_weights_open = opened_bw if opened_bw != self._bias_weights_open: self._bias_weights_open = opened_bw
if self._bias_weights_open: if self._bias_weights_open:
imgui.begin_child("btool_scroll", imgui.ImVec2(0, bh1), True) if imgui.begin_child("btool_scroll", imgui.ImVec2(0, bh1), True):
try:
for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items(): for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items():
if imgui.tree_node(f"{cat_name}##b"): if imgui.tree_node(f"{cat_name}##b_list"):
if imgui.begin_table(f"bt_{cat_name}", 2): if imgui.begin_table(f"bt_{cat_name}", 2):
try:
imgui.table_setup_column("T", imgui.TableColumnFlags_.width_fixed, 220); imgui.table_setup_column("W", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("T", imgui.TableColumnFlags_.width_fixed, 220); imgui.table_setup_column("W", imgui.TableColumnFlags_.width_stretch)
for tn in default_tools: for tn in default_tools:
imgui.table_next_row(); imgui.table_next_column(); imgui.text(tn); imgui.table_next_column() imgui.table_next_row(); imgui.table_next_column(); imgui.text(tn); imgui.table_next_column()
curr_w = self._editing_bias_profile_tool_weights.get(tn, 3); imgui.set_next_item_width(-1) curr_w = self._editing_bias_profile_tool_weights.get(tn, 3); imgui.set_next_item_width(-1)
ch_w, n_w = imgui.slider_int(f"##bw_{tn}", curr_w, 1, 10); ch_w, n_w = imgui.slider_int(f"##bw_{tn}", curr_w, 1, 10);
if ch_w: self._editing_bias_profile_tool_weights[tn] = n_w if ch_w: self._editing_bias_profile_tool_weights[tn] = n_w
finally:
imgui.end_table() imgui.end_table()
imgui.tree_pop() imgui.tree_pop()
finally:
imgui.end_child() imgui.end_child()
if self._bias_cats_open: if self._bias_cats_open:
imgui.button("###bias_splitter", imgui.ImVec2(-1, 4)) imgui.button("###bias_splitter", imgui.ImVec2(-1, 4))
@@ -1221,19 +1182,15 @@ class App:
opened_bc = imgui.collapsing_header("Category Multipliers", imgui.TreeNodeFlags_.default_open) opened_bc = imgui.collapsing_header("Category Multipliers", imgui.TreeNodeFlags_.default_open)
if opened_bc != self._bias_cats_open: self._bias_cats_open = opened_bc if opened_bc != self._bias_cats_open: self._bias_cats_open = opened_bc
if self._bias_cats_open: if self._bias_cats_open:
imgui.begin_child("bcat_scroll", imgui.ImVec2(0, bh2), True) if imgui.begin_child("bcat_scroll", imgui.ImVec2(0, bh2), True):
try:
if imgui.begin_table("bcats", 2): if imgui.begin_table("bcats", 2):
try:
imgui.table_setup_column("C", imgui.TableColumnFlags_.width_fixed, 220); imgui.table_setup_column("M", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("C", imgui.TableColumnFlags_.width_fixed, 220); imgui.table_setup_column("M", imgui.TableColumnFlags_.width_stretch)
for cn in sorted(models.DEFAULT_TOOL_CATEGORIES.keys()): for cn in sorted(models.DEFAULT_TOOL_CATEGORIES.keys()):
imgui.table_next_row(); imgui.table_next_column(); imgui.text(cn); imgui.table_next_column() imgui.table_next_row(); imgui.table_next_column(); imgui.text(cn); imgui.table_next_column()
curr_m = self._editing_bias_profile_category_multipliers.get(cn, 1.0); imgui.set_next_item_width(-1) curr_m = self._editing_bias_profile_category_multipliers.get(cn, 1.0); imgui.set_next_item_width(-1)
ch_m, n_m = imgui.slider_float(f"##cm_{cn}", curr_m, 0.1, 5.0, "%.1fx"); ch_m, n_m = imgui.slider_float(f"##cm_{cn}", curr_m, 0.1, 5.0, "%.1fx");
if ch_m: self._editing_bias_profile_category_multipliers[cn] = n_m if ch_m: self._editing_bias_profile_category_multipliers[cn] = n_m
finally:
imgui.end_table() imgui.end_table()
finally:
imgui.end_child() imgui.end_child()
if imgui.button("Save Profile", imgui.ImVec2(-1, 0)): if imgui.button("Save Profile", imgui.ImVec2(-1, 0)):
@@ -1241,30 +1198,22 @@ class App:
p = models.BiasProfile(name=self._editing_bias_profile_name, tool_weights=self._editing_bias_profile_tool_weights, category_multipliers=self._editing_bias_profile_category_multipliers) p = models.BiasProfile(name=self._editing_bias_profile_name, tool_weights=self._editing_bias_profile_tool_weights, category_multipliers=self._editing_bias_profile_category_multipliers)
self.controller._cb_save_bias_profile(p, self._editing_tool_preset_scope); self.ai_status = f"Saved: {p.name}" self.controller._cb_save_bias_profile(p, self._editing_tool_preset_scope); self.ai_status = f"Saved: {p.name}"
except Exception as e: self.ai_status = f"Error: {e}" except Exception as e: self.ai_status = f"Error: {e}"
finally:
imgui.end_child() imgui.end_child()
finally:
imgui.end_table() imgui.end_table()
finally:
imgui.end_child() imgui.end_child()
finally:
imgui.end_child() imgui.end_child()
# --- Footer Buttons --- # --- Footer Buttons ---
imgui.separator() imgui.separator()
if imgui.button("Save", imgui.ImVec2(100, 0)): if imgui.button("Save", imgui.ImVec2(100, 0)):
if self._editing_tool_preset_name.strip(): self.controller._cb_save_tool_preset(self._editing_tool_preset_name.strip(), self._editing_tool_preset_categories, self._editing_tool_preset_scope); self.ai_status = f"Saved: {self._editing_tool_preset_name}" if self._editing_tool_preset_name.strip(): self.controller._cb_save_tool_preset(self._editing_tool_preset_name.strip(), self._editing_tool_preset_categories, self._editing_tool_preset_scope); self.ai_status = f"Saved: {self._editing_tool_preset_name}"
imgui.same_line(); imgui.same_line()
if imgui.button("Delete", imgui.ImVec2(100, 0)): if imgui.button("Delete", imgui.ImVec2(100, 0)):
if self._editing_tool_preset_name: self.controller._cb_delete_tool_preset(self._editing_tool_preset_name, self._editing_tool_preset_scope); self._editing_tool_preset_name = ""; self._selected_tool_preset_idx = -1 if self._editing_tool_preset_name: self.controller._cb_delete_tool_preset(self._editing_tool_preset_name, self._editing_tool_preset_scope); self._editing_tool_preset_name = ""; self._selected_tool_preset_idx = -1
imgui.same_line(); imgui.same_line()
if not is_embedded: if not is_embedded:
if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_tool_preset_manager_window = False if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_tool_preset_manager_window = False
finally:
imgui.end_table() imgui.end_table()
finally:
pass
def _render_tool_preset_manager_window(self, is_embedded: bool = False) -> None: def _render_tool_preset_manager_window(self, is_embedded: bool = False) -> None:
if not self.show_tool_preset_manager_window and not is_embedded: return if not self.show_tool_preset_manager_window and not is_embedded: return
@@ -1292,15 +1241,14 @@ class App:
if not opened: if not opened:
imgui.end(); return imgui.end(); return
try:
if imgui.begin_table("persona_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v): if imgui.begin_table("persona_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
# --- Left Sidebar ---
imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200) imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200)
imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch) imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch)
imgui.table_next_row() imgui.table_next_row()
# --- Left Sidebar ---
imgui.table_next_column() imgui.table_next_column()
imgui.begin_child("persona_list_pane", imgui.ImVec2(0, 0), False) if imgui.begin_child("persona_list_pane", imgui.ImVec2(0, 0), False):
if imgui.button("New Persona", imgui.ImVec2(-1, 0)): if imgui.button("New Persona", imgui.ImVec2(-1, 0)):
self._editing_persona_name = ""; self._editing_persona_system_prompt = "" self._editing_persona_name = ""; self._editing_persona_system_prompt = ""
self._editing_persona_tool_preset_id = ""; self._editing_persona_bias_profile_id = "" self._editing_persona_tool_preset_id = ""; self._editing_persona_bias_profile_id = ""
@@ -1309,7 +1257,7 @@ class App:
imgui.separator() imgui.separator()
personas = getattr(self.controller, 'personas', {}) personas = getattr(self.controller, 'personas', {})
for name in sorted(personas.keys()): for name in sorted(personas.keys()):
if imgui.selectable(name, name == self._editing_persona_name and not getattr(self, '_editing_persona_is_new', False))[0]: if name and imgui.selectable(f"{name}##p_list", name == self._editing_persona_name and not getattr(self, '_editing_persona_is_new', False))[0]:
p = personas[name]; self._editing_persona_name = p.name; self._editing_persona_system_prompt = p.system_prompt or "" p = personas[name]; self._editing_persona_name = p.name; self._editing_persona_system_prompt = p.system_prompt or ""
self._editing_persona_tool_preset_id = p.tool_preset or ""; self._editing_persona_bias_profile_id = p.bias_profile or "" self._editing_persona_tool_preset_id = p.tool_preset or ""; self._editing_persona_bias_profile_id = p.bias_profile or ""
import copy; self._editing_persona_preferred_models_list = copy.deepcopy(p.preferred_models) if p.preferred_models else [] import copy; self._editing_persona_preferred_models_list = copy.deepcopy(p.preferred_models) if p.preferred_models else []
@@ -1319,9 +1267,7 @@ class App:
# --- Right Editor --- # --- Right Editor ---
imgui.table_next_column() imgui.table_next_column()
avail = imgui.get_content_region_avail() avail = imgui.get_content_region_avail()
# Bottom buttons reserved space if imgui.begin_child("persona_editor_content", imgui.ImVec2(0, avail.y - 45), False):
imgui.begin_child("persona_editor_content", imgui.ImVec2(0, avail.y - 45), False)
header_text = "New Persona" if getattr(self, '_editing_persona_is_new', True) else f"Editing Persona: {self._editing_persona_name}" header_text = "New Persona" if getattr(self, '_editing_persona_is_new', True) else f"Editing Persona: {self._editing_persona_name}"
imgui.text_colored(C_IN, header_text); imgui.separator() imgui.text_colored(C_IN, header_text); imgui.separator()
@@ -1334,7 +1280,6 @@ class App:
if imgui.radio_button("Project##pscope", getattr(self, '_editing_persona_scope', 'project') == "project"): self._editing_persona_scope = "project" if imgui.radio_button("Project##pscope", getattr(self, '_editing_persona_scope', 'project') == "project"): self._editing_persona_scope = "project"
imgui.end_table() imgui.end_table()
# Vertical Distribution Logic
rem_y = imgui.get_content_region_avail().y - 100 rem_y = imgui.get_content_region_avail().y - 100
if self._persona_models_open and self._persona_prompt_open: if self._persona_models_open and self._persona_prompt_open:
h1 = rem_y * self._persona_split_v; h2 = rem_y - h1 - 10 h1 = rem_y * self._persona_split_v; h2 = rem_y - h1 - 10
@@ -1347,7 +1292,7 @@ class App:
if opened_models != self._persona_models_open: self._persona_models_open = opened_models if opened_models != self._persona_models_open: self._persona_models_open = opened_models
if self._persona_models_open: if self._persona_models_open:
imgui.begin_child("pref_models_scroll", imgui.ImVec2(0, h1), True) if imgui.begin_child("pref_models_scroll", imgui.ImVec2(0, h1), True):
to_remove = [] to_remove = []
providers = self.controller.PROVIDERS providers = self.controller.PROVIDERS
if not hasattr(self, '_persona_pref_models_expanded'): self._persona_pref_models_expanded = {} if not hasattr(self, '_persona_pref_models_expanded'): self._persona_pref_models_expanded = {}
@@ -1410,7 +1355,7 @@ class App:
if opened_prompt != self._persona_prompt_open: self._persona_prompt_open = opened_prompt if opened_prompt != self._persona_prompt_open: self._persona_prompt_open = opened_prompt
if self._persona_prompt_open: if self._persona_prompt_open:
imgui.begin_child("p_prompt_header", imgui.ImVec2(0, 30), False) if imgui.begin_child("p_prompt_header_pane", imgui.ImVec2(0, 30), False):
imgui.text("Template:"); imgui.same_line(); p_pre = ["Select..."] + sorted(self.controller.presets.keys()) imgui.text("Template:"); imgui.same_line(); p_pre = ["Select..."] + sorted(self.controller.presets.keys())
if not hasattr(self, "_load_preset_idx"): self._load_preset_idx = 0 if not hasattr(self, "_load_preset_idx"): self._load_preset_idx = 0
imgui.set_next_item_width(200); _, self._load_preset_idx = imgui.combo("##load_p", self._load_preset_idx, p_pre) imgui.set_next_item_width(200); _, self._load_preset_idx = imgui.combo("##load_p", self._load_preset_idx, p_pre)
@@ -1441,10 +1386,6 @@ class App:
imgui.same_line(); imgui.same_line();
if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_persona_editor_window = False if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_persona_editor_window = False
imgui.end_table() imgui.end_table()
except Exception as e:
import traceback; traceback.print_exc()
imgui.text_colored(vec4(255, 0, 0), f"Error in Persona Editor: {e}")
finally:
if not is_embedded: imgui.end() if not is_embedded: imgui.end()
def _render_projects_panel(self) -> None: def _render_projects_panel(self) -> None:
if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_projects_panel") if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_projects_panel")