-
Notifications
You must be signed in to change notification settings - Fork 4k
[Fix] Theme preference persistence across reloads #13306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
d7ac2f5 to
044fc74
Compare
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0300%
🎉 Great job on improving test coverage! |
c445780 to
9606d84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #13280 where user-selected themes (Light or Dark) from the Settings menu did not persist between page reloads when custom themes were configured. The fix introduces intelligent mapping between preset and custom theme equivalents to preserve user preferences while applying full server configurations.
Key Changes:
- Adds
mapCachedThemeToAvailableThemeutility function to map cached theme preferences to available themes - Updates
getCachedThemeto restore custom light/dark themes with their displayName - Modifies
App.tsxto use theme mapping when custom themes are added or removed - Adds comprehensive test coverage (unit tests and E2E tests)
Reviewed changes
Copilot reviewed 6 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
frontend/lib/src/theme/utils.ts |
Adds bidirectional theme mapping logic and mapCachedThemeToAvailableTheme function to handle preset ↔ custom theme conversions |
frontend/lib/src/theme/utils.test.ts |
Adds comprehensive unit tests for theme mapping and restoration with displayName |
frontend/lib/src/index.ts |
Exports new mapCachedThemeToAvailableTheme function |
frontend/app/src/App.tsx |
Updates theme handling logic to use mapping when adding/removing custom themes, preserving user preferences |
frontend/app/src/App.test.tsx |
Adds systematic 3x4 matrix of tests covering all combinations of server configs and cached preferences |
e2e_playwright/theming/custom_light_theme_test.py |
Adds E2E test for theme persistence on reload; adds dark theme config for testing; renames test function |
e2e_playwright/__snapshots__/linux/... |
Updates snapshots for renamed test and adds new snapshots for persistence test |
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no bugs!
SummaryThis PR fixes issue #13280 where user-selected theme preferences (Light/Dark) from the Settings menu were not persisting across page reloads when custom light/dark themes were configured. The fix introduces a bidirectional theme mapping system that intelligently maps between preset themes ( Key changes:
Code QualityThe code quality is excellent and follows Streamlit's best practices: TypeScript Best Practices:
Code Organization:
Minor Issue:
Test CoverageTest coverage is comprehensive and well-structured: Unit Tests (
Integration Tests (
E2E Test (
Backwards CompatibilityThe changes are fully backwards compatible:
Security & RiskNo security concerns identified:
Regression Risk: Low
Recommendations
VerdictAPPROVED: This is a well-implemented fix for a user-facing issue. The code is clean, follows best practices, and has excellent test coverage including both unit tests and an E2E test that directly validates the reported issue. The backwards compatibility is preserved, and there are no security or regression risks. This is an automated AI review. Please verify the feedback and use your judgment. |
This PR fixes the interaction issue with theme caching and support of light/dark custom themes - the user-selected theme (Light or Dark) from the Settings menu does not persist between page reloads.
Describe your changes
This PR fixes the interaction issue with theme caching and support of light/dark custom themes - the user-selected theme (Light or Dark) from the Settings menu does not persist between page reloads.
GitHub Issue Link (if applicable)
Closes #13280
Testing Plan