Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7d5f900
Start squad record for feature 219
claude Nov 29, 2026
06b1b12
Write spec for feature 219
claude Nov 29, 2026
8b35a61
Write spec for feature 219
claude Nov 29, 2026
61811df
Log spec challenge for feature 219
claude Nov 29, 2026
4f18d11
Revise spec for feature 219
claude Nov 29, 2026
93f38d0
Plan feature 219
claude Nov 29, 2026
1e076f5
Log plan security review for feature 219
claude Nov 29, 2026
6895aab
Add challenge notes to plan for feature 219
claude Nov 29, 2026
7c12c81
Skeleton for theme Console (G1)
claude Nov 29, 2026
aa11ef2
Tests first for theme Console (G1)
claude Nov 29, 2026
5203d8a
Implement canvas drawing properties for theme Console (G1)
claude Nov 29, 2026
fa4708d
Add regression tests for theme Console (G1)
claude Nov 29, 2026
a51506d
Log G2 skeleton skip
claude Nov 29, 2026
e0f7310
Tests first for theme Console (G2)
claude Nov 29, 2026
896e3e6
Implement theme Console rules and number/unit split (G2)
claude Nov 29, 2026
f91383c
Log G2 decision and work in progress
claude Nov 29, 2026
59c17e1
Fix two G2 tests per decision
claude Nov 29, 2026
d86f6ea
Log documentation step
claude Nov 29, 2026
e6e3ea4
Record gate stamp for feature 219
claude Nov 29, 2026
cf52167
Log review round 1
claude Nov 29, 2026
40b3808
Fix documentation findings of review round 1
claude Nov 29, 2026
930c9cb
Record verbatim gate stamp
claude Nov 29, 2026
042a6d3
Accept decision 0043
claude Nov 29, 2026
86aaf9e
Record PR approval
claude Nov 29, 2026
ae6e7ee
Remove squad working record
claude Nov 29, 2026
ab77d34
Rename shadowing identifier in palette test
claude Nov 29, 2026
40b4941
Add Console theme screenshots
claude Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ automation systems like openHAB). Runs as a systemd service.

![PiMonitor dashboard](docs/dashboard.png)

The Console theme, light and dark:

![PiMonitor dashboard, Console theme, light](docs/dashboard-console-light.png)
![PiMonitor dashboard, Console theme, dark](docs/dashboard-console-dark.png)

## Features

- **CPU usage** - overall and per-core percentage, with a trend sparkline
Expand Down Expand Up @@ -54,8 +59,8 @@ automation systems like openHAB). Runs as a systemd service.
metric sampling
- **Light/dark mode toggle** - follows the OS setting by default, with a
manual override remembered in the browser
- **Choosable themes** - picked in the Customize dialog once more than one
theme is available (only Clear today), remembered in the browser
- **Choosable themes** - Clear and Console (a monospace, outlined look), picked
in the Customize dialog, remembered in the browser
- **Configurable dashboard layout** - show/hide and reorder metric cards
from a settings modal, remembered in the browser
- A versioned REST API (`/api/v1/...`) for third-party consumers, with
Expand Down
49 changes: 36 additions & 13 deletions docs/areas/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ client of the [HTTP API](http-api.md) like any third-party integration and has n

- CPU usage, temperature, memory, swap and each filesystem are colored `crit` when the value is greater than or
equal to the matching `*_crit` threshold from `/api/v1/config`, otherwise `warn` when greater than or equal to the
`*_warn` threshold, otherwise `ok` — the same comparison the alert engine uses.
`*_warn` threshold, otherwise `ok` — the same comparison the alert engine uses. The levels are the same in every theme; only the color of `ok` differs: green in Clear, `--text` in Console, where color marks only `warn` and `crit` (*Look*, [0043](../decisions/0043-console-colour-only-for-warn-and-crit.md)).
- The load-average gauges (1, 5 and 15 min) run from 0 to the CPU core count and are colored against the CPU
thresholds scaled to the core count (`cores × cpu_warn_percent / 100`, `cores × cpu_crit_percent / 100`).
- Coloring follows the raw value of every poll and is independent of alert state: a value can be colored `crit`
Expand Down Expand Up @@ -207,7 +207,7 @@ client of the [HTTP API](http-api.md) like any third-party integration and has n
### Theme

- A theme is a named set of palette tokens, chosen independently of the mode. The registered themes are listed once,
in `PIMONITOR_THEMES` of `theme-init.js`; today only Clear exists, and it is the default (the first entry).
in `PIMONITOR_THEMES` of `theme-init.js`: Clear, the default (the first entry), and Console (`console`), second.
- The default is the absence of the `data-style` attribute on `<html>`; any other theme sets `data-style` to its id.
- The choice is stored in `localStorage` under `pimonitor-style` (the theme's id). A stored value that is no
registered id (unknown, differently cased, unreadable) means Clear; it is kept in storage unchanged, never
Expand All @@ -220,28 +220,50 @@ client of the [HTTP API](http-api.md) like any third-party integration and has n
- All themes are in the one `style.css`, one DOM. A theme other than Clear has three palette blocks
(`:root[data-style="<id>"]`, with `[data-theme="dark"]`, and inside `prefers-color-scheme: dark` with
`:not([data-theme])`), each with the same token set as Clear's.
- Reasons: [0041](../decisions/0041-theme-choice-per-browser-as-pimonitor-style.md),
- Console follows the Clear blocks with its own palette (monospace look, outlined buttons, no shadows). Its
`--accent` and every `--accent-<card>` are the mode's `--text` hex, `--on-accent` the `--card-bg` hex, and
`--shadow` and `--dialog-shadow` are `0 0 0 transparent` instead of `none`, which would make the
`box-shadow` list of `.theme-toggle:hover` invalid. Its look beyond tokens is rules in `style.css` whose every
selector starts with `:root[data-style="console"]`; only the unit gap `.metric-unit::before` is an unscoped rule.
- Reasons: [0038](../decisions/0038-dashboard-mode-and-theme-as-token-overrides.md),
[0041](../decisions/0041-theme-choice-per-browser-as-pimonitor-style.md),
[0042](../decisions/0042-theme-registry-in-theme-init-js.md).

### Look

- The canvas renderers read exactly these custom properties through `themeColor`/`themeNumber` of `theme-init.js`:
`--accent`, `--muted`, `--card-bg`, `--track`, `--ok`, `--warn`, `--crit` and `--spark-fill-alpha`. An empty or
unparseable value, or a `--spark-fill-alpha` outside 0 to 1, is replaced by Clear's light value; any valid value,
`0` included, is used as is.
- The canvas renderers read exactly these custom properties through `themeColor`, `themeNumber` and `themeKeyword`
of `theme-init.js`: the colors `--accent`, `--muted`, `--card-bg`, `--track`, `--border`, `--ok-fill`, `--warn` and
`--crit`; the numbers `--spark-fill-alpha` (0 to 1), `--spark-line-width` (0.5 to 6) and `--gauge-width` (1 to
12); the keywords `--spark-shape` (`line`, `step`), `--spark-fill` (`fade`, `flat`), `--spark-dot` (`ring`,
`none`), `--spark-grid` (`none`, `lines`) and `--gauge-cap` (`round`, `butt`). An empty or unparseable value, a
number outside its range or a word outside its list is replaced by Clear's light value; any valid value, `0`
included, is used as is.
- Every color comes from a token of the palette blocks of `style.css` (light, explicit dark and OS dark, the two
dark blocks identical); every palette block of every theme, Clear's three included, declares the same token keys,
and no rule outside them holds a color literal. Both the text and the fills of the page use
these tokens, so a mode switch changes tokens only.
- Status text (values, percentages, badges, the alert banner, the API-key error) uses the `*-ink` variant of
`ok`/`warn`/`crit`; bar fills and the card border of an alerting card use the base color. Text on an accent fill
`ok`/`warn`/`crit`; bar fills and the card border of an alerting card use the base color (for `ok`: `--ok` on Clear's bars, `--ok-fill` on the gauge arc and on Console's bars). Text on an accent fill
uses `--on-accent`.
- Console colors `ok` text with `--text` (`.metric-ok` and the new-version column of the update list); color
appears only for `warn` and `crit`, plus the Pi-hole status dot (green when up to date, amber with an update).
The ok fill of the gauge arc and of Console's bars is `--ok-fill`: Clear's green (equal to its `--ok`, which Clear's bars use), Console's `--text`
([0043](../decisions/0043-console-colour-only-for-warn-and-crit.md)).
- A bar label shows the percentage emphasised, colored only at `warn` and `crit`, and the byte sizes muted beside it.
- The load gauge draws a 9 px arc on the `--track` color and shows its value inside the arc; the value's font size
scales with the gauge width.
- A sparkline is a 2 px line with a fill that fades towards the bottom and a dot with a ring at the newest point,
inset so the dot is never clipped.
- A card's own color appears only on its 28 px icon chip and on the hover/focus highlight of a clickable card; cards
- The load gauge draws an arc of `--gauge-width` (Clear 9 px with round caps, Console 5 px with butt caps) on the
`--track` color and shows its value inside the arc; the value's font size scales with the gauge width in both
themes.
- A sparkline (and the detail chart) is a line of `--spark-line-width` with a fill and, as the theme says, a dot
with a ring at the newest point, inset so the dot is never clipped. Clear: a 2 px line, a fill fading towards the
bottom and the dot. Console: a 1.5 px stepped line (each point held to the next x), a flat low-opacity fill, a
solid baseline with two dashed lines at 25 % and 62.5 % of the height, and no dot.
- A metric value of CPU usage and temperature is a number element (`.metric-number`) and, when there is a unit, a
unit element (`.metric-unit`), built by `createElement` and `textContent`. Clear separates them by a space
(`.metric-unit::before`); Console sets the unit 15 px, muted, 4 px apart without the space.
- Console's bars are 12 px high and square, drawn as a repeating gradient of 6 px segments with 2 px gaps on the
track and on the fill, both from the track's left edge; its card heading is a 44 px strip with a bottom border
across the card, and in a clickable card the whole strip is the button.
- A card's own color appears only on its icon chip (28 px in Clear; Console draws a 14 px icon in `--muted` without a chip and sets every card color to `--text`) and on the hover/focus highlight of a clickable card; cards
have no colored top border. Clickable cards end their heading with a chevron.
- Icons are inline SVG drawn in `currentColor`, hidden from assistive technology; the page uses no emoji. The mode
button shows the moon in light mode and the sun in dark mode, chosen by CSS. The network card names its rates
Expand Down Expand Up @@ -292,6 +314,7 @@ client of the [HTTP API](http-api.md) like any third-party integration and has n
- [0040](../decisions/0040-dashboard-icons-inline-svg.md): inline SVG icons
- [0041](../decisions/0041-theme-choice-per-browser-as-pimonitor-style.md): theme choice per browser
- [0042](../decisions/0042-theme-registry-in-theme-init-js.md): theme registry in `theme-init.js`
- [0043](../decisions/0043-console-colour-only-for-warn-and-crit.md): in Console, colour only for `warn` and `crit`

## Not here

Expand Down
Binary file added docs/dashboard-console-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dashboard-console-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- **Status:** Accepted
- **Date:** 2026-11-28
- **Area:** Dashboard
- **Source:** Issue #217, issue #218
- **Source:** Issue #217, issue #218, issue #219
- **Supersedes:** —

## Context
Expand All @@ -28,19 +28,25 @@ names, and each design has to be swappable without touching the markup or the sc
— a theme is reviewed in one file. Cost: one more request revalidated on every load per theme, a link and asset
tests per file, and the token key set test reads several files; the blocks are short, so `style.css` keeps them
after Clear's palette.
5. **Everything a theme changes as a token, so a theme is palette blocks only** (considered for Console, issue #219)
— no theme ever adds a rule. Cost: Console changes fonts, border styles, bar patterns, heading layout and hidden
elements; about thirty more tokens would enter all three blocks of every theme, Clear's included, where most
name a property Clear does not use.

## Decision

Option 1. Light/dark is the *mode*; its storage key `pimonitor-theme` and attribute `data-theme` keep their names,
since renaming them would reset every stored choice. The look is described in
[Dashboard](../areas/dashboard.md#look); the per-card colours are tokens of the palette blocks like every other
colour.
colour. What a theme changes beyond a token value (a font family, a dashed border, a segmented bar, a hidden element)
is a rule scoped to `:root[data-style="<id>"]` that uses only tokens (issue #219).

## Consequences

- A later theme only adds override blocks — light, explicit dark and OS dark under its `data-style` value
([0041](0041-theme-choice-per-browser-as-pimonitor-style.md)) — to `style.css`, after Clear's palette; `style.css`
holds no colour literal outside the palette blocks. The page has one DOM for every theme: no per-theme markup and
- A later theme adds override blocks — light, explicit dark and OS dark under its `data-style` value
([0041](0041-theme-choice-per-browser-as-pimonitor-style.md)) — to `style.css`, after Clear's palette, and its
scoped rules after those; `style.css` holds no colour literal outside the palette blocks, and no unscoped rule
changes for a theme other than Clear, so a mode switch still changes tokens only. The page has one DOM for every theme: no per-theme markup and
no per-theme HTML rendering in `app.js`.
- Canvas widgets take a theme's differences only from custom properties; every one they read is a palette token in
every block of every theme, so all blocks share one token key set (issue #218,
Expand Down
9 changes: 7 additions & 2 deletions docs/decisions/0042-theme-registry-in-theme-init-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- **Status:** Accepted
- **Date:** 2026-11-28
- **Area:** Dashboard
- **Source:** Issue #218
- **Source:** Issue #218, issue #219
- **Supersedes:** —

## Context
Expand All @@ -27,12 +27,17 @@ literal today, one of which turns a valid `0` into `0.28` and one of which has n
without blocking, so `theme-init.js` would still need its own copy.
4. **Readers and fallbacks in `chart.js`** — loaded before `gauge.js` and `app.js`. Cost: `chart.js` is a drawing
library; the fallbacks belong next to the theme list they describe.
5. **Non-colour drawing switches (line shape, end dot, fill, grid, caps) as numbers read by `themeNumber`**
(issue #219) — no third reader. Cost: a `0`/`1` that stands for a shape means nothing between its values, and a
theme that writes `step` silently gets Clear's drawing; a keyword reader names the shapes and checks them
against a fixed list.

## Decision

Option 1. `theme-init.js` declares the registry `PIMONITOR_THEMES` (id and display name, default first), the map
`DRAWING_FALLBACKS` of every custom property a canvas renderer reads with Clear's light value, and the readers
`themeColor` and `themeNumber`; `app.js`, `chart.js` and `gauge.js` use only these. The rules are in
`themeColor`, `themeNumber` and `themeKeyword` (a value from a fixed list, issue #219); `app.js`, `chart.js` and
`gauge.js` use only these. The rules are in
[Dashboard](../areas/dashboard.md#theme).

## Consequences
Expand Down
41 changes: 41 additions & 0 deletions docs/decisions/0043-console-colour-only-for-warn-and-crit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 0043: In Console, colour is reserved for `warn` and `crit`

- **Status:** Accepted
- **Date:** 2026-11-29
- **Area:** Dashboard
- **Source:** Issue #219
- **Supersedes:** —

## Context

The theme Console (issue #219) is a dense, instrument-panel look. In Clear a value in the normal range is green
(`--ok-ink` for text, `--ok` for fills), and every card has its own colour on its icon chip
([0039](0039-card-colour-only-on-icon-chip.md)), so a page in good health is full of colour, and a `warn` stands out
less than it could. The levels and thresholds are shared by every theme and must not change.

## Options considered

1. **`ok` in the text colour, colour only for `warn` and `crit`** — text and fills of the `ok` level take `--text`,
`warn` and `crit` keep their ink and base colours; green remains only as the small Pi-hole status dot. Anything
coloured needs attention. Cost: a healthy value no longer says "healthy" by colour, and a fill token of its own
(`--ok-fill`) is needed, because `--ok` stays green for the dot.
2. **`ok` in a muted green, as a quieter Clear** — keeps the colour cue. Cost: three hues still compete on every card,
which is the opposite of the look the issue asks for.
3. **`ok` in `--muted`** — even calmer. Cost: values and bars, the content of the page, would be drawn in the
secondary text colour and lose contrast against the labels around them.

## Decision

Option 1. In Console the `ok` level is drawn in `--text` for text and in `--ok-fill` (equal to `--text`) for bars and
gauge arcs; `warn` and `crit` are unchanged. The rules are in [Dashboard](../areas/dashboard.md#value-coloring).

## Consequences

- The level of every value is still computed as in Clear; only the colour of `ok` differs per theme, so the alert
engine and the dashboard keep agreeing.
- Console sets every per-card accent token to its `--text` value and its chip tint to `0%`: the icon-chip rule of
0039 still holds, but shows no colour.
- Colour that marks an event keeps its level colour: the restart markers of the openHAB memory chart stay `--warn`.
Text that had no level colour before (the gauge value) gets none; the new-version column of the updates list,
green in Clear, is `--text`.
- A later theme picks its own `ok` colour through `--ok-fill` (the gauge arc), a scoped `.bar-fill` rule and its scoped text rules; Clear's `--ok-fill` equals its `--ok`, which Clear's bars keep.
1 change: 1 addition & 0 deletions docs/decisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ once in the [area document](../areas/README.md) of the record's area, and the re
| [0040](0040-dashboard-icons-inline-svg.md) | Dashboard icons are inline stroke SVG in the page, not emoji | Accepted | 2026-11-28 |
| [0041](0041-theme-choice-per-browser-as-pimonitor-style.md) | The theme choice is a per-browser preference, stored as `pimonitor-style` and applied as `data-style` | Accepted | 2026-11-28 |
| [0042](0042-theme-registry-in-theme-init-js.md) | The theme registry and the canvas token readers live once in `theme-init.js` | Accepted | 2026-11-28 |
| [0043](0043-console-colour-only-for-warn-and-crit.md) | In Console, colour is reserved for `warn` and `crit` | Accepted | 2026-11-29 |
<!-- project:end index -->
34 changes: 26 additions & 8 deletions internal/web/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@
if (el) el.textContent = text;
}

// setMetricValue shows a metric value as a number element and, only when
// `unit` is non-empty, a unit element, so a theme can style the unit apart.
function setMetricValue(id, number, unit) {
const el = document.getElementById(id);
if (!el) return;
const num = document.createElement('span');
num.className = 'metric-number';
num.textContent = number;
const nodes = [num];
if (unit) {
const u = document.createElement('span');
u.className = 'metric-unit';
u.textContent = unit;
nodes.push(u);
}
el.replaceChildren(...nodes);
}

function fmtBytes(bytes) {
if (bytes === undefined || bytes === null) return '–';
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
Expand Down Expand Up @@ -298,7 +316,7 @@
setText('uptime-value', fmtUptime(snap.uptime_seconds));

// CPU
setText('cpu-overall', snap.cpu.overall_percent.toFixed(1) + ' %');
setMetricValue('cpu-overall', snap.cpu.overall_percent.toFixed(1), '%');
document.getElementById('cpu-overall').className =
'metric-value ' + levelClass(snap.cpu.overall_percent, t.cpu_warn_percent, t.cpu_crit_percent);
if (snap.cpu.per_core_percent?.length) {
Expand All @@ -316,17 +334,17 @@
// Temperature
const tempEl = document.getElementById('temp-value');
if (snap.temperature?.zone) {
setText('temp-value', snap.temperature.celsius.toFixed(1) + ' °C');
setMetricValue('temp-value', snap.temperature.celsius.toFixed(1), '°C');
tempEl.className = 'metric-value ' + levelClass(snap.temperature.celsius, t.temperature_warn_c, t.temperature_crit_c);
} else {
setText('temp-value', 'n/a');
setMetricValue('temp-value', 'n/a', '');
tempEl.className = 'metric-value';
}
// Secondary temperature readings, each present only when vcgencmd
// answered for it: the GPU/SoC die sensor, and the Pi 4/5 PMIC.
const tempExtras = [];
if (snap.gpu_temperature) tempExtras.push('GPU: ' + snap.gpu_temperature.celsius.toFixed(1) + ' °C');
if (snap.pmic_temperature) tempExtras.push('PMIC: ' + snap.pmic_temperature.celsius.toFixed(1) + ' °C');
if (snap.gpu_temperature) tempExtras.push(`GPU: ${snap.gpu_temperature.celsius.toFixed(1)} °C`);
if (snap.pmic_temperature) tempExtras.push(`PMIC: ${snap.pmic_temperature.celsius.toFixed(1)} °C`);
setText('temp-gpu', tempExtras.join(' · '));

// Memory & swap (show absolute sizes alongside the percentage, like
Expand Down Expand Up @@ -982,7 +1000,7 @@
title: 'CPU Usage',
historyKey: 'cpu_percent',
opts: { min: 0, max: 100 },
fmt: v => v.toFixed(1) + ' %',
fmt: v => `${v.toFixed(1)} %`,
},
load: {
title: 'Load Average (1 min)',
Expand All @@ -994,13 +1012,13 @@
title: 'Temperature',
historyKey: 'temperature',
opts: {},
fmt: v => v.toFixed(1) + ' °C',
fmt: v => `${v.toFixed(1)} °C`,
},
memory: {
title: 'Memory Usage',
historyKey: 'memory_used_percent',
opts: { min: 0, max: 100 },
fmt: v => v.toFixed(1) + ' %',
fmt: v => `${v.toFixed(1)} %`,
},
};

Expand Down
Loading