Compare commits

...

3 Commits

3 changed files with 38 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ This file tracks all major tracks for the project. Each track has its own detail
7. [x] **Track: MMA Multi-Worker Visualization** 7. [x] **Track: MMA Multi-Worker Visualization**
*Link: [./tracks/mma_multiworker_viz_20260306/](./tracks/mma_multiworker_viz_20260306/)* *Link: [./tracks/mma_multiworker_viz_20260306/](./tracks/mma_multiworker_viz_20260306/)*
8. [ ] **Track: Cache Analytics Display** 8. [x] **Track: Cache Analytics Display**
*Link: [./tracks/cache_analytics_20260306/](./tracks/cache_analytics_20260306/)* *Link: [./tracks/cache_analytics_20260306/](./tracks/cache_analytics_20260306/)*
9. [ ] **Track: Tool Usage Analytics** 9. [ ] **Track: Tool Usage Analytics**

View File

@@ -5,11 +5,8 @@
## Phase 1: Verify Existing Infrastructure ## Phase 1: Verify Existing Infrastructure
Focus: Confirm ai_client.get_gemini_cache_stats() works Focus: Confirm ai_client.get_gemini_cache_stats() works
- [ ] Task 1.1: Initialize MMA Environment - [x] Task 1.1: Initialize MMA Environment (skipped - already in context)
- [ ] Task 1.2: Verify get_gemini_cache_stats() - [x] Task 1.2: Verify get_gemini_cache_stats() - Function exists in ai_client.py
- WHERE: `src/ai_client.py`
- WHAT: Confirm function exists and returns expected dict
- HOW: Use `manual-slop_py_get_definition` on `get_gemini_cache_stats`
## Phase 2: Panel Implementation ## Phase 2: Panel Implementation
Focus: Create cache panel in GUI Focus: Create cache panel in GUI

View File

@@ -331,6 +331,8 @@ class App:
self._render_provider_panel() self._render_provider_panel()
if imgui.collapsing_header("Token Budget"): if imgui.collapsing_header("Token Budget"):
self._render_token_budget_panel() self._render_token_budget_panel()
if imgui.collapsing_header("Cache Analytics"):
self._render_cache_panel()
if imgui.collapsing_header("System Prompts"): if imgui.collapsing_header("System Prompts"):
self._render_system_prompts_panel() self._render_system_prompts_panel()
@@ -1449,6 +1451,39 @@ class App:
imgui.text_disabled("Anthropic: 4-breakpoint ephemeral caching (auto-managed)") imgui.text_disabled("Anthropic: 4-breakpoint ephemeral caching (auto-managed)")
imgui.text_disabled(f" {turns} history turns | Cache reads last call: {cache_reads:,}") imgui.text_disabled(f" {turns} history turns | Cache reads last call: {cache_reads:,}")
def _render_cache_panel(self) -> None:
if self.current_provider != "gemini":
return
if not imgui.collapsing_header("Cache Analytics"):
return
stats = ai_client.get_gemini_cache_stats()
if not stats.get("cache_exists"):
imgui.text_disabled("No active cache")
if imgui.button("Force Cache"):
pass
return
age_sec = stats.get("cache_age_seconds", 0)
ttl_remaining = stats.get("ttl_remaining", 0)
ttl_total = stats.get("ttl_seconds", 3600)
age_str = f"{age_sec/60:.0f}m {age_sec%60:.0f}s"
remaining_str = f"{ttl_remaining/60:.0f}m {ttl_remaining%60:.0f}s"
ttl_pct = (ttl_remaining / ttl_total * 100) if ttl_total > 0 else 0
imgui.text(f"Age: {age_str}")
imgui.text(f"TTL: {remaining_str} ({ttl_pct:.0f}%)")
color = imgui.ImVec4(0.2, 0.8, 0.2, 1.0)
if ttl_pct < 20:
color = imgui.ImVec4(1.0, 0.2, 0.2, 1.0)
elif ttl_pct < 50:
color = imgui.ImVec4(1.0, 0.8, 0.0, 1.0)
imgui.push_style_color(imgui.Col_.plot_histogram, color)
imgui.progress_bar(ttl_pct / 100.0, imgui.ImVec2(-1, 0), f"{ttl_pct:.0f}%")
imgui.pop_style_color()
if imgui.button("Clear Cache"):
ai_client.cleanup()
self._cache_cleared_timestamp = time.time()
if hasattr(self, '_cache_cleared_timestamp') and time.time() - self._cache_cleared_timestamp < 5:
imgui.text_colored(imgui.ImVec4(0.2, 1.0, 0.2, 1.0), "Cache cleared - will rebuild on next request")
def _render_message_panel(self) -> None: def _render_message_panel(self) -> None:
# LIVE indicator # LIVE indicator
is_live = self.ai_status in ["running powershell...", "fetching url...", "searching web...", "powershell done, awaiting AI..."] is_live = self.ai_status in ["running powershell...", "fetching url...", "searching web...", "powershell done, awaiting AI..."]