feat(dashboard): show weekly token pace#534
Conversation
b9a9ce2 to
d5b3f5e
Compare
39843cc to
d377b18
Compare
d377b18 to
5df0354
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5df035489a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .filter((account) => account.resetAtMs > nowMs) | ||
| .map((account) => ({ | ||
| resetAtMs: account.resetAtMs, | ||
| topUpCredits: Math.max(0, account.fullCredits - account.remainingCredits), |
There was a problem hiding this comment.
Model first reset as full replenishment
In buildWeeklyPoolProjection, the first reset event initializes topUpCredits as fullCredits - remainingCredits, which is the amount already consumed, not the amount needed at reset time to restore the account to full. This underestimates post-reset capacity and can falsely project shortfall/depletion (and therefore trigger "danger" status plus pause/throttle recommendations) for accounts whose real burn is sustainable across weekly resets; for example, an account mid-cycle with moderate usage can be marked as depleting even though each reset would keep it above zero.
Useful? React with 👍 / 👎.
Summary
Why
A nearly empty account near its weekly reset should not look scary, and a healthy pool should not tell the operator to do recovery work. The card compares actual remaining tokens to expected remaining tokens per account, then derives display percentages from aggregate token totals instead of averaging account percentages.
Live data sanity check
Checked the real codex-lb usage history around the "tokens were insufficient, then an account was added, then tokens were sufficient" case:
2026-05-03 18:13 UTC: 6-account pool was danger, about 91.5% used vs 76.4% scheduled, short by about 18.8K credits.2026-05-03 18:16 UTC: after adding the unused Pro account, actual 7-account pool became on track, about 64.1% used vs 53.6% scheduled, projected low-water about 31.7K credits.2026-05-03 18:16 UTCstayed danger, short by about 18.7K credits.That matches the intended continuity context: adding a real account turns the pool from insufficient to sufficient, and the card should stop showing Recovery options once the pool is safe.
Validation
cd frontend && bun run test -- ./src/features/dashboard/utils.test.ts ./src/features/dashboard/components/weekly-credits-pace-card.test.tsxcd frontend && bun run typecheckcd frontend && bun run lint(passes with two pre-existing warnings inaccount-multi-select.tsx)cd frontend && bun run build(passes with existing Vite chunk-size/dynamic-import warnings)git diff --check.venv/bin/python -m pytest tests/integration/test_dashboard_overview.py::test_dashboard_overview_combines_dataopenspecCLI is not installed in this workspace, so I could not run local OpenSpec validation.