From c14f63fa2644d2ddc210ee7a708f93f07f528058 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 7 Mar 2026 11:07:47 -0500 Subject: [PATCH] fix(gui): add 1s caching to cache/tool analytics panels to improve performance --- src/gui_2.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui_2.py b/src/gui_2.py index 5290006..12a5630 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -1456,7 +1456,11 @@ class App: return if not imgui.collapsing_header("Cache Analytics"): return - stats = ai_client.get_gemini_cache_stats() + now = time.time() + if not hasattr(self, '_cache_stats_cache_time') or now - self._cache_stats_cache_time > 1.0: + self._cached_cache_stats = ai_client.get_gemini_cache_stats() + self._cache_stats_cache_time = now + stats = self._cached_cache_stats if not stats.get("cache_exists"): imgui.text_disabled("No active cache") if imgui.button("Force Cache"): @@ -1487,11 +1491,11 @@ class App: def _render_tool_analytics_panel(self) -> None: if not imgui.collapsing_header("Tool Usage Analytics"): return - tool_stats = getattr(self, '_worker_status', {}) - if not tool_stats: - tool_stats = {} - if hasattr(self.controller, '_tool_stats'): - tool_stats = self.controller._tool_stats + now = time.time() + if not hasattr(self, '_tool_stats_cache_time') or now - self._tool_stats_cache_time > 1.0: + self._cached_tool_stats = getattr(self.controller, '_tool_stats', {}) + self._tool_stats_cache_time = now + tool_stats = getattr(self, '_cached_tool_stats', {}) if not tool_stats: imgui.text_disabled("No tool usage data") return