Repository navigation
Conversation
The theme, text scale, text weight, high contrast, custom theme variable and custom CSS caches in localStorage were untagged, so on a shared browser a second account inherited the first account's appearance: with no server value of its own, every fallback resolved to whatever the previous account had stored, and the leftover `silo-theme` key also suppressed the admin-configured default theme for the new account. DateTimeFormatProvider already solved this by stamping its cache with the authenticated user id and refusing another account's values. Extract that mechanism into `createOwnedCache` in utils/storage.ts (where key namespacing lives) and put all three groups behind it, so appearance and custom theme get the same protection instead of a third copy of the rule. - Each group carries its own owner stamp. A shared stamp would be unsafe: the groups are written by hooks nested inside each other, and effects run inner-first, so whichever hook stamped first would vouch for the other's still-stale values. - A null owner (auth bootstrapping, or signed out) still trusts the cache, which keeps the warm start and the login screen's last look. - An unstamped cache is not trusted once an account is known, so existing users take a one-time appearance reset on first load rather than a chance of seeing someone else's settings. - When a foreign cache is detected the values are dropped and the empty cache is handed to the new account, so a later single save cannot re-trust the rest of the previous account's state. Owner is the user id because /settings is user-scoped server side; it lives in one helper (`appearanceCacheOwner`) so it can be widened if appearance moves to profile scope. `shouldLoadApiTheme` is gone: it had become a synonym for `appearanceCacheOwner(...) !== null` with no callers left. Part of #376 AI-use disclosure: implemented with Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
Author
|
Superseded by #479, which combines the design, the manifest, the |
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.
Signing into a second account on the same browser showed you the first account's theme, text size, contrast, and custom CSS until you saved your own. Verified finding from #376.
Incognito is not the leaking case — it starts empty. The bug is two accounts in one regular browser profile.
What changed
web/src/utils/storage.ts— newcreateOwnedCache(ownerKey, memberKeys)returningisTrusted/get/set/clear, plus three instances and two new owner sidecar keys.getreturns null when untrustedcleardrops every member key and re-stamps for the new ownerweb/src/hooks/useTheme.tsxanduseCustomTheme.ts— derive an owner, read trust once per render before any effect re-stamps, gate everyapiValue ?? localValuefallback on it, and clear + reset to defaults when the cache belongs to someone else. That also restores the admin default theme for the new account, which a leftoversilo-themekey had been suppressing.web/src/hooks/useDateTimeFormat.tsx— refactored onto the shared mechanism. Behavior unchanged; it already did this correctly and was the pattern the other two were missing. Reuses its existing owner key so nobody loses their warm start.Three cache groups, three separate stamps — deliberately not one shared stamp. These are written by hooks nested inside one another and React runs effects inner-first, so a shared stamp would let whichever hook resolved first vouch for the other's still-stale values.
Verification
vitest run src/hooks src/utils→ 36 files, 148 tests passtsc -b,format:check→ clean;lint→ 0 errors (160 warnings, same count asmain)expected 'large' to be 'default',expected 'cobalt-studio' to be null, admin default not applied)pnpm testhas 6 pre-existing failures (SeasonContent,ServerStorageStep, allNo QueryClient set), confirmed pre-existing by stashing the whole changeKnown limits
useDateTimeFormatalready shipped; stamping the existing cache with whoever signs in first would reintroduce the leak./settings. Household profiles share auser_id, so profile switching still shares the cache. docs(settings): define the cross-platform settings contract #477 moves appearance to profile scope — that is a one-line change inappearanceCacheOwner().Part of #376. Design: #477. Supersedes #476, closed when its branch was renamed.
AI-use disclosure
Implemented with AI assistance (Claude Opus 5) under maintainer direction; tests, tsc, lint, and format were re-run independently, and the ownership logic was read against the already-shipped
useDateTimeFormatpattern.