Skip to content

Fix cutoff is not defined (charts fail silently) + add Today/3d ranges + vendor Chart.js#103

Open
MatrixCODEBreak wants to merge 1 commit into
phuryn:mainfrom
MatrixCODEBreak:fix/cutoff-undefined-and-add-short-ranges
Open

Fix cutoff is not defined (charts fail silently) + add Today/3d ranges + vendor Chart.js#103
MatrixCODEBreak wants to merge 1 commit into
phuryn:mainfrom
MatrixCODEBreak:fix/cutoff-undefined-and-add-short-ranges

Conversation

@MatrixCODEBreak
Copy link
Copy Markdown

What

Three independent improvements; please cherry-pick if you only want one.

1. Fix `ReferenceError: cutoff is not defined` (the headline bug)

`applyFilter()` filters `daily_by_model` on `start`/`end` but the hourly filter just below references `cutoff`, which is never declared. This blew up every page load — `loadData()` threw mid-flight and all panels rendered empty even though the API and the database were fully populated. Spent a while chasing CDN/network issues before noticing the actual JS error in the browser console.

Fix: use the same `(!start || r.day >= start) && (!end || r.day <= end)` shape the daily filter already uses (line 745).

2. Add Today and 3d range buttons

Shortest range was "This Week" / "7d". Wanted to see same-day burn at a glance, especially during heavy work windows. Added `today` and `3d` to the range button row + `getRangeBounds()` + `RANGE_LABELS` / `RANGE_TICKS`.

3. Vendor Chart.js locally + no-cache headers on `/`

Multiple users in private setups (ad blockers like uBlock, corp firewalls, Brave shields) silently lose the jsdelivr CDN, which makes `chart.umd.min.js` 404 inside the browser. Page loads, charts don't render, no error visible without F12. Self-hosting `chart.umd.min.js` from `/static/` removes the dependency entirely.

Also added `Cache-Control: no-store` on `/` — without it, future template changes get stuck behind browser-cached old HTML (which is how I diagnosed the `cutoff` bug in the first place; my fix wasn't taking effect until I forced a hard refresh).

Verification

Loaded with Playwright headless: zero console errors, all charts render correctly, new range buttons filter the data set as expected.

Notes

Built this on top of your dashboard while debugging cost-routing on a heavy Claude Code project. Thanks for the tool — it's been the single most useful piece of observability for that work.

…t.js

Three independent improvements; maintainer feel free to cherry-pick.

1. **Fix `ReferenceError: cutoff is not defined`** (the headline bug).
   applyFilter() filters daily_by_model on start/end but the hourly
   filter references `cutoff`, never declared. Causes charts to
   silently fail — loadData() aborts and panels render empty even
   though API data is fully populated.

2. **Add Today and 3d range buttons.** Shortest range was This Week /
   7d. Both new buttons added with range bounds + labels.

3. **Vendor Chart.js locally + no-cache headers on /.** CDN
   sometimes blocked by ad-blockers / corp firewalls. Self-hosting
   chart.umd.min.js from /static/ removes the dependency. Cache-
   Control: no-store on / prevents stuck-cached old HTML.

Verified locally: zero console errors via Playwright headless, all
charts render, new buttons filter correctly.
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.

1 participant