Skip to content

react to OS theme changes in real time#28

Merged
AntonNiklasson merged 2 commits into
mainfrom
an/system-theme-auto-update
May 5, 2026
Merged

react to OS theme changes in real time#28
AntonNiklasson merged 2 commits into
mainfrom
an/system-theme-auto-update

Conversation

@AntonNiklasson
Copy link
Copy Markdown
Owner

Closes #27.

Subscribe to prefers-color-scheme changes when theme=system so the
dashboard re-themes immediately, instead of only on initial load.

Test plan

  • With theme set to System, toggle macOS appearance — dashboard switches light/dark without reload.
  • With theme set to Light or Dark, OS toggle has no effect.

Subscribe to prefers-color-scheme changes when theme=system so the
dashboard re-themes immediately, instead of only on initial load.

Closes #27
@AntonNiklasson AntonNiklasson marked this pull request as ready for review May 5, 2026 19:37
Copilot AI review requested due to automatic review settings May 5, 2026 19:37
@AntonNiklasson AntonNiklasson merged commit 5982728 into main May 5, 2026
1 check passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds real-time OS theme change handling to the main dashboard when the user’s theme preference is set to system, so the UI updates immediately without requiring a reload.

Changes:

  • Replaces the simple “apply theme on theme change” effect with a prefers-color-scheme subscription that’s only active when theme === "system".
  • Cleans up the media query listener on effect teardown to avoid leaking listeners across renders.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/web/src/App.tsx
Comment on lines +96 to +101

useEffect(() => {
applyTheme(theme);
if (theme !== "system") return;
const mql = window.matchMedia("(prefers-color-scheme: dark)");
const onChange = () => applyTheme(theme);
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.

system theme doesn't auto-update when OS theme changes

2 participants