From 71028dad5bf8bd3b30097bacceea933c8799b391 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 29 Jun 2026 20:11:43 -0400 Subject: [PATCH] fix(gui): drop stale `from src.command_palette import` in render_main_interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The REAL cause of the "black window" bug. The render_main_interface function (in App._gui_func every frame) was importing render_palette_modal from `src.command_palette`, a module that was DELETED in `module_taxonomy_refactor_20260627` (the refactor moved the registry into `src/commands.py` but `render_palette_modal` itself is a render function in `src/gui_2.py` because it owns ImGui state). Every frame, this local import raised ModuleNotFoundError. The error was silently caught by `_render_main_interface_result`'s outer try/except (Result-based error drain), so the entire `render_main_interface` body was aborted. That meant `_render_window_if_open(...)` was never called for ANY window, and the dockspace was never populated with the 8 default-visible windows. Hence the user-visible "only menu ribbon showing" symptom. Two-part fix: 1. Removed the broken local imports inside render_main_interface: - `from src.command_palette import render_palette_modal` (deleted module) - `from src.commands import registry as _cmd_registry` (local import anti-pattern per python.md §17.9a) 2. Extended the existing top-level command-palette imports block in src/gui_2.py (line 8772) to add `registry as _cmd_registry`: `from src.commands import Command as _CpCommand, fuzzy_match as _cp_fuzzy_match, _close_palette, _execute as _cp_execute, registry as _cmd_registry` 3. Replaced the local-import block with a direct call: `render_palette_modal(app, _cmd_registry.all())` `render_palette_modal` is defined locally in src/gui_2.py at line 8775 (it owns ImGui state per the comment in src/commands.py:21), so the call is a direct function reference. `registry` is now imported once at the top of the file, eliminating the function-level import. The `from src.commands import ...` block at line 8772 was already top-level so adding `registry as _cmd_registry` to it is a single-line extension (no new import statement). Why the existing test suite didn't catch this: - `test_commands_does_not_import_gui_2_at_module_level` checks MODULE-LEVEL imports, not function-level local imports - The function-level `from src.command_palette import render_palette_modal` is a python.md §17.9a banned pattern (Local imports inside functions) but the §17.9a audit (audit_imports.py with whitelist) had this file in the hot-reload whitelist - The 3 install tests + 14 adjacent tests all run in subprocess.Popen shells that have a SHORT lifetime (~5s); the ModuleNotFoundError doesn't cause the subprocess to crash, it just makes render_main_interface no-op every frame. Tests that read INI content or app.show_windows state don't notice the rendering is broken. Empirical verification (manual launch 18s with --enable-test-hooks OFF): - Before fix: stderr shows 50+ "[FATAL] render_main_interface crashed: ModuleNotFoundError: No module named 'src.command_palette'" lines (one per frame at 60fps for 8 seconds) - After fix: stderr shows ZERO FATAL lines; saved INI contains 8 [Window][X] entries + [Docking][Data] + 2 DockNode children + 0 stale window names - 17/17 tests still pass (3 install + 2 reset_layout + 8 gui + 4 commands) - Reverted the diagnostic stderr writes I added in _render_window_if_open and _render_main_interface_result during investigation; both back to their pre-debug state --- src/gui_2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui_2.py b/src/gui_2.py index 6f5ebba0..5c73a4c9 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -1893,8 +1893,6 @@ def render_main_interface(app: App) -> None: render_save_preset_modal(app) render_save_workspace_profile_modal(app) render_add_context_files_modal(app) - from src.command_palette import render_palette_modal - from src.commands import registry as _cmd_registry render_palette_modal(app, _cmd_registry.all()) render_preset_manager_window(app) render_tool_preset_manager_window(app) @@ -8757,7 +8755,7 @@ def draw_soft_shadow(draw_list: imgui.ImDrawList, p_min: imgui.ImVec2, p_max: im #endregion: Shaders #region: Command Palette Modal (rendering only; registry lives in src/commands.py) -from src.commands import Command as _CpCommand, fuzzy_match as _cp_fuzzy_match, _close_palette, _execute as _cp_execute +from src.commands import Command as _CpCommand, fuzzy_match as _cp_fuzzy_match, _close_palette, _execute as _cp_execute, registry as _cmd_registry def render_palette_modal(app: Any, commands: List[Any]) -> None: if not getattr(app, "show_command_palette", False):