Skip to content

fix(theme): persist theme preference and respect system prefers-color-scheme#2440

Open
anuragbraveboy-sudo wants to merge 1 commit into
Umbrella-io:mainfrom
anuragbraveboy-sudo:fix/theme-persistence
Open

fix(theme): persist theme preference and respect system prefers-color-scheme#2440
anuragbraveboy-sudo wants to merge 1 commit into
Umbrella-io:mainfrom
anuragbraveboy-sudo:fix/theme-persistence

Conversation

@anuragbraveboy-sudo

Copy link
Copy Markdown

Description

This PR resolves the issues surrounding theme preference persistence across the dashboard and public profile routes, and adds proper system default (prefers-color-scheme) support on initial visits.
Closes #2434

Key Changes

  1. System Default Integration:

    • Updated ThemeContext.tsx and the root injection script in layout.tsx to inspect the client's OS color preference (prefers-color-scheme: dark) on their first visit if no manual theme override exists.
    • Removed the mount-time automatic localStorage write side-effect to avoid locking down the dynamic system preference on initial visit.
    • Wrapped all localStorage read/write operations in safe try-catch blocks to protect against restricted environments.
  2. Unified Theme State:

    • Refactored ProfileThemeWrapper.tsx to consume the global ThemeContext directly. This eliminates the duplicate "profile-theme" storage key and aligns public profiles with the app's global theme selection.
  3. E2E Tests:

    • Updated e2e/theme.spec.js with page reload assertions to verify theme persistence on both the authenticated dashboard and public profiles.

Verification

  • Local Playwright E2E suite ran and passed successfully: npx playwright test e2e/theme.spec.js (2/2 tests passed).

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:testing GSSoC type bonus: tests (+10 pts) labels Jun 14, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Umbrella-io — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) labels Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Theme preference resets to default on page reload — dark mode selection not persisted across sessions

1 participant