From b4594c55b5c0d336d5803f09ffb6f337f98629f9 Mon Sep 17 00:00:00 2001 From: Renfei Zhou Date: Sat, 10 Oct 2026 17:59:14 +0000 Subject: [PATCH] Follow the system colour scheme when no theme is stored Co-Authored-By: Claude Opus 5.5 --- apps/web/index.html | 2 +- apps/web/src/hooks/useEnvironmentThemeSync.test.ts | 2 +- apps/web/src/hooks/useTheme.ts | 6 +++--- apps/web/src/themeBoot.test.ts | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/web/index.html b/apps/web/index.html index 0d24369e56b44..c2d164742402c 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -248,7 +248,7 @@ storedTheme === "dark" || storedTheme === "system" || themeModes !== null; - const theme = isKnownTheme && storedTheme ? storedTheme : "light"; + const theme = isKnownTheme && storedTheme ? storedTheme : "system"; const isThemed = isKnownTheme && themeModes !== null; const baseAppearance = customTheme ? customTheme.appearance : "light"; const systemMode = prefersDark ? "dark" : "light"; diff --git a/apps/web/src/hooks/useEnvironmentThemeSync.test.ts b/apps/web/src/hooks/useEnvironmentThemeSync.test.ts index 27962e291e325..1f22e0617bccd 100644 --- a/apps/web/src/hooks/useEnvironmentThemeSync.test.ts +++ b/apps/web/src/hooks/useEnvironmentThemeSync.test.ts @@ -141,7 +141,7 @@ describe("published theme refresh", () => { expectPreview(); publish([LIGHT_THEME, { ...NIGHTFALL_THEME, id: "unused-theme" }]); expectPreview(); - expect(publish([]).theme).toBe("light"); + expect(publish([]).theme).toBe("system"); expectPreview(); const current = publish([{ ...NIGHTFALL_THEME, canvas: "#112233" }]); diff --git a/apps/web/src/hooks/useTheme.ts b/apps/web/src/hooks/useTheme.ts index 23edc8335abd8..7a750fd7434a8 100644 --- a/apps/web/src/hooks/useTheme.ts +++ b/apps/web/src/hooks/useTheme.ts @@ -38,11 +38,11 @@ type DesktopThemeBridge = Pick; const STORAGE_KEY = "t3code:theme"; const MEDIA_QUERY = "(prefers-color-scheme: dark)"; const DEFAULT_THEME_SNAPSHOT: ThemeSnapshot = { - theme: "light", + theme: "system", resolvedTheme: "light", systemDark: false, - followSystem: false, - appearanceMode: "light", + followSystem: true, + appearanceMode: "system", themeHalves: null, }; diff --git a/apps/web/src/themeBoot.test.ts b/apps/web/src/themeBoot.test.ts index 5a1a8f92191ee..ae82d184e4c68 100644 --- a/apps/web/src/themeBoot.test.ts +++ b/apps/web/src/themeBoot.test.ts @@ -113,7 +113,7 @@ function runtimeResolvedAppearance( invalidateCustomThemes(); try { const raw = storage[THEME_STORAGE_KEY] ?? null; - const theme = raw !== null && isKnownThemePreference(raw) ? raw : "light"; + const theme = raw !== null && isKnownThemePreference(raw) ? raw : "system"; const followRaw = storage[THEME_FOLLOW_SYSTEM_STORAGE_KEY] ?? null; const appearanceRaw = storage[THEME_APPEARANCE_MODE_STORAGE_KEY] ?? null; const appearanceMode = @@ -504,7 +504,7 @@ describe("index.html boot script", () => { }); expect(boot.themeId).toBeUndefined(); expect(boot.themeSelected).toBeUndefined(); - expect(boot.isDark).toBe(false); + expect(boot.isDark).toBe(true); }); it("follows the OS appearance when storage is unavailable", () => {