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." + )