fix(layout): make 2-column dock layout actually auto-apply

The pre-run install wrote the bundled INI to cwd, and the
_install_default_layout_if_empty helper applies it via
imgui.load_ini_settings_from_memory() when cwd is empty. But the
GUI was rendering all panels as floating windows at default position
(60, 60) with no DockId, despite the bundled INI having a full
[Docking][Data] block with DockSpace + DockNodes + per-window DockIds.

Root cause analysis (via imgui.save_ini_settings_to_memory() at runtime):

1. With default_imgui_window_type=provide_full_screen_dock_space:
   HelloImGui creates its own DockSpace at runtime, overriding the INI's
   DockSpace settings. The DockSpace ID matches (0xAFC85805) but the
   Split/X and child DockNodes from the bundled INI are discarded.
   Runtime INI shows: 'DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,28
   Size=1666,1172 CentralNode=1' (no DockNodes, no DockIds honored).

2. The pre-run install writes the INI to disk, but HelloImGui's
   load_user_pref runs BEFORE post_init, so even a perfect on-disk
   INI doesn't get re-applied to the current session's dock state
   unless we call imgui.load_ini_settings_from_memory() after the
   first frame.

Two-part fix:

A. src/gui_2.py line 678: change default_imgui_window_type from
   'provide_full_screen_dock_space' to 'no_default_window'. Without
   the auto-created DockSpace, HelloImGui honors the INI's full
   docking tree structure.

B. src/gui_2.py _post_init (line 575): always call
   imgui.load_ini_settings_from_memory() after _install_default_layout
   runs, regardless of whether the cwd INI was empty. This re-applies
   the bundled INI to the live session after the first frame is
   rendered, so the panels are docked correctly on the current launch.

Layouts/default.ini: replace the simple 'DockSpace + 2 direct
DockNode children' structure (silently ignored by HelloImGui) with
the user's working nested DockNode tree (5-level deep), mapped to:
- LEFT column (DockNode 0x10, CentralNode=1): Theme, Project Settings,
  AI Settings, Files & Media, Operations Hub
- RIGHT column (DockNode 0x01): Discussion Hub, Log Management,
  Diagnostics

Verification (imgui.save_ini_settings_to_memory at runtime after
15s + first frame):
- LEFT column windows: Pos=0,28, Size=881,1697 (5 panels stacked)
- RIGHT column windows: Pos=883,28, Size=1183,1697 (3 panels stacked)
- [Docking][Data] block fully preserved (DockSpace + 8 DockNodes)
- All 8 panels docked (not floating)

Tests:
- tests/test_default_layout_install.py: 3/3 PASS
- tests/test_api_hooks_gui_health_live.py: 1/1 PASS
- tests/test_command_palette_sim.py: 7/7 PASS
- tests/test_saved_presets_sim.py: 2/2 PASS
- tests/test_live_gui_integration_v2.py: 3/3 PASS
This commit is contained in:
ed
2026-06-30 07:30:44 -04:00
parent 670e255505
commit 5ab23f9eea
3 changed files with 60 additions and 147 deletions
+14 -1
View File
@@ -580,6 +580,19 @@ class App:
if not install_result.ok:
if not hasattr(self, "_startup_timeline_errors"): self._startup_timeline_errors = []
self._startup_timeline_errors.append(("_install_default_layout", install_result.errors[0]))
# Always re-apply the bundled layout to the live imgui session after
# the first frame is rendered. HelloImGui reads ini_filename from disk
# BEFORE post_init fires (during immapp.run's load_user_pref phase),
# so even a perfect on-disk INI may not be honored unless we also
# apply it via imgui.load_ini_settings_from_memory here. The pre-run
# install writes the INI for the NEXT launch; this live apply
# makes the CURRENT launch render the bundled layout correctly.
try:
src_text = src_layout_path.read_text(encoding="utf-8", errors="replace")
imgui.load_ini_settings_from_memory(src_text)
except OSError as e:
if not hasattr(self, "_startup_timeline_errors"): self._startup_timeline_errors = []
self._startup_timeline_errors.append(("_post_init.live_apply", str(e)))
if hasattr(self.controller, "on_warmup_complete"):
cb_result = _post_init_callback_result(self)
if not cb_result.ok:
@@ -662,7 +675,7 @@ class App:
self.runner_params.imgui_window_params.enable_viewports = getattr(self, "ui_multi_viewport", False)
self.runner_params.imgui_window_params.remember_theme = True
self.runner_params.imgui_window_params.tweaked_theme = theme.get_tweaked_theme()
self.runner_params.imgui_window_params.default_imgui_window_type = hello_imgui.DefaultImGuiWindowType.provide_full_screen_dock_space
self.runner_params.imgui_window_params.default_imgui_window_type = hello_imgui.DefaultImGuiWindowType.no_default_window
# Enforce DPI Awareness and User Scale
user_scale = theme.get_current_scale()