Repository navigation
fix: prevent share pages from overriding the user's theme preference - #17098
Conversation
Visiting a shared chat/agent link with ?theme=light persisted that theme to localStorage, so the main app switched to light mode after refresh. Theme synced from URL params is now applied without persistence, and the previous theme is restored when leaving the share page.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTheme updates now accept an optional persistence flag. Query-parameter theme changes avoid localStorage writes and restore the prior theme when the synchronization hook cleans up. ChangesTheme persistence control
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant useSyncThemeFromParams
participant ThemeProvider
participant localStorage
participant documentElement
useSyncThemeFromParams->>ThemeProvider: setTheme(theme, false)
ThemeProvider->>documentElement: update light/dark class
ThemeProvider->>localStorage: write theme only when persistence is enabled
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Visiting a shared chat/agent link (e.g.
?theme=light) calledsetThemethroughuseSyncThemeFromParams, and theThemeProvidereffect persisted every theme change tolocalStorage. As a result, a user in dark mode who opened a light-themed share page and then returned to the main app would see the app stuck in light mode after a browser refresh, because their stored preference had been silently overwritten.This PR makes URL-driven theme sync non-destructive:
setThemenow accepts apersistflag (defaulttrue); whenfalse, the theme is applied to the document but not written tolocalStorage.useSyncThemeFromParamsusespersist: false, so share pages render with the theme from the URL without touching the user's saved preference.Manual theme toggles in the main app still persist as before.