OTWO-7576 Preserve dark mode settings per user#1894
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds server-backed (per-account) theme preference support so “dark mode” can persist across sessions/devices, and updates the frontend theme toggle to use cookies + a small JSON API instead of only localStorage.
Changes:
- Added
Account#theme_preferenceandAccount#theme_preference=backed bySettingrecords keyed by account id. - Introduced
GET /accounts/:id/theme_preference.jsonandPOST /accounts/:id/set_theme_preferenceendpoints plus JS fetch-based syncing. - Updated layout/theme JS to apply theme early (cookie +
prefers-color-scheme) and removed debug logging from mobile menu JS.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
app/models/account.rb |
Adds per-account theme preference getter/setter backed by Setting. |
app/controllers/accounts_controller.rb |
Adds JSON endpoints to read/update theme preference. |
config/routes.rb |
Adds member routes for theme preference endpoints. |
app/views/layouts/application.html.haml |
Adds early theme application script and emits a current-user meta tag for client-side detection. |
app/assets/javascripts/theme_toggle.js |
Switches theme persistence to cookie + server sync for authenticated users. |
app/assets/javascripts/mobile_menu.js |
Removes console logging from mobile menu toggle script. |
app/controllers/sessions_controller.rb |
Bypasses reCAPTCHA in development for login flow. |
test/models/setting_test.rb |
Adds tests around storing/retrieving theme settings via Setting. |
test/models/account_test.rb |
Adds tests for Account#theme_preference behavior and sparse storage semantics. |
test/controllers/accounts_controller_test.rb |
Adds controller tests for the new endpoints. |
test/integration/theme_preference_test.rb |
Adds integration coverage for theme preference API behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.