Skip to content

feat: header streak counter (🔥 N-day streak)#30

Open
jakduch wants to merge 1 commit into
josepe98:mainfrom
jakduch:feat/streak-counter
Open

feat: header streak counter (🔥 N-day streak)#30
jakduch wants to merge 1 commit into
josepe98:mainfrom
jakduch:feat/streak-counter

Conversation

@jakduch
Copy link
Copy Markdown
Collaborator

@jakduch jakduch commented May 23, 2026

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 turns table, one helper, one CSS pill, one JSON field, and a few lines of JS. No new dependencies, no new files outside dashboard.py and a focused test module. The badge auto-hides at streak 0 so it never adds noise.

Checklist

Code correctness

  • All calcCost() calls pass 6 arguments: (model, inp, out, cache_read, cache_creation, cache_1h) — n/a, no calcCost calls added
  • JavaScript template literals use bare backticks (`), not escaped ones (\`) — no template literals introduced; rendered strings use plain concatenation
  • No JS variables referenced before they are defined
  • No new third-party dependencies introduced

Tests

  • 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 passing
  • New behaviour is covered by at least one test — tests/test_streak.py adds 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 (streak key present, zero for empty DB)

Scope

  • This is a single concern — one feature or fix per PR (header streak counter only)
  • Only touches existing files (dashboard.py, scanner.py, cli.py, pricing.py, cowork.py, tests/) — or I've explained below why a new file is needed

A new test file (tests/test_streak.py) is added under tests/ 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 to dashboard.py.

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.
@jakduch jakduch force-pushed the feat/streak-counter branch from 362ffac to d5b4f7e Compare May 25, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants