Conversation
Default to 'auto' color scheme instead of hardcoded 'dark', so the app respects the user's prefers-color-scheme setting. Update the toggle button to reset to auto when cycling back to the OS-preferred theme. Closes #437 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughMantine color-scheme handling was changed to support automatic system detection: Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
client/src/components/ColorSchemeToggleButton/ColorSchemeToggleButton.tsx (1)
18-18: Optional: useuseComputedColorSchemeforshowSunIconinstead of deriving it fromuseMediaQuery.Mantine's
useMantineColorSchemereturnscolorSchemeas'dark' | 'light' | 'auto';useComputedColorSchemeresolves the'auto'value to'dark'or'light'based on the user's system preference. Using it here would simplifyshowSunIconand eliminate the dependency onuseMediaQueryfor icon display:♻️ Proposed refactor
-import { useMediaQuery } from '@mantine/hooks' +import { useComputedColorScheme } from '@mantine/core' import { ActionIcon, useMantineColorScheme, type BoxProps } from '@mantine/core' +import { useMediaQuery } from '@mantine/hooks' const { colorScheme, toggleColorScheme, clearColorScheme } = useMantineColorScheme() +const computedColorScheme = useComputedColorScheme('light', { getInitialValueInEffect: false }) const prefersDarkColorScheme = useMediaQuery('(prefers-color-scheme: dark)', undefined, { getInitialValueInEffect: false, }) -const showSunIcon = (colorScheme === 'auto' && prefersDarkColorScheme) || colorScheme === 'dark' +const showSunIcon = computedColorScheme === 'dark'
prefersDarkColorSchemeis still needed for theclearColorSchemedecision inonClick.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@client/src/components/ColorSchemeToggleButton/ColorSchemeToggleButton.tsx` at line 18, The showSunIcon boolean is derived manually using prefersDarkColorScheme; instead use Mantine's useComputedColorScheme to resolve 'auto' into 'dark' or 'light' and compute showSunIcon from that value. Replace the current expression that uses colorScheme and prefersDarkColorScheme with a computedScheme from useComputedColorScheme and set showSunIcon = (computedScheme === 'dark'), keeping prefersDarkColorScheme in place for the onClick logic that decides clearColorScheme. Update references: ColorSchemeToggleButton, showSunIcon, useMantineColorScheme/useComputedColorScheme, and the onClick handler that checks clearColorScheme.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@client/src/components/ColorSchemeToggleButton/ColorSchemeToggleButton.tsx`:
- Line 16: The media-query hook initializes asynchronously causing a flash;
change the initialization of prefersDarkColorScheme (the const using
useMediaQuery) to evaluate synchronously by passing the options object {
getInitialValueInEffect: false } to useMediaQuery so the correct dark-mode value
is used on first render and the icon no longer flashes.
---
Nitpick comments:
In `@client/src/components/ColorSchemeToggleButton/ColorSchemeToggleButton.tsx`:
- Line 18: The showSunIcon boolean is derived manually using
prefersDarkColorScheme; instead use Mantine's useComputedColorScheme to resolve
'auto' into 'dark' or 'light' and compute showSunIcon from that value. Replace
the current expression that uses colorScheme and prefersDarkColorScheme with a
computedScheme from useComputedColorScheme and set showSunIcon = (computedScheme
=== 'dark'), keeping prefersDarkColorScheme in place for the onClick logic that
decides clearColorScheme. Update references: ColorSchemeToggleButton,
showSunIcon, useMantineColorScheme/useComputedColorScheme, and the onClick
handler that checks clearColorScheme.
client/src/components/ColorSchemeToggleButton/ColorSchemeToggleButton.tsx
Outdated
Show resolved
Hide resolved
…eButton.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Claudia-Anthropica
left a comment
There was a problem hiding this comment.
@krusche Clean and well-thought-out implementation. The toggle cycling logic that skips redundant explicit states matching the OS preference is a nice touch. Looks good!
Summary
autocolor scheme instead of hardcodeddark, so the app respects the user'sprefers-color-schemeOS settingautowhen cycling back to the OS-preferred theme, instead of always alternating betweendarkandlightautomode)Inspired by #437 — thanks to @twihno for the original contribution idea.
Test plan
Summary by CodeRabbit
Bug Fixes
New Features