Trends: one chart area for every metric, Money included, drawn by the shared module
ci/woodpecker/push/woodpecker Pipeline failed

Money was its own tab with its own renderers (renderMoney, renderMoneyCumulative,
renderMoneyDaily, renderMoneyLegend), its own period and spend-mode toggles, and
its own titles. It is now a metric of Trends like the others: the definitions come
from CoOpChart.CHART_METRICS, the chart is drawn by the shared renderChart(), and
the Money tab is a shortcut into Trends with that metric selected.

Removed: TREND_CONF, trendVal, trendLabel, the four money renderers, the
period/spend-mode toggles (the single Period row governs every metric now) — 5.1k
chars of duplicate chart code. Added: METRIC_SOURCE (which fetch each metric
needs), buildMetricButtons() (buttons rendered from the shared list, so the panel
and dashboard describe the same charts in the same order), and the metric-aware
renderTrends() that delegates.

The daily token-spend view is now the shared "spend" metric — the same numbers the
metrics endpoint already served, so nothing is lost by dropping the second source.
No caption under the money chart, as before.

Harness rewritten for the new path (it drove renderMoney): invariants preserved —
2 cumulative polylines + single-point balance marker, shared tooltip host, legend
that IS the definition's series list, 5 ascending ticks with the top clearing the
max, 30-day slice. New: every shared metric has a button, and a metric with no
source says so instead of drawing another chart. Tests green (page JS, pins,
guest guard).
This commit is contained in:
inference-admin committed 2026-11-13 20:55:59 +00:00
1 parent 79f3f00165
commit fba50e3f93
5 files changed
+390 -288

No files matched your search

+14 -6
View File
@@ -62,12 +62,20 @@ if [ -n "$HARNESS" ]; then
// Minimal browser stubs, loaded BEFORE the page JS: these pages call
// load()/loadModels() at the end of the script, which need document + fetch.
const els = {};
const mkEl = (id) => ({
id, style: {}, textContent: "", innerHTML: "", className: "",
offsetWidth: 120, offsetHeight: 48,
getAttribute: () => null,
appendChild: () => {},
});
const mkEl = (id) => {
const el = {
id, style: {}, textContent: "", innerHTML: "", className: "",
offsetWidth: 120, offsetHeight: 48,
getAttribute: () => null,
setAttribute: () => {},
appendChild: () => {},
};
// The pages build some markup by inserting HTML into a container
// (buildMetricButtons inserts the SHARED metric list), so the stub has to
// support it or the harness cannot exercise that path at all.
el.insertAdjacentHTML = (pos, html) => { el.innerHTML += html; };
return el;
};
globalThis.document = {
getElementById: (id) => (els[id] = els[id] || mkEl(id)),
querySelectorAll: () => [],