Skip to content

Comments

Implement system theme auto-detection via prefers-color-scheme#78

Merged
thehack904 merged 4 commits intomainfrom
copilot/implement-auto-detect-theme
Feb 15, 2026
Merged

Implement system theme auto-detection via prefers-color-scheme#78
thehack904 merged 4 commits intomainfrom
copilot/implement-auto-detect-theme

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

Adds automatic dark/light theme detection based on OS/browser preference using CSS prefers-color-scheme media query.

Changes

  • Auto-detection on first visit: New users get system-matched theme automatically
  • "Auto (System)" mode: Continuous tracking of system preference via MediaQuery listener
  • Flash prevention: Inline detection in base.html applies theme before paint
  • Backward compatible: Existing saved preferences preserved

Implementation

Added detectSystemTheme() using window.matchMedia('(prefers-color-scheme: dark)'):

function detectSystemTheme() {
  try {
    if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
      return 'dark';
    }
  } catch (e) { /* ignore */ }
  return 'light';
}

Theme resolution logic:

  1. Saved preference = 'auto' → resolve to system theme
  2. Saved preference = specific theme → use that theme
  3. No saved preference → auto-detect system theme once

MediaQuery change listener updates theme dynamically only when 'auto' explicitly selected.

UI Updates

Added "Auto (System)" to theme selector menus (desktop + mobile).

Light mode (auto-detected)

Light Theme

Dark mode (manual)

Dark Theme

Auto mode

Auto Theme

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • iptv.lan
    • Triggering command: /usr/bin/python python app.py (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement dark/light theme auto-detect in UI</issue_title>
<issue_description>Enhance the UI by auto-detecting the user's preferred dark/light theme. Implementation details:

  • Use CSS 'prefers-color-scheme' media query or JS detection
  • Apply existing theme classes to switch appearance
  • Optionally store manual preference for override
    This improves accessibility and modernizes the interface.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 15, 2026 01:46
- Add detectSystemTheme() function to detect prefers-color-scheme
- Auto-detect system theme on first visit (no saved preference)
- Add "Auto (System)" option to theme menu
- Support dynamic theme switching when system preference changes
- Maintain backward compatibility with existing theme preferences

Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
- Remove redundant lightModeQuery listener
- Fix condition to only auto-update when 'auto' is explicitly selected

Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
- Remove redundant light mode check - fall through to default instead

Co-authored-by: thehack904 <35552907+thehack904@users.noreply.github.com>
Copilot AI changed the title [WIP] Add dark/light theme auto-detect in UI Implement system theme auto-detection via prefers-color-scheme Feb 15, 2026
Copilot AI requested a review from thehack904 February 15, 2026 01:52
@thehack904 thehack904 marked this pull request as ready for review February 15, 2026 02:02
@thehack904 thehack904 merged commit 642da36 into main Feb 15, 2026
1 check passed
@thehack904 thehack904 deleted the copilot/implement-auto-detect-theme branch February 15, 2026 02:02
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.

Implement dark/light theme auto-detect in UI

2 participants