Add live limits widget, session health, multi-metric efficiency grader, and per-message live session view#123
Open
changsunglim wants to merge 3 commits into
Conversation
…view - limits.py: plan auto-detect via keychain OAuth + 24h cache; per-plan session-5h + weekly budgets for pro/max_5x/max_20x; rolling 7d split by opus/sonnet/haiku - Dashboard top banner: weekly stacked bar (Opus/Sonnet/Haiku) with per-model breakdown line; ThreadingHTTPServer so /api/data and /api/limits don't block each other - Session Health card: heuristic "start new session" warning when context >150k, cache-hit <40%, avg >60k tok/turn, or age >3h - Token Efficiency: weighted grader (Cache Hit 40% + Reuse Ratio 25% + Cost Efficiency 20% + Output Discipline 15%) with info tooltip; replaces "By Model" pie; respects date-range filter - Per-message live view: /api/session/<id> groups turns by user prompt; click row → polls every 5s; filters skill/system-reminder noise so list shows only real human turns - Session titles from first JSONL user prompt (replaces opaque project IDs) - Local TZ auto-detect via datetime().astimezone().utcoffset() - Hourly chart: average divides by calendar days in range (not active-only days); SQL pre-shifts so JS no longer double-shifts - Auto-rescan on every /api/data fetch - Bug fix: cutoff → start/end ReferenceError that killed all charts
- Fork banner with link to upstream - Fork features section: limits widget, plan budget table, session health heuristic, efficiency grader formula, live view, new endpoints - Add limits.py to files table
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds plan-budget visibility, session-health hints, a multi-metric efficiency grade, and a per-message live view of in-flight sessions. Also fixes a
ReferenceError(cutoff→start/end) that was killing all charts, and replaces UTC-only timestamps with auto-detected local TZ.All changes are additive — no breaking API changes, no new third-party deps, still standard-library only.
What's new
Live limits widget (
limits.py+/api/limits)opus X% · 5.5M sonnet Y% · 550k haiku Z%.CLAUDE_USAGE_PLANenv →prodefault. 24h cache at~/.claude/usage-plan-cache.json.pro/max_5x/max_20x(Anthropic doesn't publish exact caps — calibrated to within ~25% on real usage).0.1×in billable totals to mirror Anthropic's cost-equivalent counting.ThreadingHTTPServerso/api/limitsand/api/datadon't block each other.Session Health card
Heuristic "start new session" warning when any of:
States:
ok/info/warnwith colored border.Token Efficiency grader (replaces "By Model" pie)
Weighted A/B/C/D grade:
?info button reveals the formula. Recalcs with/api/data, respects date-range filter.Per-message live session view (
/api/session/<id>)Click a session row → polls every 5s. Each user prompt shows token totals (input / output / cache_read / cache_creation), model, turn count, and tools used. Skill invocations and
<system-reminder>blocks are filtered so the list shows real human turns only.Quality-of-life
datetime.now().astimezone().utcoffset()— no more manual UTC offset./api/datafetch (incremental scan is cheap).cutoff→start/endReferenceErrorthat was killing all charts in the previous filter refactor.Files touched
dashboard.pylimits.pyREADME.mdNotes for review
PLAN_BUDGETSare approximations — happy to remove the table and surface "% of weekly" only if you prefer not to ship numbers Anthropic hasn't published.Happy to split this into smaller PRs (limits / efficiency / live-view / bugfix) if that's easier to review. Let me know what you prefer.