Four equal columns (the name/meta, the bar, the value, the action) instead of a
wider bar column, and the chat row shows ' - ' in the action column rather than
rendering an empty cell that made the row look broken.
The first cut built a row per key in the metadata list and attached usage to it.
Live, an account with three keys that had spent real money (homebot $11.84,
office-pi $0.19, base-pi $0.19) came back with an EMPTY key list and four usage
rows, so the chart drew one bar — the chat key — and quietly dropped the rest.
Exactly the kind of "listing" this chart exists to compare.
Now the usage rows are the authoritative set: every row gets a bar, metadata is
attached when we have it, and a key with no usage still gets a zero row so a key
you own is never invisible. The harness pins all three cases.
* Chart buttons take the admin panel's look: bordered, 8px radius, green-mid when
active (was a borderless segmented control). One design across both apps.
* "co-op spend, all time" now reads the portal's figure from /api/metrics instead
of summing the chart series in the browser. The second card ("of which the
co-op's own accounts") is gone: it was that same client-side sum, and the
portal's own breakdown is a panel-side notion I will not fake here.
* The API keys are a chart: one bar row per key — the chat key included, so the
built-in key's usage is comparable rather than a footnote — with a Spend /
Requests toggle. Revoke stays on each real key's row.
buildMetricButtons() was defined but never called — a one-shot replace had
slipped the call into loadGuests()'s 401 branch, and removing that left no call
at all. So the dashboard rendered its data with an empty metric row: no way to
switch between the shared metrics. Called at boot now, anchored on the closing
script tag, and the harnesses plus the served-page browser check confirm the row
exists with all six data-metric buttons.
The dashboard carried the identical inline-handler line inside PAGE_HTML — the
served JS was a syntax error from there on, so the page loaded and then did
nothing — and a second casualty of the same sloppy one-shot replace:
`location.reload()` had become `location.rebuildMetricButtons()\nload()` inside
loadGuests(). Both are fixed, and the same gate fix applies (the gate now reads
PAGE_HTML via ast.literal_eval, i.e. the string the app serves, not the source
text between the quotes).
Buttons are delegated data-metric clicks now, the harness proves the click
reaches setTrendMetric, and the stub gained stateful attributes plus
addEventListener/__fire to make that possible.
The dashboard kept its own TREND_CONF with its own titles ("The co-op over time",
"What the co-op spent (members + the co-op's own accounts)") and its own toggles —
the other half of the drift the panel just lost. The metric list is now
CoOpChart.CHART_METRICS, the chart is drawn by the shared renderChart(), and the
buttons are built from the shared list, so members and stewards read the same
charts with the same names.
Money arrives as a metric here too, fed by a new /api/money-series proxy to the
portal's /broker/money-series — the co-op's cumulative revenue, cumulative token
spend and OC balance (a gap before snapshots began, never a zero). Deleting the
local TREND_CONF/trendVal/trendLabel also removes the second set of formatters.
Two page-blanking bugs caught by check-page-js.sh before they could ship: a
destructured fmtMoney colliding with this page's own (duplicate const), and `esc`
(which the panel defines and this page does not — it uses escapeHtml).
Harness extended: the money metric draws 2 lines + a single-point balance marker,
the tooltip lists every series and reports the unmeasured balance as not
measured, the metric row equals the shared list filtered by METRIC_SOURCE, and a
metric with no source says so. Geometry proof: 15 captured renders (5 metrics x 3
ranges) byte-identical to the predecessor with aria stripped.
Same byte-identical module as the panel; the dashboard's own port to the shared
definitions is the next commit. check-page-js.sh's DOM stub now supports
setAttribute/insertAdjacentHTML, which the shared metric-button builder needs.