ui: route genuine success and failure through the roles

Sixteen call sites, chosen by reading each one rather than by grepping for a
hue.  Four sub-agents judged them independently against one rule: convert only
what genuinely means success or failure; identification, category and
decoration stay hue-named.

Converted:
  SMART drive health (all four branches -- PASS/WARN/FAIL/unknown)
  config validity: valid / invalid / empty
  "Failed to load preview"
  the two "Download error" triggers
  expired inventory items, desktop and mobile
  the refresh phases: complete / active / not reached
  a refresh Progress bar in its error state
  cookie status: Unlocked / Locked
  a chip-mismatch label on the flasher
  CPU load thresholds (LoadStatistic)
  the outcome of an API call in useAPIButton
  the gallery's "Danger zone" heading and its load readings

Left alone, deliberately:
  the file browser toolbar -- every action has its own colour to be told apart,
    and delete already uses role='danger' (Roland's ruling)
  diff add/remove in the config and inventory import previews.  Adding is not a
    success and removing is not a failure; in Overwrite mode the removals are
    exactly what the user asked for, and painting them danger would report their
    intended action as broken
  seasons in DatesSelector, the uploader star and favourite heart, TagIcon,
  downloader category buttons, "Recommended to Keep"

Three sites were wrong in a way worth naming.  Both "Download error" triggers
guard on the same condition and render the same modal, but one was `orange` and
the other `red` -- and `orange` is the single worst choice, byte-identical to
`--text` in night, so that error button was indistinguishable from an ordinary
control.  Config validity drew its valid state in `--violet`, which no user
parses as "valid".  And `LoadStatistic` -- the thing users actually watch on the
Status page -- rendered its warning threshold in that same invisible orange.

Also fixed a stale comment in Videos.js that claimed no token existed for these.

Two notes on the tests:

The first LoadStatistic test I wrote rendered the component and asserted the
inline colour.  jsdom REJECTS `color: var(--danger)` as an invalid declaration
and drops it, so every colour reads back as the empty string -- two of the four
assertions passed for that reason alone and would have kept passing with the
hues restored.  It is a source guard now, with the painted result asserted in
the browser instead.

That browser test then found something real: an uncoloured reading inherits
`--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine
under load is marginally QUIETER than one that is fine.  Not fixed here.  The
only way up on a dark panel is lightness, and night's danger would desaturate
from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for
loudness.  That is a palette decision, so the test documents it and asserts what
does hold rather than quietly making it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-01 18:08:34 -06:00
parent b7ef6af8bd
commit 7a6b09aee6
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
12 changed files with 133 additions and 25 deletions

View file

@ -606,12 +606,16 @@ function ServicesSection() {
// Helper to get health status color from SMART assessment
const getHealthColor = (assessment) => {
if (!assessment) return 'var(--muted)';
// Roles, not hues: a drive's assessment is a severity and has to rank as one. All
// four branches together -- a helper where PASS and FAIL rank but WARN is an
// unranked hue is worse than either choice, and in night `--amber` is byte-identical
// to `--yellow` so WARN would stop sitting between them.
if (!assessment) return 'var(--neutral)';
const upper = assessment.toUpperCase();
if (upper === 'PASS') return 'var(--green)';
if (upper === 'WARN') return 'var(--amber)';
if (upper === 'FAIL') return 'var(--red)';
return 'var(--muted)';
if (upper === 'PASS') return 'var(--success)';
if (upper === 'WARN') return 'var(--warning)';
if (upper === 'FAIL') return 'var(--danger)';
return 'var(--neutral)';
};
// Helper to format power-on hours
@ -829,7 +833,9 @@ function MountModal({disk, open, onClose, onMount}) {
<p>
Found <strong>{entries}</strong> ({formatBytes(shadowed.size_bytes)}) at the mount target.
</p>
<p style={{color: 'var(--red)'}}>
{/* A caution about a consequence, not a failure -- the destructive
weight is already carried by the confirm button below. */}
<p style={{color: 'var(--warning)'}}>
Those files will continue to consume space on the underlying filesystem
(typically the SD card on a Raspberry Pi) and can fill it up.
</p>