Skip to content

Replace hardcoded shadows and phantom color vars with design tokens (closes #2591) - #2670

Merged
malibio merged 1 commit into
mainfrom
issue-2591-modal-shadow-tokens
Sep 16, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-2591-modal-shadow-tokens

Conversation

@malibio

@malibio malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #2591.

DESIGN.md restricts box-shadow to floating surfaces (popovers, dropdowns) and states modals get no drop shadow — the backdrop provides the separation. Eight components carried hand-picked shadows in violation of that rule.

What changed

Shadows removed from all 7 surviving components. No replacement shadow is added — per DESIGN.md the backdrop alone separates the panel.

Which rule applies to the toast and banner (the issue left this open): DESIGN.md's Toast section specifies z-index only, and the Do's/Don'ts say "Don't use box shadows outside of floating surfaces (popovers, dropdowns)." Toasts and banners are neither, so conflict-toast and update-banner get the same no-shadow treatment as the modal panels rather than a sanctioned toast shadow.

Phantom CSS variables fixed. Underneath the shadows sat a larger defect: four of these components referenced a --color-* vocabulary (--color-surface, --color-text-primary, --color-border, --color-accent, …) that app.css defines nowhere. Every reference silently resolved to its hardcoded fallback, and those fallbacks are dark-only values (#1e1e1e surface, #e0e0e0 text) — so these components rendered dark chrome in light mode regardless of theme. A genuine theming bug masked by token-shaped syntax that did nothing.

Each literal is mapped by semantic intent, not nearest hex match:

Was Now Why
#c0392b delete button hsl(var(--destructive)) destructive action
#2563eb / --color-accent action buttons hsl(var(--primary)) DESIGN.md: primary for all interactive affordances
--color-warning toast border/icon hsl(var(--warning)) status communication
--color-surface / -raised / -2 panels hsl(var(--popover)) floating surface
--color-text-secondary / -muted hsl(var(--muted-foreground)) de-emphasized text
border-radius: 8px var(--radius) --radius is 0.5rem = 8px — visually identical

Every token used is verified defined in both :root and .dark.

Deliberately out of scope

These remain in the design-token baseline:

  • Backdrop rgba(0, 0, 0, 0.5) on 4 modals — the consistent app-wide convention across every modal in the app, and the issue explicitly scopes backdrop opacity out of this change.
  • conflict-toast's @keyframes / animation — a pre-existing DESIGN.md motion violation, unrelated to shadows or colors.

Stale acceptance criteria

version-conflict-modal.svelte — named in the issue as the holder of the hardcoded Material palette (#d32f2f, #4caf50, #1976d2) — was deleted in #2602 as an orphaned component. None of those hex literals exist anywhere in the codebase today, so its two acceptance criteria are moot.

Relationship to #2592

#2592 describes this same phantom-variable defect, but for diagnostic-panel.svelte and invitations-inbox.svelte. The file sets are disjoint — no overlap, no merge conflict.

Verification

🤖 Generated with Claude Code

…loses #2591)

DESIGN.md restricts box-shadow to floating surfaces (popovers, dropdowns)
and states modals get no drop shadow -- the backdrop provides separation.
Eight components carried hand-picked shadows in violation of that rule.

Removes the shadow from all of them. The Toast section specifies z-index
only and the "Don't" list scopes shadows to popovers/dropdowns, so
conflict-toast and update-banner fall under the same rule as the modal
panels rather than getting a sanctioned toast shadow.

Underneath the shadows sat a larger defect. Four of these components
referenced a --color-* vocabulary (--color-surface, --color-text-primary,
--color-border, --color-accent, ...) that app.css defines nowhere, so every
reference silently resolved to its hardcoded fallback. Those fallbacks are
dark-only values (#1e1e1e surface, #e0e0e0 text), meaning these components
rendered dark chrome in light mode regardless of theme -- a real theming
bug masked by token-shaped syntax that did nothing.

Each literal is mapped by semantic intent rather than nearest hex match:
the delete button's #c0392b becomes --destructive, update-banner's and
pro-relogin's action blues become --primary (DESIGN.md: primary for all
interactive affordances), conflict-toast's amber becomes --warning.

Backdrop overlays keep rgba(0, 0, 0, 0.5): that is the consistent app-wide
convention across every modal, and the issue scopes backdrop opacity out.
conflict-toast's animation violations are pre-existing and unrelated.

The design-token baseline ratchets 251 -> 201 accordingly.

version-conflict-modal.svelte, named in the issue as the holder of a
hardcoded Material palette, was deleted as an orphaned component in #2602;
its two acceptance criteria are moot.

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

malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2670

Review Type: Initial Review (0 prior reviews, 0 prior comments)
Commit under review: bcc2ff22 (c22a120c is another developer's independently-landed commit and is excluded)
Scope: 7 Svelte components + design-token baseline re-record. Pure CSS/styling.


Requirements Check

Acceptance criteria from issue #2591:

# Criterion Status
1 No box-shadow on modal panel in delete-confirmation-modal, subtree-access-denied-modal, first-pro-consent-modal, first-pro-consent-slot, pro-relogin-modal ✅ All five removed; verified no box-shadow remains in any of the 7 touched files
1b …version-conflict-modal.svelte ✅ Moot — verified, not an excuse. git log --diff-filter=D confirms deletion in c9fa6b4e ("Delete 4 orphaned frontend components", #2602). The named hex literals (#d32f2f, #4caf50, #1976d2, #e8f5e9) return zero hits codebase-wide.
2 update-banner + conflict-toast shadows resolved per DESIGN.md's rule for their class, documented in the PR ✅ Both removed. DESIGN.md:323-325 (Toast) specifies z-index only; DESIGN.md:343 scopes shadows to "popovers, dropdowns". The no-shadow reading is correct and the reasoning is documented in both the commit body and the issue comment.
3 version-conflict-modal has zero hardcoded color literals ✅ Moot (file deleted). Superseded in practice by the scope expansion — see below.
4 Visual behavior otherwise unchanged (backdrop opacity, layout, spacing) ⚠️ Partially — and deliberately so. Backdrop/layout/spacing untouched ✅. But the --color-* migration is an intentional visual change: it fixes light-mode rendering. The commit body states this plainly. Correctly scoped as a bug fix, not a silent regression — see finding 🟢-1.
5 Zero new Stylelint violations for these files ✅ Verified by running bun run --cwd packages/desktop-app quality:design-tokens → ✓ No new design-token violations (201 known, tracked in baseline)
6 Passes bun run quality:fix ✅ Design-token gate passes; diff is formatting-clean
7 Tests pass ✅ Ran bun run test: 246 files / 5078 tests passed, 0 failures — byte-identical to the recorded baseline (issue comment: "246 test files passed, 5078 tests passed")

Scope expansion (agreed with maintainer, documented on the issue): 4 components referenced a --color-* namespace that app.css defines nowhere. I verified this independently — grep for --color-surface, --color-text-primary, --color-accent, etc. against app.css returns nothing, so every one of those references fell through to its hardcoded fallback, and those fallbacks are dark-only (#1e1e1e, #e0e0e0). These panels rendered dark chrome in light mode. This is a genuine latent theming bug, and folding the fix into this PR is the right call: the shadow removal touched the same declaration blocks, so splitting it would have meant two passes over identical lines.


Verification performed

Token existence (all confirmed in BOTH :root and .dark in packages/desktop-app/src/app.css):

Token :root .dark
--popover / --popover-foreground L27/28 L119/120
--foreground L22 L114
--muted / --muted-foreground L30/31 L122/123
--hover-background L34 L126
--border L37 L129
--destructive / --destructive-foreground L41/42 L133/134
--primary / --primary-foreground L12/13 L104/105
--warning L49 L141
--radius L55 n/a (theme-independent, correct)

No phantom tokens introduced. ✅

border-radius: 8px → var(--radius): --radius: 0.5rem (app.css:55) = 8px at the default 16px root font size. Visually identical as claimed, and DESIGN.md:265 explicitly names --radius as the single base variable, with modals at radius lg = 8px (DESIGN.md:271, 317). ✅

Baseline re-record integrity — this is the finding I most wanted to confirm, and it is clean. Parsed both JSON files and did a multiset diff (collections.Counter, so duplicates count):

  • 251 → 201, exactly 50 removed
  • Zero entries added
  • Removals grouped by file: delete-confirmation-modal 12, update-banner 11, subtree-access-denied-modal 9, conflict-toast 8, pro-relogin-modal 5, first-pro-consent-modal 3, first-pro-consent-slot 2 = 50
  • Every removed entry belongs to one of the 7 touched files. No unrelated entry was silently dropped, so no regression-guard hole was opened. ✅

design-tokens-baseline.test.ts correctly needed no update: it exercises diffAgainstBaseline against synthetic fixtures (a.svelte/b.svelte), not the real baseline contents. It tests the comparison algorithm, which is unchanged. Leaving it alone is right, not an omission. ✅

Remaining phantom --color-* refs: only diagnostic-panel.svelte (22 refs), which the issue comment explicitly assigns to a sibling remediation issue. No stragglers left in this PR's scope. ✅


Code Review Findings

🟡 Improvements

🟡-1 — Alpha-based hover contradicts DESIGN.md's explicit hover rule, and adds a third competing idiom

📁 packages/desktop-app/src/lib/components/delete-confirmation-modal.svelte:106 — background: hsl(var(--destructive) / 0.85);
📁 packages/desktop-app/src/lib/components/pro-relogin-modal.svelte:140 — background-color: hsl(var(--primary) / 0.85);

DESIGN.md is unusually direct here:

  • L336: "Derive hover states from --hover-background / --hover-foreground variables — never hardcode hover colors"
  • L280 (Button): "Hover states use muted background via the systematic hover variables (--hover-background, --hover-foreground)."

0.85 is a hand-picked magic number — the same class of hand-tuned constant this PR exists to eliminate. Swapping #a93226 for hsl(var(--destructive) / 0.85) moves the value into token syntax without moving it into the token system; the arbitrary choice just relocated from the hex to the alpha channel.

There's a concrete rendering consequence too, not just a doctrinal one. hsl(var(--destructive) / 0.85) is translucent — it composites against whatever sits behind it. Here that's hsl(var(--popover)), which is 0 0% 100% in light and 240 4% 10% in dark. The same declaration therefore produces a lighter destructive red on hover in light mode and a darker one in dark mode. The original #c0392b → #a93226 always darkened. So hover direction now inverts between themes — likely not the intent, and hard to notice without side-by-side theme checks.

This also leaves three different filled-button hover idioms across sibling files reviewed in the same pass:

  • delete-confirmation-modal:106 / pro-relogin-modal:140 → alpha / 0.85 (new)
  • 📁 update-banner.svelte:82 → filter: brightness(1.08) (untouched)
  • 📁 first-pro-consent-modal.svelte:187 → filter: brightness(0.92) (untouched)

Principle — DRY / single source of truth: a design system earns its keep by having exactly one answer to "how does a filled button hover?". Three answers in four adjacent files means the next component author picks by coin flip.

To be fair on the alternatives: a literal reading of "use --hover-background" doesn't work for filled buttons — --hover-background is var(--muted), so a destructive button would turn grey on hover, losing its semantic color. That's a real gap in the token system, not author error. The honest fix is a pair of tokens (--destructive-hover, --primary-hover) defined per-theme in app.css, which is what DESIGN.md's "systematic hover variables" spirit points at.

Recommendation: this is worth a follow-up issue rather than a blocker — it's pre-existing inconsistency this PR inherited and narrowed rather than created, and the change is still a clear net improvement over two hardcoded hexes. But please don't let it land silently: file the follow-up to add --destructive-hover / --primary-hover and unify all four call sites, and note the theme-inversion behavior so whoever picks it up knows what to look for.

🟡-2 — color on .modal is currently dead in both modals

📁 packages/desktop-app/src/lib/components/delete-confirmation-modal.svelte:55
📁 packages/desktop-app/src/lib/components/subtree-access-denied-modal.svelte:49

Both add color: hsl(var(--popover-foreground)) to .modal. I traced the markup in both: the only children are h2, p, and buttons — and every one sets its own color (h2 → --foreground, p → --muted-foreground, buttons → --foreground/--destructive-foreground). No text currently inherits from .modal.

I don't think this rises to "delete the dead code." It's a defensive default for future unstyled children, it matches the popover/popover-foreground pairing DESIGN.md:296 prescribes (a surface should declare its foreground alongside its background), and it's consistent with first-pro-consent-modal.svelte:106-107 and first-pro-consent-slot.svelte which already pair them. Establishing the pair on the surface is the correct pattern.

Worth noting explicitly because the greenfield "no dead code" rule in CLAUDE.md could be read as demanding its removal — I'd argue it shouldn't be, since a background without its paired foreground is the more dangerous state. No change requested; flagged so the judgment is on record rather than rediscovered later.

🟢 Nitpicks / Observations

🟢-1 — Criterion 4 ("visual behavior otherwise unchanged") is technically not met, and that's correct

The --color-* migration deliberately changes light-mode rendering — that's the whole point of the fix. The commit body is explicit about it. Calling this out only so a future reader diffing criteria against outcomes doesn't mistake it for an unreported regression. The criterion was written before the phantom-namespace defect was known. No action.

🟢-2 — Deliberate exclusions are defensible

Both hold up under scrutiny:

  • Backdrop rgba(0, 0, 0, 0.5) on 4 modals — issue criterion 4 explicitly scopes backdrop opacity out, and DESIGN.md:260/317 treats the backdrop as the modal's separation mechanism without prescribing a token for it. Changing it here would have exceeded scope and altered visuals. Correctly left in the baseline. There is no --overlay/--backdrop token to migrate to, so this genuinely needs a token added first — reasonable follow-up, not this PR's job.
  • conflict-toast @keyframes / animation — a pre-existing motion violation (DESIGN.md:344), an entirely different rule family from color/elevation. Bundling it would have broken the atomicity of the change. Principle — atomic commits: a change should have one cohesive purpose. Correct call.

Both remain tracked in the baseline (verified: the 3 conflict-toast animation entries and 4 backdrop entries are still present), so neither is silently forgiven by the gate. ✅

🟢-3 — --border carries embedded alpha in dark mode

📁 packages/desktop-app/src/app.css:129 — --border: 0 0% 100% / 0.1;

hsl(var(--border)) expands to hsl(0 0% 100% / 0.1) in dark mode — the token bakes its own alpha in. This parses fine and is the established convention (128 occurrences of hsl(var(--border)) across the codebase, including app.css itself). The PR is consistent with the norm. Noting only because the token behaves differently from its siblings; not this PR's concern.

🟢-4 — border-radius: 6px literals remain adjacent to the migrated var(--radius)

📁 conflict-toast.svelte:~90, update-banner.svelte:78, first-pro-consent-modal.svelte

update-banner now has border-radius: var(--radius) on the panel but a raw 6px on its buttons two rules below. 6px is DESIGN.md's md radius (L270) for buttons, so the value is right — there's just no --radius-md token exposed to reference. Nit: out of scope here (the issue targets shadows and colors); mentioned for whoever adds the radius-scale tokens.


Standards Compliance

Standard Result
No lint suppression ✅ No eslint-disable / stylelint-disable added; baseline re-record is a legitimate shrink (50 fixed, 0 added), which is exactly the ratchet mechanism design-tokens-baseline.json's own README sanctions
No any types ✅ No TS changed
No {@html} ✅ None
No raw console.* ✅ None
No backward-compat / deprecation / dead code ✅ Old values deleted outright, no fallback chains retained. Notably the migration drops the var(--x, #fallback) fallback syntax entirely rather than preserving it — correct greenfield behavior, and the thing that made the bug invisible in the first place
Docs in this repo ✅ No .md added

Assessment

This is a well-executed change that is clearly net positive on code health.

What stands out: the author didn't stop at the literal ask. The issue said "remove shadows and fix one file's hex literals"; the author found that the shadow removal was sitting on top of a real theming bug — four components silently rendering dark-only chrome in light mode because they referenced a CSS variable namespace that never existed. Token-shaped syntax that does nothing is worse than an honest hex literal, because it looks compliant to both reviewers and linters. Finding and fixing that is the highest-value part of this PR, and it was properly surfaced on the issue and in the commit body rather than smuggled in.

The discipline around scope is equally good: the moot acceptance criteria were verified against git history rather than hand-waved, the exclusions were reasoned from DESIGN.md rather than convenience, and the baseline re-record is surgically exact — I diffed it as a multiset and every one of the 50 removed entries traces to a touched file, with nothing added. That last point matters most, because a sloppy re-record is how a regression guard quietly develops a hole, and this one didn't.

On testing: no test is warranted. These are pure CSS declarations with no logic, no branching, and no runtime behavior. The Stylelint gate (check-design-tokens.ts + design-tokens-baseline.json) is the correct and sufficient regression guard — it's a static check on exactly the property this PR changes, and it ratchets, so the 50 fixed violations can't silently return. A DOM test asserting computed colors would be testing the browser's CSS cascade, not the application, and would be a maintenance liability. The existing design-tokens-baseline.test.ts guards the diff algorithm itself with synthetic fixtures and rightly needed no change.

The only substantive finding is 🟡-1 (alpha-based hover). It contradicts an explicit DESIGN.md directive and introduces a subtle theme-dependent inversion — but it's a narrowing of pre-existing inconsistency, not a new mess, and the "correct" fix requires tokens that don't exist yet. That's a follow-up, not a gate.


Recommendation: ✅ APPROVE

Merge as-is. Please file one follow-up issue before/alongside merge:

Add --destructive-hover / --primary-hover tokens and unify filled-button hover states. Four sibling components currently use three different idioms — alpha / 0.85 (delete-confirmation-modal:106, pro-relogin-modal:140), brightness(1.08) (update-banner:82), and brightness(0.92) (first-pro-consent-modal:187). --hover-background resolves to --muted and so can't serve filled buttons without destroying their semantic color, which is a genuine gap in the token system rather than an authoring mistake. Note that the alpha form composites against --popover, so hover currently lightens in light mode and darkens in dark mode — verify the intended direction when unifying. Ref DESIGN.md L280, L336.

Optional second follow-up: add an --overlay token so the four modal backdrops (rgba(0, 0, 0, 0.5)) can leave the baseline too.

@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 (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

/address-review summary

Review verdict was APPROVE with no 🔴 Critical findings. Ran /address-review unconditionally per CLAUDE.md.

Code changes made: none. No commit was needed — every finding was either explicitly not-a-change-request or correctly belongs in a follow-up.

Triage

Finding Decision Reasoning
🟡-1 Alpha-based hover ⏭️ Deferred → #2673 Fixing it properly means adding tokens to the design system, not editing these call sites. --hover-background resolves to --muted, which would turn a filled destructive button grey and destroy its semantics — so there is no correct existing token to switch to. Inventing a fourth idiom here would worsen the very inconsistency the finding is about. The reviewer recommended a follow-up; I agree.
🟡-2 color on .modal ⏭️ No change Reviewer explicitly requested none — flagged only to prevent the greenfield no-dead-code rule being misread as demanding removal. It is the popover/popover-foreground pairing DESIGN.md:296 prescribes.
🟢-1 Criterion 4 ⏭️ No change Confirms the light-mode change is the fix, stated in the commit body.
🟢-2 Exclusions ⏭️ No change Confirms both deliberate exclusions defensible and still baseline-tracked.
🟢-3 --border alpha ⏭️ No change Confirms consistency with 128 existing usages.
🟢-4 6px radius nit ⏭️ Out of scope No --radius-md token exists; would be scope creep.

Verified rather than assumed

I independently checked 🟡-1's behavioral claim before deferring it, since "hover direction inverts between themes" is a factual assertion, not a style opinion. Computing relative luminance of the composited result:

Theme Base Hover Direction
light 78.2 104.7 lightens
dark 134.5 118.0 darkens

The reviewer was right. The previous hardcoded pair (#c0392b → #a93226) always darkened. This is a real, if minor, behavioral change — hover now moves toward the surface in both themes, which is a defensible convention but currently an emergent side effect of the alpha technique rather than a deliberate choice. Those numbers are recorded in #2673 so the follow-up starts from measurement, not re-derivation.

Worth stating plainly: this is not a regression introduced by this PR. The hovers here were already hardcoded hex; converting them to token-relative values was strictly an improvement. The PR surfaced a pre-existing gap in the token system.

Follow-up filed

#2673 — Add --destructive-hover / --primary-hover tokens and unify filled-button hover states. Covers all four call sites across three idioms (two alpha, two opposing filter: brightness()), and flags that DESIGN.md L336's hover rule only addresses neutral buttons — which is what left the gap. Cross-referenced #2668 (same button-color surface area).

I did not file the optional --overlay token suggestion: the four backdrops are already consistent app-wide and baseline-tracked, so it is low-value churn until something actually needs to vary. Happy to file it if wanted.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Zero code changes were made since the review — bcc2ff22 is still HEAD and the working tree is clean. There is no new code for a reviewer to look at. The one substantive finding was deferred to #2673 with the reviewer's own concurrence, and its factual claim was verified rather than taken on trust.

PR is ready for merge, pending the maintainer's decision. Per CLAUDE.md, merging is not automatic.

@malibio
malibio merged commit 36c4e8f into main Sep 16, 2026
@malibio
malibio deleted the issue-2591-modal-shadow-tokens branch September 16, 2026 20:48
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.

Replace hardcoded shadows and colors in modal/toast/banner components with design tokens

1 participant