From 3dc08a6ed03a25e175c4209febdf67f0a943730f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 13:06:08 +0000 Subject: [PATCH 01/22] Start squad record for feature 218 --- specs/feature-218-theme-selection/log.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 specs/feature-218-theme-selection/log.md diff --git a/specs/feature-218-theme-selection/log.md b/specs/feature-218-theme-selection/log.md new file mode 100644 index 00000000..6df151f1 --- /dev/null +++ b/specs/feature-218-theme-selection/log.md @@ -0,0 +1,8 @@ +# Log: feature 218 – theme selection + +One line per pipeline step: date and time of day (UTC), step, member, result. Lead decisions and escalations +are quoted in full. + +| Date | Step | Member | Result | +| ---- | ---- | ------ | ------ | +| 2026-11-28 13:06 | 1 Intake | Orchestrator | Issue #218 (feature, label enhancement, open, milestone v1.5.0): selectable dashboard theme stored per browser. Branch claude/busy-archimedes-cnsq6t off main d05bb19 (theme Clear, #296, merged). Reported environment: n/a. | From eff33d3efa09648cc679730911ddf99a5f65153c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 13:08:49 +0000 Subject: [PATCH 02/22] Add spec for feature 218 --- specs/feature-218-theme-selection/spec.md | 154 ++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 specs/feature-218-theme-selection/spec.md diff --git a/specs/feature-218-theme-selection/spec.md b/specs/feature-218-theme-selection/spec.md new file mode 100644 index 00000000..647123f5 --- /dev/null +++ b/specs/feature-218-theme-selection/spec.md @@ -0,0 +1,154 @@ +# Spec: Let the user choose a dashboard theme, stored per browser + +Source: Issue #218 +Status: Draft + +## Problem + +v1.5.0 ships three visual designs of the dashboard (Clear from #217, Console and Berry in their own issues), and +each user should be able to pick the one they prefer, with Clear as the default. Today the dashboard has one look +and only the light/dark *mode* switch; there is no place to register a second design, no storage for the choice and +no control to make it. The terms *mode* (light/dark: `pimonitor-theme`, `data-theme`) and *theme* (the design) are +those of the issue and of [decision 0038](../../docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md). +The registry (ids `clear`, `console`, `berry`, display names Clear, Console, Berry, default first) is the issue's +*Terminology* table; this feature ships with `clear` alone registered, and the two others plug into it. + +## Scenarios + +- S1: Given a browser that never chose a theme, when the user opens the dashboard, then it shows the theme Clear in + the mode of the operating system (or the stored mode), exactly as before this feature. +- S2: Given at least two registered themes, when the user opens "Customize dashboard", then the dialog starts with a + section headed "Theme" — before the card hint "Show, hide, and reorder cards. Saved in this browser only." and the + card list — holding one radio option per registered theme, labelled with its display name, in registry order, + with the active theme checked. +- S3: Given the dialog open, when the user selects another theme, then the page takes that theme at once, without a + reload; the dialog stays open with focus on the selected option; the sparklines, load gauges and openHAB memory + chart are redrawn in the new theme; and the choice is stored in this browser. +- S4: Given a stored theme, when the user reloads the page, then the stored theme and the stored mode are both in + effect from the first paint, the page never shows Clear first, and the dialog shows the stored theme checked. +- S5: Given any theme, when the user presses the header mode button, then the mode switches and the theme stays; + given any mode, choosing a theme keeps the mode; with no stored mode the page follows the operating system's + light/dark setting live in every theme. +- S6: Given a chosen theme, when the user presses "Reset to default" in the dialog, then the card layout returns to + its default and the theme stays as chosen. +- S7: Given only one registered theme (the state this feature ships in), when the user opens "Customize dashboard", + then there is no "Theme" section and the dialog looks and works as today. +- S8: Given a keyboard user in the dialog, when they Tab into the Theme group and press the arrow keys, then focus + and selection move between the options and each selection applies as in S3; a screen reader announces a radio + group named "Theme". +- S9: Given any theme, the header mode button's accessible name reads "Switch to dark mode" in light mode and + "Switch to light mode" in dark mode, so it is not confused with the Theme group (today it says "… theme"). + +## Errors and edge cases + +- E1: A stored value that is not a registered id — a theme removed later, a value written by a newer version before + a downgrade, or a case or whitespace variant such as `Console` or ` clear` (only an exact id counts) — shows Clear + with no message and no console error; the stored value stays untouched until the user chooses a theme. The dialog + then shows Clear checked. +- E2: Storage that cannot be read (private browsing, blocked storage) means Clear on every load; no message. +- E3: Storage that cannot be written: choosing a theme still applies it for the current page, nothing is stored, no + message is shown and nothing throws; after a reload the page shows Clear (or what was stored before). +- E4: With JavaScript disabled or `theme-init.js` failing, the page shows Clear. +- E5: Selecting the theme that is already active changes nothing visible. +- E6: Only one theme registered and a stored id of another theme (E1 applies): Clear, and no Theme section (S7). +- E7: A canvas drawing property that a theme does not declare, or declares with a value the renderer cannot use, + draws as in Clear. + +## Non-functional requirements + +- N1: The page keeps running under `style-src 'self'; script-src 'self'`: no inline style or script, `theme-init.js` + stays an external synchronous script in ``; `app.js` assigns no non-empty `innerHTML`. +- N2: No API, configuration or server-side change: no `config.yaml` option, no API field, no server state. The + choice is per browser like mode and layout. No external resources, web fonts or build step. +- N3: Compatibility: `pimonitor-api-key`, `pimonitor-theme`, `pimonitor-layout` and `pimonitor-openhab-things` keep + their keys, formats and behavior; an upgraded browser with no `pimonitor-style` sees Clear (S1). An older version + ignores `pimonitor-style`. +- N4: Storage: the choice is the theme id under `localStorage` key `pimonitor-style`; the dashboard then stores + exactly five entries (the four of today and `pimonitor-style`). +- N5: Extensibility, as the issue's *Specification* §1–§2 requires: one registry of themes is the single source for + the selector and for validating a stored id; adding a theme is a registry entry plus its style rules, with no + change to the selection logic; one DOM for all themes (no per-theme markup in `index.html`, no per-theme HTML + rendering branches in `app.js`); canvas widgets take theme differences only from declared custom properties + (E7). Each theme defines the same token set in its light block and in both dark blocks. +- N6: Every theme's stylesheet rules are loaded statically with the page, never on demand; any new asset file is + served like the others (`Cache-Control: no-cache`, per-file `ETag`) and covered by the asset tests. +- N7: Dialog behavior (modal, focus in and back, Escape, outside click, close button) is unchanged. + +## Acceptance criteria + +- AC1: With no stored theme the dashboard shows Clear, and `` carries no `data-style` attribute (S1, E4). +- AC2: A stored, registered, non-default theme id is applied by `theme-init.js` as `data-style=""` on `` + before the first paint, next to the stored mode; a stored `clear` leaves the attribute absent (S4). +- AC3: A stored value that is not exactly a registered id results in Clear, without an error and without the stored + value being changed or removed (E1, E2, E6). +- AC4: With more than one registered theme, "Customize dashboard" shows a "Theme" section before the card hint and + list, with one radio option per registered theme labelled with its display name in registry order, and the + option of the active theme is checked whenever the dialog opens (S2, S4). +- AC5: Choosing an option applies the theme immediately without a reload, keeps the dialog open, stores the id under + `pimonitor-style` (choosing Clear stores `clear` and removes the attribute), and redraws the sparklines, load + gauges and openHAB memory chart in the new theme; a detail chart opened afterwards is drawn in it (S3, E5). +- AC6: With exactly one registered theme the "Theme" section is not rendered (S7). +- AC7: Theme and mode are independent: switching the mode keeps the theme, choosing a theme keeps the mode, and with + no stored mode the page follows `prefers-color-scheme` live in every theme (S5). +- AC8: When `localStorage` cannot be read or written, choosing a theme works for the current page, nothing is stored + and nothing throws (E2, E3). +- AC9: The id list `theme-init.js` validates against and the registry the selector is built from hold the same ids + in the same order (N5). +- AC10: Every registered theme defines the same set of palette tokens in its light block and in both of its dark + blocks, and a canvas property it leaves undeclared draws as in Clear (N5, E7). +- AC11: The selector is a `
` with a `` "Theme" and native radio inputs sharing one name, reachable + and operable by keyboard alone, and the dialog's modal, focus, Escape, outside-click and close behavior is + unchanged (S8, N7). +- AC12: The dashboard stores no `localStorage` entry other than `pimonitor-api-key`, `pimonitor-theme`, + `pimonitor-layout`, `pimonitor-openhab-things` and `pimonitor-style` (N3, N4). +- AC13: "Reset to default" restores the default card layout and leaves the chosen theme and `pimonitor-style` as + they are (S6). +- AC14: `index.html` still has no inline style or script, `theme-init.js` is still an external synchronous script in + ``, `app.js` still assigns no non-empty `innerHTML`, and the page loads nothing from another origin and reads + no API field or configuration option for the theme (N1, N2). +- AC15: The mode button's accessible name is "Switch to dark mode" in light mode and "Switch to light mode" in dark + mode, in every theme (S9). +- AC16: Every theme's style rules are loaded by the page's static `` elements before the first paint, never on + demand, and every asset file the feature adds is served with `Cache-Control: no-cache` and its own `ETag` (N6). + +## Out of scope + +- The designs of Console and Berry (their own issues), and a contrast test over their palettes. +- Swatches or previews in the selector (question 4). +- A server-side default theme or a theme option in `config.yaml`. +- A control to return the mode to following the operating system. +- Syncing the choice across open tabs. +- User-defined themes or colour pickers. + +## Open questions + +1. Should "Reset to default" also reset the theme? Answered: no (the issue's default). The button sits under the + card list and its hint speaks of cards only; AC13. +2. Default theme as `data-style="clear"` or as the absence of the attribute? Answered: absence. Clear's tokens are + today's unscoped palette blocks of `style.css` (#217), so the page without JavaScript (E4), with unreadable + storage or with an unknown value is already Clear, and Clear has one representation instead of two; other themes + override under their `data-style` value. AC1, AC2, AC5. +3. One stylesheet or one file per theme? Answered: the plan's decision, as the issue says, within N6 and decision + 0038, which rejected per-design copies of the layout rules (a theme is overrides only). +4. Should the selector show swatches? Answered: no, not in this feature. A choice applies at once with the dialog + open (S3), so the user sees the theme itself rather than a swatch, and a swatch would need each theme's tokens + resolved outside its own scope, which only pays once more than one theme exists. It can become its own issue. + +Corrections to the issue, checked against the code at `d05bb19`: the dashboard already stores four entries today +(`pimonitor-openhab-things` is the fourth, `docs/areas/dashboard.md`, *Browser storage*), so it stores five after +this feature (AC12). The detail chart and the layout dialog are both modal, so no detail chart can be open while a +theme is chosen; AC5 requires the next one opened to be in the new theme, and adds the openHAB memory chart, which +the mode switch also redraws. The mode button's accessible name still says "theme" (`app.js`, +`updateThemeToggle`), which S9 and AC15 change. + +## Area documents + +- `docs/areas/dashboard.md`: *Scope* names the theme among the per-browser preferences. *Mode* stays as is (the mode + button's names in "mode"); a new *Theme* section states the registered themes and their order, the default Clear + as the absence of `data-style`, storage under `pimonitor-style`, the fallback for an unknown or unreadable value + (kept, not removed), application before the first paint, independence from the mode, immediate application with + redrawn canvases, and that a theme is token overrides plus declared canvas properties over one DOM. *Look* names + the canvas custom properties after #217 and the Clear fallback. *Card layout* says the dialog also holds the Theme + section (shown only with more than one theme) and that "Reset to default" leaves the theme. *Browser storage* + lists five entries. +- `README.md`: the feature list mentions selectable themes. From bb6765f30fb73bca2c6fc569d2ecc3d37e64423f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 13:08:59 +0000 Subject: [PATCH 03/22] Log spec step of feature 218 --- specs/feature-218-theme-selection/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-218-theme-selection/log.md b/specs/feature-218-theme-selection/log.md index 6df151f1..187b49ab 100644 --- a/specs/feature-218-theme-selection/log.md +++ b/specs/feature-218-theme-selection/log.md @@ -6,3 +6,4 @@ are quoted in full. | Date | Step | Member | Result | | ---- | ---- | ------ | ------ | | 2026-11-28 13:06 | 1 Intake | Orchestrator | Issue #218 (feature, label enhancement, open, milestone v1.5.0): selectable dashboard theme stored per browser. Branch claude/busy-archimedes-cnsq6t off main d05bb19 (theme Clear, #296, merged). Reported environment: n/a. | +| 2026-11-28 13:08 | 2a Spec | Lead | RESULT: DONE. spec.md written (status Draft); answers the four open questions; adds AC15 (mode button name), AC12 lists five storage entries. (opus/medium · 61,327 tokens · 14 tool uses · 153 s · 28 in · 13,503 out · 549,756 cache read · 60,171 cache write · 340,489 weighted) | From 84de9a5d57430b69b4cbff248b9769de8bb4c04c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 13:11:19 +0000 Subject: [PATCH 04/22] Log spec challenge of feature 218 --- specs/feature-218-theme-selection/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-218-theme-selection/log.md b/specs/feature-218-theme-selection/log.md index 187b49ab..9f99d53d 100644 --- a/specs/feature-218-theme-selection/log.md +++ b/specs/feature-218-theme-selection/log.md @@ -7,3 +7,4 @@ are quoted in full. | ---- | ---- | ------ | ------ | | 2026-11-28 13:06 | 1 Intake | Orchestrator | Issue #218 (feature, label enhancement, open, milestone v1.5.0): selectable dashboard theme stored per browser. Branch claude/busy-archimedes-cnsq6t off main d05bb19 (theme Clear, #296, merged). Reported environment: n/a. | | 2026-11-28 13:08 | 2a Spec | Lead | RESULT: DONE. spec.md written (status Draft); answers the four open questions; adds AC15 (mode button name), AC12 lists five storage entries. (opus/medium · 61,327 tokens · 14 tool uses · 153 s · 28 in · 13,503 out · 549,756 cache read · 60,171 cache write · 340,489 weighted) | +| 2026-11-28 13:11 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 2 major, 3 minor. Major: (1) AC10/N5 weaker than the issue: token key sets of all blocks of all themes, Clear's unscoped blocks included, must be identical; E7 vs AC10 contradiction. (2) Selector/AC2 branch must be verified against a registry of at least two themes, not the shipped one-entry registry. Minor: (3) AC15 misses index.html aria-label 'Toggle theme' and icons_test.go:356 assertion; (4) E7 must define 'unusable' (valid 0 honoured; chart.js:43 and gauge.js:44 fallbacks); (5) issue wrongly claims line width is a canvas property after #217; add to Corrections, list only real properties. (opus/medium · 62,072 tokens · 19 tool uses · 141 s · 38 in · 12,115 out · 702,151 cache read · 59,037 cache write · 339,034 weighted) | From f5200729f3951a0e96cea8f9019a6196996040e3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 13:12:35 +0000 Subject: [PATCH 05/22] Revise spec of feature 218 after challenge --- specs/feature-218-theme-selection/log.md | 1 + specs/feature-218-theme-selection/spec.md | 63 ++++++++++++++++++++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/specs/feature-218-theme-selection/log.md b/specs/feature-218-theme-selection/log.md index 9f99d53d..2fc7a1eb 100644 --- a/specs/feature-218-theme-selection/log.md +++ b/specs/feature-218-theme-selection/log.md @@ -8,3 +8,4 @@ are quoted in full. | 2026-11-28 13:06 | 1 Intake | Orchestrator | Issue #218 (feature, label enhancement, open, milestone v1.5.0): selectable dashboard theme stored per browser. Branch claude/busy-archimedes-cnsq6t off main d05bb19 (theme Clear, #296, merged). Reported environment: n/a. | | 2026-11-28 13:08 | 2a Spec | Lead | RESULT: DONE. spec.md written (status Draft); answers the four open questions; adds AC15 (mode button name), AC12 lists five storage entries. (opus/medium · 61,327 tokens · 14 tool uses · 153 s · 28 in · 13,503 out · 549,756 cache read · 60,171 cache write · 340,489 weighted) | | 2026-11-28 13:11 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 2 major, 3 minor. Major: (1) AC10/N5 weaker than the issue: token key sets of all blocks of all themes, Clear's unscoped blocks included, must be identical; E7 vs AC10 contradiction. (2) Selector/AC2 branch must be verified against a registry of at least two themes, not the shipped one-entry registry. Minor: (3) AC15 misses index.html aria-label 'Toggle theme' and icons_test.go:356 assertion; (4) E7 must define 'unusable' (valid 0 honoured; chart.js:43 and gauge.js:44 fallbacks); (5) issue wrongly claims line width is a canvas property after #217; add to Corrections, list only real properties. (opus/medium · 62,072 tokens · 19 tool uses · 141 s · 38 in · 12,115 out · 702,151 cache read · 59,037 cache write · 339,034 weighted) | +| 2026-11-28 13:12 | 2a Spec revise (challenge) | Lead | RESULT: DONE. All five objections accepted and answered in the Challenge section; AC10/N5 strengthened, Verification paragraph (two-theme registry, manual browser check), AC15 extended, E7 defined with AC17, corrections added. (opus/medium · 12,119 tokens · 6 tool uses · 67 s · 14 in · 6,449 out · 390,427 cache read · 11,952 cache write · 133,441 weighted · continued) | diff --git a/specs/feature-218-theme-selection/spec.md b/specs/feature-218-theme-selection/spec.md index 647123f5..958d7c2e 100644 --- a/specs/feature-218-theme-selection/spec.md +++ b/specs/feature-218-theme-selection/spec.md @@ -51,8 +51,11 @@ The registry (ids `clear`, `console`, `berry`, display names Clear, Console, Ber - E4: With JavaScript disabled or `theme-init.js` failing, the page shows Clear. - E5: Selecting the theme that is already active changes nothing visible. - E6: Only one theme registered and a stored id of another theme (E1 applies): Clear, and no Theme section (S7). -- E7: A canvas drawing property that a theme does not declare, or declares with a value the renderer cannot use, - draws as in Clear. +- E7: A canvas drawing property whose computed value is unusable — empty, not parseable, or out of its range (a fill + opacity outside 0–1, a colour the canvas does not accept) — draws with Clear's light value of that property. A + valid value is always honoured, `0` included (today `chart.js` turns a fill opacity of `0` into `0.28`, and + `gauge.js` has no fallback for the arc's level colour). Every property the renderers read is a palette token + (N5), so a registered theme cannot leave one undeclared. ## Non-functional requirements @@ -69,7 +72,10 @@ The registry (ids `clear`, `console`, `berry`, display names Clear, Console, Ber the selector and for validating a stored id; adding a theme is a registry entry plus its style rules, with no change to the selection logic; one DOM for all themes (no per-theme markup in `index.html`, no per-theme HTML rendering branches in `app.js`); canvas widgets take theme differences only from declared custom properties - (E7). Each theme defines the same token set in its light block and in both dark blocks. + (E7). Every canvas drawing property is a palette token: there is no drawing property outside the palette blocks. + All blocks of all registered themes — Clear's three unscoped blocks (light, explicit dark, OS dark) included — + declare one identical token key set; Clear declares the defaults. This feature adds no drawing property: the line + widths stay as they are, and #219/#220 add the tokens they need to every block, Clear's included. - N6: Every theme's stylesheet rules are loaded statically with the page, never on demand; any new asset file is served like the others (`Cache-Control: no-cache`, per-file `ETag`) and covered by the asset tests. - N7: Dialog behavior (modal, focus in and back, Escape, outside click, close button) is unchanged. @@ -94,8 +100,9 @@ The registry (ids `clear`, `console`, `berry`, display names Clear, Console, Ber and nothing throws (E2, E3). - AC9: The id list `theme-init.js` validates against and the registry the selector is built from hold the same ids in the same order (N5). -- AC10: Every registered theme defines the same set of palette tokens in its light block and in both of its dark - blocks, and a canvas property it leaves undeclared draws as in Clear (N5, E7). +- AC10: The token key set of every palette block of every registered theme — Clear's three unscoped blocks + included — is identical, and every custom property `chart.js`, `gauge.js` and `app.js` read for drawing is in + that set (N5). - AC11: The selector is a `
` with a `` "Theme" and native radio inputs sharing one name, reachable and operable by keyboard alone, and the dialog's modal, focus, Escape, outside-click and close behavior is unchanged (S8, N7). @@ -107,9 +114,20 @@ The registry (ids `clear`, `console`, `berry`, display names Clear, Console, Ber ``, `app.js` still assigns no non-empty `innerHTML`, and the page loads nothing from another origin and reads no API field or configuration option for the theme (N1, N2). - AC15: The mode button's accessible name is "Switch to dark mode" in light mode and "Switch to light mode" in dark - mode, in every theme (S9). + mode, in every theme; its static label in `index.html` (today "Toggle theme") reads "Toggle mode" until the + script sets it; no accessible name of the page says "theme" for the mode (S9). - AC16: Every theme's style rules are loaded by the page's static `` elements before the first paint, never on demand, and every asset file the feature adds is served with `Cache-Control: no-cache` and its own `ETag` (N6). +- AC17: Each custom property a renderer reads draws with Clear's light value of that property when its computed + value is empty, unparseable or out of range, and with its own value otherwise, `0` included (E7). + +Verification: AC2, AC4, AC5, AC9 and AC11 are verified against a registry of at least two themes — a second, +test-only entry that never ships — not against the shipped one-entry registry; AC6 against exactly one. The +repository has no JavaScript runtime in its tests (the `internal/web` tests check the embedded asset sources), and +adding one is a dependency this spec does not ask for. A criterion whose behavior the asset sources settle is +verified by such a Go test; one that only a running page shows (before the first paint in AC2, the redraw in AC5, +the live OS following in AC7, blocked storage in AC8) gets, in the plan, a named hand check in a browser on the +built binary with a local two-theme registry, recorded in the verification matrix. ## Out of scope @@ -139,7 +157,11 @@ Corrections to the issue, checked against the code at `d05bb19`: the dashboard a this feature (AC12). The detail chart and the layout dialog are both modal, so no detail chart can be open while a theme is chosen; AC5 requires the next one opened to be in the new theme, and adds the openHAB memory chart, which the mode switch also redraws. The mode button's accessible name still says "theme" (`app.js`, -`updateThemeToggle`), which S9 and AC15 change. +`updateThemeToggle`) and its static label in `index.html` says "Toggle theme"; S9 and AC15 change both. No line +width is a canvas property after #217: the widths are fixed in `chart.js` (lines 85, 135, 147) and `gauge.js` +(line 28). The renderers read `--accent`, `--spark-fill-alpha`, `--card-bg`, `--track`, `--ok`, `--warn`, `--crit` +and, for the openHAB memory chart, `--accent`, `--muted` and `--warn` (`app.js` 1412–1421); this feature declares +no new one (N5). ## Area documents @@ -148,7 +170,32 @@ the mode switch also redraws. The mode button's accessible name still says "them as the absence of `data-style`, storage under `pimonitor-style`, the fallback for an unknown or unreadable value (kept, not removed), application before the first paint, independence from the mode, immediate application with redrawn canvases, and that a theme is token overrides plus declared canvas properties over one DOM. *Look* names - the canvas custom properties after #217 and the Clear fallback. *Card layout* says the dialog also holds the Theme + the custom properties the canvas widgets read (exactly those listed under *Corrections*) and the Clear fallback + for an unusable value, and states one identical token key set for every block of every theme. *Card layout* says the dialog also holds the Theme section (shown only with more than one theme) and that "Reset to default" leaves the theme. *Browser storage* lists five entries. - `README.md`: the feature list mentions selectable themes. + +## Challenge + +1. (major) AC10/N5 weaker than the issue; E7 contradicts AC10. Accepted. N5 and AC10 now require one identical + token key set across every block of every registered theme, Clear's three unscoped blocks included (today all + three hold the same 37 tokens). Every canvas drawing property is a palette token, none exists outside the + blocks, and Clear declares the defaults; so E7 no longer speaks of an undeclared property, only of an unusable + value. +2. (major) Criteria verified against the shipped one-entry registry; script behavior without a JS runtime. + Accepted. A *Verification* paragraph under the criteria requires a test-only second registry entry for AC2, + AC4, AC5, AC9 and AC11 (AC6 with one entry). It also states that the asset-source Go tests verify what the + sources settle, and that the plan names a browser hand check on the built binary, with a local two-theme + registry, for what only a running page shows (AC2, AC5, AC7, AC8). +3. AC15 misses the static label and the test assertion. Accepted. AC15 now covers the static `aria-label` "Toggle + theme" in `index.html` (it becomes "Toggle mode"), and no accessible name may say "theme" for the mode. The + assertion at `internal/web/icons_test.go:356` is adapted to the new names (the Tester's, named in the plan's + *Test files*), not left failing. +4. E7 "unusable" undefined; a valid 0 overridden. Accepted. E7 defines unusable as empty, unparseable or out of + range and requires a valid value, `0` included, to be honoured, with Clear's light value as the fallback for + every property a renderer reads. The new AC17 tests it; it also covers the missing fallback of the gauge's level + colour. +5. Line width is no canvas property after #217. Accepted. *Corrections to the issue* names the fixed widths in + `chart.js` and `gauge.js` and lists the properties the renderers really read. N5 says this feature declares + none and leaves new ones to #219/#220, and the *Look* outline documents only the real ones. From ee21de1629b910d29fcda5fca00a02c389aa8b93 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 13:18:14 +0000 Subject: [PATCH 06/22] Add plan, tasks and decisions for feature 218 --- ...board-mode-and-theme-as-token-overrides.md | 14 +- ...e-choice-per-browser-as-pimonitor-style.md | 40 ++++ .../0042-theme-registry-in-theme-init-js.md | 43 ++++ docs/decisions/README.md | 2 + specs/feature-218-theme-selection/log.md | 1 + specs/feature-218-theme-selection/plan.md | 208 ++++++++++++++++++ specs/feature-218-theme-selection/spec.md | 2 +- specs/feature-218-theme-selection/tasks.md | 11 + 8 files changed, 318 insertions(+), 3 deletions(-) create mode 100644 docs/decisions/0041-theme-choice-per-browser-as-pimonitor-style.md create mode 100644 docs/decisions/0042-theme-registry-in-theme-init-js.md create mode 100644 specs/feature-218-theme-selection/plan.md create mode 100644 specs/feature-218-theme-selection/tasks.md diff --git a/docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md b/docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md index 9f3a41f9..94b49fe2 100644 --- a/docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md +++ b/docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md @@ -3,7 +3,7 @@ - **Status:** Accepted - **Date:** 2026-11-28 - **Area:** Dashboard -- **Source:** Issue #217 +- **Source:** Issue #217, issue #218 - **Supersedes:** — ## Context @@ -24,6 +24,10 @@ names, and each design has to be swappable without touching the markup or the sc key and the attribute keep a name that no longer matches the user-facing concept of the milestone's issues. 3. **One stylesheet per design** — each design free in its rules. Cost: three copies of every layout rule to keep in step, more embedded bytes on a Pi Zero, and a design switch that reloads a stylesheet. +4. **Each further theme's override blocks in a file of its own, linked statically after `style.css`** (issue #218) + — 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. ## Decision @@ -34,5 +38,11 @@ colour. ## Consequences -- A later theme only adds override blocks; `style.css` holds no colour literal outside the palette blocks. +- 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 + 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, + [0042](0042-theme-registry-in-theme-init-js.md)). - The stored key keeps the old word: code and documentation say "mode" and name the key as it is. diff --git a/docs/decisions/0041-theme-choice-per-browser-as-pimonitor-style.md b/docs/decisions/0041-theme-choice-per-browser-as-pimonitor-style.md new file mode 100644 index 00000000..a24667c3 --- /dev/null +++ b/docs/decisions/0041-theme-choice-per-browser-as-pimonitor-style.md @@ -0,0 +1,40 @@ +# 0041: The theme choice is a per-browser preference, stored as `pimonitor-style` and applied as `data-style` + +- **Status:** Proposed +- **Date:** 2026-11-28 +- **Area:** Dashboard +- **Source:** Issue #218 +- **Supersedes:** — + +## Context + +v1.5.0 lets the user choose the dashboard's theme (Clear, later Console and Berry) independently of the light/dark +mode ([0038](0038-dashboard-mode-and-theme-as-token-overrides.md)). The mode already occupies the names that would +suit the theme: the `localStorage` key `pimonitor-theme` and the attribute `data-theme` on ``. Renaming them +would reset every stored mode on upgrade. Mode and layout are per-browser preferences without server-side state, and +the page applies the stored mode before the first paint from `theme-init.js` under `script-src 'self'`. + +## Options considered + +1. **Per browser, a new key `pimonitor-style` and attribute `data-style`; the default theme is the absence of the + attribute** — mode and theme stay two independent values, and the page without script, with unreadable storage or + with an unknown stored value is Clear by the unscoped palette. Cost: the code says "style" where the user reads + "theme". +2. **One combined value in `pimonitor-theme`** (`clear-dark`, …) — one key. Cost: changes the key's format, so a + stored mode is lost or needs a migration, and an older version reading the new value forgets the mode. +3. **A server-side default theme (`config.yaml` option, an API field)** — one look for every browser. Cost: a new + configuration and API surface, and per-user choice still needs browser storage; the issue leaves it out of scope. +4. **Default as an explicit `data-style="clear"`** — every theme scoped the same way. Cost: two representations of + Clear (absent before the script runs, explicit after), and Clear's palette, unscoped since #217, would move. + +## Decision + +Option 1. The theme id is stored per browser under `pimonitor-style`; a registered non-default id is applied as +`data-style=""` on ``, and Clear is the absence of the attribute. The rules (fallback, storage entries) +are in [Dashboard](../areas/dashboard.md#theme). + +## Consequences + +- An unknown stored value (downgrade, removed theme) means Clear and is kept, so an upgrade back restores the choice. +- Code names the theme "style" and the mode "theme" (`applyTheme`, `THEME_KEY`); comments say which is which. +- A server-side default would need its own decision and a new configuration option. diff --git a/docs/decisions/0042-theme-registry-in-theme-init-js.md b/docs/decisions/0042-theme-registry-in-theme-init-js.md new file mode 100644 index 00000000..03d09f3c --- /dev/null +++ b/docs/decisions/0042-theme-registry-in-theme-init-js.md @@ -0,0 +1,43 @@ +# 0042: The theme registry and the canvas token readers live once in `theme-init.js` + +- **Status:** Proposed +- **Date:** 2026-11-28 +- **Area:** Dashboard +- **Source:** Issue #218 +- **Supersedes:** — + +## Context + +Two scripts need the list of known themes: `theme-init.js`, which validates the stored id before the first paint, +and `app.js`, which builds the selector after the page loaded. The issue allows a second copy of the list in `app.js` +if a test keeps the two identical, as the fallback threshold keys are kept in step with the server. Three scripts +(`chart.js`, `gauge.js`, `app.js`) also read custom properties for canvas drawing, each with its own inline fallback +literal today, one of which turns a valid `0` into `0.28` and one of which has no fallback at all. + +## Options considered + +1. **One registry as a global constant in `theme-init.js`, read by `app.js`; the token readers and Clear's fallback + values as one map and two functions in the same file** — `theme-init.js` loads first, synchronously in ``, + so every later script sees them; nothing is duplicated, and a test only checks that `app.js` keeps no list and + that the fallback map equals Clear's light block. Cost: two more page-wide names, and `theme-init.js` is more than + a pre-paint snippet. +2. **A copy of the id list in `app.js`, kept equal by a Go test** — the issue's suggestion. Cost: two lists to edit + per theme, and a test that only exists to keep them in step. +3. **A JSON registry asset fetched by both scripts** — one file. Cost: a fetch cannot run before the first paint + 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. + +## 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 +[Dashboard](../areas/dashboard.md#theme). + +## Consequences + +- Adding a theme is one registry entry plus its palette blocks; a new drawing property is one map entry plus a + token in every palette block (guarded by the token key set test). +- `app.js`, `chart.js` and `gauge.js` depend on `theme-init.js` having run, as `app.js` already depends on the + drawing functions of `chart.js` and `gauge.js`. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 75da1e00..e29fa92f 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -102,4 +102,6 @@ once in the [area document](../areas/README.md) of the record's area, and the re | [0038](0038-dashboard-mode-and-theme-as-token-overrides.md) | Dashboard "mode" is light or dark, a "theme" is a set of custom-property overrides | Accepted | 2026-11-28 | | [0039](0039-card-colour-only-on-icon-chip.md) | The per-card colour appears only on the icon chip; status colours have a fill and an ink variant | Accepted | 2026-11-28 | | [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` | Proposed | 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` | Proposed | 2026-11-28 | diff --git a/specs/feature-218-theme-selection/log.md b/specs/feature-218-theme-selection/log.md index 2fc7a1eb..d2891e6a 100644 --- a/specs/feature-218-theme-selection/log.md +++ b/specs/feature-218-theme-selection/log.md @@ -9,3 +9,4 @@ are quoted in full. | 2026-11-28 13:08 | 2a Spec | Lead | RESULT: DONE. spec.md written (status Draft); answers the four open questions; adds AC15 (mode button name), AC12 lists five storage entries. (opus/medium · 61,327 tokens · 14 tool uses · 153 s · 28 in · 13,503 out · 549,756 cache read · 60,171 cache write · 340,489 weighted) | | 2026-11-28 13:11 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 2 major, 3 minor. Major: (1) AC10/N5 weaker than the issue: token key sets of all blocks of all themes, Clear's unscoped blocks included, must be identical; E7 vs AC10 contradiction. (2) Selector/AC2 branch must be verified against a registry of at least two themes, not the shipped one-entry registry. Minor: (3) AC15 misses index.html aria-label 'Toggle theme' and icons_test.go:356 assertion; (4) E7 must define 'unusable' (valid 0 honoured; chart.js:43 and gauge.js:44 fallbacks); (5) issue wrongly claims line width is a canvas property after #217; add to Corrections, list only real properties. (opus/medium · 62,072 tokens · 19 tool uses · 141 s · 38 in · 12,115 out · 702,151 cache read · 59,037 cache write · 339,034 weighted) | | 2026-11-28 13:12 | 2a Spec revise (challenge) | Lead | RESULT: DONE. All five objections accepted and answered in the Challenge section; AC10/N5 strengthened, Verification paragraph (two-theme registry, manual browser check), AC15 extended, E7 defined with AC17, corrections added. (opus/medium · 12,119 tokens · 6 tool uses · 67 s · 14 in · 6,449 out · 390,427 cache read · 11,952 cache write · 133,441 weighted · continued) | +| 2026-11-28 13:18 | 2b Plan | Lead | RESULT: DONE. Tier standard, security areas none. spec.md Approved by Lead; plan.md, tasks.md, decisions 0041/0042 new, 0038 extended. One stylesheet; PIMONITOR_THEMES and canvas readers in theme-init.js; manual browser cases M1-M11. (opus/medium · 59,072 tokens · 29 tool uses · 330 s · 56 in · 31,985 out · 2,841,979 cache read · 58,587 cache write · 750,627 weighted · continued) | diff --git a/specs/feature-218-theme-selection/plan.md b/specs/feature-218-theme-selection/plan.md new file mode 100644 index 00000000..5b60ee62 --- /dev/null +++ b/specs/feature-218-theme-selection/plan.md @@ -0,0 +1,208 @@ +# Plan: Let the user choose a dashboard theme, stored per browser + +Source: Issue #218 | [spec.md](spec.md) +Tier: standard — a behavior change of the dashboard (a new per-browser preference, its selector and the canvas +token readers) that creates, changes or removes no security control. +Security areas touched: none + +## Problem / root cause + +See [spec.md](spec.md) (AC1–AC17). + +## Verified facts + +| # | Claim | Evidence | Status | +| - | ----- | -------- | ------ | +| 1 | The mode is `pimonitor-theme` / `data-theme`, applied before first paint by `theme-init.js`, a sync `