fix(gui): add 1s caching to cache/tool analytics panels to improve performance
This commit is contained in:
16
src/gui_2.py
16
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
|
||||
|
||||
Reference in New Issue
Block a user