From 7d5f9009e24ac5fe3d9fc4addd4d92246477f05d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:23:15 +0000 Subject: [PATCH 01/27] Start squad record for feature 219 --- specs/feature-219-theme-console/log.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 specs/feature-219-theme-console/log.md diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md new file mode 100644 index 00000000..141de043 --- /dev/null +++ b/specs/feature-219-theme-console/log.md @@ -0,0 +1,8 @@ +# Log: #219 Theme Console + +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-29 19:23 | 1 Intake | Orchestrator | Feature issue #219 (theme Console), open, dependencies #217/#218 merged; branch claude/epic-volta-wusl4o, work folder specs/feature-219-theme-console | From 06b1b12a7a819eaa56d445ed1d473a960ceee66f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:26:39 +0000 Subject: [PATCH 02/27] Write spec for feature 219 --- specs/feature-219-theme-console/spec.md | 156 ++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 specs/feature-219-theme-console/spec.md diff --git a/specs/feature-219-theme-console/spec.md b/specs/feature-219-theme-console/spec.md new file mode 100644 index 00000000..351f9020 --- /dev/null +++ b/specs/feature-219-theme-console/spec.md @@ -0,0 +1,156 @@ +# Spec: Theme Console (light and dark) + +Source: Issue #219 +Status: Draft + +## Problem + +Since #217 and #218 the dashboard has a theme selection, but only one theme, Clear, so the Theme group of the +Customize dialog stays hidden. A user who wants a dense, technical look in which colour only marks what needs +attention has no choice: in Clear every normal value is green and every card carries its own colour. The issue's +*Summary* and *Specification* (sections 1–14) describe the theme Console the user can choose instead; they are the +binding look and are referred to here by section number (`§n`), not restated. The mockups in `docs/design/v1.5.0/` +only illustrate it. + +## Scenarios + +- S1: Given the dashboard with no stored theme, when the user opens "Customize dashboard", then a Theme group lists + "Clear" (checked) and "Console" in that order; when the user picks "Console", the page takes the Console look at + once, without a reload, the dialog stays open, and every chart and gauge is redrawn in it. +- S2: Given Console was chosen earlier in this browser, when the page loads, then it paints in Console from the + first frame, in the stored mode (or the operating system's mode when none is stored). +- S3: Given Console is active, when the user presses the mode button (or, with no stored mode, the operating system + switches), then the page switches between Console light and Console dark and redraws every chart and gauge; the + theme stays Console. +- S4: Given Console is active and every value is in the normal range, then values, percentages, bars, gauge arcs, + sparklines and card icons are drawn in the text or muted colour only; the only colour on the page is the small + green square in front of the Pi-hole status "Up to date" (§3, §9). +- S5: Given Console is active and a value reaches its `warn` or `crit` threshold (for example a filesystem at 89.3 %), + then that value's text takes the level's ink colour and its bar or gauge arc the level's base colour (§3); the + thresholds and levels are those of [Value coloring](../../docs/areas/dashboard.md#value-coloring). +- S6: Given Console is active and an alert fires, then the card badge and the banner show it in the Console form + (§5, §14), with the same content and visibility as in Clear. +- S7: Given Console is active, then the cards show a heading strip, metric values in monospace with the unit set + apart, segmented bars, stepped sparklines, thin butt-capped gauge arcs, dashed key/value dividers, an outlined + updates button and the header, network card, dialogs and footer of §4–§14. +- S8: Given Console is active, when the user opens the detail view of CPU, load, temperature or memory, then the + chart is drawn stepped like the sparklines (§11), with range buttons outlined and the active one filled (§14). +- S9: Given Console is active, when the user picks "Clear", then the page returns to the Clear look without a + reload and looks exactly as it did before this feature. + +## Errors and edge cases + +- E1: The stored theme is `console` but storage is blocked, or the stored value is `Console`, ` console` or an id no + longer registered (downgrade to a version without Console): the page shows Clear and the stored value is kept, as + [Theme](../../docs/areas/dashboard.md#theme) states today. +- E2: A canvas property Console declares is missing, empty or out of range (a browser that does not compute it, a + later palette edit): the widget draws with Clear's value of that property instead of failing or drawing nothing. +- E3: A sparkline or detail chart with fewer than two points: nothing is drawn, and the detail view says so, as + today; a flat series is drawn as a horizontal stepped line at mid-height. +- E4: A metric value without a unit — the temperature `n/a`, the placeholder `–` before the first poll, the + updates count, `Not checked yet`, `Check failed` — shows no unit element and no stray space. +- E5: A bar at 0 %, at 100 % and at a fill width that ends inside a segment: the fill's segments lie exactly on the + track's segments; a fill ending inside a segment shows that segment cut, never shifted. +- E6: The gauge arc at every column width (three columns above 1100 px, two up to 1100 px, one up to 720 px, and a + narrow phone): the arc and its butt ends are never clipped. +- E7: Long text in a monospace face (a long host name, kernel, mountpoint, interface name, package version): the + existing ellipsis and wrapping rules still hold; key/value values wrap anywhere (§7). +- E8: A Pi-hole update is available: an amber square dot and the text "Update available" in `--warn-ink`; "Up to + date": a green dot and the text in `--text` (§9). Without Pi-hole the section stays hidden. +- E9: Alerting disabled on the server: no badge and no banner in Console either. +- E10: With Clear active, the Customize dialog now shows the Theme group, because two themes are registered + (`picker.classList.toggle('hidden', PIMONITOR_THEMES.length < 2)` in `app.js`): this is the one visible change in + Clear and intended by #218. + +## Non-functional requirements + +- N1: No font file, `@font-face` or request to another origin; the monospace face is the system stack of §2. No new + asset file: Console lives in `style.css` and the existing scripts ([0038](../../docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md)). +- N2: The strict Content-Security-Policy holds: no inline style or script; `app.js` assigns no non-empty + `innerHTML` (security area *Dashboard XSS*); the split of number and unit (§8) inserts both through `textContent`. +- N3: Contrast in both modes: text at least 4.5:1 and graphical elements (fills, arcs, icons, dots) at least 3:1 + against their background; the segmented track is decorative (issue *Constraints*). +- N4: Choosing or leaving Console changes only the appearance: polling, alerts, layout, detail view, API key + handling, storage entries (still exactly five), the API and the configuration are unchanged. +- N5: One DOM for every theme: no Console-specific markup in `index.html` and no Console-specific branch of HTML + rendering in `app.js`; Console's differences are CSS and declared canvas drawing properties + ([0042](../../docs/decisions/0042-theme-registry-in-theme-init-js.md)). + +## Acceptance criteria + +- AC1: The registry holds a theme with the id `console` and the display name "Console" after Clear; it can be chosen + in the "Customize dashboard" dialog and, when stored, is applied before the first paint (S1, S2, E1). +- AC2: Console declares every palette token in its light block and in both dark blocks, with the values of §1 for + the tokens §1 lists; the two dark blocks are identical and all three hold the same token keys as Clear's (S3). +- AC3: In Console a value in the `ok` level is drawn in `--text`, text and fill; `warn` and `crit` use their ink + colour for text and their base colour for fills. This holds for CPU usage, temperature, RAM, swap, every + filesystem, the openHAB heap bar and the load-gauge arcs; the new-version column of the updates list is in + `--text`; the only `--ok` on the page is the Pi-hole status dot (S4, S5, E8). +- AC4: Values, card titles, header, banner, buttons, captions and footer use the monospace stack of §2; no font file + is requested from the network or added to the embedded assets (S7, N1). +- AC5: Console cards have a 6 px radius, no shadow and a heading strip with a bottom border; card icons are drawn in + `--muted`, without a chip and without the per-card colours of Clear (S4, S7). +- AC6: Every bar in Console (Memory & Swap, Filesystems, the openHAB heap) is segmented — 6 px segments, 2 px gaps, + 12 px high — and fill and track segments are aligned at every fill width (S7, E5). +- AC7: In Console, sparklines and the detail chart are drawn as a stepped line in `--text` with a flat low-opacity + fill, a solid baseline and two dashed grid lines, without an end dot; with fewer than two points nothing is drawn + (S7, S8, E3). +- AC8: In Console the load gauges are drawn with a 5 px arc and butt caps; the arc is not clipped at any column width + (S7, E6). +- AC9: The number and the unit of the CPU usage and temperature values are separate elements, both set through + `textContent`; in Console the unit is smaller and muted (§8), and a value without a unit has no unit element + shown (S7, E4, N2). +- AC10: Switching between Clear and Console, and between light and dark while Console is active, restyles the page + and redraws every canvas widget without a reload (S1, S3, S9). +- AC11: In both Console modes the contrast is at least 4.5:1 for `--text`, `--muted` and the three ink tokens against + `--card-bg`, and for `--text` and `--muted` against `--bg`; at least 3:1 for `--ok`, `--warn` and `--crit` against + `--card-bg` (N3). +- AC12: With Clear active, the page looks and behaves exactly as before this feature, except for the Theme group + that now appears in the Customize dialog (S9, E10). +- AC13: No inline style or script is added; `app.js` assigns no non-empty `innerHTML`; the existing tests under + `internal/web` pass (N2, N5). +- AC14: Every canvas property Console declares is read through the readers of `theme-init.js` with Clear's value as + fallback, so a missing or invalid value draws the widget as in Clear (E2). +- AC15: In Console the header, the alert banner and badges, the key/value rows, the Updates card, the network card, + the dialogs and the footer take the look of §4, §5, §7, §9, §13 and §14 (S6, S7, S8, E7, E9). + +## Out of scope + +- The per-core meter rows (#221), the sparkline caption (#222), the header status dot (#223), the "OK" markers and + the gauge scale line (#224), all visible in the mockups. +- Any new data, behaviour, storage entry, configuration option or API change (N4). +- A stepped style for the openHAB memory chart: §11 names only the sparklines and the detail chart. + +## Open questions + +- Does #217 already split the number and the unit of a metric value (§8)? Answered: no — `app.js` sets + `'… .toFixed(1) + ' %'` and `' °C'` as one string on `#cpu-overall` and `#temp-value`, so this feature splits them, + for every theme (N5); in Clear the unit inherits size, weight and colour so the look is unchanged (AC12). +- Is the openHAB card, missing from §10, §11 and the mockups, styled by Console? Answered: from the issue — it shares + the bar markup and §3 must hold everywhere, so its heap bar is segmented and text-coloured at `ok`; its memory + chart keeps its time-scaled line shape and takes Console's tokens (RSS in `--accent` = `--text`, heap `--muted`, + restart markers `--warn`). +- Is the gauge's value text coloured by level? Answered: no (code) — `renderGauge` sets no level class on + `.gauge-value`, and the issue keeps "the level of each value exactly those of today"; it stays `--text`, only the + arc follows §3. +- The new-version column of the updates list is `--ok-ink` in Clear; in Console? Answered: `--text`, from §3 ("must hold + everywhere", green only as a status dot). +- Do the §1 values meet the contrast of AC11? Answered: yes, by the WCAG ratios computed from the §1 values — lowest text + ratio 4.59:1 (`--ok-ink` light on `--bg`), lowest graphic ratio 3.19:1 (`--warn` light on `--card-bg`); ink on a + 10 % tint at least 5.09:1. All pass. +- What does the README show? Answered: a real screenshot of the built dashboard in Console light and dark beside + `docs/dashboard.png`, not the mockups, which show elements this feature does not build; who takes it is the plan's. +- Which canvas properties does Console need? Answered: today the readers serve exactly eight + ([Look](../../docs/areas/dashboard.md#look)); Console needs further ones (line shape, end dot, fill style, grid, + arc width, caps, the `ok` fill colour). Their names are the plan's; AC14 fixes their fallback. + +## Area documents + +- `docs/areas/dashboard.md`, *Theme*: the registered themes are Clear (default) and Console. +- *Value coloring*: the colour rule of Console (`ok` in `--text`, `warn`/`crit` in ink and base colour), levels + unchanged; decision record "In Console, colour is reserved for `warn` and `crit`". +- *Look*: the canvas properties the renderers read (the new ones with their Clear fallback), and per theme the + sparkline (smooth or stepped), the gauge arc (width, caps) and the bar (rounded or segmented); a metric value's + number and unit are separate elements. The document is long; the plan checks its size against `AREA_MAX_WORDS` + and plans a split (a theme-look area document) if needed. +- `README.md`: the theme list ("only Clear today" at line 57) names Console; screenshots of Console light and dark. From 8b35a61181366e09512c72ff3474e414ebfc7868 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:26:44 +0000 Subject: [PATCH 03/27] Write spec for feature 219 --- specs/feature-219-theme-console/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index 141de043..e878ca35 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -6,3 +6,4 @@ are quoted in full. | Date | Step | Member | Result | | ---- | ---- | ------ | ------ | | 2026-11-29 19:23 | 1 Intake | Orchestrator | Feature issue #219 (theme Console), open, dependencies #217/#218 merged; branch claude/epic-volta-wusl4o, work folder specs/feature-219-theme-console | +| 2026-11-29 19:26 | 2a Spec | Lead | RESULT: DONE — spec.md written (15 AC, 9 scenarios), Status Draft; open points for PM: openHAB card choice, new-version column colour, real README screenshot (opus/medium · 70,390 tokens · 11 tool uses · 71 s · 22 in · 5,029 out · 404,562 cache read · 69,406 cache write · 264,305 weighted) | From 61811df384501765073389d22514f60f9074aef9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:30:32 +0000 Subject: [PATCH 04/27] Log spec challenge for feature 219 --- specs/feature-219-theme-console/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index e878ca35..e1c1152c 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -7,3 +7,4 @@ are quoted in full. | ---- | ---- | ------ | ------ | | 2026-11-29 19:23 | 1 Intake | Orchestrator | Feature issue #219 (theme Console), open, dependencies #217/#218 merged; branch claude/epic-volta-wusl4o, work folder specs/feature-219-theme-console | | 2026-11-29 19:26 | 2a Spec | Lead | RESULT: DONE — spec.md written (15 AC, 9 scenarios), Status Draft; open points for PM: openHAB card choice, new-version column colour, real README screenshot (opus/medium · 70,390 tokens · 11 tool uses · 71 s · 22 in · 5,029 out · 404,562 cache read · 69,406 cache write · 264,305 weighted) | +| 2026-11-29 19:30 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 1 major, 4 minor. Major: gauge value (mono 18px) must fit inside 5px arc at all widths (extend AC8/edge case). Minor: AC13 existing tests pinning Clear drawing literals need adapting; AC14 readers only handle colour/number; openHAB restart markers vs S4; number/unit spacing (opus/medium · 93,100 tokens · 30 tool uses · 220 s · 56 in · 19,793 out · 1,464,453 cache read · 89,228 cache write · 567,557 weighted) | From 4f18d11ea151843b902421c653a89a15496e2ef1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:31:20 +0000 Subject: [PATCH 05/27] Revise spec for feature 219 --- specs/feature-219-theme-console/log.md | 1 + specs/feature-219-theme-console/spec.md | 51 ++++++++++++++++++++----- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index e1c1152c..7e375232 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -8,3 +8,4 @@ are quoted in full. | 2026-11-29 19:23 | 1 Intake | Orchestrator | Feature issue #219 (theme Console), open, dependencies #217/#218 merged; branch claude/epic-volta-wusl4o, work folder specs/feature-219-theme-console | | 2026-11-29 19:26 | 2a Spec | Lead | RESULT: DONE — spec.md written (15 AC, 9 scenarios), Status Draft; open points for PM: openHAB card choice, new-version column colour, real README screenshot (opus/medium · 70,390 tokens · 11 tool uses · 71 s · 22 in · 5,029 out · 404,562 cache read · 69,406 cache write · 264,305 weighted) | | 2026-11-29 19:30 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 1 major, 4 minor. Major: gauge value (mono 18px) must fit inside 5px arc at all widths (extend AC8/edge case). Minor: AC13 existing tests pinning Clear drawing literals need adapting; AC14 readers only handle colour/number; openHAB restart markers vs S4; number/unit spacing (opus/medium · 93,100 tokens · 30 tool uses · 220 s · 56 in · 19,793 out · 1,464,453 cache read · 89,228 cache write · 567,557 weighted) | +| 2026-11-29 19:31 | 2a Spec revise (challenge) | Lead | RESULT: DONE — all 5 objections accepted and answered in the spec's Challenge section (E11, AC8/9/13/14 amended, S4 openHAB exception) (opus/medium · 33,200 tokens · 4 tool uses · 37 s · 10 in · 4,176 out · 377,298 cache read · 13,419 cache write · 113,057 weighted · continued) | diff --git a/specs/feature-219-theme-console/spec.md b/specs/feature-219-theme-console/spec.md index 351f9020..3653b443 100644 --- a/specs/feature-219-theme-console/spec.md +++ b/specs/feature-219-theme-console/spec.md @@ -24,7 +24,8 @@ only illustrate it. theme stays Console. - S4: Given Console is active and every value is in the normal range, then values, percentages, bars, gauge arcs, sparklines and card icons are drawn in the text or muted colour only; the only colour on the page is the small - green square in front of the Pi-hole status "Up to date" (§3, §9). + green square in front of the Pi-hole status "Up to date" (§3, §9) and, in the openHAB memory chart, the amber + marker of a restart, which is an event that needs attention. - S5: Given Console is active and a value reaches its `warn` or `crit` threshold (for example a filesystem at 89.3 %), then that value's text takes the level's ink colour and its bar or gauge arc the level's base colour (§3); the thresholds and levels are those of [Value coloring](../../docs/areas/dashboard.md#value-coloring). @@ -48,11 +49,16 @@ only illustrate it. - E3: A sparkline or detail chart with fewer than two points: nothing is drawn, and the detail view says so, as today; a flat series is drawn as a horizontal stepped line at mid-height. - E4: A metric value without a unit — the temperature `n/a`, the placeholder `–` before the first poll, the - updates count, `Not checked yet`, `Check failed` — shows no unit element and no stray space. + updates count, `Not checked yet`, `Check failed` — shows no unit element and no trailing space, in every theme. + A value with a unit reads exactly `20.5 %` / `45.2 °C` in Clear, as today; in Console the gap between number and + unit is the unit's 4 px margin only, with no space character added. - E5: A bar at 0 %, at 100 % and at a fill width that ends inside a segment: the fill's segments lie exactly on the track's segments; a fill ending inside a segment shows that segment cut, never shifted. - E6: The gauge arc at every column width (three columns above 1100 px, two up to 1100 px, one up to 720 px, and a narrow phone): the arc and its butt ends are never clipped. +- E11: The gauge value at its widest form `NN.NN` in the monospace face at the narrowest gauge (72 px, the width the + existing gauge test checks): it fits inside the inner arc; a fixed 18 px monospace value (about 54 px wide) would + not, so 18 px is the upper bound of a size that scales with the gauge width, as in Clear. - E7: Long text in a monospace face (a long host name, kernel, mountpoint, interface name, package version): the existing ellipsis and wrapping rules still hold; key/value values wrap anywhere (§7). - E8: A Pi-hole update is available: an amber square dot and the text "Update available" in `--warn-ink`; "Up to @@ -95,11 +101,13 @@ only illustrate it. - AC7: In Console, sparklines and the detail chart are drawn as a stepped line in `--text` with a flat low-opacity fill, a solid baseline and two dashed grid lines, without an end dot; with fewer than two points nothing is drawn (S7, S8, E3). -- AC8: In Console the load gauges are drawn with a 5 px arc and butt caps; the arc is not clipped at any column width - (S7, E6). +- AC8: In Console the load gauges are drawn with a 5 px arc and butt caps; the arc is not clipped at any column width; + the value, sized with the gauge width up to 18 px, fits as `NN.NN` inside the inner arc at every gauge width from + 72 px up, checked with the glyph width of a monospace face, not of the sans face (S7, E6, E11). - AC9: The number and the unit of the CPU usage and temperature values are separate elements, both set through - `textContent`; in Console the unit is smaller and muted (§8), and a value without a unit has no unit element - shown (S7, E4, N2). + `textContent`; in Clear the visible text stays exactly `20.5 %` / `45.2 °C`, in Console the unit is smaller and + muted (§8) and set apart by its 4 px margin only; a value without a unit shows no unit element and no trailing + space in either theme (S7, E4, N2). - AC10: Switching between Clear and Console, and between light and dark while Console is active, restyles the page and redraws every canvas widget without a reload (S1, S3, S9). - AC11: In both Console modes the contrast is at least 4.5:1 for `--text`, `--muted` and the three ink tokens against @@ -108,9 +116,12 @@ only illustrate it. - AC12: With Clear active, the page looks and behaves exactly as before this feature, except for the Theme group that now appears in the Customize dialog (S9, E10). - AC13: No inline style or script is added; `app.js` assigns no non-empty `innerHTML`; the existing tests under - `internal/web` pass (N2, N5). + `internal/web` pass. A test may be adapted only where it pins a drawing literal that becomes a declared property + (the sparkline's 2 px line, gradient fade and end dot, the gauge's 9 px arc); the adapted test still asserts + Clear's values, and the arc-inside-canvas and value-chord checks run for Clear's and Console's arc width (N2, N5). - AC14: Every canvas property Console declares is read through the readers of `theme-init.js` with Clear's value as - fallback, so a missing or invalid value draws the widget as in Clear (E2). + fallback, so a missing or invalid value draws the widget as in Clear; each new property is a token in all three of + Clear's palette blocks too, with Clear's current drawing value, and its fallback equals Clear's light value (E2). - AC15: In Console the header, the alert banner and badges, the key/value rows, the Updates card, the network card, the dialogs and the footer take the look of §4, §5, §7, §9, §13 and §14 (S6, S7, S8, E7, E9). @@ -129,7 +140,7 @@ only illustrate it. - Is the openHAB card, missing from §10, §11 and the mockups, styled by Console? Answered: from the issue — it shares the bar markup and §3 must hold everywhere, so its heap bar is segmented and text-coloured at `ok`; its memory chart keeps its time-scaled line shape and takes Console's tokens (RSS in `--accent` = `--text`, heap `--muted`, - restart markers `--warn`). + restart markers `--warn`, the exception S4 names). - Is the gauge's value text coloured by level? Answered: no (code) — `renderGauge` sets no level class on `.gauge-value`, and the issue keeps "the level of each value exactly those of today"; it stays `--text`, only the arc follows §3. @@ -142,7 +153,8 @@ only illustrate it. `docs/dashboard.png`, not the mockups, which show elements this feature does not build; who takes it is the plan's. - Which canvas properties does Console need? Answered: today the readers serve exactly eight ([Look](../../docs/areas/dashboard.md#look)); Console needs further ones (line shape, end dot, fill style, grid, - arc width, caps, the `ok` fill colour). Their names are the plan's; AC14 fixes their fallback. + arc width, caps, the `ok` fill colour). Their names, and whether a non-colour property is a bounded number read + by `themeNumber` or a keyword from a fixed list read by a new reader, are the plan's; AC14 fixes their fallback. ## Area documents @@ -154,3 +166,22 @@ only illustrate it. number and unit are separate elements. The document is long; the plan checks its size against `AREA_MAX_WORDS` and plans a split (a theme-look area document) if needed. - `README.md`: the theme list ("only Clear today" at line 57) names Console; screenshots of Console light and dark. + +## Challenge + +- 1 (major) No requirement that the gauge value fits inside the 5 px arc; §12's fixed 18 px monospace breaks it at + 72 px. Accepted: verified in `style.css` (`clamp(12px, 19cqi, 18px)`) and `checkGaugeValueChord` of + `internal/web/gauge_test.go`; E11 added and AC8 extended — 18 px is the upper bound of a width-scaled size, and the + fit of `NN.NN` is checked with monospace glyph width at every gauge width from 72 px. +- 2 (minor) AC13 cannot hold unchanged: `chart_test.go` and `gauge_test.go` pin `ctx.lineWidth = 2`, the gradient, + the end-dot arcs and `const lineWidth = 9`. Accepted: AC13 now allows adapting exactly those pins, the adapted + tests still assert Clear's values, and the arc and chord checks run for both arc widths. +- 3 (minor) AC14 must fit the readers and `TestThemeInit_DrawingFallbacks_AC17`, which ties fallback keys to the + properties read. Accepted: AC14 now requires each new property as a token in Clear's three blocks with Clear's + current value and a fallback equal to Clear's light value; the reader form (bounded number or a keyword reader + with the extractor extended) is left to the plan, noted under *Open questions*. +- 4 (minor) The openHAB restart markers in `--warn` contradict S4. Accepted: the marker stays `--warn` — a restart + is an event that needs attention, which is §3's reason for colour — and S4 and the openHAB answer now name it as + the exception. +- 5 (minor) Number/unit spacing undefined. Accepted: E4 and AC9 now fix the visible text in Clear (`20.5 %`, + `45.2 °C`), the 4 px margin as the only gap in Console and no trailing space without a unit in either theme. From 93f38d0cdac6f82f8ff57c6897c237b44fa50d93 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:38:33 +0000 Subject: [PATCH 06/27] Plan feature 219 --- ...board-mode-and-theme-as-token-overrides.md | 16 +- .../0042-theme-registry-in-theme-init-js.md | 9 +- ...3-console-colour-only-for-warn-and-crit.md | 42 ++++ docs/decisions/README.md | 1 + specs/feature-219-theme-console/log.md | 1 + specs/feature-219-theme-console/plan.md | 205 ++++++++++++++++++ specs/feature-219-theme-console/spec.md | 9 +- specs/feature-219-theme-console/tasks.md | 14 ++ 8 files changed, 286 insertions(+), 11 deletions(-) create mode 100644 docs/decisions/0043-console-colour-only-for-warn-and-crit.md create mode 100644 specs/feature-219-theme-console/plan.md create mode 100644 specs/feature-219-theme-console/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 94b49fe2..1e848981 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, issue #218 +- **Source:** Issue #217, issue #218, issue #219 - **Supersedes:** — ## Context @@ -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=""]` 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, diff --git a/docs/decisions/0042-theme-registry-in-theme-init-js.md b/docs/decisions/0042-theme-registry-in-theme-init-js.md index 9dfe11a6..e88f7563 100644 --- a/docs/decisions/0042-theme-registry-in-theme-init-js.md +++ b/docs/decisions/0042-theme-registry-in-theme-init-js.md @@ -3,7 +3,7 @@ - **Status:** Accepted - **Date:** 2026-11-28 - **Area:** Dashboard -- **Source:** Issue #218 +- **Source:** Issue #218, issue #219 - **Supersedes:** — ## Context @@ -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 diff --git a/docs/decisions/0043-console-colour-only-for-warn-and-crit.md b/docs/decisions/0043-console-colour-only-for-warn-and-crit.md new file mode 100644 index 00000000..ce666b4c --- /dev/null +++ b/docs/decisions/0043-console-colour-only-for-warn-and-crit.md @@ -0,0 +1,42 @@ +# 0043: In Console, colour is reserved for `warn` and `crit` + +- **Status:** Proposed +- **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` and its scoped text rules; Clear's `--ok-fill` equals + its `--ok`. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index da72155a..b5f7353c 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -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` | Proposed | 2026-11-29 | diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index 7e375232..18f2cbc3 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -9,3 +9,4 @@ are quoted in full. | 2026-11-29 19:26 | 2a Spec | Lead | RESULT: DONE — spec.md written (15 AC, 9 scenarios), Status Draft; open points for PM: openHAB card choice, new-version column colour, real README screenshot (opus/medium · 70,390 tokens · 11 tool uses · 71 s · 22 in · 5,029 out · 404,562 cache read · 69,406 cache write · 264,305 weighted) | | 2026-11-29 19:30 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 1 major, 4 minor. Major: gauge value (mono 18px) must fit inside 5px arc at all widths (extend AC8/edge case). Minor: AC13 existing tests pinning Clear drawing literals need adapting; AC14 readers only handle colour/number; openHAB restart markers vs S4; number/unit spacing (opus/medium · 93,100 tokens · 30 tool uses · 220 s · 56 in · 19,793 out · 1,464,453 cache read · 89,228 cache write · 567,557 weighted) | | 2026-11-29 19:31 | 2a Spec revise (challenge) | Lead | RESULT: DONE — all 5 objections accepted and answered in the spec's Challenge section (E11, AC8/9/13/14 amended, S4 openHAB exception) (opus/medium · 33,200 tokens · 4 tool uses · 37 s · 10 in · 4,176 out · 377,298 cache read · 13,419 cache write · 113,057 weighted · continued) | +| 2026-11-29 19:38 | 2b Plan | Lead | RESULT: DONE — tier standard, security area Dashboard XSS; plan.md, tasks.md (G1, G2, PM screenshot row), decision 0043 new, 0038/0042 extended (opus/medium · 89,675 tokens · 29 tool uses · 425 s · 52 in · 43,887 out · 3,838,551 cache read · 88,804 cache write · 1,044,839 weighted · continued) | diff --git a/specs/feature-219-theme-console/plan.md b/specs/feature-219-theme-console/plan.md new file mode 100644 index 00000000..c2788a77 --- /dev/null +++ b/specs/feature-219-theme-console/plan.md @@ -0,0 +1,205 @@ +# Plan: Theme Console (light and dark) + +Source: Issue #219 | [spec.md](spec.md) +Tier: standard — a new user-visible theme that changes dashboard rendering and creates, changes or removes no +security control. +Security areas touched: Dashboard XSS (`app.js` builds the metric value's number and unit as new DOM nodes) + +## Problem / root cause + +The feature of [spec.md](spec.md) (AC1–AC15). + +## Verified facts + +| # | Claim | Evidence | Status | +| - | ----- | -------- | ------ | +| 1 | The registry holds only Clear; the Theme group is hidden below two themes | `theme-init.js:3-5`; `app.js:144` | confirmed | +| 2 | Number and unit are one string | `app.js:301` (`+ ' %'`), `app.js:319` (`+ ' °C'`); `n/a` at `:322` | confirmed | +| 3 | The canvas readers read eight properties; `TestThemeInit_DrawingFallbacks_AC17` ties `DRAWING_FALLBACKS` keys to the reads found by `themeReaderRE` (`theme(?:Color\|Number)`) | `theme-init.js:8-17`; `theme_test.go:25,714` | confirmed | +| 4 | `drawSparkline` draws the sparklines and the detail chart; the openHAB chart is `drawTimeChart` | `app.js:1039,1311-1312,1474` | confirmed | +| 5 | The gauge draws a 9 px arc with round caps; `gaugeColorVar` returns `--ok` for `ok`; the gauge value is HTML (`.gauge-value`, `clamp(12px, 19cqi, 18px)`) with no level class | `gauge.js`; `style.css:514-522`; `app.js:1093-1098` | confirmed | +| 6 | Tests pin Clear's drawing literals: `ctx.lineWidth = 2;` and `const lineWidth = 9;` | `chart_test.go:46`, `gauge_test.go:96,115` | confirmed | +| 7 | `colourLiterals` and `checkNoBaseTokenText` skip only Clear's blocks (`isPaletteRule`), so Console's blocks would be reported | `palette_test.go:102,308,425` | confirmed | +| 8 | `contrastFailures` parses hex only and checks `--on-accent` on `--accent` and the button tint: Console's `--accent`/`--on-accent` must be hex literals, not `var(--text)` | `palette_test.go:593-640` | confirmed | +| 9 | `registryCopyProblems` fails on a `'console'` literal in `app.js`, `chart.js`, `gauge.js`; none holds one today | `theme_test.go:444`; grep | confirmed | +| 10 | `.theme-toggle:hover` lists `var(--shadow)` in a `box-shadow` list, so a `--shadow: none` makes the declaration invalid | `style.css:208-211` | confirmed | +| 11 | Cards have no body wrapper: the `h2` is the first child, clickable cards carry `.card-clickable` and a `.card-header-btn` | `index.html:35-127` | confirmed | +| 12 | Mode and theme switches call `repaintCanvases` (metrics and history redraw) | `app.js:92-135` | confirmed | +| 13 | The assets are outside the coverage measure but Sonar analyses the JS (cognitive complexity) | `sonar-project.properties:18,34`; `COVERAGE_PATHSPECS` | confirmed | +| 14 | At 72 px with a 5 px arc and `clamp(12px, 19cqi, 18px)`, `NN.NN` at 3.1 em (0.62 em per glyph) is 42.4 px against an inner chord of 47.1 px; the narrowest margin of all widths is at 72 px | computed with the formula of `checkGaugeValueChord` | confirmed | +| 15 | `88.88` at weight 600 in the §2 stack measures at most 3.1 em; the 72 px chord allows 3.44 em | headless Chrome `measureText` in the session: Liberation Mono 3.000 em, DejaVu Sans Mono 3.010 em; the stack's other fonts are not installed here, and Menlo is DejaVu's metric twin | confirmed | +| 16 | The §1 values meet AC11 (lowest text 4.59:1, lowest fill 3.19:1) | spec, *Open questions* | confirmed | +| 17 | Records 0038 and 0042 are unreleased | `git ls-remote --tags origin` (latest v1.4.1 = `8f1a81f`), `git tag --contains b4a3c35` empty | confirmed | + +## Tests per criterion + +| AC | Test(s) | Test file | +| -- | ------- | --------- | +| AC1 | `TestThemeRegistry_HasConsole_AC1` (entry `console`/"Console" second; existing stored-theme and picker tests run over the registry) | `internal/web/theme_test.go` | +| AC2 | `TestStyleCSS_ConsolePalette_AC2` (three blocks, §1 values, dark blocks identical, key set equal to Clear's) | `internal/web/palette_test.go` | +| AC3 | `TestStyleCSS_ConsoleColourRule_AC3`; `TestGaugeJS_OkFill_AC3` | `internal/web/palette_test.go`; `internal/web/gauge_test.go` | +| AC4 | `TestStyleCSS_ConsoleMonospace_AC4` (the stack in one rule covering the §2 elements; no `@font-face`, no font file in `assets/`) | `internal/web/look_test.go` | +| AC5 | `TestStyleCSS_ConsoleCards_AC5` | `internal/web/look_test.go` | +| AC6 | `TestStyleCSS_ConsoleSegmentedBars_AC6` | `internal/web/look_test.go` | +| AC7 | `TestChartJS_ConsoleSparkline_AC7`; adapted `TestChartJS_Sparkline_AC7` | `internal/web/chart_test.go` | +| AC8 | `TestGaugeJS_ConsoleArc_AC8`; adapted `TestGaugeJS_ArcNeverClipped_AC8` | `internal/web/gauge_test.go` | +| AC9 | `TestAppJS_MetricValueUnit_AC9` | `internal/web/look_test.go` | +| AC10 | `TestAppJS_ThemeSwitchRedraws_AC10` | `internal/web/theme_test.go` | +| AC11 | `TestStyleCSS_ThemeContrast_AC11` | `internal/web/palette_test.go` | +| AC12 | `TestStyleCSS_ConsoleRulesScoped_AC12`; the existing Clear tests with `expectedTokens` extended; manual: orchestrator, step 9, Clear light and dark on the branch build beside `main` | `internal/web/palette_test.go` | +| AC13 | existing `xss_test.go`, `TestIndexHTML_NoInlineStyle_AC11`, the whole `internal/web` suite | `internal/web/xss_test.go`, `internal/web/look_test.go` | +| AC14 | `TestThemeInit_KeywordReader_AC14`; adapted `TestThemeInit_DrawingFallbacks_AC17` | `internal/web/theme_test.go` | +| AC15 | `TestStyleCSS_ConsoleChrome_AC15`; manual: orchestrator, step 9, Console light and dark against §4–§14 | `internal/web/look_test.go` | + +## Approach + +**Registry and readers (`theme-init.js`).** Add `Object.freeze({ id: 'console', name: 'Console' })` after Clear. +Add `themeKeyword(name, allowed)`: the trimmed computed value when `allowed` holds it, else +`DRAWING_FALLBACKS[name]` (no `||` default). `DRAWING_FALLBACKS` gains Clear's light value of every new read: +`--border`, `--ok-fill`, `--spark-line-width`, `--spark-shape`, `--spark-fill`, `--spark-dot`, `--spark-grid`, +`--gauge-width`, `--gauge-cap`. + +**Tokens (`style.css`).** Clear's three blocks gain: `--ok-fill` (= its `--ok`), `--spark-line-width: 2`, +`--spark-shape: line`, `--spark-fill: fade`, `--spark-dot: ring`, `--spark-grid: none`, `--gauge-width: 9`, +`--gauge-cap: round`. Console's three blocks follow Clear's palette blocks, with the §1 values and, all as literals: +`--accent` and every `--accent-` = the mode's `--text` hex, `--on-accent` = `--card-bg` hex, `--ok-fill` = `--text` +hex; `--shadow` and `--dialog-shadow`: `0 0 0 transparent` (fact 10); `--chip-tint: 0%`, `--btn-tint: 0%`, +`--btn-border-tint: 100%` (outlined buttons through the existing rules); `--spark-fill-alpha` 0.07 / 0.09; +`--radius-card`, `--radius-control`, `--radius-button: 6px`, `--radius-chip: 0`; `--card-padding: 0 14px 14px`; +`--gap: 12px`; `--backdrop` as Clear; `--spark-line-width: 1.5`, `--spark-shape: step`, `--spark-fill: flat`, +`--spark-dot: none`, `--spark-grid: lines`, `--gauge-width: 5`, `--gauge-cap: butt`. + +**Scoped rules.** After Console's blocks, rules whose every selector starts with `:root[data-style="console"]`, +using tokens only ([0038](../../docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md)); no unscoped rule +changes except the unit rule below. The monospace stack of §2 is written once, in one rule whose selector list names +the §2 elements. Per issue section: +- §3/AC3: `.metric-ok`, `.kv-val.metric-ok`, `.updates-table td.pkg-new` → `var(--text)`; the Pi-hole dot is + `#pihole-status::before` (6 × 6, `var(--ok)` with `.metric-ok`, `var(--warn)` with `.metric-warn`), the only + `--ok` in Console's rules ([0043](../../docs/decisions/0043-console-colour-only-for-warn-and-crit.md)). +- §4: `.logo-tile` hidden; title 18 px/700, subtitle 12 px muted; header buttons radius from the token, icon + `stroke-width: 1.75`; header and `main` padding 16 px / 20 px; `body` 13 px. +- §5, §14: banner and badges — 1 px solid base colour, `color-mix(in srgb, var(--) 10%, transparent)` + background, ink text, square `::before` dot for badges and the stale badge, badge radius 0, uppercase 11 px. +- §6: the `h2` is the strip — `margin: 0 -14px 12px`, `padding: 0 14px`, 44 px min height, bottom border, text + 12 px/600/uppercase/0.08em `--text`; in `.card-clickable` the `h2` has no padding and `.card-header-btn` takes + `padding: 0 14px`, so the whole strip is the button; `.card-icon` 14 px, no chip, `--muted`; chevron 14 px muted; + `#card-system`, `#card-uptime` body 8 px 14px 10 px (h2 margin 8 px, padding-bottom 10 px). +- §7: `.kv-row` 13 px, 6 px padding, dashed bottom border; `.kv-val` regular weight. +- §8: `.metric-value` 30 px/600/−0.03em/1.1; `.metric-unit` 15 px/500 muted, `margin-left: 4px`, + `::before` `content: none`; `.metric-sub` 12 px. +- §9: updates button outlined by the tokens, 13 px/600, 44 px; Pi-hole section dashed top border, sub lines 12 px. +- §10: `.bar-track` and `.bar-fill` 12 px high, radius 0, each `background: repeating-linear-gradient(90deg, + 0 6px, transparent 6px 8px)` — track `--track`, fill `--ok-fill`, `.metric-warn` `--warn`, + `.metric-crit` `--crit`; the track has no padding or border, so both patterns start at the track's left edge and + stay aligned at every width; bar rows 12 px apart; label 12 px. +- §11, §12: `.sparkline` 48 px; gauge value 600, label 11 px uppercase 0.06em muted; the value keeps Clear's + `clamp(12px, 19cqi, 18px)` (spec E11, facts 14–15). +- §13, §14: network rows dashed, name 600, arrows 13 px muted; dialogs radius from the token, mono headings; range + buttons, layout buttons and the API key submit outlined (the active range button filled by the existing + `--accent`/`--on-accent` rule); footer 12 px muted, link `--text` underlined. + +Values the issue does not fix (an offset, a gap of a strip) are the Dev's, approved in step 9 against the mockups. + +**Canvas (`chart.js`, `gauge.js`).** `drawSparkline` keeps its signature and its `< 2` guard before any drawing; it +reads its style through `sparkStyle()` and draws in this order: grid (`--spark-grid: lines` → a solid 1 px baseline +at the bottom and dashed `[2, 4]` lines at 25 % and 62.5 % of the height, in `--border`), fill (`flat`: the fill +alpha only; `fade`: today's `destination-out` gradient), line (`--spark-line-width`; `step`: each point held +horizontally to the next x, then vertical), dot (`ring`: today's dot; `none`: no dot). The padding of 7 px stays. +`drawGauge` takes `lineWidth` from `themeNumber('--gauge-width', 1, 12)` and `lineCap` from +`themeKeyword('--gauge-cap', ['round', 'butt'])`; the radius bound is unchanged. `gaugeColorVar` returns `--ok-fill` +for `ok`. The helpers keep each function within Sonar's cognitive complexity (fact 13). `drawTimeChart` is unchanged. + +**Number and unit (`app.js`).** A private `setMetricValue(id, number, unit)` rebuilds the element's children with +`replaceChildren`: a `span.metric-number` and, only when `unit` is non-empty, a `span.metric-unit`, both by +`createElement` + `textContent`. CPU (`'%'`) and temperature (`'°C'`) use it; `n/a` passes an empty unit. Clear: one +unscoped rule `.metric-unit::before { content: " "; }` and no size, weight or colour, so Clear renders `20.5 %` as +before (spec E4). + +Early draft PR: no + +## Options considered + +- **Console's look as scoped rules plus tokens** (chosen) against **every differing property as a token** (about + thirty more tokens in all six blocks, most unused by Clear) and one stylesheet per theme (rejected in 0038) — + recorded in [0038](../../docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md). +- **Keyword reader** (chosen) against **shapes as numbers through `themeNumber`** (spec challenge 3) — recorded in + [0042](../../docs/decisions/0042-theme-registry-in-theme-init-js.md). +- **`ok` in `--text`** against a muted green or `--muted` — [0043](../../docs/decisions/0043-console-colour-only-for-warn-and-crit.md). +- **Clear's unit gap as `::before { content: " " }`** against a text-node space (Console's gap would be the space + plus 4 px, spec E4) and a leading space in the unit's text (same defect). +- **Restart markers in `--warn`** against `--muted` (spec challenge 4): a restart is an event needing attention. +- **Gauge value keeps Clear's width-scaled size** against §12's fixed 18 px, which overflows at 72 px (spec E11). + +## Affected projects and types + +| Project | Type / file | Change | +| ------- | ----------- | ------ | +| `internal/web` | `assets/theme-init.js` | registry entry, `themeKeyword`, fallbacks | +| `internal/web` | `assets/style.css` | Clear's new tokens, `.metric-unit`, Console's blocks and scoped rules | +| `internal/web` | `assets/chart.js` | `drawSparkline` styles and helpers | +| `internal/web` | `assets/gauge.js` | arc width, caps, `--ok-fill` | +| `internal/web` | `assets/app.js` | `setMetricValue` and its two callers | + +## Signatures (for the Dev's skeleton) + +- `function themeKeyword(name, allowed)` (theme-init.js) +- `function sparkStyle()` (chart.js): returns an object with shape, lineWidth, fill, fillAlpha, dot, grid, cardBg + and border +- `function drawSparkGrid(ctx, width, height, color)` (chart.js) +- `function traceSparkline(ctx, xy, stepped)` (chart.js): xy is an array of points with x and y +- `function fillSparkline(ctx, xy, height, color, style)` (chart.js) +- `function drawSparkDot(ctx, last, color, cardBg)` (chart.js): last is the newest point with x and y + +drawSparkline, drawGauge and gaugeColorVar keep their signatures. The skeleton holds the registry entry and both +palettes for real (the token tests of AC2 and AC11 then pass at once). + +## Test files + +`internal/web/theme_test.go`, `internal/web/palette_test.go`, `internal/web/look_test.go`, +`internal/web/chart_test.go`, `internal/web/gauge_test.go` (the asset tests are grouped by topic, as today). + +Existing test code to adapt, all by the Tester: `checkSparklineStyle` (`chart_test.go`: the line width through the +token, Clear's value asserted from its block); `checkGaugeStroke` and the `lineWidth` regex (`gauge_test.go`: the +token, arc and chord checks run for Clear at 2.89 em and Console at 3.1 em at 72, 100, 150, 250, 400 px); +`isPaletteRule` (`palette_test.go`: every registered theme's three selectors); `expectedTokens` (Clear's new +tokens); `themeReaderRE` (`theme_test.go`: `Keyword` added; a fixture case in `checkReadExtractors`). + +Files no unit test can cover: the five assets have no JS test runner; they are outside the coverage measure already +(fact 13) and are checked by the Go text tests above. No new exclusion. + +## Areas + +- `docs/areas/dashboard.md` (+300 words): *Theme* (Clear and Console registered), *Value coloring* (the colour of + `ok` per theme, link to 0043), *Look* (the properties read and `themeKeyword`; per theme the sparkline, gauge arc + and bars; the metric value's number and unit; Console's scoped rules). About 4,250 words afterwards, below + `AREA_MAX_WORDS`. + +## Documentation updates + +- `docs/areas/dashboard.md`: as *Areas*, by the Dev. +- `README.md` lines 57–58: "Choosable themes" names Clear and Console; two screenshots beside `docs/dashboard.png` + (`docs/dashboard-console-light.png`, `docs/dashboard-console-dark.png`), by the Dev; the image files come from the + Product Manager, taken on a Pi from the branch build (the session runs on no Pi, so its page would show no model or + temperature), requested by the orchestrator before step 9. +- `docs/ARCHITECTURE.md`: none (line 25 already names theme and look). + +## Architecture check + +One DOM for every theme, no new asset, no request to another origin, no API, storage or configuration change; the +Content-Security-Policy is untouched (no inline style; generated content comes from `style.css`). The XSS guarantee +holds: the new nodes take `textContent` only. + +## Security considerations + +- [x] no limits. +- [x] none: no exception reaches a user-visible message. + +## Decision records + +- `docs/decisions/0043-console-colour-only-for-warn-and-crit.md` (Proposed) +- `docs/decisions/0038-dashboard-mode-and-theme-as-token-overrides.md` (extended in place: scoped rules, option 5) +- `docs/decisions/0042-theme-registry-in-theme-init-js.md` (extended in place: `themeKeyword`, option 5) + +## Out of scope / follow-ups + +The elements of #221–#224; a stepped openHAB chart (spec *Out of scope*). diff --git a/specs/feature-219-theme-console/spec.md b/specs/feature-219-theme-console/spec.md index 3653b443..97688f59 100644 --- a/specs/feature-219-theme-console/spec.md +++ b/specs/feature-219-theme-console/spec.md @@ -1,7 +1,7 @@ # Spec: Theme Console (light and dark) Source: Issue #219 -Status: Draft +Status: Approved by Lead ## Problem @@ -152,9 +152,10 @@ only illustrate it. - What does the README show? Answered: a real screenshot of the built dashboard in Console light and dark beside `docs/dashboard.png`, not the mockups, which show elements this feature does not build; who takes it is the plan's. - Which canvas properties does Console need? Answered: today the readers serve exactly eight - ([Look](../../docs/areas/dashboard.md#look)); Console needs further ones (line shape, end dot, fill style, grid, - arc width, caps, the `ok` fill colour). Their names, and whether a non-colour property is a bounded number read - by `themeNumber` or a keyword from a fixed list read by a new reader, are the plan's; AC14 fixes their fallback. + ([Look](../../docs/areas/dashboard.md#look)); the plan adds `--border`, `--ok-fill`, two numbers (line and arc + width) and five keywords (line shape, fill, end dot, grid, arc caps) read by a new `themeKeyword` from a fixed + list ([plan.md](plan.md), [0042](../../docs/decisions/0042-theme-registry-in-theme-init-js.md)); AC14 fixes + their fallback. ## Area documents diff --git a/specs/feature-219-theme-console/tasks.md b/specs/feature-219-theme-console/tasks.md new file mode 100644 index 00000000..8e865cc2 --- /dev/null +++ b/specs/feature-219-theme-console/tasks.md @@ -0,0 +1,14 @@ +# Tasks: Theme Console (light and dark) + +Plan: [plan.md](plan.md) + +| # | Group | Task | Files | Criteria | Depends on | Owner | Done | +| - | ----- | ---- | ----- | -------- | ---------- | ----- | ---- | +| 1 | G1 | Skeleton: registry entry, `themeKeyword` stub, `DRAWING_FALLBACKS` keys, Clear's new tokens, Console's three palette blocks, stubs of `sparkStyle`, `drawSparkGrid`, `traceSparkline`, `fillSparkline`, `drawSparkDot` | `internal/web/assets/theme-init.js`, `internal/web/assets/style.css`, `internal/web/assets/chart.js` | AC1, AC2, AC14 | — | Dev | [ ] | +| 2 | G1 | Tests first: registry, Console palette, contrast, keyword reader, redraw on switch, `--ok-fill` gauge colour, stepped sparkline, arc and chord for both themes; adapt `checkSparklineStyle`, `checkGaugeStroke`, `isPaletteRule`, `expectedTokens`, `themeReaderRE` | `internal/web/theme_test.go`, `internal/web/palette_test.go`, `internal/web/chart_test.go`, `internal/web/gauge_test.go` | AC1, AC2, AC3, AC7, AC8, AC10, AC11, AC13, AC14 | 1 | Tester | [ ] | +| 3 | G1 | Implement `themeKeyword`, `drawSparkline` with its helpers, `drawGauge` width/caps and `gaugeColorVar` | `internal/web/assets/theme-init.js`, `internal/web/assets/chart.js`, `internal/web/assets/gauge.js` | AC3, AC7, AC8, AC10, AC14 | 2 | Dev | [ ] | +| 4 | G2 | Skeleton: no new API (`setMetricValue` is private to `app.js`) | — | AC9 | 3 | Dev | [ ] | +| 5 | G2 | Tests first: colour rule, monospace, cards, segmented bars, number/unit split, scoped rules, the §4–§14 chrome | `internal/web/palette_test.go`, `internal/web/look_test.go` | AC3, AC4, AC5, AC6, AC9, AC12, AC13, AC15 | 4 | Tester | [ ] | +| 6 | G2 | Implement `setMetricValue` and its callers, Clear's `.metric-unit` rule and Console's scoped rules | `internal/web/assets/app.js`, `internal/web/assets/style.css` | AC3, AC4, AC5, AC6, AC9, AC12, AC13, AC15 | 5 | Dev | [ ] | +| 7 | G2 | Documentation: dashboard area document (*Theme*, *Value coloring*, *Look*) and README (theme list, screenshots) | `docs/areas/dashboard.md`, `README.md` | AC1, AC3 | 6 | Dev | [ ] | +| 8 | PM | Screenshots of Console light and dark from a Pi running the branch build | `docs/dashboard-console-light.png`, `docs/dashboard-console-dark.png` | — | 6 | Product Manager | [ ] | From 1e076f5bf7932356709e8de3fdeb23ef60ffddc5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:39:27 +0000 Subject: [PATCH 07/27] Log plan security review for feature 219 --- specs/feature-219-theme-console/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index 18f2cbc3..fca3b43e 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -10,3 +10,4 @@ are quoted in full. | 2026-11-29 19:30 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 1 major, 4 minor. Major: gauge value (mono 18px) must fit inside 5px arc at all widths (extend AC8/edge case). Minor: AC13 existing tests pinning Clear drawing literals need adapting; AC14 readers only handle colour/number; openHAB restart markers vs S4; number/unit spacing (opus/medium · 93,100 tokens · 30 tool uses · 220 s · 56 in · 19,793 out · 1,464,453 cache read · 89,228 cache write · 567,557 weighted) | | 2026-11-29 19:31 | 2a Spec revise (challenge) | Lead | RESULT: DONE — all 5 objections accepted and answered in the spec's Challenge section (E11, AC8/9/13/14 amended, S4 openHAB exception) (opus/medium · 33,200 tokens · 4 tool uses · 37 s · 10 in · 4,176 out · 377,298 cache read · 13,419 cache write · 113,057 weighted · continued) | | 2026-11-29 19:38 | 2b Plan | Lead | RESULT: DONE — tier standard, security area Dashboard XSS; plan.md, tasks.md (G1, G2, PM screenshot row), decision 0043 new, 0038/0042 extended (opus/medium · 89,675 tokens · 29 tool uses · 425 s · 52 in · 43,887 out · 3,838,551 cache read · 88,804 cache write · 1,044,839 weighted · continued) | +| 2026-11-29 19:39 | 3 Plan security | Security | VERDICT: APPROVED — no findings (opus/medium · 40,578 tokens · 7 tool uses · 41 s · 12 in · 2,825 out · 132,555 cache read · 39,079 cache write · 139,227 weighted) | From 6895aab000fac997ee943917c59397265495f73c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:42:04 +0000 Subject: [PATCH 08/27] Add challenge notes to plan for feature 219 --- specs/feature-219-theme-console/log.md | 2 ++ specs/feature-219-theme-console/plan.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index fca3b43e..a8adfad6 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -11,3 +11,5 @@ are quoted in full. | 2026-11-29 19:31 | 2a Spec revise (challenge) | Lead | RESULT: DONE — all 5 objections accepted and answered in the spec's Challenge section (E11, AC8/9/13/14 amended, S4 openHAB exception) (opus/medium · 33,200 tokens · 4 tool uses · 37 s · 10 in · 4,176 out · 377,298 cache read · 13,419 cache write · 113,057 weighted · continued) | | 2026-11-29 19:38 | 2b Plan | Lead | RESULT: DONE — tier standard, security area Dashboard XSS; plan.md, tasks.md (G1, G2, PM screenshot row), decision 0043 new, 0038/0042 extended (opus/medium · 89,675 tokens · 29 tool uses · 425 s · 52 in · 43,887 out · 3,838,551 cache read · 88,804 cache write · 1,044,839 weighted · continued) | | 2026-11-29 19:39 | 3 Plan security | Security | VERDICT: APPROVED — no findings (opus/medium · 40,578 tokens · 7 tool uses · 41 s · 12 in · 2,825 out · 132,555 cache read · 39,079 cache write · 139,227 weighted) | +| 2026-11-29 19:42 | 2b Plan challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 3 minor. (1) DRAWING_FALLBACKS must drop --ok, Clear's --ok-fill hex literals; (2) AC2 test asserts --shadow as 0 0 0 transparent, name exception in test and dashboard.md; (3) test that no console-scoped rule sets font-size/bottom/line-height on .gauge-value (opus/medium · 84,954 tokens · 26 tool uses · 200 s · 50 in · 17,132 out · 1,279,167 cache read · 83,207 cache write · 507,354 weighted) | +| 2026-11-29 19:42 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | diff --git a/specs/feature-219-theme-console/plan.md b/specs/feature-219-theme-console/plan.md index c2788a77..139c63fa 100644 --- a/specs/feature-219-theme-console/plan.md +++ b/specs/feature-219-theme-console/plan.md @@ -203,3 +203,20 @@ holds: the new nodes take `textContent` only. ## Out of scope / follow-ups The elements of #221–#224; a stepped openHAB chart (spec *Out of scope*). + +## Challenge notes + +Devil's Advocate, mode plan: specs/feature-219-theme-console/plan.md (and spec.md, tasks.md) + +I found no major objection. I checked the plan's facts against the code and they hold: the registry (theme-init.js:3-5), the single string for number and unit (app.js:301, 319, 322), `repaintCanvases`, which redraws the detail chart and the openHAB chart through `renderHistory` → `redrawSparklines`/`renderDetailChart` (app.js:111-114, 1310-1333), the `box-shadow` list at style.css:210, the hex-only contrast check (palette_test.go:593-637), and the chord numbers of fact 14 (5 px arc at 72 px: inner radius 27, chord 47.1 against 42.4). The openHAB heap bar has no level class (app.js:1367), so the plan's Console `.bar-fill` → `--ok-fill` rule covers it. All three green text rules (style.css:463, 474, 695) are covered. With `--btn-tint: 0%`, the button label check reduces to `--text` on `--card-bg`, so it passes. + +Three minor objections, written as instructions: + +1. **minor: `DRAWING_FALLBACKS` must also lose `--ok`, and Clear's `--ok-fill` must be a hex literal.** Why: as planned, the existing `TestThemeInit_DrawingFallbacks_AC17` fails. + - The test requires the fallback keys to equal the properties read exactly (`slices.Equal`, internal/web/theme_test.go:719-724). + - `gaugeColorVar` (internal/web/assets/gauge.js:13) is the only place `--ok` is read. Once it returns `--ok-fill`, `--ok` is no longer read, but the plan only adds keys ("gains"). + - The same test compares each fallback with Clear's light block value (theme_test.go:727-733). Clear's three blocks must therefore write `--ok-fill` as the mode's `--ok` hex (`#16a34a` light, `#22c55e` in both dark blocks), not as `var(--ok)`. + +2. **minor: the AC2 test checks Console's `--shadow` as `0 0 0 transparent`, not §1's `none`.** Why: the plan deliberately departs from §1 (fact 10, style.css:210), but spec AC2 asks for "the values of §1 for the tokens §1 lists". A Tester who follows AC2 literally would write a test the planned CSS cannot pass. Assert `0 0 0 transparent` for `--shadow` as the rendering equivalent of `none`. Name this exception in the test's comment and in `docs/areas/dashboard.md` (*Look*). + +3. **minor: the Console value-chord check must pin that Console does not change the gauge value's box.** Why: `checkGaugeValueChord` reads only the unscoped `.gauge .gauge-value` declarations (`gaugeValueDecls`, internal/web/gauge_test.go:159-175). A Console-scoped rule that changes `font-size`, `bottom` or `line-height` would slip past the AC8/E11 check. Have `TestGaugeJS_ConsoleArc_AC8` (or the scoped-rules test) assert that no `:root[data-style="console"]` rule sets those three properties on `.gauge-value`. From 7c12c8133bc4dc456fc5bf63812c72ec763893c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:43:07 +0000 Subject: [PATCH 09/27] Skeleton for theme Console (G1) --- internal/web/assets/chart.js | 27 ++++ internal/web/assets/style.css | 172 +++++++++++++++++++++++++ internal/web/assets/theme-init.js | 17 ++- specs/feature-219-theme-console/log.md | 1 + 4 files changed, 216 insertions(+), 1 deletion(-) diff --git a/internal/web/assets/chart.js b/internal/web/assets/chart.js index 7fb1bfec..d3328ca6 100644 --- a/internal/web/assets/chart.js +++ b/internal/web/assets/chart.js @@ -1,6 +1,33 @@ // Minimal canvas sparkline renderer. Deliberately hand-rolled instead of // vendoring a charting library: the dashboard only needs a handful of // small trend lines, not zoom/pan/tooltip interactivity. +// sparkStyle reads the sparkline drawing properties of the active theme and +// returns { shape, lineWidth, fill, fillAlpha, dot, grid, cardBg, border }. +// Skeleton: not implemented. +function sparkStyle() { + return undefined; +} + +// drawSparkGrid draws the baseline and the two dashed grid lines in `color`. +// Skeleton: not implemented. +function drawSparkGrid(ctx, width, height, color) { +} + +// traceSparkline adds the path through the points xy ({ x, y }) to ctx, held +// horizontally to the next x when `stepped`. Skeleton: not implemented. +function traceSparkline(ctx, xy, stepped) { +} + +// fillSparkline fills the area under the traced line in `color` as `style` +// (see sparkStyle) says. Skeleton: not implemented. +function fillSparkline(ctx, xy, height, color, style) { +} + +// drawSparkDot draws the newest-point dot at `last` ({ x, y }) with a ring in +// `cardBg`. Skeleton: not implemented. +function drawSparkDot(ctx, last, color, cardBg) { +} + function drawSparkline(canvas, points, opts) { opts = opts || {}; const color = opts.color || themeColor('--accent'); diff --git a/internal/web/assets/style.css b/internal/web/assets/style.css index c7855fcb..d48c5b9c 100644 --- a/internal/web/assets/style.css +++ b/internal/web/assets/style.css @@ -37,6 +37,14 @@ --radius-chip: 8px; --card-padding: 8px 18px 18px; --gap: 16px; + --ok-fill: #16a34a; + --spark-line-width: 2; + --spark-shape: line; + --spark-fill: fade; + --spark-dot: ring; + --spark-grid: none; + --gauge-width: 9; + --gauge-cap: round; } /* Dark palette. Applied either by an explicit user choice @@ -81,6 +89,14 @@ --radius-chip: 8px; --card-padding: 8px 18px 18px; --gap: 16px; + --ok-fill: #22c55e; + --spark-line-width: 2; + --spark-shape: line; + --spark-fill: fade; + --spark-dot: ring; + --spark-grid: none; + --gauge-width: 9; + --gauge-cap: round; } @media (prefers-color-scheme: dark) { @@ -122,6 +138,162 @@ --radius-chip: 8px; --card-padding: 8px 18px 18px; --gap: 16px; + --ok-fill: #22c55e; + --spark-line-width: 2; + --spark-shape: line; + --spark-fill: fade; + --spark-dot: ring; + --spark-grid: none; + --gauge-width: 9; + --gauge-cap: round; + } +} + +/* Console theme (`data-style="console"`): the same three blocks as Clear. Accent, on-accent + and the ok fill are literals so the contrast checks can read them. */ +:root[data-style="console"] { + --bg: #f4f5f6; + --card-bg: #ffffff; + --text: #111418; + --muted: #5a626e; + --border: #d5d9df; + --track: #dde0e5; + --accent: #111418; + --on-accent: #ffffff; + --ok: #16a34a; + --ok-ink: #15803d; + --warn: #d97706; + --warn-ink: #92400e; + --crit: #dc2626; + --crit-ink: #b91c1c; + --shadow: 0 0 0 transparent; + --accent-system: #111418; + --accent-updates: #111418; + --accent-uptime: #111418; + --accent-cpu: #111418; + --accent-load: #111418; + --accent-temperature: #111418; + --accent-memory: #111418; + --accent-disks: #111418; + --accent-network: #111418; + --accent-openhab: #111418; + --chip-tint: 0%; + --btn-tint: 0%; + --btn-border-tint: 100%; + --spark-fill-alpha: 0.07; + --dialog-shadow: 0 0 0 transparent; + --backdrop: rgba(0, 0, 0, 0.5); + --radius-card: 6px; + --radius-control: 6px; + --radius-button: 6px; + --radius-chip: 0; + --card-padding: 0 14px 14px; + --gap: 12px; + --ok-fill: #111418; + --spark-line-width: 1.5; + --spark-shape: step; + --spark-fill: flat; + --spark-dot: none; + --spark-grid: lines; + --gauge-width: 5; + --gauge-cap: butt; +} + +:root[data-style="console"][data-theme="dark"] { + --bg: #0b0c0e; + --card-bg: #121417; + --text: #e6e8eb; + --muted: #98a0ab; + --border: #282c33; + --track: #2b2f36; + --accent: #e6e8eb; + --on-accent: #121417; + --ok: #22c55e; + --ok-ink: #4ade80; + --warn: #f59e0b; + --warn-ink: #fbbf24; + --crit: #ef4444; + --crit-ink: #f87171; + --shadow: 0 0 0 transparent; + --accent-system: #e6e8eb; + --accent-updates: #e6e8eb; + --accent-uptime: #e6e8eb; + --accent-cpu: #e6e8eb; + --accent-load: #e6e8eb; + --accent-temperature: #e6e8eb; + --accent-memory: #e6e8eb; + --accent-disks: #e6e8eb; + --accent-network: #e6e8eb; + --accent-openhab: #e6e8eb; + --chip-tint: 0%; + --btn-tint: 0%; + --btn-border-tint: 100%; + --spark-fill-alpha: 0.09; + --dialog-shadow: 0 0 0 transparent; + --backdrop: rgba(0, 0, 0, 0.5); + --radius-card: 6px; + --radius-control: 6px; + --radius-button: 6px; + --radius-chip: 0; + --card-padding: 0 14px 14px; + --gap: 12px; + --ok-fill: #e6e8eb; + --spark-line-width: 1.5; + --spark-shape: step; + --spark-fill: flat; + --spark-dot: none; + --spark-grid: lines; + --gauge-width: 5; + --gauge-cap: butt; +} + +@media (prefers-color-scheme: dark) { + :root[data-style="console"]:not([data-theme]) { + --bg: #0b0c0e; + --card-bg: #121417; + --text: #e6e8eb; + --muted: #98a0ab; + --border: #282c33; + --track: #2b2f36; + --accent: #e6e8eb; + --on-accent: #121417; + --ok: #22c55e; + --ok-ink: #4ade80; + --warn: #f59e0b; + --warn-ink: #fbbf24; + --crit: #ef4444; + --crit-ink: #f87171; + --shadow: 0 0 0 transparent; + --accent-system: #e6e8eb; + --accent-updates: #e6e8eb; + --accent-uptime: #e6e8eb; + --accent-cpu: #e6e8eb; + --accent-load: #e6e8eb; + --accent-temperature: #e6e8eb; + --accent-memory: #e6e8eb; + --accent-disks: #e6e8eb; + --accent-network: #e6e8eb; + --accent-openhab: #e6e8eb; + --chip-tint: 0%; + --btn-tint: 0%; + --btn-border-tint: 100%; + --spark-fill-alpha: 0.09; + --dialog-shadow: 0 0 0 transparent; + --backdrop: rgba(0, 0, 0, 0.5); + --radius-card: 6px; + --radius-control: 6px; + --radius-button: 6px; + --radius-chip: 0; + --card-padding: 0 14px 14px; + --gap: 12px; + --ok-fill: #e6e8eb; + --spark-line-width: 1.5; + --spark-shape: step; + --spark-fill: flat; + --spark-dot: none; + --spark-grid: lines; + --gauge-width: 5; + --gauge-cap: butt; } } diff --git a/internal/web/assets/theme-init.js b/internal/web/assets/theme-init.js index cd69f0a0..28a153d3 100644 --- a/internal/web/assets/theme-init.js +++ b/internal/web/assets/theme-init.js @@ -2,6 +2,7 @@ // (Clear). A theme's id is its `data-style` value and the stored choice. const PIMONITOR_THEMES = Object.freeze([ Object.freeze({ id: 'clear', name: 'Clear' }), + Object.freeze({ id: 'console', name: 'Console' }), ]); // Clear's light values of the custom properties the canvas renderers read. @@ -10,10 +11,18 @@ const DRAWING_FALLBACKS = Object.freeze({ '--muted': '#5f6876', '--card-bg': '#ffffff', '--track': '#e8eaef', - '--ok': '#16a34a', '--warn': '#d97706', '--crit': '#dc2626', '--spark-fill-alpha': '0.28', + '--border': '#e4e7ec', + '--ok-fill': '#16a34a', + '--spark-line-width': '2', + '--spark-shape': 'line', + '--spark-fill': 'fade', + '--spark-dot': 'ring', + '--spark-grid': 'none', + '--gauge-width': '9', + '--gauge-cap': 'round', }); // themeValue returns the trimmed computed value of the custom property `name`. @@ -37,6 +46,12 @@ function themeNumber(name, min, max) { return v !== '' && Number.isFinite(n) && n >= min && n <= max ? n : Number(DRAWING_FALLBACKS[name]); } +// themeKeyword returns the trimmed computed value of the custom property +// `name` when `allowed` holds it, else Clear's value. Skeleton: not implemented. +function themeKeyword(name, allowed) { + return undefined; +} + // Apply a previously chosen theme before the first paint to avoid a flash // of the wrong palette. With no stored choice we leave `data-theme` unset // so the CSS `prefers-color-scheme` default takes over. diff --git a/specs/feature-219-theme-console/log.md b/specs/feature-219-theme-console/log.md index a8adfad6..fbaab9b6 100644 --- a/specs/feature-219-theme-console/log.md +++ b/specs/feature-219-theme-console/log.md @@ -13,3 +13,4 @@ are quoted in full. | 2026-11-29 19:39 | 3 Plan security | Security | VERDICT: APPROVED — no findings (opus/medium · 40,578 tokens · 7 tool uses · 41 s · 12 in · 2,825 out · 132,555 cache read · 39,079 cache write · 139,227 weighted) | | 2026-11-29 19:42 | 2b Plan challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 3 minor. (1) DRAWING_FALLBACKS must drop --ok, Clear's --ok-fill hex literals; (2) AC2 test asserts --shadow as 0 0 0 transparent, name exception in test and dashboard.md; (3) test that no console-scoped rule sets font-size/bottom/line-height on .gauge-value (opus/medium · 84,954 tokens · 26 tool uses · 200 s · 50 in · 17,132 out · 1,279,167 cache read · 83,207 cache write · 507,354 weighted) | | 2026-11-29 19:42 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | +| 2026-11-29 19:43 | 4 Skeleton (G1) | Dev | RESULT: DONE — registry, Console palettes, Clear tokens, stubs (zero-value JS stubs deviation); 2 existing tests red as planned (sonnet/medium · 107,892 tokens · 12 tool uses · 51 s · 22 in · 5,988 out · 933,697 cache read · 106,531 cache write · 256,495 weighted) | From aa11ef25bef1aa391d5652db92c611c5db23ad9d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 19:47:09 +0000 Subject: [PATCH 10/27] Tests first for theme Console (G1) --- internal/web/chart_test.go | 164 ++++++++++++++++++-- internal/web/gauge_test.go | 113 +++++++++++--- internal/web/palette_test.go | 35 ++++- internal/web/theme_test.go | 200 ++++++++++++++++++++++++- specs/feature-219-theme-console/log.md | 1 + 5 files changed, 474 insertions(+), 39 deletions(-) diff --git a/internal/web/chart_test.go b/internal/web/chart_test.go index f34de391..c17fa0aa 100644 --- a/internal/web/chart_test.go +++ b/internal/web/chart_test.go @@ -13,11 +13,12 @@ import ( // least this much. const sparkDotReach = 4 + 3 -// TestChartJS_Sparkline_AC7 guards the sparkline style of feature 217: a 2 px -// round-joined accent line, a fill fading to transparent built without string -// concatenation on the colour, a dot with a card-coloured ring at the newest -// point, nothing drawn below two points, and a plot inset that keeps the dot -// inside the canvas. +// TestChartJS_Sparkline_AC7 guards the sparkline style of feature 217 as the +// feature 219 declares it: Clear's 2 px round-joined accent line (the width +// through the --spark-line-width token), a fill fading to transparent built +// without string concatenation on the colour, a dot with a card-coloured ring +// at the newest point, nothing drawn below two points, and a plot inset that +// keeps the dot inside the canvas. func TestChartJS_Sparkline_AC7(t *testing.T) { js := readAsset(t, "chart.js") body := jsFunctionBody(js, "function drawSparkline(") @@ -26,7 +27,7 @@ func TestChartJS_Sparkline_AC7(t *testing.T) { } t.Run("AC7 line, gradient fade and dot", func(t *testing.T) { - checkSparklineStyle(t, body) + checkSparklineStyle(t, js, body) }) t.Run("AC7 fewer than two points draw nothing", func(t *testing.T) { @@ -38,20 +39,62 @@ func TestChartJS_Sparkline_AC7(t *testing.T) { }) } -// checkSparklineStyle checks the line, the gradient fade and the dot of drawSparkline. -func checkSparklineStyle(t *testing.T, body string) { +// checkSparklineStyle checks the line, the gradient fade and the dot of the +// sparkline: drawSparkline takes its style from sparkStyle and draws grid, +// fill, line and dot in that order; Clear's values are asserted from its block. +func checkSparklineStyle(t *testing.T, js, body string) { t.Helper() checkAssetParts(t, []assetCheck{ {"drawSparkline", body, []string{ - "ctx.lineWidth = 2;", "ctx.lineJoin = 'round'", "createLinearGradient(", - "destination-out", "source-over", "--spark-fill-alpha", "--card-bg", "arc(", + "sparkStyle(", "drawSparkGrid(", "fillSparkline(", "traceSparkline(", "drawSparkDot(", + "ctx.lineJoin = 'round'", "ctx.stroke()", "themeColor('--accent')", + }}, + {"fillSparkline (fade)", jsFunctionBody(js, "function fillSparkline("), []string{ + "createLinearGradient(", "destination-out", "source-over", "globalAlpha", + }}, + {"drawSparkDot (ring)", jsFunctionBody(js, "function drawSparkDot("), []string{"arc(", "cardBg"}}, + {"sparkStyle", jsFunctionBody(js, "function sparkStyle("), []string{ + "themeNumber('--spark-line-width'", "themeNumber('--spark-fill-alpha'", "themeColor('--card-bg')", }}, }) checkAssetPartsAbsent(t, []assetCheck{ - {"drawSparkline (fill works for any CSS colour)", body, []string{"color + '", "lineWidth = 1.5"}}, + {"drawSparkline (width through the token, fill works for any CSS colour)", body, []string{"color + '", "ctx.lineWidth = 2;", "lineWidth = 1.5"}}, }) - if n := strings.Count(body, "arc("); n < 2 { - t.Errorf("chart.js drawSparkline: %d arc( calls, want at least 2 (ring and dot)", n) + if !regexp.MustCompile(`ctx\.lineWidth\s*=\s*\w+\.lineWidth\s*;`).MatchString(body) { + t.Error("chart.js drawSparkline: expected ctx.lineWidth =