Skip to content

fix: sync PWA status bar theme-color with app color scheme#28006

Open
heimoshuiyu wants to merge 1 commit into
anomalyco:devfrom
heimoshuiyu:fix/remove-redundant-theme-color-meta
Open

fix: sync PWA status bar theme-color with app color scheme#28006
heimoshuiyu wants to merge 1 commit into
anomalyco:devfrom
heimoshuiyu:fix/remove-redundant-theme-color-meta

Conversation

@heimoshuiyu
Copy link
Copy Markdown
Contributor

@heimoshuiyu heimoshuiyu commented May 17, 2026

Issue for this PR

Closes #17663

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When the app is installed as a PWA on mobile Chrome, the top status bar color doesn't match the app's actual theme — it stays #F8F7F7 (light) regardless of whether the user has selected light or dark mode.

The HTML had two <meta name="theme-color"> tags — the second one with media="(prefers-color-scheme: dark)" was supposed to kick in when the system is in dark mode, but it never actually worked. According to the WHATWG HTML Living Standard algorithm for obtaining a page's theme color (https://html.spec.whatwg.org/multipage/semantics.html#meta-theme-color), browsers walk meta tags in tree order and return the first one whose media matches. Our first tag has no media attribute at all, which means it unconditionally matches — the second tag is never even checked.

The fix removes the dead second tag and instead dynamically updates the single remaining meta tag's content in oc-theme-preload.js (runs synchronously before paint) and the theme context (handles runtime changes).

How did you verify your code works?

Confirmed on a mobile Chrome PWA install: before the fix the status bar was always light, after the fix it correctly follows the app's light/dark theme setting.

Screenshots / recordings

before

IMG_20260517_182332

after

IMG_20260517_182320

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@heimoshuiyu heimoshuiyu force-pushed the fix/remove-redundant-theme-color-meta branch from 609bae0 to c73df21 Compare May 17, 2026 10:15
@heimoshuiyu heimoshuiyu marked this pull request as ready for review May 17, 2026 10:16
@heimoshuiyu heimoshuiyu requested a review from adamdotdevin as a code owner May 17, 2026 10:16
@heimoshuiyu heimoshuiyu force-pushed the fix/remove-redundant-theme-color-meta branch 7 times, most recently from 5bd6e3e to 609bae0 Compare May 17, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Adaptive Android Statusbar Color for OpenCode PWA (use --background-base theme color)

1 participant