Skip to content

Add --primary-hover / --destructive-hover and unify filled-button hovers (closes #2673) - #2685

Merged
malibio merged 3 commits into
mainfrom
issue-2673-hover-tokens
Sep 17, 2026
Merged

malibio merged 3 commits into
mainfrom
issue-2673-hover-tokens

Conversation

@malibio

@malibio malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #2673.

The gap

DESIGN.md's hover rule — "derive hover states from --hover-background / --hover-foreground" — works for neutral and ghost surfaces but had no answer for filled semantic buttons. --hover-background resolves to --muted, so applying it literally to a filled destructive button turns it grey and destroys the semantic the button exists to communicate.

With no token to reach for, four sibling files each invented their own idiom — and two of them moved in opposite directions:

File Was Now
delete-confirmation-modal.svelte hsl(var(--destructive) / 0.85) hsl(var(--destructive-hover))
pro-relogin-modal.svelte hsl(var(--primary) / 0.85) hsl(var(--primary-hover))
update-banner.svelte filter: brightness(1.08) hsl(var(--primary-hover))
first-pro-consent-modal.svelte filter: brightness(0.92) hsl(var(--destructive-hover))

Zero filter: brightness() and zero alpha-based hovers remain among them.

The rule

Hover moves 6 points of HSL lightness away from the surface — darker in light mode, lighter in dark. This is now stated in app.css and DESIGN.md rather than being emergent.

The consequence that makes it the right direction: contrast against the button's own foreground rises on hover in both themes, so hovering can never make a label harder to read.

Token Theme Base → hover Contrast vs its foreground
--primary light 35% → 29% 3.51 → 4.86:1
--destructive light 46% → 40% 5.36 → 6.66:1
--primary dark 41% → 47% 4.47 → 5.79:1
--destructive dark 70% → 76% 6.95 → 8.45:1

All four clear WCAG AA. Note light-mode --primary at rest is 3.51:1 against --primary-foreground — fine for a button per #2668's reasoning (UI component, not body text), and hover improves it rather than eroding it.

Why a token and not a convention

The alpha form is the concrete argument. hsl(var(--x) / 0.85) is translucent, so it composites against the surface behind it — which inverted the hover direction between themes:

Theme Base Hover Direction
light 78.2 104.7 lightened
dark 134.5 118.0 darkened

Nobody chose that; it fell out of the technique. The new values are opaque, which also fixes the latent bug the issue flagged — a translucent button lets whatever sits behind it show through, invisible on today's opaque modal panels but a surprise waiting for the first such button over non-uniform content.

Scope: no --success-hover / --warning-hover

The issue asked whether a general law should cover every filled semantic color. It should — and DESIGN.md now states it — but neither token is used as a filled button anywhere. The only solid --success is the code-block "copied" state, which has no hover. Defining hover tokens for them today would be unused code, which this repo's greenfield rules forbid. Documenting the rule means adding one later is an application of it, not a fresh invention.

Considered and rejected: a constant perceptual step

Equal CIE L* movement is the more principled law, but HSL lightness is not perceptually uniform, so holding L* constant needs per-token deltas of 4–13pp — the values stop being derivable by eye and every future token needs a script to compute. A flat 6pp HSL move lands between 2.6 and 9.8 L*: uneven, but visible everywhere, and consistent with both the ~3–6% tonal steps DESIGN.md already uses for surface hierarchy and the 5.5pp delta of the hardcoded #c0392b → #a93226 pair this ultimately replaces.

Docs

DESIGN.md (in nodespace-docs, pushed separately as 3d48f90) splits the hover rule by button kind, documents the derivation, and adds a Don't covering both replaced idioms as theme-blind.

Verification

  • bun run test — 247 files / 5085 tests passed, identical to the pre-change baseline
  • bun run quality:fix — clean; design-token baseline unchanged at 137 entries (did not grow)
  • Pre-push gate (full pyramid incl. Rust + e2e) — passed
  • Contrast figures above computed from the token values via WCAG relative luminance

🤖 Generated with Claude Code

…ers (closes #2673)

Filled semantic buttons had no hover token to reach for, so four sibling files
had each invented their own idiom — two of them moving in opposite directions:

  delete-confirmation-modal   hsl(var(--destructive) / 0.85)   alpha
  pro-relogin-modal           hsl(var(--primary) / 0.85)       alpha
  update-banner               filter: brightness(1.08)         lightens
  first-pro-consent-modal     filter: brightness(0.92)         darkens

All four now use --primary-hover / --destructive-hover, defined per-theme.

The rule, now documented rather than emergent: hover moves 6 points of HSL
lightness AWAY from the surface — darker in light mode, lighter in dark. That
makes contrast against the button's own foreground RISE on hover in both themes
(4.86-8.45:1, up from 3.51-6.95:1 at rest), so hovering can never make a label
harder to read. Every pairing clears WCAG AA.

The alpha form is what made this worth a token rather than a convention. It is
translucent, so it composites against the surface behind it and inverted the
hover direction between themes: the destructive button lightened in light mode
(luminance 78.2 -> 104.7) and darkened in dark (134.5 -> 118.0). Nobody chose
that; it fell out of the technique. The new values are opaque, which also fixes
the latent bug that a translucent button lets background content show through.

Scope: no --success-hover / --warning-hover. Neither token is used as a filled
button anywhere — the only solid --success is the code-block "copied" state,
which has no hover — so they would be unused code. DESIGN.md records the rule
so adding one later is an application of it, not a fresh invention.

Considered and rejected: a constant perceptual step (equal CIE L*) instead of a
constant HSL delta. It is the more principled law, but because HSL lightness is
not perceptually uniform it needs per-token deltas of 4-13pp to hold — the
values stop being derivable by eye and every future token needs a script. A flat
6pp HSL move lands between 2.6 and 9.8 L*, which is uneven but visible
everywhere, and matches both the ~3-6% tonal steps DESIGN.md already uses for
surface hierarchy and the 5.5pp of the hardcoded pair this ultimately replaces.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2685

Review Type: Initial Review
Scope: 5 files, +28/−4, plus DESIGN.md in nodespace-docs (3d48f90)
Verdict: ✅ APPROVE — correct, verified, well-reasoned, clearly net-positive. Two follow-ups worth filing; both are pre-existing scope, not defects introduced here.


Summary

This is a genuinely good change. It replaces three competing ad-hoc hover idioms across four sibling files with two tokens and — more valuably — a stated law ("move 6 points of HSL lightness away from the surface") that makes future hover values derivable rather than invented.

The commit message and PR body do something worth calling out: they document the rejected alternative (a constant perceptual CIE L* step) with the concrete reason it loses — per-token deltas of 4–13pp, values no longer derivable by eye, a script needed for every future token. That is the kind of reasoning that stops a future contributor from re-litigating a settled decision.

I independently recomputed every number in the diff and PR body from the HSL token values via WCAG relative luminance. All eight figures are exactly right.


Verification of the stated claims

Contrast figures — all four verified exact:

Token Theme Rest Hover Claimed ✅
--primary light 3.51:1 4.86:1 4.86 ✅
--destructive light 5.36:1 6.66:1 6.66 ✅
--primary dark 4.47:1 5.79:1 5.79 ✅
--destructive dark 6.95:1 8.45:1 8.45 ✅

The "contrast RISES on hover in all four cases" claim holds, and the stated range "4.86–8.45:1, up from 3.51–6.95:1" is accurate to the digit. All four clear AA (≥4.5:1) at rest and hover — note light-mode --primary at rest is 3.51:1 and hover repairs it to 4.86:1, so the rule actively improves the weakest pairing rather than eroding it.

6pp HSL delta — verified for all four (light primary 35→29, light destructive 46→40, dark primary 41→47, dark destructive 70→76), direction "away from the surface" in both themes as claimed.

The L* honesty check: the PR claims the flat 6pp move "lands between 2.6 and 9.8 L*". For these four tokens I measure ΔL* of 9.10 / 5.93 / 7.90 / 6.08 — inside the stated envelope. The PR does not oversell the uniformity it is buying, which is the right way to document a deliberately imperfect heuristic.

Alpha-inversion claim — verified. Light-mode destructive under hsl(var(--destructive) / 0.85) over a white popover composites to luminance 47.6/255 from a base of 37.2/255 — it lightened, confirming the direction genuinely flipped between themes. The motivating bug was real, not theoretical.


Requirements Check (7 acceptance criteria)

# Criterion Status Notes
1 --destructive-hover / --primary-hover in both :root and .dark ✅ app.css:23, 82 (:root); :161, 200 (.dark)
2 All four call sites migrated; zero filter: brightness(), zero alpha hovers among them ✅ Verified. I also grepped the whole frontend: zero filter: brightness( remains anywhere in packages/desktop-app/src — the migration is repo-complete for that idiom, not just complete for the four listed files
3 Hover direction consistent across themes and documented in DESIGN.md ✅ DESIGN.md:287; mirrored in app.css:68-71 and :195-196
4 DESIGN.md L336 hover rule amended to cover filled semantic buttons ✅ Both sites that stated it were amended — Button section (:282-289) and the Do's bullet (:345) — plus a new Don't (:357). More thorough than the criterion asked for
5 Buttons fully opaque at rest and on hover ✅ All four opaque in both states. See note below on the remaining alpha/opacity usages
6 Hover states meet WCAG AA against their foreground in both themes ✅ 4.86 / 6.66 / 5.79 / 8.45 — independently recomputed
7 quality:fix clean; design-token baseline does not grow ✅ The baseline (packages/desktop-app/design-tokens-baseline.json, 137 entries) is a two-way ratchet keyed on {file, rule, text}. src/app.css is exempt from the raw-color rules, and swapping a token name inside an already-compliant hsl(var(--x)) was never a violation — so this change is structurally incapable of moving the count. No --update re-record needed. Consistent with the PR's reported result

On criterion 5 specifically — I checked the remaining alpha/opacity usages in the touched files and agree both categories are legitimately out of scope:

  • :disabled { opacity: 0.6 / 0.7 } (update-banner.svelte:85, first-pro-consent-modal.svelte:169, pro-relogin-modal.svelte:131) — this is the disabled state, not rest or hover; the criterion says "at rest and on hover". Dimming a disabled control is the conventional affordance.
  • hsl(var(--muted) / 0.7) on .btn-secondary:hover (first-pro-consent-modal.svelte:178, pro-relogin-modal.svelte:149) — a neutral button, which DESIGN.md explicitly routes to --hover-background, not to a --*-hover token. Out of scope for a filled-semantic-button rule. (Minor: these two would ideally use hsl(var(--hover-background)) like delete-confirmation-modal.svelte:97 already does — but not this PR's job.)

Code Review Findings

🔴 Critical

None.

🟡 Important

📁 packages/desktop-app/src/lib/components/ui/button/types.ts:12-14 — the canonical shadcn Button still uses the idiom this PR just declared a "Don't", and it measurably loses contrast on hover.

This is the finding I most want on the record. The PR migrates four hand-rolled .svelte buttons, but the app's shared Button component — the one DESIGN.md's "Button" section actually describes — was not touched and still reads:

default:     'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
destructive: 'bg-destructive shadow-xs hover:bg-destructive/90 dark:bg-destructive/60 text-white',

Those are alpha fills — exactly what DESIGN.md:357 now forbids ("Don't build a hover state out of filter: brightness() or an alpha fill"). Not hypothetical dead code: variant="destructive" renders at settings/sections/database-settings.svelte:226, and the default (primary) variant is used across ~18 files (identity-card.svelte:135, integrations-settings.svelte:185, import-options-modal.svelte:244, …).

I computed what those alpha hovers actually do. All four cases move the wrong way — contrast falls on hover, the precise failure mode this PR's law exists to prevent:

Variant Theme Rest Hover Direction
destructive dark 5.92:1 3.39:1 ↓ fails AA on hover
destructive light 5.36:1 4.76:1 ↓
default light 3.51:1 3.05:1 ↓
default dark 4.47:1 3.81:1 ↓

The dark-mode destructive case is the notable one: dark:bg-destructive/60 → hover:bg-destructive/90 composites toward the dark surface, dropping from a comfortable 5.92:1 to 3.39:1, under the 4.5:1 AA threshold. A user hovering "Remove database" in dark mode gets a less readable label at the moment of commitment.

Why I am not blocking: it is pre-existing, outside the issue's stated four call sites, and the issue was explicitly scoped to those four. Widening a clean +28/−4 token PR into a shadcn-variant refactor is exactly the scope creep the Pragmatic Quality framework says not to force. The change in front of me is unambiguously net-positive without it.

But the PR body claims "Zero filter: brightness() and zero alpha-based hovers remain among them" — true for those four, and honestly worded — while DESIGN.md now states the Don't as a global rule. That gap between documented law and shipped reality should be closed deliberately rather than discovered by the next contributor.

Recommendation: file a follow-up to migrate buttonVariants to the new tokens and drop the dark:bg-destructive/60 alpha base. Complexity: small — one file, four string edits, plus deciding whether the destructive variant's text-white should become --destructive-foreground (a second inconsistency worth resolving in the same pass, since dark-mode --destructive-foreground is near-black by design).

Principle: DRY / single source of truth. A design law stated in DESIGN.md but contradicted by the most-used component in the system erodes the law's authority — the next author reasonably copies the shared component, not the doc.


📁 Eight sites — opacity: 0.9 hover on solid hsl(var(--primary)) buttons: a third un-migrated variant of the same trick.

The issue enumerated three idioms; there is a fourth the issue did not catalogue. These are genuine filled primary buttons whose hover is a whole-element opacity fade:

  • settings/model-manager.svelte:747 — .btn--primary:hover:not(:disabled) { opacity: 0.9; } (fill at :743)
  • chat/chat-input.svelte:131 — .send-button:not(:disabled):hover (fill at :119)
  • viewers/collection-node-viewer.svelte:593 — .retry-button:hover (fill at :585)
  • viewers/query-node-viewer.svelte:815 — .retry-button:hover (fill at :807)
  • viewers/query-node-viewer.svelte:854 — .new-instance-button:hover:not(:disabled) (fill at :845)
  • viewers/ai-chat-pty-session.svelte:692 — .launch-button:hover:not(:disabled) (fill at :684)
  • query/query-editor.svelte:408 — .btn-save:hover (fill at :400)
  • onboarding/onboarding-wizard.svelte:831 — .primary-button:hover:not(:disabled) (fill at :823)

These are less harmful than the alpha-background form: opacity fades the element including its text, so the fill/foreground contrast ratio is roughly preserved rather than collapsing. But it is still theme-blind in the same way — the button washes toward whatever surface is behind it, so the hover lightens in light mode and darkens in dark, which is the inverted-direction problem the PR set out to eliminate. It also fades the button's border and any focus ring.

Same reasoning as above: out of the issue's stated scope, correctly not absorbed into this PR, worth filing. Complexity: small-to-medium — eight one-line changes, but each needs a glance to confirm the base fill is --primary and that nothing depends on the element-wide fade.

Principle: consistency. The PR's value is that there is now one answer; leaving a fourth idiom in eight files means the "one answer" is still competing with something.

🟢 Suggestions

📁 packages/desktop-app/src/app.css:23 — the --*-hover documentation is ~40 lines away from --primary-hover.

The shared rule for all --*-hover tokens lives in the comment above --destructive (lines 62-78), but --primary-hover is declared at line 23, well above it, carrying only a bare /* 4.86:1 under --primary-foreground */. Someone reading top-down hits --primary-hover with no explanation of the 6pp law and no pointer to where it is explained; someone editing --primary is not looking at line 62.

Nit: add a breadcrumb at line 23 — e.g. /* 4.86:1 under --primary-foreground; see the --*-hover rule below */. Cheap, and keeps the single authoritative explanation in one place rather than duplicating it.

Principle: locality of reference — documentation should be discoverable from the thing it documents.

📁 packages/desktop-app/src/app.css:77-78 — the "only define a --*-hover for a token actually used as a filled button" premise can go stale silently.

The constraint is correct today, and I verified it independently: the only solid --success fills in the entire frontend are the code-block "copied" state (app.css:714 and code-block-node.svelte:582 — the same rule declared twice), and neither has a .copied:hover; the only nearby hover is an opacity: 1 reveal on the wrapper. There are zero solid --warning fills — every other --success/--warning usage is color:, border-color:, or an alpha tint.

So the scope decision to omit --success-hover / --warning-hover is factually correct and I endorse it. YAGNI and this repo's explicit no-dead-code rule both point the same way. The issue asked to "consider whether a general rule is better than per-color tokens" — and DESIGN.md:287 now states exactly that general rule, so the law is delivered; only the unused instantiations are not. This is not under-delivering on the issue.

The residual risk is only that the day someone adds a filled success button, nothing mechanically reminds them the law exists. The comment mitigates that as well as a comment can.

🟢 Nit: tailwind.config.js:19-29 does not register the new tokens. It maps primary.DEFAULT/.foreground and destructive.DEFAULT/.foreground but has no -hover key, so there is no bg-primary-hover utility. Harmless today — all four call sites use plain CSS in <style> blocks, and zero hover:bg-primary/hover:bg-destructive utilities exist in the codebase. Note the config already omits --success, --warning and the state -foreground tokens, so it was never the token registry and omitting -hover is consistent with the status quo rather than a new inconsistency. Worth folding into the buttonVariants follow-up, since that fix is Tailwind-based and would want the utility.


On whether a regression test is warranted

I looked hard at this, since the PR now states a law future tokens must follow. My read: a narrow test is justified, but as a follow-up, not a merge blocker.

The precedent cuts both ways:

  • For: src/tests/design/node-accent-colors.test.ts exists with a docblock that justifies itself explicitly — "Stylelint cannot catch a return of that bug… the invariant needs an executable guard." That reasoning transfers cleanly. Stylelint will happily accept --primary-hover: 174 67% 80% (wrong direction, contrast collapses) because it is a well-formed token in a file exempted from the color rules. Nothing mechanical guards the 6pp law. Note that test's regex only matches --node-*, so it does not incidentally cover these.
  • Against: Bring every state-token pairing to WCAG AA in both themes (closes #2668) #2678/Success token is below WCAG AA as text on light surfaces; *-foreground tokens are white in both themes #2668 did comparable contrast work with no automated test, documenting figures in comments. I confirmed there is no contrast or WCAG assertion anywhere in the repo today, and no luminance helper to build on — a test here is net-new infrastructure.

The pragmatic call: the values are static, change roughly never, and are documented at the declaration site with figures I verified as correct. That is adequate for now.

That said, the 🟡 finding above is the argument for the test — the shadcn variants drifted from the law precisely because nothing enforced it. If one is written later, the high-value assertion is not the 6pp delta but:

for every --*-hover, contrast against its --*-foreground is ≥ AA and ≥ the rest-state contrast, in both themes

That single property is what the whole design is for, and it would have caught the dark-mode destructive regression above. Worth folding into the follow-up issue rather than gating this PR.


Consistency / staleness check

I grepped every hover mention in both app.css and DESIGN.md for contradictions:

  • ✅ No stale unqualified hover rule remains in DESIGN.md. Both sites that stated it (Button section :277, Do's bullet :336→:345) were amended. No third location states the old wording.
  • ✅ --hover-background: var(--muted) (app.css:44, 182) does not contradict the new comment — the comment explicitly carves out why it is wrong for filled buttons while leaving it correct for neutral ones. The two coexist coherently.
  • ✅ --console-surface-hover (app.css:151) is a console-namespace surface token, not a --<semantic>-hover, so it does not fall under the new law and does not conflict.
  • ✅ The dark-mode comment (:195-196) correctly frames itself as the mirror of the light-mode block rather than restating the rule — no drift risk between two copies of the same prose.
  • ✅ CSS property pairing is correct at all four call sites — background/background in delete-confirmation-modal and update-banner, background-color/background-color in first-pro-consent-modal and pro-relogin-modal. No property mismatch, and each hover rule is one class-plus-pseudo more specific than its base rule, so the override lands. The two sites that switched away from filter: brightness() to a background declaration both matched their base rule's property correctly.
  • ✅ delete-confirmation-modal.svelte:105 uses a bare :hover without the :not(:disabled) guard the other three carry — correct here, since that button (:36) has no disabled binding at all. Not an inconsistency worth changing.

What this PR does well

Worth stating explicitly, because it is why this is an approve:

  1. It converts an emergent accident into a stated decision. The old behavior was not so much wrong as unchosen — nobody decided the destructive button should lighten in light mode; it fell out of the alpha technique. Naming the rule is the real deliverable, and it is what makes the two follow-ups above identifiable as bugs rather than merely as inconsistencies.
  2. Every number is correct. I checked all eight independently and they are exact. Documented figures that are subtly wrong are worse than none, because they get trusted.
  3. The rejected alternative is documented with its reason, which prevents re-litigation.
  4. Scope discipline. Four files, two tokens, no drive-by refactors, and a correct + verified decision not to add unused --success-hover / --warning-hover.

Recommendation

APPROVE. Correct, verified, well-documented, and a clear net improvement to code health. The 🟡 findings are pre-existing scope this PR is not obligated to absorb — but they should be filed before they are forgotten, since this PR is precisely what makes them legible as defects.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE

All 7 acceptance criteria met. I independently recomputed all eight WCAG contrast figures from the HSL token values via relative luminance — every number in the diff, comments and PR body is exact (light primary 4.86:1, light destructive 6.66:1, dark primary 5.79:1, dark destructive 8.45:1), the 6pp HSL delta holds for all four tokens, and the "contrast rises on hover" claim is true in both themes. The scope decision to omit --success-hover/--warning-hover is factually correct and verified: the only solid --success fill in the frontend is the code-block "copied" state, which has no hover, and there are zero solid --warning fills.

Submitted as a comment rather than an approval because GitHub rejects self-approval on an own-authored PR. The real verdict is APPROVE.

Two follow-ups worth filing (both pre-existing scope, correctly not absorbed here):

  • 🟡 The shared shadcn buttonVariants (ui/button/types.ts:12-14) still uses the alpha idiom DESIGN.md now forbids, and loses contrast on hover in all four cases — dark-mode destructive drops 5.92:1 → 3.39:1, below AA.
  • 🟡 Eight filled primary buttons use opacity: 0.9 on hover, a fourth un-catalogued variant of the same theme-blind trick.

Full findings in the PR comment above.

Adds src/tests/design/filled-button-hover.test.ts (21 tests) and a breadcrumb
from --primary-hover to the rule comment ~40 lines below it.

The review's strongest point was that the rule this PR documents is one
stylelint structurally cannot enforce. `--destructive-hover: 345 77% 60%` is a
well-formed custom property holding a plain HSL triple in the one file allowed
to contain raw values — every design-token rule passes while the button fades
toward its background on hover. The invariant is arithmetic on the values, so
it needs an executable guard, the same argument node-accent-colors.test.ts
makes for the single-accent rule.

The load-bearing assertion is not the 6pp delta but:

  contrast(hover, foreground) > contrast(base, foreground)

An AA floor alone is too weak. A dark --destructive-hover of 64% sits at 7.3:1
against near-black — comfortably above 4.5:1 — while being DARKER than the 70%
base, i.e. hover making a destructive button's label harder to read. Verified
by temporarily injecting exactly that value: the direction and no-contrast-loss
tests both fail, the AA test passes. That is the regression class this catches.

Two things the test found while being written:

- An early draft had readHsl() take a token with the colon already appended,
  so the built pattern was `--primary:\s*:`, matching nothing. It returned null
  on a miss and callers did `if (!base) return`, so 16 tests passed vacuously.
  readHsl now throws on a miss — a token that cannot be read is a broken test,
  not a passing one.
- Asserting every --*-hover has a .dark twin failed on --console-surface-hover,
  correctly: app.css documents the console surface as deliberately
  theme-invariant, defined once under :root. Requiring a twin would push
  app.css toward the duplication that comment argues against, so the assertion
  is scoped to theme-tracking tokens.

Review findings NOT addressed here, filed instead:

- #2689 — the shared shadcn Button still uses `hover:bg-primary/90` and
  `hover:bg-destructive/90 dark:bg-destructive/60`. Every variant loses contrast
  on hover; dark destructive hits 3.39:1, below AA. Not a token swap: the dark
  rest state is itself translucent and `text-white` bypasses
  --destructive-foreground, so it needs a design decision plus ~18 consumers
  re-checked. Stock shadcn boilerplate untouched since the repo flattening,
  never reconciled with the token system.
- #2690 — eight filled primary buttons use `opacity: 0.9` as hover, a fourth
  idiom the issue did not catalogue. Milder (opacity fades the label too, so the
  ratio holds) but theme-blind the same way. Mechanical, but eight files each
  needing its base property checked and orphaned opacity transitions removed.

Both are pre-existing, in files this PR does not touch, and absorbing either
would turn a token change into a component refactor.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed — 8f0eea34

Thanks for recomputing all eight contrast figures independently; good to have them confirmed rather than taken on faith.

✅ Addressed: the test (🟢 → promoted)

You called the high-value assertion correctly, and it wasn't the one I'd have written first. Not the 6pp delta but:

contrast(hover, foreground) > contrast(base, foreground)

Added src/tests/design/filled-button-hover.test.ts (21 tests), following the node-accent-colors.test.ts precedent and its justification: stylelint structurally cannot see this. --destructive-hover: 345 77% 60% is a well-formed custom property holding a plain HSL triple in the one file allowed to contain raw values — every design-token rule passes while the button fades toward its background on hover.

Verified the guard actually bites rather than passing vacuously. Temporarily set dark --destructive-hover to 0 100% 64% — darker than the 70% base, but 7.3:1 against near-black, comfortably above AA:

Assertion Result
AA floor (≥4.5:1) ✅ passes — too weak on its own
moves lighter than base ❌ fails
does not lose contrast ❌ fails

That's the regression class this exists for, and precisely your #2689 scenario.

Two things surfaced while writing it, both in the commit message:

  • An early draft's readHsl() built the pattern --primary:\s*: and matched nothing — it returned null, callers did if (!base) return, and 16 tests passed vacuously. It now throws on a miss.
  • Asserting every --*-hover has a .dark twin failed on --console-surface-hover — correctly. app.css documents that surface as deliberately theme-invariant. Requiring a twin would push toward the duplication that comment argues against, so the assertion is scoped to theme-tracking tokens.

✅ Addressed: breadcrumb (🟢)

--primary-hover at line 23 now reads /* 4.86:1 on its fg; see --*-hover rule below */, keeping the ratio and adding the pointer to the block ~40 lines down.

⏭️ Filed, not fixed: both 🟡 findings

I sized both before deciding, per issue-workflow.md's "establish the size before you decide, not after."

#2689 — shared shadcn Button. I reproduced your numbers; dark destructive hover is 3.39:1. This is not a token swap, which is what makes it separate scope: dark:bg-destructive/60 makes the dark rest state translucent too, so swapping only the hover leaves a translucent rest under an opaque hover, and text-white bypasses the --destructive-foreground that #2668 gave real per-theme values. That's a design decision (is the muted /60 deliberate?) plus tailwind.config.js registration plus ~18 consumers re-checked. git log shows the file untouched since the repository flattening — stock shadcn boilerplate that predates the token work.

#2690 — eight opacity: 0.9 hovers. Confirmed all eight. Mechanical per site, but each needs its base property checked (background vs background-color) and some carry now-orphaned transition: opacity declarations; :disabled { opacity } must be left alone. Eight files this PR doesn't touch.

Both are pre-existing; absorbing either turns a +28/−4 token change into a component refactor.

On scope, since you raised it

Agreed the --success-hover / --warning-hover omission delivers the law without the unused instantiations — and the new test encodes that: FILLED_BUTTON_TOKENS is the list to extend when a token earns a filled-button use, and the suite then holds it to the same rule automatically.

Verification

  • bun run test — 248 files / 5106 tests passed (baseline 247/5085, + the 21 new)
  • bun run quality:fix — clean; design-token baseline unchanged at 137
  • Pre-push gate — full pyramid passed

Derives the remaining two state colors by the same rule — 6 points of HSL
lightness away from the surface — so all four semantic tokens carry a hover and
the rule has no gaps:

  --success-hover  light 32% -> 26%   7.26:1 on its fg (up from 5.35)
                   dark  37% -> 43%  10.54:1 on its fg (up from 7.81)
  --warning-hover  light 30% -> 24%   7.32:1 on its fg (up from 5.26)
                   dark  51% -> 57%  10.77:1 on its fg (up from 9.96)

All four clear AA and rise on hover, with a clean 6pp delta and no clamping at
either end of the lightness range.

Neither token has a filled-button use today, so this is deliberately ahead of
demand. The argument for deriving them now rather than at first use is the
history this PR is cleaning up: the three competing idioms it replaced all came
about because someone needed a hover, had no token to reach for, and invented
one. A derived value waiting in the file means the first --success button
applies the law instead of starting that cycle again.

Extends FILLED_BUTTON_TOKENS so the suite holds the full set to the rule — 41
tests, up from 21. Re-verified the guard bites on the new tokens by injecting a
dark --warning-hover of 45% (darker than its 51% base, still far above AA): the
direction and no-contrast-loss assertions fail, the AA assertion passes.

Updates the app.css comment and DESIGN.md, both of which stated the now-reversed
"--success and --warning have no such use today and so have no hover token".
DESIGN.md gains the contrast table for all four.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

--success-hover / --warning-hover added — 63512a7d

Reversing the scope call from the review discussion: all four state colors now carry a hover token, derived by the same rule rather than hand-tuned.

Token Theme Base → hover Contrast on its fg
--success-hover light 32% → 26% 5.35 → 7.26:1
--success-hover dark 37% → 43% 7.81 → 10.54:1
--warning-hover light 30% → 24% 5.26 → 7.32:1
--warning-hover dark 51% → 57% 9.96 → 10.77:1

Clean 6pp delta on all four, no clamping at either end of the lightness range, every value clears AA and rises on hover.

This is deliberately ahead of demand — neither token has a filled-button use today. The argument for deriving now rather than at first use is the history this PR is cleaning up: all three competing idioms it replaced came about because someone needed a hover, had no token to reach for, and invented one. A derived value sitting in the file means the first --success button applies the law instead of restarting that cycle.

FILLED_BUTTON_TOKENS extended, so the suite holds the full set to the rule — 41 tests, up from 21. Re-verified the guard bites on the new tokens: injected a dark --warning-hover of 45% (darker than its 51% base, but still far above AA) and the direction + no-contrast-loss assertions failed while the AA assertion passed, same as the earlier destructive check.

Also corrected the two places that stated the now-reversed decision — the app.css comment and the DESIGN.md note — since a stale rationale is exactly the drift this PR exists to remove. DESIGN.md (6d91adc) gains the contrast table for all four and a pointer to the enforcing test.

Verification

  • bun run test — 248 files / 5126 tests passed (5106 + the 20 new assertions)
  • bun run quality:fix — clean; design-token baseline unchanged at 137
  • Pre-push gate — full pyramid passed

@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2685 (Re-Review)

Review Type: Re-Review
Scope: 195aa074..HEAD — 2 commits, 2 files, +193/−6
Verdict: ✅ APPROVE

Re-review of 8f0eea34 (add the executable guard) and 63512a7d (close the hover-token set). Everything at or before 195aa074 was reviewed in comment 5710983688 and is not re-litigated here.


Previous Review Summary

The prior review returned APPROVE with 7/7 acceptance criteria met, zero 🔴, two 🟡, and three 🟢.

# Prior recommendation Severity Status in this range
1 buttonVariants (shadcn Button) still uses alpha hovers; dark destructive drops to 3.39:1 🟡 Not addressed — correctly so. Explicitly out of the issue's four call sites; the prior review said not to absorb it. Now cited in the new test's docblock as the motivating real-world failure, which is a better outcome than a silent deferral: the follow-up's rationale is recorded in code
2 Eight opacity: 0.9 hover sites — a fourth un-migrated idiom 🟡 Not addressed — correctly so. Same scope reasoning; still worth filing
3 --primary-hover at app.css:23 is ~40 lines from the rule that explains it; add a breadcrumb 🟢 ✅ Addressed. app.css:23 and :169 now read see --*-hover rule below; :88/:92/:96/:208/:212/:216 read above. Directionally correct at every one of the six sites
4 The "only define a --*-hover for a token used as a filled button" premise can go stale silently 🟢 ✅ Resolved by removing the premise — the set is now closed, so there is no staleness surface left
5 Suggested regression test; named the high-value assertion as "contrast vs its --*-foreground is ≥ AA and ≥ the rest-state contrast, in both themes" 🟢 ✅ Addressed exactly as specified. Both halves implemented, plus direction, hue/saturation invariance, and a both-themes-declared check

New issues introduced in this range: none. Two 🟢 observations below, neither blocking.


The central risk: test and values share an author

The values were computed by a script; the test that checks them was written by the same author. If the WCAG math were wrong it would be wrong identically in both places and still pass green. I treated this as the review's main job.

1. I recomputed all 16 figures independently, in Python via colorsys.hls_to_rgb — a different algorithm shape from the test's k/f formulation — with my own WCAG luminance implementation:

Token Theme Rest (claimed → mine) Hover (claimed → mine) ✅
--primary light 3.51 → 3.5146 4.86 → 4.8551 ✅
--destructive light 5.36 → 5.3551 6.66 → 6.6644 ✅
--success light 5.35 → 5.3466 7.26 → 7.2610 ✅
--warning light 5.26 → 5.2567 7.32 → 7.3173 ✅
--primary dark 4.47 → 4.4666 5.79 → 5.7902 ✅
--destructive dark 6.95 → 6.9542 8.45 → 8.4476 ✅
--success dark 7.81 → 7.8062 10.54 → 10.5426 ✅
--warning dark 9.96 → 9.9605 10.77 → 10.7727 ✅

All 16 match to the stated precision, including the four rest-state figures the new values rise from. Every hover clears AA and exceeds its own rest contrast.

2. I verified the test file's helpers are themselves correct, which is the part a shared author could not self-check. I ran the test's own hslToRgb/luminance/contrast against a structurally different reference (hue-chroma C/X/m formulation) over 200,000 random HSL pairs:

max RGB channel deviation vs reference: 5.551e-16
max contrast deviation vs reference   : 1.421e-14

Floating-point identical. Against WCAG's own anchors the test's helpers return white/black = 21.0000, white/white = 1.0000, and #767676 on white = 4.5430 (the canonical AA boundary grey). The math is right in both places independently, not merely consistently wrong.


Does the test actually assert anything?

The prior draft's --primary:\s*: regex bug produced 16 vacuous passes. I verified the current version cannot. I mutated token values and confirmed the suite fails (working tree restored afterwards; git status clean, 41/41 green again):

Mutation Result
Light --success-hover 26% → 38% (wrong direction) 3 failed — direction, AA floor, and no-contrast-loss
Light --destructive-hover hue 345 → 200 3 failed — hue/saturation invariance fires
Delete dark --success-hover entirely 5 failed, including the both-themes assertion, each naming the token
Dark --warning-hover 57% → 47% (still 8.86:1, clears AA) 2 failed — does not lose contrast hovering --warning

That last one is the important one: it is the exact regression class the AA floor alone would let through, and it is precisely the assertion the prior review asked for. It works.

Mechanics verified individually:

  • Regex boundary — I ran readHsl against an adversarial block with --primary-hover declared before --primary; (?![\w-]) resolves all three tokens correctly. --sidebar-primary (app.css:103,221) does not collide: it contains -primary, not --primary.
  • themeBlock brace-counting — :root spans 8→163 and .dark 165→241 inside @layer base. The only { inside the scanned range is .dark's own, so depth-counting correctly terminates :root at 163 rather than running into .dark. The deletion mutation confirms empirically that the two blocks are genuinely isolated — a light-block value does not satisfy a dark-block lookup.
  • No trivially-true assertion. Every one of the 41 fails under at least one mutation.

The 6pp rule

All eight pairs are exactly ±6pp, correct direction per theme, no clamping:

light primary      35 ->  29   -6    light success   32 ->  26   -6
light destructive  46 ->  40   -6    light warning   30 ->  24   -6
dark  primary      41 ->  47   +6    dark  success   37 ->  43   +6
dark  destructive  70 ->  76   +6    dark  warning   51 ->  57   +6

Nothing approaches 0 or 100 — the nearest is light warning at 24%, with 24 points of headroom.


The --console-surface-hover exclusion

Legitimate, and I verified the justification rather than taking the comment's word. --console-surface-hover is declared once at app.css:159 under :root and has no .dark twin. The comment at :144-156 documents the console surface as deliberately theme-invariant — "defined once here and NOT redefined under .dark" — because the diagnostic panel stays a dark console in both themes. Without the filter the both-themes assertion would fail on a correct file, so the filter is load-bearing, not cosmetic.

Could it mask a future genuine violation? Only for a token literally named --console-*, and only if someone made the console theme-tracking — which would contradict the documented design and require editing that comment. The filter is startsWith('--console-'), tightly scoped rather than a broad pattern. Acceptable.


Stale documentation

Both locations updated; no third location survives.

  • app.css:74-85 — the old "Only define a --*-hover for a token actually used as a filled button; --success and --warning have no such use today" is gone, replaced with the closed-set rationale.
  • DESIGN.md (nodespace-docs 6d91adc) — the matching sentence is replaced, and a contrast table for all four tokens plus a pointer to the test was added.

I grepped packages/ and scripts/ for the old phrasings. The only surviving hit is app.css:80, which is the new wording (--success and --warning have no filled-button use today, but …) — a statement of current fact that motivates the decision, not a stale claim of the reversed one. Nothing else states the old decision.


Requirements Check — issue #2673

All seven remain met. The reversal affects none of them; criterion 3 is strengthened.

# Criterion Status Note
1 --destructive-hover / --primary-hover in both :root and .dark ✅ app.css:23, 88 / :169, 208. Untouched by this range beyond comment text
2 Four call sites migrated; zero filter: brightness(), zero alpha hovers among them ✅ Unchanged in this range; verified in the prior review
3 Hover direction consistent across themes and documented in DESIGN.md ✅ strengthened Was documentation only; now mechanically enforced for all four tokens in both themes, and the doc carries the contrast table
4 DESIGN.md L336 rule amended to cover filled semantic buttons ✅ 3d48f90 (prior range) + 6d91adc (this range)
5 Buttons fully opaque at rest and on hover ✅ The four new values are opaque HSL triples; no alpha introduced
6 Hover states meet WCAG AA in both themes ✅ Independently recomputed — all 8 hover figures ≥ 4.86:1, all above their rest state
7 quality:fix clean; design-token baseline does not grow ✅ quality:design-tokens: "No new design-token violations (137 known)" — 137, unchanged

Verification run locally:

  • bun run --cwd packages/desktop-app test -- src/tests/design/filled-button-hover.test.ts — 41 passed
  • bun run test — 248 files / 5126 tests passed, matching the author's claim exactly
  • bun run --cwd packages/desktop-app quality:design-tokens — clean at 137

Code Review Findings

🔴 Critical

None.

🟡 Important

None in this range. The two 🟡 items from the prior review (buttonVariants, the eight opacity: 0.9 sites) remain open follow-ups and remain correctly out of scope.

🟢 Suggestions

📁 packages/desktop-app/src/tests/design/filled-button-hover.test.ts:100 — readHsl's regex is unanchored on the left.

new RegExp(\${token}(?![\w-])…`)guards the right edge but not the left, so a token whose name *ends with* the target would mis-bind. I confirmed this is **not** currently exploitable —--sidebar-primarycontains-primary, not --primary, and a real CSS custom property cannot embed --mid-name — so this is theoretical. A(?<![\w-])` lookbehind would close it symmetrically for one character of cost.

Principle: defensive symmetry. A guard applied to one edge of a boundary invites the question of why not the other; the answer here is "it happens not to matter", which is worth one character to stop relying on.

📁 packages/desktop-app/src/app.css:78-85 — the dead-code justification is sound and, more importantly, legible.

The repo's CLAUDE.md forbids unused code, and --success-hover/--warning-hover have no call sites. The user requested them, so whether they exist is settled; the question I assessed is whether a future reader will understand why rather than deleting them as dead.

They will. The justification is recorded in three places that a reader is likely to hit:

  1. app.css:79-85 — at the declaration, naming the concrete history ("which is how the three competing idioms this replaced came about")
  2. DESIGN.md — in the Button rule, with the contrast table
  3. The test docblock at :78-83 — FILLED_BUTTON_TOKENS explicitly states the set is closed and tells the next author to extend it

That last one matters most: because the test holds all four to the rule, these are not inert constants. They are covered by an executable invariant, which is a materially different thing from dead code — a wrong edit to --success-hover fails CI today, with no filled success button anywhere. I read the greenfield rule as aimed at unused code paths and speculative abstraction; a derived constant under test, whose derivation is the PR's entire thesis, does not carry the maintenance burden that rule exists to prevent. The YAGNI tension is real but small, and the anti-drift argument is the stronger one given this PR exists because four files each invented a value in the absence of one.

🟢 Nit: 41 tests for 8 values is proportionate, not bloated. It is 5 assertions × 4 tokens × 2 themes + 1 cross-theme check. Each of the five checks a distinct property (declared / direction / hue-saturation invariance / AA floor / no contrast loss), and my mutation testing showed different mutations caught by different subsets — the hue mutation is caught only by the hue assertion, and the 47% mutation only by direction and no-contrast-loss. None is redundant. Per-token, per-theme naming means a failure reports dark theme > does not lose contrast hovering --warning, which names the token, the theme, and the violated law without opening the file. Failure messages are actionable.

🟢 Nit: FILLED_BUTTON_TOKENS is the right extension point. A single as const array with a docblock saying "Add a token here when you add its hover" — adding a fifth state color is one line and inherits all ten assertions. The base()/hover()/foreground() thunk pattern is a deliberate, correct choice: reading lazily inside each it means a missing token fails that test with --X-hover is not declared as a plain HSL triple in this theme block rather than crashing collection for the whole file. My deletion mutation confirmed exactly that behavior — 5 targeted failures with readable messages, not a collection error.


Recommendation

APPROVE.

Both commits do what they claim. The test is the rare case of a guard that genuinely guards: I verified its arithmetic against an independent implementation to floating-point precision, checked it against WCAG's published anchors, and broke the token values four different ways to confirm it fails — including a mutation that clears AA and is caught only by the no-contrast-loss assertion the prior review specifically asked for. The four new values are exactly ±6pp in the right direction and their eight contrast figures are correct to the digit.

The scope reversal is executed cleanly: both documentation sites updated, no third location left stating the old decision, and the "unused token" objection answered by putting the tokens under an executable invariant and recording the reasoning where a future reader will find it.

The two 🟡 items from the prior review remain the right follow-ups — the shadcn buttonVariants alpha hovers (where dark-mode destructive drops to 3.39:1, below AA) are now the most valuable thing left in this area, and this PR's test is the tool that would catch them once those variants move onto tokens.

No re-review needed for the two 🟢 nits above; neither blocks merge.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review (re-review): APPROVE

Scope: 195aa074..HEAD — 8f0eea34 (executable guard) and 63512a7d (closed hover-token set). 2 files, +193/−6.

Verified independently rather than taking the diff's word, since the values and the test that checks them share an author:

  • All 16 contrast figures recomputed (4 new hovers + 4 new rest states + the 8 pre-existing) in Python via a different HSL algorithm and my own WCAG luminance — every one matches to the stated precision.
  • The test's own hslToRgb/luminance/contrast helpers cross-checked against a structurally different reference over 200,000 random HSL pairs: max deviation 1.4e-14. They also hit WCAG's anchors exactly (21.0000 / 1.0000 / 4.5430). The math is independently right, not identically wrong.
  • Mutation-tested for vacuous passes (the earlier draft's regex bug produced 16). Four mutations, all caught — including dark --warning-hover 57%→47%, which still clears AA at 8.86:1 and is caught only by the does not lose contrast assertion the prior review asked for. Working tree restored, 41/41 green.
  • 6pp rule: all eight pairs exactly ±6pp, correct direction per theme, no clamping.
  • --console-* filter: legitimate — that surface is documented at app.css:144-156 as deliberately theme-invariant and defined once under :root. Load-bearing, tightly scoped.
  • Stale docs: both app.css and DESIGN.md (6d91adc) updated; grep found no third location stating the old decision.

Prior review's 🟢 test suggestion and breadcrumb suggestion both addressed; its two 🟡 items (shadcn buttonVariants alpha hovers — dark destructive at 3.39:1, below AA — and eight opacity: 0.9 sites) correctly remain out of scope as follow-ups.

7/7 acceptance criteria still met; criterion 3 strengthened from documented to mechanically enforced. bun run test: 248 files / 5126 passed. Design-token baseline unchanged at 137.

Two 🟢 nits, neither blocking: readHsl's regex is unanchored on the left (not currently exploitable), and the dead-code tension on --success-hover/--warning-hover is resolved well — they are covered by an executable invariant and the rationale is recorded in three places a future reader will hit.

Full findings in the review comment above. Self-authored PR, so --approve is unavailable; the real verdict is APPROVE.

@malibio
malibio merged commit 3c9d26e into main Sep 17, 2026
@malibio
malibio deleted the issue-2673-hover-tokens branch September 17, 2026 08:42
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.

Add --destructive-hover / --primary-hover tokens and unify filled-button hover states

1 participant