refactor(gui): Implement user feedback for UI layout
This commit is contained in:
75
gui_2.py
75
gui_2.py
@@ -159,9 +159,11 @@ class App:
|
|||||||
|
|
||||||
_default_windows = {
|
_default_windows = {
|
||||||
"Context Hub": True,
|
"Context Hub": True,
|
||||||
"AI Settings Hub": True,
|
"Files & Media": True,
|
||||||
|
"AI Settings": True,
|
||||||
"Discussion Hub": True,
|
"Discussion Hub": True,
|
||||||
"Operations Hub": True,
|
"Operations Hub": True,
|
||||||
|
"Theme": True,
|
||||||
"Diagnostics": False,
|
"Diagnostics": False,
|
||||||
}
|
}
|
||||||
saved = self.config.get("gui", {}).get("show_windows", {})
|
saved = self.config.get("gui", {}).get("show_windows", {})
|
||||||
@@ -683,62 +685,57 @@ class App:
|
|||||||
# imgui.end_main_menu_bar()
|
# imgui.end_main_menu_bar()
|
||||||
|
|
||||||
|
|
||||||
# ---- Context Hub
|
|
||||||
|
# --- Hubs ---
|
||||||
if self.show_windows.get("Context Hub", False):
|
if self.show_windows.get("Context Hub", False):
|
||||||
exp, self.show_windows["Context Hub"] = imgui.begin("Context Hub", self.show_windows["Context Hub"])
|
exp, self.show_windows["Context Hub"] = imgui.begin("Context Hub", self.show_windows["Context Hub"])
|
||||||
if exp:
|
if exp:
|
||||||
if imgui.begin_tab_bar("ContextTabs"):
|
|
||||||
if imgui.begin_tab_item("Projects")[0]:
|
|
||||||
self._render_projects_panel()
|
self._render_projects_panel()
|
||||||
imgui.end_tab_item()
|
|
||||||
if imgui.begin_tab_item("Files")[0]:
|
|
||||||
self._render_files_panel()
|
|
||||||
imgui.end_tab_item()
|
|
||||||
if imgui.begin_tab_item("Screenshots")[0]:
|
|
||||||
self._render_screenshots_panel()
|
|
||||||
imgui.end_tab_item()
|
|
||||||
imgui.end_tab_bar()
|
|
||||||
imgui.end()
|
imgui.end()
|
||||||
|
|
||||||
# ---- AI Settings Hub
|
if self.show_windows.get("Files & Media", False):
|
||||||
if self.show_windows.get("AI Settings Hub", False):
|
exp, self.show_windows["Files & Media"] = imgui.begin("Files & Media", self.show_windows["Files & Media"])
|
||||||
exp, self.show_windows["AI Settings Hub"] = imgui.begin("AI Settings Hub", self.show_windows["AI Settings Hub"])
|
|
||||||
if exp:
|
if exp:
|
||||||
if imgui.begin_tab_bar("AISettingsTabs"):
|
if imgui.collapsing_header("Files"):
|
||||||
if imgui.begin_tab_item("Provider")[0]:
|
self._render_files_panel()
|
||||||
self._render_provider_panel()
|
if imgui.collapsing_header("Screenshots"):
|
||||||
imgui.end_tab_item()
|
self._render_screenshots_panel()
|
||||||
if imgui.begin_tab_item("System Prompts")[0]:
|
|
||||||
self._render_system_prompts_panel()
|
|
||||||
imgui.end_tab_item()
|
|
||||||
if imgui.begin_tab_item("Theme")[0]:
|
|
||||||
self._render_theme_panel()
|
|
||||||
imgui.end_tab_item()
|
|
||||||
imgui.end_tab_bar()
|
|
||||||
imgui.end()
|
imgui.end()
|
||||||
|
|
||||||
# ---- Discussion Hub
|
if self.show_windows.get("AI Settings", False):
|
||||||
|
exp, self.show_windows["AI Settings"] = imgui.begin("AI Settings", self.show_windows["AI Settings"])
|
||||||
|
if exp:
|
||||||
|
if imgui.collapsing_header("Provider & Model"):
|
||||||
|
self._render_provider_panel()
|
||||||
|
if imgui.collapsing_header("System Prompts"):
|
||||||
|
self._render_system_prompts_panel()
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
|
if self.show_windows.get("Theme", False):
|
||||||
|
self._render_theme_panel()
|
||||||
|
|
||||||
if self.show_windows.get("Discussion Hub", False):
|
if self.show_windows.get("Discussion Hub", False):
|
||||||
exp, self.show_windows["Discussion Hub"] = imgui.begin("Discussion Hub", self.show_windows["Discussion Hub"])
|
exp, self.show_windows["Discussion Hub"] = imgui.begin("Discussion Hub", self.show_windows["Discussion Hub"])
|
||||||
if exp:
|
if exp:
|
||||||
if imgui.begin_tab_bar("DiscussionTabs"):
|
# Top part for the history
|
||||||
if imgui.begin_tab_item("History")[0]:
|
with imgui.begin_child("HistoryChild", size=(0, -200)):
|
||||||
self._render_discussion_panel()
|
self._render_discussion_panel()
|
||||||
imgui.end_tab_item()
|
|
||||||
imgui.end_tab_bar()
|
|
||||||
imgui.end()
|
|
||||||
|
|
||||||
# ---- Operations Hub
|
# Bottom part with tabs for message and response
|
||||||
if self.show_windows.get("Operations Hub", False):
|
if imgui.begin_tab_bar("MessageResponseTabs"):
|
||||||
exp, self.show_windows["Operations Hub"] = imgui.begin("Operations Hub", self.show_windows["Operations Hub"])
|
|
||||||
if exp:
|
|
||||||
if imgui.begin_tab_bar("OperationsTabs"):
|
|
||||||
if imgui.begin_tab_item("Message")[0]:
|
if imgui.begin_tab_item("Message")[0]:
|
||||||
self._render_message_panel()
|
self._render_message_panel()
|
||||||
imgui.end_tab_item()
|
imgui.end_tab_item()
|
||||||
if imgui.begin_tab_item("Response")[0]:
|
if imgui.begin_tab_item("Response")[0]:
|
||||||
self._render_response_panel()
|
self._render_response_panel()
|
||||||
imgui.end_tab_item()
|
imgui.end_tab_item()
|
||||||
|
imgui.end_tab_bar()
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
|
if self.show_windows.get("Operations Hub", False):
|
||||||
|
exp, self.show_windows["Operations Hub"] = imgui.begin("Operations Hub", self.show_windows["Operations Hub"])
|
||||||
|
if exp:
|
||||||
|
if imgui.begin_tab_bar("OperationsTabs"):
|
||||||
if imgui.begin_tab_item("Tool Calls")[0]:
|
if imgui.begin_tab_item("Tool Calls")[0]:
|
||||||
self._render_tool_calls_panel()
|
self._render_tool_calls_panel()
|
||||||
imgui.end_tab_item()
|
imgui.end_tab_item()
|
||||||
@@ -747,7 +744,6 @@ class App:
|
|||||||
imgui.end_tab_item()
|
imgui.end_tab_item()
|
||||||
imgui.end_tab_bar()
|
imgui.end_tab_bar()
|
||||||
imgui.end()
|
imgui.end()
|
||||||
# ---- Diagnostics
|
|
||||||
if self.show_windows["Diagnostics"]:
|
if self.show_windows["Diagnostics"]:
|
||||||
exp, self.show_windows["Diagnostics"] = imgui.begin("Diagnostics", self.show_windows["Diagnostics"])
|
exp, self.show_windows["Diagnostics"] = imgui.begin("Diagnostics", self.show_windows["Diagnostics"])
|
||||||
if exp:
|
if exp:
|
||||||
@@ -1609,6 +1605,8 @@ class App:
|
|||||||
ch, self.ui_project_system_prompt = imgui.input_text_multiline("##psp", self.ui_project_system_prompt, imgui.ImVec2(-1, 100))
|
ch, self.ui_project_system_prompt = imgui.input_text_multiline("##psp", self.ui_project_system_prompt, imgui.ImVec2(-1, 100))
|
||||||
|
|
||||||
def _render_theme_panel(self):
|
def _render_theme_panel(self):
|
||||||
|
exp, self.show_windows["Theme"] = imgui.begin("Theme", self.show_windows["Theme"])
|
||||||
|
if exp:
|
||||||
imgui.text("Palette")
|
imgui.text("Palette")
|
||||||
cp = theme.get_current_palette()
|
cp = theme.get_current_palette()
|
||||||
if imgui.begin_combo("##pal", cp):
|
if imgui.begin_combo("##pal", cp):
|
||||||
@@ -1645,6 +1643,7 @@ class App:
|
|||||||
imgui.text("UI Scale (DPI)")
|
imgui.text("UI Scale (DPI)")
|
||||||
ch, scale = imgui.slider_float("##scale", theme.get_current_scale(), 0.5, 3.0, "%.2f")
|
ch, scale = imgui.slider_float("##scale", theme.get_current_scale(), 0.5, 3.0, "%.2f")
|
||||||
if ch: theme.set_scale(scale)
|
if ch: theme.set_scale(scale)
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
def _load_fonts(self):
|
def _load_fonts(self):
|
||||||
font_path, font_size = theme.get_font_loading_params()
|
font_path, font_size = theme.get_font_loading_params()
|
||||||
|
|||||||
128
refactor_gui2_v2.py
Normal file
128
refactor_gui2_v2.py
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
with open("gui_2.py", "r", encoding="utf-8") as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
# Define the new structure for the GUI function
|
||||||
|
new_gui_func_body = """
|
||||||
|
# --- Hubs ---
|
||||||
|
if self.show_windows.get("Context Hub", False):
|
||||||
|
exp, self.show_windows["Context Hub"] = imgui.begin("Context Hub", self.show_windows["Context Hub"])
|
||||||
|
if exp:
|
||||||
|
self._render_projects_panel()
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
|
if self.show_windows.get("Files & Media", False):
|
||||||
|
exp, self.show_windows["Files & Media"] = imgui.begin("Files & Media", self.show_windows["Files & Media"])
|
||||||
|
if exp:
|
||||||
|
if imgui.collapsing_header("Files"):
|
||||||
|
self._render_files_panel()
|
||||||
|
if imgui.collapsing_header("Screenshots"):
|
||||||
|
self._render_screenshots_panel()
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
|
if self.show_windows.get("AI Settings", False):
|
||||||
|
exp, self.show_windows["AI Settings"] = imgui.begin("AI Settings", self.show_windows["AI Settings"])
|
||||||
|
if exp:
|
||||||
|
if imgui.collapsing_header("Provider & Model"):
|
||||||
|
self._render_provider_panel()
|
||||||
|
if imgui.collapsing_header("System Prompts"):
|
||||||
|
self._render_system_prompts_panel()
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
|
if self.show_windows.get("Theme", False):
|
||||||
|
self._render_theme_panel()
|
||||||
|
|
||||||
|
if self.show_windows.get("Discussion Hub", False):
|
||||||
|
exp, self.show_windows["Discussion Hub"] = imgui.begin("Discussion Hub", self.show_windows["Discussion Hub"])
|
||||||
|
if exp:
|
||||||
|
# Top part for the history
|
||||||
|
with imgui.begin_child("HistoryChild", size=(0, -200)):
|
||||||
|
self._render_discussion_panel()
|
||||||
|
|
||||||
|
# Bottom part with tabs for message and response
|
||||||
|
if imgui.begin_tab_bar("MessageResponseTabs"):
|
||||||
|
if imgui.begin_tab_item("Message")[0]:
|
||||||
|
self._render_message_panel()
|
||||||
|
imgui.end_tab_item()
|
||||||
|
if imgui.begin_tab_item("Response")[0]:
|
||||||
|
self._render_response_panel()
|
||||||
|
imgui.end_tab_item()
|
||||||
|
imgui.end_tab_bar()
|
||||||
|
imgui.end()
|
||||||
|
|
||||||
|
if self.show_windows.get("Operations Hub", False):
|
||||||
|
exp, self.show_windows["Operations Hub"] = imgui.begin("Operations Hub", self.show_windows["Operations Hub"])
|
||||||
|
if exp:
|
||||||
|
if imgui.begin_tab_bar("OperationsTabs"):
|
||||||
|
if imgui.begin_tab_item("Tool Calls")[0]:
|
||||||
|
self._render_tool_calls_panel()
|
||||||
|
imgui.end_tab_item()
|
||||||
|
if imgui.begin_tab_item("Comms History")[0]:
|
||||||
|
self._render_comms_history_panel()
|
||||||
|
imgui.end_tab_item()
|
||||||
|
imgui.end_tab_bar()
|
||||||
|
imgui.end()
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Replace the old hub code with the new one
|
||||||
|
start_marker = "# ---- Context Hub"
|
||||||
|
end_marker = "# ---- Diagnostics"
|
||||||
|
|
||||||
|
start_idx = content.find(start_marker)
|
||||||
|
end_idx = content.find(end_marker)
|
||||||
|
|
||||||
|
if start_idx != -1 and end_idx != -1:
|
||||||
|
indented_new_code = "\\n".join([f" {line}" for line in new_gui_func_body.split("\\n")])
|
||||||
|
content = content[:start_idx] + indented_new_code + content[end_idx:]
|
||||||
|
else:
|
||||||
|
print("Could not find the hub markers to replace.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Update the _default_windows dictionary to reflect the new layout
|
||||||
|
old_default = """ _default_windows = {
|
||||||
|
"Context Hub": True,
|
||||||
|
"AI Settings Hub": True,
|
||||||
|
"Discussion Hub": True,
|
||||||
|
"Operations Hub": True,
|
||||||
|
"Diagnostics": False,
|
||||||
|
}"""
|
||||||
|
new_default = """ _default_windows = {
|
||||||
|
"Context Hub": True,
|
||||||
|
"Files & Media": True,
|
||||||
|
"AI Settings": True,
|
||||||
|
"Discussion Hub": True,
|
||||||
|
"Operations Hub": True,
|
||||||
|
"Theme": True,
|
||||||
|
"Diagnostics": False,
|
||||||
|
}"""
|
||||||
|
content = content.replace(old_default, new_default)
|
||||||
|
|
||||||
|
theme_method_start = "def _render_theme_panel(self):"
|
||||||
|
theme_method_end_line = "theme.set_scale(scale)"
|
||||||
|
|
||||||
|
theme_start_idx = content.find(theme_method_start)
|
||||||
|
if theme_start_idx != -1:
|
||||||
|
theme_end_idx = content.find(theme_method_end_line, theme_start_idx)
|
||||||
|
if theme_end_idx != -1:
|
||||||
|
theme_end_idx += len(theme_method_end_line)
|
||||||
|
body = content[theme_start_idx + len(theme_method_start) : theme_end_idx]
|
||||||
|
|
||||||
|
new_theme_method = """ def _render_theme_panel(self):
|
||||||
|
exp, self.show_windows["Theme"] = imgui.begin("Theme", self.show_windows["Theme"])
|
||||||
|
if exp:
|
||||||
|
{}
|
||||||
|
imgui.end()
|
||||||
|
""".format(body)
|
||||||
|
old_method_text = content[theme_start_idx : theme_end_idx+1]
|
||||||
|
content = content.replace(old_method_text, new_theme_method)
|
||||||
|
|
||||||
|
with open("gui_2.py", "w", encoding="utf-8") as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
print("GUI refactoring V2 complete.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -24,9 +24,11 @@ def test_gui2_hubs_exist_in_show_windows(app_instance):
|
|||||||
"""
|
"""
|
||||||
expected_hubs = [
|
expected_hubs = [
|
||||||
"Context Hub",
|
"Context Hub",
|
||||||
"AI Settings Hub",
|
"AI Settings",
|
||||||
"Discussion Hub",
|
"Discussion Hub",
|
||||||
"Operations Hub",
|
"Operations Hub",
|
||||||
|
"Files & Media",
|
||||||
|
"Theme",
|
||||||
]
|
]
|
||||||
|
|
||||||
for hub in expected_hubs:
|
for hub in expected_hubs:
|
||||||
|
|||||||
Reference in New Issue
Block a user