feat(dashboard): show Claude usage per day/week instead of per session

Persists per-day token usage (usage_store, ~/.config/wsai/usage.json, survives
restarts) and surfaces it in status as claude_usage.{today,week}. The navbar now
shows two cards — 오늘 토큰 / 주간 토큰 (input+output, with per-card tooltips
breaking down input/output tokens and requests) — replacing the session-only
token count.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-08-22 22:20:30 +09:00
parent 7ea07c13ad
commit d1d4bd1514
3 changed files with 95 additions and 6 deletions

View File

@@ -194,10 +194,15 @@ class Monitor:
with self._lock:
s = dict(self._status)
s["uptime_s"] = round(_now_wall() - s["started_wall"], 1)
from . import usage_store
s["claude_usage"] = usage_store.summary() # 오늘 / 최근 7일 토큰
return s
def add_claude_usage(self, input_tokens: int, output_tokens: int) -> None:
"""Accumulate one Claude call's token usage for the dashboard."""
"""Record one Claude call's token usage (session counters + persisted
per-day store for the dashboard's 하루/일주일 사용량)."""
from . import usage_store
usage_store.record(input_tokens, output_tokens)
with self._lock:
self._status["claude_requests"] += 1
self._status["claude_input_tokens"] += int(input_tokens or 0)