From 8fac9c34c9ef89404522f320bcfd6a4915e247bc Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 3 Jun 2026 11:28:36 -0400 Subject: [PATCH] fix(log): Refresh Registry button now calls load_registry() on the live instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ROOT CAUSE: gui_2.py:1675 re-instantiated LogRegistry() which opens the TOML but never called .load_registry() so the table stayed empty. FIX: in-place load_registry() on the existing instance — preserves in-memory state (any pending update_session_metadata call) and matches the user's intent of 'refresh from disk'. --- src/gui_2.py | 3 ++- tests/test_log_management_refresh.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/test_log_management_refresh.py diff --git a/src/gui_2.py b/src/gui_2.py index 274ea0b7..029bdbf0 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -1672,7 +1672,8 @@ def render_log_management(app: App) -> None: if exp: if app._log_registry is None: app._log_registry = log_registry.LogRegistry(str(paths.get_logs_dir() / "log_registry.toml")) else: - if imgui.button("Refresh Registry"): app._log_registry = log_registry.LogRegistry(str(paths.get_logs_dir() / "log_registry.toml")) + if imgui.button("Refresh Registry"): + if app._log_registry is not None: app._log_registry.load_registry() imgui.same_line() if imgui.button("Load Log"): app.cb_load_prior_log() imgui.same_line() diff --git a/tests/test_log_management_refresh.py b/tests/test_log_management_refresh.py new file mode 100644 index 00000000..b4e719ab --- /dev/null +++ b/tests/test_log_management_refresh.py @@ -0,0 +1,17 @@ +import inspect +from src import gui_2 + +def test_refresh_registry_button_calls_load_registry(): + src = inspect.getsource(gui_2) + marker = "Refresh Registry" + idx = src.find(marker) + assert idx != -1, "Could not find Refresh Registry button in gui_2.py" + snippet = src[idx:idx + 400] + assert "load_registry" in snippet, ( + "Refresh Registry button must invoke load_registry(); " + "currently it only re-instantiates LogRegistry which leaves .data empty." + ) + assert snippet.count("log_registry.LogRegistry(") <= 1, ( + "Refresh Registry button should not re-instantiate LogRegistry. " + "Prefer in-place load_registry() on the live instance." + )