Files
dflike/docs/superpowers/specs/2026-03-13-llm-stats-reset-design.md
root b2ac0e7a00 feat: add Reset Stats button to admin LLM tracking panel
Allows resetting the LLM stats aggregation window without deleting
historical data. Stores a reset timestamp in metadata and filters
the aggregation query to only include calls after that point.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 01:59:24 +00:00

1.2 KiB

LLM Stats Reset Button

Goal

Add a "Reset Stats" button to the Admin panel's LLM tracking column that gives a clean aggregation window without deleting historical data.

Behavior

  1. "Reset Stats" button appears at the bottom of the right column, below the TOTAL row.
  2. Clicking it emits admin-reset-llm-stats socket event.
  3. Server stores the current timestamp in the metadata table as llm_stats_reset_after.
  4. Server's getAggregatedStats() adds WHERE timestamp > ? using that value.
  5. Server responds with updated (now-empty) stats via existing admin-llm-stats-result.
  6. Client renders the refreshed stats as usual.

Changes

  • server/src/llm/llmStatsService.tsgetAggregatedStats() reads reset timestamp from metadata, filters query. New resetStats() method to store the timestamp.
  • server/src/network/SocketServer.ts — Handle admin-reset-llm-stats event: call resetStats(), respond with fresh stats.
  • client/src/ui/AdminPanel.ts — Add "Reset Stats" button in updateLlmStats(), wire click to new callback.
  • client/src/scenes/GameScene.ts — Wire the new callback through to SocketClient.
  • client/src/network/SocketClient.ts — Add resetLlmStats() method emitting the event.