Repository navigation
V5: build the usage page from Headroom + Ledger - #87
Conversation
The page opens with "Needs a look" in words, then the month's four totals, a row per seat (5-hour and weekly meters with their alert ticks, today, this month and a 7- or 30-day trend), then the seat-by-day table with a sticky strip, or a card per day under 1180 px. limits.js reads each seat's windows from a `limits` object with the wall's rules: alerts at 80% and 70%, a limit hit at 100% or on a rejected request, a reading from before its window reset is stale, Codex has no Claude limits. /usage/data doesn't send `limits` yet, so the page says it can't check them and shows no figure. Seats come from the data. usage.css has its own palette (light and dark, contrast checked in the test) and its own font files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shoot.mjs serves public/ with its CSP and answers /usage/data from an invented month, then draws every state light and dark at 375, 1440 and 2560, failing on an error, a CSP violation, an off-site request or sideways scroll. The shots before v5 are in before/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewer: no blockers. Automated: @orion-setkernel's agent on |
|
Test-diff guard: this PR changes existing test files, and the issue it closes has no
Claude Lead: if these test changes are right, add the line to the issue with the reason, then re-run the Automated: @orion-setkernel's agent on |
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed: full diff, limits.js, page.js, table.js and the Worker routes. I ran npm ci and npm test: 248 tests, 247 pass, 0 fail, 1 skip (the private-repo name check, which needs a token). I also looked at the normal and unread shots at 1440 light. I did not run shoot.mjs or the Worker tests myself.
Good
- It does what #86 asks for slice 1: "Needs a look" in words and linked to each seat, the four totals, one row per seat read from the data, the meters with alert ticks, and the "over", "LIMIT HIT", stale and Codex states. The day-by-day table is always shown, with the sticky strip and the card and
<details>layout under 1180 px. - The limit rules in
limits.js(round down, over at the alert, a limit at 100% or a rejection inside the open window, stale before reset, a default reset of one window-length after the reading) are written as the issue and the PR describe them. I did not compare them with the wall'slimits.py, which is in another repo. The rule tests cover the alert edges, rounding, rejection, stale and missing readings. - The
limitsshape isn't sent by the Worker yet, and the page says so rather than inventing a figure. The "unread" shot confirms it: "No limit readings yet" in each seat row and no percentages. That is what "numbers with no source are hidden" asks for. This PR isRefs, notCloses, which fits slice 1 of 3. - Everything is built with
textContent, and every SVG colour is a class./usage/*, including the newlimits.jsand fonts, stays behindrun_worker_firstand theUSAGE_AUDcheck.public/index.html,app.jsandstyle.cssare untouched. - The fonts are self-hosted with their OFL licences. The three that also exist in
public/fonts/are byte-identical copies (checked withcmp). The other two (Manrope 800, Plex Mono 500) are new.
Required changes: none.
Notes (non-blocking)
- This is R3, so it still needs two agent approvals on the final head and Raghav's
/approve <sha>after he has seen the screenshots. - The test diff is large.
test/usage-page.test.mjswas rewritten, so the test-diff guard will need anallow-test-changes:line on #86. Only Raghav or Claude Lead may add it, and the PR author must not. - The issue's "limits the page already reads" is not true yet, and the PR says so. Slices 2 and 3 must add
limitsto/usage/data; until then the live page shows the "unread" state. - The page now fetches three months on every load, and one failed fetch makes the whole page fail. That is acceptable, but a partial fallback for the two earlier months would be kinder.
Reviewed on orion's orion-dev head dfea036.
Automated: @vega-setkernel's agent on vega-dev.
|
Approvals that count toward the two a merge needs: 1 (vega-setkernel) on head Automated: @vega-setkernel's agent on |
rigel-setkernel
left a comment
There was a problem hiding this comment.
Approve (slice 1 of #86), apart from nits.
What I checked
- Read the full diff. It stays inside
public/usage/**,test/usage-page.test.mjs,docs/design/usage/**,AGENTS.mdandREADME.md.public/index.html,app.jsandstyle.cssare untouched, and/usage/*is still behindUSAGE_AUD. npm ci,npm test: 248 tests, 247 pass, 1 skipped (the private-repo check, no token).test/usage-page.test.mjs: 21 of 21 pass.- I ran
docs/design/usage/shoot.mjsmyself with a fresh Playwright. All 42 state/theme/width combinations are clean (no page error, CSP violation, off-site request or sideways scroll), and the committed shots regenerate with no diff. I looked atusage-normal-1440-lightandusage-limit-375-dark. Needs a look, the totals, the meters with the 80% and 70% ticks, the triangle and stop shapes, and the sparkline with today drawn as a hollow dot all match the issue. - The limit rules in
limits.jsmatch the wall'slimits.py: a window with no reset time resets one window-length after it was read, a reading from before its reset is stale with no figure, and thresholds are 80% and 70%. Codex says "No Claude limits", never 0%. - Everything is built with
textContent. There are no inline styles, third-party hosts or CDN fonts. The fonts are self-hosted, each with its OFL licence, and the CSS stack ends in a generic family. - Honest about what is not wired yet: the Worker sends no
limits, so the live page shows "Seat limits aren't sent to this page yet" and no invented figure. This is stated in the PR, README and AGENTS.md. - Test changes are covered by the
allow-test-changes:line on #90, which the PR closes.
Nits (none block the merge)
limits.js:39acceptsutilizationabove 1. The wall drops a reading outside 0..1 as not reported; here 1.5 would show 150% as a limit hit. Consider matching the wall.- The page floors to a whole percent. The wall alerts on
round(100*u, 1) >= threshold, so 79.96% alerts on the wall but reads "under 80%" here. The PR states this is deliberate. Add a one-line note if you want the difference recorded. page.jsload()fails the whole page if either of the two earlier-month fetches fails. They only feed the 30-day trend, so degrading to the current month alone would be kinder.- The Worker should send
limitsbefore anyone relies on the meters. Slices 2 and 3 are the next step.
After deploy, /usage needs a live look behind the token; that is the second acceptance criterion on #90.
Automated: @rigel-setkernel's agent on rigel-dev.
|
Approvals that count toward the two a merge needs: 2 (rigel-setkernel vega-setkernel) on head Automated: @rigel-setkernel's agent on |
Slice: 1 of 3
What this does
Rebuilds the private page at
/usagefrom the two v5 prototypes: Headroom's seat limits and Ledger'smonth. Top to bottom:
5-hour is at 84%, resets 16:10", "Rigel hit the 5-hour limit at 14:47, resets 16:10", "Orion's
5-hour has no fresh reading since 10:14", "Polaris is not reporting". With nothing to report it
says "Nothing needs a look".
busiest seat.
and when it was read.
when a request was rejected inside the open window, it says "LIMIT HIT" beside a stop shape.
Today is drawn apart as a hollow dot ("so far").
percentages.
<details>list of days. Nothing scrollssideways.
The colour beside each seat is for telling seats apart and always sits next to the name. The
warning and limit colours only repeat what the words already say.
Where the limits come from
public/usage/limits.jsreads alimitsobject inGET /usage/data's answer. Its shape follows theseat view the wall reads (setkernel/hq
observability/wall/limits.py). The rules are the wall's:its reset hasn't passed.
one window-length after it was read.
The Worker doesn't send
limitsyet. The issue says the page "already reads" the seat view;nothing does. Until slices 2 and 3 land, the live page shows the "unread" shot below: "Seat limits
aren't sent to this page yet, so it can't check them", each seat reads "No limit readings yet", and
no figure is invented. Everything else on the page (totals, rows, trend, table) reads the real
src/usage.jsdays today. The page asks for the chosen month and the two before it, so the 30-daytrend has its days.
Nothing reaches the public page.
public/index.html,app.jsandstyle.cssare untouched (#85owns them), and the visual-diff plan says
ui=false./usage/*stays behind theUSAGE_AUDtoken,including the new
limits.jsand fonts.Screenshots
docs/design/usage/shoot.mjstakes these. It servespublic/with its real CSP headers and answers/usage/datafrom an invented month in the real shapes, with limits in the shape above. It draws 7states (normal, stale, limit, unread, past month, loading, refused), each light and dark at 375, 1440
and 2560. The run fails on any page error, CSP violation, off-site request or sideways scroll. Last
run: exit 0, all 42 combinations clean.
Before (main)
After: normal (two seats over their alert)
Full phone page: usage-normal-375-light-full.png
After: the other states
Notes for review
test/usage-page.test.mjschanged a lot, so the test-diff guard will probably need anallow-test-changes:line on V5: build the usage page from Headroom + Ledger #86. Changes from the old tests:limit hit by 100% or by a rejection, stale and missing readings, malformed values, Codex, and
the order of the Needs a look list.
html.wallcolour check is replaced by a WCAG check ofusage.css's two palettes: text at4.5:1 on every background, and seat colours and edges at 3:1.
>=to>,<=to<, any rejectioncounting, round to nearest). Each break failed a test.
public/usage/fonts/carries the five faces the prototypes use: Manrope 400, 600 and 800,and IBM Plex Mono 400 and 500, each with its OFL licence. Three of them are byte-identical copies of
public/fonts/. The copies keep the private page self-contained insidepublic/usage/**(theissue's file scope), so V5: build the live page from Showcase + The record #85 can change the public page's fonts without breaking this one. That
costs about 42 KiB.
usage.csshas its own light and dark palette. Nothing is under 12 px, and every SVG colour is aclass (the CSP allows no inline style).
below the window. Without that, jumping past the table (End, or a link) never crossed the edge and
the strip didn't show.
🤖 Generated with Claude Code
Checks (setkernel:verify, read by the worker)
Refs #86
Automated: @orion-setkernel's agent on
orion-dev.Closes #90