Skip to content

color-themes: check.mjs --skin measures a text tier the skin leaves unset with the stock value, as the GUI does - #19

Open
connorburgess wants to merge 1 commit into
spacesheep-dev:mainfrom
connorburgess:fix/check-skin-stock-text-tiers
Open

connorburgess wants to merge 1 commit into
spacesheep-dev:mainfrom
connorburgess:fix/check-skin-stock-text-tiers

Conversation

@connorburgess

Copy link
Copy Markdown
Contributor

What

@sessionpipe-gui/color-themes: scripts/check.mjs --skin now measures a text tier the skin leaves unset with its stock value, the way the GUI's skin listing does, so a skin the GUI marks "low contrast" no longer passes here.

In --skin mode, for the pairs the GUI checks (--fg, --fg-2, --fg-3 and --fg-4 on --bg and --bg-2), the checker now fills a side the skin leaves unset with the stock value from STOCK_TEXT_TOKENS in packages/shared-types/contrast.ts, when the skin sets the other side. That side is marked (stock) in the output. A token set must set --bg and --fg, so in practice the filled side is --fg-2, --fg-3, --fg-4 or --bg-2. If the skin sets neither side of a pair, the pair is the stock scheme's own and is skipped, as in the GUI.

Colour-theme mode (no --skin) is unchanged. It does not read the stock values, and the GUI shows no such warning for colour themes.

Why

The GUI's skin listing (server/skins/registry.ts contrastWarning → shared/contrast.ts textTierWarnings) draws a skin over the stock scheme. It fills each unset text tier or ground with the stock value and warns when the pair falls under the tier's floor. check.mjs skipped every pair with an unset side ("A token the theme does not set is nothing to measure"). So a skin author who ran the checker got "all good" and then saw "low contrast" in the GUI. This follows #13 ("never skips a pair silently").

Floors. A stock-filled pair is held to the GUI's floor for that tier, read from TEXT_TIERS in the same contrast.ts: --fg 7, --fg-2 5, --fg-3 4.5, --fg-4 3. With those floors the checker fails exactly the stock-filled pairs the GUI warns about. If it used its own stricter floors from tokens.css (--fg-2 7, --fg-3 5 on --bg and --bg-2), a tier the author never set would fail here while the GUI shows nothing. A pair where the skin sets both sides keeps this script's own floors, as before.

Not covered. The GUI at its current main also checks --focus on --bg and --bg-2 against a stock --focus. The shared-types mirror here predates that and has no --focus in STOCK_TEXT_TOKENS, so --focus is not filled yet. Once the mirror is refreshed, the checker picks it up from the same block (--focus on --bg and --bg-2 keeps its floor of 3, the same as the GUI's). Updating the mirror is a separate change.

Proof

The probe is a dark skin that sets only --bg and --bg-2 (#454545) and --fg (#ffffff):

{"id":"probe-skin","name":"Probe","version":"1.0.0","scheme":"dark","tokens":{"--bg":"#454545","--bg-2":"#454545","--fg":"#ffffff"}}

On main (d92e06a):

$ node scripts/check.mjs --skin probe-skin.json
probe-skin (dark)  (Probe, dark)  3/49 tokens, missing --bg-3 --bg-4 … --label-grey
  ok   --fg               on --bg                 9.59  (≥ 7)
  ok   --fg               on --bg-2               9.59  (≥ 7)

all good
exit 0

On this branch:

$ node scripts/check.mjs --skin probe-skin.json
probe-skin (dark)  (Probe, dark)  3/49 tokens, missing --bg-3 --bg-4 … --label-grey
  ok   --fg               on --bg                 9.59  (≥ 7)
  ok   --fg               on --bg-2               9.59  (≥ 7)
  ok   --fg-2 (stock)     on --bg                 5.48  (≥ 5)
  ok   --fg-2 (stock)     on --bg-2               5.48  (≥ 5)
  LOW  --fg-3 (stock)     on --bg                 3.40  (≥ 4.5)
  LOW  --fg-3 (stock)     on --bg-2               3.40  (≥ 4.5)
  LOW  --fg-4 (stock)     on --bg                 1.87  (≥ 3)
  LOW  --fg-4 (stock)     on --bg-2               1.87  (≥ 3)

FAILED
exit 1

The GUI's textTierWarnings gives four warnings for the same tokens: --fg-3 on --bg 3.4:1 (needs 4.5), --fg-4 on --bg 1.9:1 (needs 3), and the same two on --bg-2. Those are the four LOW lines above.

A second probe is a dark skin that sets all four text tiers but leaves --bg-2 unset. Its --fg-2 on stock --bg-2 is 6.37 and its --fg-3 is 4.94, both over the GUI's floors and both under this script's own floors. The GUI gives no warning, and the checker passes it on main and on this branch alike ("all good").

The bundled skins and themes pass with exit 0 on main and on this branch: npm test in skin-paper-serif, skin-spacesheep and skin-spacesheep-vivid (each runs check.mjs --skin skin.json), and in color-themes (the four colour themes, no --skin).

Repo checks on this branch:

  • npm run typecheck: exit 0.
  • npm run lint: "Checked 91 files … No fixes applied", exit 0. It reports 3 warnings, the same 3 as on main; none is in check.mjs.
  • npm run build: exit 0.
  • npm test: every workspace passes except packages/canvas. All 43 of its Playwright tests fail before running, with browserType.launch: Executable doesn't exist (no Chromium installed on the machine that ran this). This change does not touch canvas.

There is no unit-test harness for check.mjs; #12 and #13 were proved the same way. The probe is not committed as a fixture, because every JSON file in the package folder is read as a colour theme.

Checklist

  • Every commit is signed off (git commit -s): the DCO is the only paperwork.
  • npm run typecheck && npm run lint && npm run build && npm test pass, except the canvas Playwright tests on a machine without the browser (above).
  • New source files start with // SPDX-License-Identifier: Apache-2.0. No new files.
  • No token, real address, hostname or home path in code, fixtures or screenshots.
  • A line under Unreleased in CHANGELOG.md if a person would notice: under Fixed.

…nset with the stock value, as the GUI does

The GUI's skin listing (textTierWarnings in shared/contrast.ts) fills a
text tier or ground a skin leaves unset with the stock scheme's value
and warns when that pair falls under the GUI's floor for the tier.
check.mjs skipped every pair with an unset side, so a dark skin with
only --bg/--bg-2 #454545 and --fg #fff passed here while the GUI flagged
--fg-3 and --fg-4 as low contrast.

In --skin mode, a pair of --fg..--fg-4 and --bg/--bg-2 with one side
set is now measured with the other side's stock value from
STOCK_TEXT_TOKENS in shared-types/contrast.ts, against that file's
TEXT_TIERS floor, and the filled side is marked "(stock)". Since a
token set must set --bg and --fg, the filled side is --fg-2, --fg-3,
--fg-4 or --bg-2. Pairs with both sides set keep this script's floors;
colour-theme mode does not read the stock values and is unchanged.

Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
@graphide-review

Copy link
Copy Markdown

Open in GraphideGraphide review

TL;DR

  • Nothing changes for people using the product. This only affects a developer checking tool for skin authors.
  • The tool now flags a low-contrast skin the same way the app's skin listing does. Before, a skin could pass the check and then show a "low contrast" warning in the app.
  • The review found no problems and rated its confidence at the top of its scale.
  • Safe to ship.

Merge  nothing found that needs a look first

Before this change, check.mjs skipped any pair with an unset side. A skin that set only --bg, --bg-2 and --fg therefore passed here, while the GUI's textTierWarnings filled the missing tiers with stock values and marked the skin "low contrast". In --skin mode the script now reads STOCK_TEXT_TOKENS and TEXT_TIERS from the shared-types contrast.ts mirror. When a pair (--fg…--fg-4 on --bg/--bg-2) has exactly one side set by the skin, the script fills the other side with the stock value, labels it (stock) and holds the pair to the GUI's tier floor. A pair the skin sets both sides of keeps the script's own floors. A pair it sets neither side of is still skipped. Colour-theme mode is unchanged. The change also adds a CHANGELOG entry under Unreleased/Fixed.

No findings sure enough to post from reading the change.

Merge confidence 5 of 5

Where to read first
  1. packages/color-themes/scripts/check.mjs:28 - readStock parses STOCK_TEXT_TOKENS and TEXT_TIERS out of the mirror's contrast.ts with regexes and throws if a needed entry is missing
  2. packages/shared-types/contrast.ts:57 - the source being parsed: TEXT_TIERS floors, STOCK_TEXT_TOKENS, and textTierWarnings, which the script now mirrors
  3. packages/color-themes/scripts/check.mjs:168 - readStock runs only when --skin is given; otherwise the stock table is empty, so nothing is filled
  4. packages/color-themes/scripts/check.mjs:239 - the pair loop: the fill condition (both tokens in stock, exactly one set by the skin), the stock-labelled pick, and the floor choice
  5. CHANGELOG.md:17 - the user-facing note under Unreleased/Fixed
Tests and reach

Reach: no graph yet, so this review could not trace what the change reaches.

Stages: 169 s
Stage State Seconds
diff done 0.0
reach skipped 100.4
risks skipped 0.0
ci skipped 0.0
find done 68.6
agent skipped 0.0
slop skipped 0.0
scenarios skipped 0.0
verify skipped 0.0
prove skipped 0.0
score done 0.0

Reviewed 22eb3f2 in 169 s · graph check: no graph yet, so this review ran without it · Full report · For agents: gr review findings spacesheep-dev/sessionpipe-gui-themes 19

@connorburgess

Copy link
Copy Markdown
Contributor Author

#20 refreshes packages/shared-types to GUI 0.8.15, including the contrast.ts this pull request's check.mjs reads (it adds a stock --focus to STOCK_TEXT_TOKENS and a MARKS list). Both also add a line to CHANGELOG.md. #20 merges cleanly into this branch's head (22eb3f2), and with both applied check.mjs and --skin on the three bundled skins give the same output as this branch alone.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant