Refresh the look and layout of the model-usage plugin

This commit is contained in:
David Heinemeier Hansson
2026-07-28 09:18:24 -07:00
parent 234ac7b3b6
commit 9b693cca63
11 changed files with 1153 additions and 1293 deletions
@@ -94,6 +94,7 @@ def scan(projects_path: Path) -> dict[str, Any]:
seen: set[str] = set()
sessions: set[str] = set()
active_days: set[str] = set()
today_sessions: set[str] = set()
today_tokens: dict[str, int] = {}
usage_by_model: dict[str, dict[str, int]] = {}
@@ -145,6 +146,7 @@ def scan(projects_path: Path) -> dict[str, Any]:
day = local_date_from_timestamp(entry.get("timestamp") or message.get("timestamp"))
session_key = str(entry.get("sessionId") or path)
sessions.add(session_key)
active_days.add(day)
prompts += 1
bucket = usage_by_model.setdefault(model, empty_bucket())
@@ -177,6 +179,11 @@ def scan(projects_path: Path) -> dict[str, Any]:
"modelUsage": usage_by_model,
"totalPrompts": prompts,
"totalSessions": len(sessions),
# Days with any recorded usage, for the all-time "N days" summary.
# The dates travel too: merging snapshots from several machines needs
# their union, which a count alone cannot give.
"activeDays": len(active_days),
"activeDates": sorted(active_days),
"dailyActivity": recent_days,
"scannedFiles": scanned_files,
"malformedLines": malformed_lines,
@@ -71,6 +71,7 @@ today_tokens_by_model = {}
model_usage = {}
sessions_by_day = {day: set() for day in recent_dates}
today_sessions = set()
active_days = set()
today_prompts = 0
today_total_tokens = 0
@@ -86,6 +87,7 @@ def add_usage(day, session_key, model, input_tokens, output_tokens, cache_read,
total = input_tokens + output_tokens + cache_read + cache_write
total_prompts += 1
total_sessions.add(session_key)
active_days.add(day)
bucket = model_usage.setdefault(model, {
"inputTokens": 0,
@@ -336,6 +338,11 @@ out = {
"recentDays": [recent[day] for day in recent_dates],
"totalPrompts": total_prompts,
"totalSessions": len(total_sessions),
# Days with any recorded usage, for the all-time "N days" summary.
# The dates travel too: merging snapshots from several machines needs
# their union, which a count alone cannot give.
"activeDays": len(active_days),
"activeDates": sorted(active_days),
"modelUsage": model_usage,
"usageStatusText": usage_status,
"authHelpText": usage_help,