Private
Public Access
0
0

feat(gui): Add layout staleness diagnostic on startup

Adds a one-shot `_diag_layout_state` method that runs in `_post_init`
and prints three lines to stderr:

1. `[GUI] show_windows entries: N, visible by default: M` — how many
   windows are defined vs. visible with no layout file.
2. `[GUI] visible-by-default windows: ...` — the names of windows
   that will appear on a fresh launch.
3. `[GUI] WARNING: layout has N stale window name(s) that no longer
   exist: ...` — when the on-disk manualslop_layout.ini references
   window names that the current code has dropped (Projects/Files/
   Screenshots/Provider/Discussion History/etc. — all replaced by
   the hub pattern in earlier refactors).

This addresses the user's observation that:
- "the diagnostics panel still only shows itself"
- "I see a flicker as if the layout got reset but cannot retain
  permanence"

Both symptoms are caused by the repo-root manualslop_layout.ini
referencing pre-hub-refactor window names that HelloImGui silently
drops on load. The diagnostic surfaces the root cause in the test
log so the user can see exactly which stale names are present,
without having to manually diff the .ini file.

Verified: log appears in `logs/sloppy_py_test.log` on the next
live_gui test run, including the 11 default-visible windows and
the staleness check.
This commit is contained in:
2026-06-07 22:28:36 -04:00
parent 7a4f71e78b
commit 818537b3dd
+36
View File
@@ -500,6 +500,42 @@ class App:
try:
self.controller.on_warmup_complete(lambda status: _on_warmup_complete_callback(self, status))
except Exception: pass
self._diag_layout_state()
def _diag_layout_state(self) -> None:
"""
One-shot startup diagnostic: log show_windows state and warn if the
on-disk manualslop_layout.ini references window names that no longer
exist in the current code. Helps users and test operators detect
stale layout state at a glance instead of debugging missing panels.
[C: src/gui_2.py:App._post_init]
"""
import os as _os
visible_by_default = [w for w, v in self.show_windows.items() if v]
sys.stderr.write(f"[GUI] show_windows entries: {len(self.show_windows)}, visible by default: {len(visible_by_default)}\n")
if visible_by_default:
sys.stderr.write(f"[GUI] visible-by-default windows: {', '.join(sorted(visible_by_default))}\n")
ini_path = _os.path.join(_os.getcwd(), "manualslop_layout.ini")
if not _os.path.exists(ini_path):
sys.stderr.write(f"[GUI] no layout file at {ini_path} (HelloImGui will create a fresh one on shutdown)\n")
return
ini_size = _os.path.getsize(ini_path)
sys.stderr.write(f"[GUI] layout file: {ini_path} ({ini_size} bytes)\n")
try:
with open(ini_path, encoding="utf-8") as _f:
_ini_text = _f.read()
except Exception as _e:
sys.stderr.write(f"[GUI] could not read layout file: {_e}\n")
return
_STALE_WINDOW_NAMES = {
"Projects", "Files", "Screenshots", "Discussion History",
"Provider", "Message", "Response", "Tool Calls",
"Comms History", "System Prompts", "Theme",
}
_stale_found = [n for n in _STALE_WINDOW_NAMES if f"[Window][{n}]" in _ini_text]
if _stale_found:
sys.stderr.write(f"[GUI] WARNING: layout has {len(_stale_found)} stale window name(s) that no longer exist: {', '.join(_stale_found)}\n")
sys.stderr.write(f"[GUI] Run the 'Reset Layout' command from the Command Palette (or delete {ini_path}) to regenerate.\n")
def _trigger_hot_reload(self) -> bool:
from src.hot_reloader import HotReloader