fix(gui): add 1s caching to cache/tool analytics panels to improve performance

This commit is contained in:
2026-03-07 11:07:47 -05:00
parent 992f48ab99
commit c14f63fa26

View File

@@ -1456,7 +1456,11 @@ class App:
return return
if not imgui.collapsing_header("Cache Analytics"): if not imgui.collapsing_header("Cache Analytics"):
return 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"): if not stats.get("cache_exists"):
imgui.text_disabled("No active cache") imgui.text_disabled("No active cache")
if imgui.button("Force Cache"): if imgui.button("Force Cache"):
@@ -1487,11 +1491,11 @@ class App:
def _render_tool_analytics_panel(self) -> None: def _render_tool_analytics_panel(self) -> None:
if not imgui.collapsing_header("Tool Usage Analytics"): if not imgui.collapsing_header("Tool Usage Analytics"):
return return
tool_stats = getattr(self, '_worker_status', {}) now = time.time()
if not tool_stats: if not hasattr(self, '_tool_stats_cache_time') or now - self._tool_stats_cache_time > 1.0:
tool_stats = {} self._cached_tool_stats = getattr(self.controller, '_tool_stats', {})
if hasattr(self.controller, '_tool_stats'): self._tool_stats_cache_time = now
tool_stats = self.controller._tool_stats tool_stats = getattr(self, '_cached_tool_stats', {})
if not tool_stats: if not tool_stats:
imgui.text_disabled("No tool usage data") imgui.text_disabled("No tool usage data")
return return