fix(configurator): align Auto dark derivation with CSS formula - #428
Conversation
The JS deriveDarkFromLight formula (l + 0.27) didn't match the CSS formula in themes.css (clamp(0.65, 0.95 - l * 0.5, 0.88)), and the base color used a completely different formula that wasn't handled at all. In Auto dark mode the configurator was also baking the derived dark value into the exported CSS override, bypassing the runtime CSS formula entirely. - Fix deriveDarkFromLight to mirror the exact CSS formulas (including the base-specific clamp(0.16, 1.18 - l, 0.24) / c * 0.5 variant) - In Auto dark mode, only write the light token to overrides — the CSS formula in themes.css handles source-dark at runtime - Switching Auto → Manual now removes the dark override; switching Manual → Auto populates dark as a pre-filled starting point Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gjdz9WEvMA8M1ve3Z1Xsoc
|
Warning Review limit reached
More reviews will be available in 53 minutes and 40 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughColorsPanel now derives auto-dark values with colorKey-specific logic, applies light-token edits without auto-dark side effects, changes auto/manual dark toggling to seed or clear overrides, and resets only the light brand token. ChangesColorsPanel auto-dark updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoFix configurator Auto dark to match themes.css OKLCH derivation Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
6 rules 1.
|
autoDarkSet is only updated via toggleDarkMode, but overrides can change externally (import, undo/redo) while ColorsPanel is mounted. A dark override introduced that way would cause the row to display "Auto dark" while the CSS formula is actually bypassed by the hidden override. Derive isAutoMode from both autoDarkSet and the live absence of a dark override in overrides, and apply the same guard in toggleDarkMode so clicking the toggle on an externally-overridden row correctly switches to Auto (clearing the stale override) rather than Manual. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gjdz9WEvMA8M1ve3Z1Xsoc
The JS deriveDarkFromLight formula (l + 0.27) didn't match the CSS
formula in themes.css (clamp(0.65, 0.95 - l * 0.5, 0.88)), and the
base color used a completely different formula that wasn't handled at all.
In Auto dark mode the configurator was also baking the derived dark value
into the exported CSS override, bypassing the runtime CSS formula entirely.
base-specific clamp(0.16, 1.18 - l, 0.24) / c * 0.5 variant)
formula in themes.css handles source-dark at runtime
Manual → Auto populates dark as a pre-filled starting point
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Gjdz9WEvMA8M1ve3Z1Xsoc
Summary by CodeRabbit
New Features
Bug Fixes