feat(ui): persist the dark-mode choice via the per-user settings store#204
Merged
Conversation
#197) Wire the topbar theme toggle to the /_user/settings document from #151 so the preference roams across devices instead of living only in per-device localStorage: - theme.js: first paint stays synchronous from the localStorage cache (cache -> OS preference -> light, no flash); an async GET then reconciles with the server document — a roamed choice from another device wins and refreshes the cache. On toggle, apply + cache immediately and persist with an RFC 7386 merge-patch ({"theme":"dark"}) so no other settings key is touched. - Server values are validated (light|dark) before applying — the settings document is opaque by design, so a corrupted value must not break the UI. Fetch failures degrade to the old cache-only behavior. - rest tests: the exact UI round-trip (merge-patch as first write with and without a pre-existing document, unrelated keys preserved, toggle back). - ui test: smoke-guard that the embedded theme.js keeps the settings wiring and the localStorage cache.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
…/197-theme-user-settings
smunini
approved these changes
Jul 8, 2026
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.
Wires the topbar theme toggle to the
/_user/settingsdocument from #151, so the dark-mode preference roams across devices. Implements #197.Stacked PR — depends on #151. Base is
feat/user-ui-settings; merge #151 first, then this (the first commit mergesmainto bring in thecrates/uiUI crate, so the diff shrinks once the base catches up).How it works (theme.js)
GET /_user/settings; a valid roamedthemefrom another device wins over the local cache and refreshes it.{"theme":"dark"}) so no other settings key is touched.light|dark) before applying — the settings document is opaque by design, so a corrupted value (e.g.{"theme":"purple"}, which the store happily accepts) cannot break the UI. Any fetch failure degrades to today's cache-only behavior.Tests
helios-rest/tests/user_settings.rs: the exact UI round-trip — merge-patch as the first write (document created on the fly), unrelated keys preserved, toggle back; plus the brand-new-user case.helios-ui: smoke-guard that the embeddedtheme.jskeeps the settings wiring and the cache key.Verified against the running server
GET→{}(W/"0") →PATCH {"theme":"dark"}→GET→{"theme":"dark"}→PATCH {"theme":"light"}→ round-trip clean; non-objectPATCHbody → 400; servedtheme.jscarries the wiring. (The in-browser localStorage/fetch behavior itself is smoke-tested only — a Playwright-style browser test would be the follow-up if we want it covered.)Closes #197.