feat: header streak counter (🔥 N-day streak)#30
Open
jakduch wants to merge 1 commit into
Open
Conversation
9 tasks
9 tasks
Add a small streak badge to the dashboard header that shows the current run of consecutive UTC days with at least one assistant turn. The streak is computed in dashboard._compute_streak from distinct turn dates, anchored at today (returns 0 when there is no activity today), and ignores future-dated rows so a wrong clock cannot inflate the count. The value is exposed on /api/data as `streak` and rendered by a tiny JS block in loadData() into a hidden-by-default span. Tests in tests/test_streak.py cover empty DB, single day, multi-day runs, gaps, future timestamps, and the payload integration.
362ffac to
d5b4f7e
Compare
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.
What does this add and why do you believe it belongs in this dashboard?
Adds a small streak badge to the dashboard header —
🔥 N-day streak— that shows the current run of consecutive UTC days with at least one assistant turn. The badge stays hidden when the streak is 0.A personal Claude Code usage dashboard is the right surface for this kind of nudge: it's the one place you already glance at to see how much you used the tool today, this week, this month. A header streak counter turns that passive lookup into gamification — at a glance you see whether you kept the run alive, whether you've already used Claude today, or whether yesterday's streak just ended. Same low-friction motivator as Duolingo, GitHub contribution graphs, or Apple's Activity rings: one number, in the chrome, rewarding consistency without nagging.
It belongs here (and not in some external tool) because the data is already local, already aggregated by day, and the implementation is tiny: one SQL query over the existing
turnstable, one helper, one CSS pill, one JSON field, and a few lines of JS. No new dependencies, no new files outsidedashboard.pyand a focused test module. The badge auto-hides at streak 0 so it never adds noise.Checklist
Code correctness
calcCost()calls pass 6 arguments:(model, inp, out, cache_read, cache_creation, cache_1h)— n/a, nocalcCostcalls added`), not escaped ones (\`) — no template literals introduced; rendered strings use plain concatenationTests
python3 -m unittest discover -s tests -v— all 199 tests passing (6 pre-existing skips)python3 -m unittest tests.test_browser -v— all 6 tests passingtests/test_streak.pyadds 9 unit tests covering_compute_streak(empty DB, single day, multi-day run, gap before today, missing-today, future timestamps ignored, multiple turns per day) and payload integration (streakkey present, zero for empty DB)Scope
dashboard.py,scanner.py,cli.py,pricing.py,cowork.py,tests/) — or I've explained below why a new file is neededA new test file (
tests/test_streak.py) is added undertests/to keep the streak coverage isolated and easy to grep — consistent with the per-feature test files already in the repo (test_pareto.py,test_period_delta.py,test_health.py, …). All non-test changes are confined todashboard.py.