LearnNewsExamplesServices
Frontmatter
id8844
titleAuto-detect System Theme Preference
stateClosed
labels
enhancementai
assigneestobiu
createdAtJan 21, 2026, 11:06 AM
updatedAtJan 21, 2026, 11:26 AM
githubUrlhttps://github.com/neomjs/neo/issues/8844
authortobiu
commentsCount1
parentIssue8727
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 21, 2026, 11:26 AM

Auto-detect System Theme Preference

Closed v11.23.0 enhancementai
tobiu
tobiu commented on Jan 21, 2026, 11:06 AM

Improve UX by automatically detecting the user's system-level color scheme preference (Dark/Light Mode) and using it as the default theme if no user preference is saved.

Requirements:

  1. Detection: In the Main Thread (src/Main.mjs), detect the system preference using window.matchMedia('(prefers-color-scheme: dark)').matches.
  2. Config Propagation: Store this boolean value in Neo.config as prefersDarkTheme so it is automatically passed to the App Worker during initialization.
  3. App Logic: Update Portal.view.ViewportController to use Neo.config.prefersDarkTheme as the default fallback when no portalTheme is found in LocalStorage.

Note: This ensures the first-time visit respects the user's OS settings.

tobiu added the enhancement label on Jan 21, 2026, 11:06 AM
tobiu added the ai label on Jan 21, 2026, 11:06 AM
tobiu added parent issue #8727 on Jan 21, 2026, 11:07 AM
tobiu referenced in commit b59d41f - "feat: Auto-detect System Theme Preference (#8844)" on Jan 21, 2026, 11:25 AM
tobiu
tobiu Jan 21, 2026, 11:26 AM

Input from Gemini 3 Pro:

✦ I have implemented the auto-detection logic.

Changes:

  1. Updated DefaultConfig.mjs: Added prefersDarkTheme (default: false) with clear documentation.
  2. Updated src/worker/Manager.mjs: Enhanced detectFeatures to check matchMedia('(prefers-color-scheme: dark)') and update Neo.config.prefersDarkTheme before workers are created. This ensures the correct value is propagated during the initial worker handshake without requiring a secondary remote call.
  3. Updated ViewportController.mjs: Modified onConstructed to use Neo.config.prefersDarkTheme as the fallback if no local storage preference exists.

The implementation is efficient, avoiding unnecessary post-startup configuration synchronization.

tobiu assigned to @tobiu on Jan 21, 2026, 11:26 AM
tobiu closed this issue on Jan 21, 2026, 11:26 AM