From 6f33d57750b1c9a2fad078adbde5b3b7b8af8e69 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 12 Jun 2026 21:51:42 -0400 Subject: [PATCH] Fix render_paths_panel scoping bug and nest render_path_field --- project_history.toml | 2 +- src/gui_2.py | 73 ++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/project_history.toml b/project_history.toml index ecacc583..32a74196 100644 --- a/project_history.toml +++ b/project_history.toml @@ -9,5 +9,5 @@ active = "main" [discussions.main] git_commit = "" -last_updated = "2026-06-12T06:55:16" +last_updated = "2026-06-12T21:51:33" history = [] diff --git a/src/gui_2.py b/src/gui_2.py index 5323132f..bc1ea556 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -18,14 +18,13 @@ import typing # Ensure thirdparty is in sys.path for defer _project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -_thirdparty = os.path.join(_project_root, "thirdparty") +_thirdparty = os.path.join(_project_root, "thirdparty") if _thirdparty not in sys.path: sys.path.insert(0, _thirdparty) from contextlib import ExitStack, nullcontext -# from defer import defer -from pathlib import Path -from typing import Optional, Any +from pathlib import Path +from typing import Optional, Any from imgui_bundle import imgui, hello_imgui, immapp, imgui_node_editor as ed, imgui_color_text_edit as ced # Lazy proxies (startup_speedup_20260606 Phase 5D) @@ -83,7 +82,6 @@ class _FiledialogStub: `if p and p not in app.x: app.x.append(p)` treat a missing dialog as a no-op. Exposes a `available` flag so the UI can detect the stub and offer an ImGui-based path input as an alternative. - [C: src/gui_2.py:_LazyModule._resolve] """ available: bool = False def askopenfilename(self, *args: _Any, **kwargs: _Any) -> str: return "" @@ -272,7 +270,6 @@ def _render_v2_capability_badges(caps: "VendorCapabilities") -> None: the original 7 v1 fields (vision, tool_calling, caching, streaming, model_discovery, context_window, cost_tracking) which are already gated elsewhere in the GUI. - [C: src/gui_2.py:render_provider_panel] """ badged_fields: list[tuple[str, str]] = [ ("reasoning", "Reasoning"), @@ -1394,18 +1391,6 @@ class App: self.config["tools"]["default_editor"]["default_editor"] = editor_name self.save_config() self.ai_status = f"Default editor set to: {editor_name}" - - _render_path_field("Logs Directory", "ui_logs_dir", "logs_dir", "Directory where session JSON-L logs and artifacts are stored.") - _render_path_field("Scripts Directory", "ui_scripts_dir", "scripts_dir", "Directory for AI-generated PowerShell scripts.") - - imgui.separator() - if imgui.button("Apply", imgui.ImVec2(120, 0)): self._save_paths() - imgui.same_line() - if imgui.button("Reset", imgui.ImVec2(120, 0)): - self.init_state() - self.ai_status = "paths reset to defaults" - - if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_paths_panel") def _save_paths(self) -> None: """ @@ -2281,29 +2266,51 @@ def render_projects_panel(app: App) -> None: if app.perf_profiling_enabled: app.perf_monitor.end_component("_render_projects_panel") def render_paths_panel(app: App) -> None: + """ + Renders the System Path Configuration panel, allowing editing of logs + and scripts directories. Updates the directories on user input. + + State Mutations: + app.ui_logs_dir, app.ui_scripts_dir (via input text or file dialog select) + + SSDL Shape: + `[I] -> [B:inputs] => [B:apply_reset]` + """ if app.perf_profiling_enabled: app.perf_monitor.start_component("_render_paths_panel") path_info = paths.get_full_path_info() imgui.text_colored(C_IN(), "System Path Configuration") imgui.separator() -def render_path_field(label: str, attr: str, key: str, tooltip: str): - info = path_info.get(key, {'source': 'unknown'}) - imgui.text(label) - if imgui.is_item_hovered(): imgui.set_tooltip(tooltip) - imgui.same_line() - imgui.text_disabled(f"(Source: {info['source']})") + def render_path_field(label: str, attr: str, key: str, tooltip: str): + info = path_info.get(key, {'source': 'unknown'}) + imgui.text(label) + if imgui.is_item_hovered(): imgui.set_tooltip(tooltip) + imgui.same_line() + imgui.text_disabled(f"(Source: {info['source']})") + + val = getattr(app, attr) + changed, new_val = imgui.input_text(f"##{key}", val) + if imgui.is_item_hovered(): imgui.set_tooltip(tooltip) + if changed: setattr(app, attr, new_val) + imgui.same_line() + if imgui.button(f"Browse##{key}"): + r = hide_tk_root() + d = filedialog.askdirectory(title=f"Select {label}") + r.destroy() + if d: setattr(app, attr, d) + + render_path_field("Logs Directory", "ui_logs_dir", "logs_dir", "Directory where session JSON-L logs and artifacts are stored.") + render_path_field("Scripts Directory", "ui_scripts_dir", "scripts_dir", "Directory for AI-generated PowerShell scripts.") - val = getattr(app, attr) - changed, new_val = imgui.input_text(f"##{key}", val) - if imgui.is_item_hovered(): imgui.set_tooltip(tooltip) - if changed: setattr(app, attr, new_val) + imgui.separator() + if imgui.button("Apply", imgui.ImVec2(120, 0)): app._save_paths() imgui.same_line() - if imgui.button(f"Browse##{key}"): - r = hide_tk_root() - d = filedialog.askdirectory(title=f"Select {label}") - r.destroy() - if d: setattr(app, attr, d) + if imgui.button("Reset", imgui.ImVec2(120, 0)): + app.init_state() + app.ai_status = "paths reset to defaults" + + if app.perf_profiling_enabled: app.perf_monitor.end_component("_render_paths_panel") #endregion: Project Management