Skip to content

fix(theme): make the destructive token pair meet WCAG AA in both themes - #25534

Closed
matbrgz wants to merge 3 commits into
stablyai:mainfrom
UndefinedDump:fix/destructive-contrast
Closed

matbrgz wants to merge 3 commits into
stablyai:mainfrom
UndefinedDump:fix/destructive-contrast

Conversation

@matbrgz

@matbrgz matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

ELI5

The text color meant for red "danger" buttons was too close to the red itself, especially in dark mode, where it was red on red. The text color is now white on the light theme's red and near-black on the dark theme's lighter red, so it is easy to read.

What Changed

  • Before: --destructive-foreground on --destructive measured 4.47:1 in light and 1.66:1 in dark, both under the 4.5:1 WCAG AA floor.
  • After: 4.87:1 in light and 6.24:1 in dark.
theme before after
light #fcf3f3 on #e40014: 4.47:1 #fff on #e40014: 4.87:1
dark #df2225 on #ff6568: 1.66:1 #171717 on #ff6568: 6.24:1
  • Mechanism: two token values in src/renderer/src/assets/main.css; --destructive itself is unchanged. A unit test reads both theme blocks from main.css and asserts the pair is at least 4.5:1 with the WCAG 2.x relative-luminance formula.

Why

Changing only the foreground keeps every existing red surface (buttons, badges, error text that uses --destructive) looking the same. Both new values are existing palette values (--background in light, --primary-foreground in dark), so no new color is introduced. The dark theme cannot simply mirror the light fix: near-white #fafafa on the dark #ff6568 is only 2.75:1, so it needs dark ink.

Linked Issue

Fixes #25533

Visual Proof

Visible only where text-destructive-foreground is painted on bg-destructive (the shipped Button/Badge destructive variants use text-white and do not change). Before/after screenshots will be attached by the author.

Testing

  • New src/renderer/src/assets/destructive-token-contrast.test.ts. With the old main.css it fails with 4.468… < 4.5 (light) and 1.664… < 4.5 (dark); with the fix both pass.

  • Ratios checked independently with the same formula in a separate script: #fcf3f3/#e40014 4.47, #fff/#e40014 4.87, #df2225/#ff6568 1.66, #fafafa/#ff6568 2.75, #171717/#ff6568 6.24.

  • pnpm exec vitest run --config config/vitest.config.ts src/shared/plugins src/renderer/src/assets: 23 files, 165 tests pass

  • pnpm lint passes

  • pnpm typecheck passes

  • Full pnpm test not run locally (CI will cover)

  • I manually tested these changes locally (no rendered check yet; contrast ratios only)

  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with Claude Code (Claude Opus 5.5); reviewed by the author.

Review

  • Cross-platform: CSS token values only; same on macOS, Linux, Windows.
  • SSH / remote / local: no effect.
  • Agents / integrations: plugin panels that read --destructive-foreground get the readable value.
  • Performance: none.
  • Security: none.
  • UI: follows docs/STYLEGUIDE.md, using existing palette values rather than new ones. No change to shipped Button/Badge variants.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

--destructive-foreground on --destructive measured 4.47:1 in light
(#fcf3f3 on #e40014) and 1.66:1 in dark (#df2225 on #ff6568), both under
the 4.5:1 AA floor. Use #fff in light (4.87:1) and #171717 in dark
(6.24:1); dark --destructive is a light red, so near-white would only reach
2.75:1. A test computes the ratio from main.css for both themes.

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

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c551146b-068c-447a-86d0-537a3a29bd91
📥 Commits

Reviewing files that changed from the base of the PR and between a2b5caf and 5f9e3b9.

📒 Files selected for processing (1)
  • src/renderer/src/assets/destructive-token-contrast.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/assets/destructive-token-contrast.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The light theme’s --destructive-foreground changes to white. The dark theme’s token changes to #171717 in both application and documentation stylesheets. A new test extracts both theme blocks and checks that each foreground and destructive token pair has a WCAG contrast ratio of at least 4.5:1.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5f9e3

This change updates the destructive foreground colors to meet the accessibility contrast threshold and adds a test for it. No merge-blocking risk was identified.

Architecture Summary

Architecture risk: 🔵 Low · up to a2b5c

The change affects 2 systems.

Changed systems: src, docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 2 changed files map to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/renderer/src/assets/destructive-token-contrast.test.ts: Adds CSS color parsing and WCAG 2.x relative-luminance and contrast-ratio helpers, extracts the light and dark theme blocks, and throws if a requested token does not match the hex-color pattern.
  • observed — Modified behavior in src/renderer/src/assets/destructive-token-contrast.test.ts: Adds a test for each extracted theme that calculates the contrast ratio between the destructive foreground and destructive tokens and expects a ratio of at least 4.5.
  • observed — Modified behavior in src/renderer/src/assets/main.css: The light-mode --destructive-foreground changes from #fcf3f3 to white; the accompanying comment records the contrast rationale.
  • observed — Modified behavior in src/renderer/src/assets/main.css: The dark-mode --destructive-foreground changes from #df2225 to #171717; the accompanying comment records the contrast rationale.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: meeting WCAG AA contrast for destructive tokens in both themes.
Description check ✅ Passed The description explains the change, rationale, implementation, linked issue, and test results. It also notes that visual proof is pending and that full tests and a rendered check were not run.
Linked Issues check ✅ Passed Issue #25533 requires the documented destructive token pair to meet 4.5:1 contrast in both themes. main.css sets the foreground to #fff in light mode and #171717 in dark mode, and the added test…
Out of Scope Changes check ✅ Passed The token updates and contrast test directly address issue #25533. The matching values in docs/site/src/app/globals.css keep the duplicate token declarations aligned with the corrected app values. N…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Minor suggestions only.

Reviewed changes

  • main.css token values: --destructive-foreground is now #fff in light and #171717 in dark, lifting the destructive / destructive-foreground pair to 4.87:1 and 6.24:1. --destructive itself is untouched, so no red surface shifts.
  • New destructive-token-contrast.test.ts: reads both theme blocks from main.css, computes the WCAG 2.x relative-luminance ratio, and asserts ≥ 4.5:1. I independently reproduced the ratios (old light 4.468 / dark 1.665; new 4.874 / 6.243) and confirmed the test fails against the old values, so it is genuine coverage rather than theatre.

ℹ️ Nitpicks

  • The same token pair is duplicated in docs/site/src/app/globals.css (#fcf3f3 at line 99, #df2225 at line 129) and was not updated, so that copy still falls short of AA. Nothing renders differently today because the docs site never references --destructive-foreground, but if the two copies are meant to stay aligned it is a one-line follow-up.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

The docs site keeps a copy of the app's base tokens; align its
destructive foreground with main.css so the copies do not drift.

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

matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review notes from the review summary:

Pullfrog nitpick (the docs site still has the old --destructive-foreground values): aligned in a2b5caf. docs/site/src/app/globals.css now uses #fff in light and #171717 in dark, matching main.css. As you noted, the docs site never reads that token, so nothing renders differently. This only keeps the two copies of the base tokens from drifting. No test change: destructive-token-contrast.test.ts stays on main.css, which is the canonical source.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — only a2b5caf landed since the prior pullfrog review at 48f23dd.

  • Mirrored the AA destructive foreground tokens into the docs site: docs/site/src/app/globals.css now carries #fff (light) and #171717 (dark) for --destructive-foreground, matching main.css and retiring the prior review's drift nitpick.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@matbrgz

matbrgz commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nwparker

nwparker commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #36561, which fixes the built-in color defaults (WCAG AA pairs, light-mode active tab and the TOC scrollbar). Thank you for this PR, it shaped the design.

@nwparker nwparker closed this Nov 2, 2026
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.

[Bug]: --destructive-foreground on --destructive fails WCAG AA contrast in both themes

2 participants