From 95e56303f704d795a6047a0c072371c8722437fb Mon Sep 17 00:00:00 2001 From: John Coffey Date: Wed, 26 Aug 2026 11:37:47 -0700 Subject: [PATCH] Pin the theme settings as account-level, not per-browser Both `theme` and `lastDarkTheme` sync, so a theme chosen on one machine -- and the toggle's way back to it -- are the same everywhere. That is already true, by the rule that DEVICE_KEYS is a list of exceptions and anything else syncs by default, but nothing said so. The existing test cannot say it: it derives what should sync from DEVICE_KEYS, so moving one of these into that list would move the expectation with it and still pass. These name the two keys outright. --- web/src/lib/__tests__/theme.test.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web/src/lib/__tests__/theme.test.ts b/web/src/lib/__tests__/theme.test.ts index bc62612..f73ce3e 100644 --- a/web/src/lib/__tests__/theme.test.ts +++ b/web/src/lib/__tests__/theme.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { DEFAULT_SETTINGS, isDarkTheme, toggleTarget, useSettings, type Theme } from "@/store/settings"; +import { DEFAULT_SETTINGS, DEVICE_KEYS, acceptRemote, isDarkTheme, syncedPart, toggleTarget, useSettings, type Theme } from "@/store/settings"; import { loadJson, saveJson } from "@/lib/storage"; /** @@ -144,3 +144,22 @@ describe("remembering which dark theme you were on", () => { expect(back.theme).toBe("ihasmail"); }); }); + +describe("where the theme settings live", () => { + it("follows the account, not the browser", () => { + // Both of these ride in the account's settings.json, so a theme chosen on + // one machine — and the toggle's way back to it — are the same everywhere. + // Named explicitly rather than derived from DEVICE_KEYS: the test that + // does derive it would still pass if one of these were moved there, since + // its expectation would move too. + const synced = syncedPart(DEFAULT_SETTINGS); + expect(synced).toHaveProperty("theme"); + expect(synced).toHaveProperty("lastDarkTheme"); + expect(DEVICE_KEYS.has("theme")).toBe(false); + expect(DEVICE_KEYS.has("lastDarkTheme")).toBe(false); + }); + + it("is applied from a settings file another device wrote", () => { + expect(acceptRemote({ theme: "dark", lastDarkTheme: "dark" })).toEqual({ theme: "dark", lastDarkTheme: "dark" }); + }); +});