Skip to content

Commit 3b65be0

Browse files
samejrclaude
andcommitted
fix(webapp): treat the White theme as light, not dark
useThemeMode only counted `light` itself as a light theme, so White fell through to the dark branch. The toast rendered dark on a white page, and the agent logo picked its dark dot palette. It now classifies by theme family, reusing the enum that drives the "Light" end of the `system` preference so a new theme is only classified once. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1570540 commit 3b65be0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/webapp/app/hooks/useThemeMode.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { useEffect, useState } from "react";
2+
import { SystemLightTheme } from "~/utils/themePreference";
23

34
export type ThemeMode = "dark" | "light";
45

6+
/* Which themes read as light. Taken from the enum that also drives the "Light"
7+
end of the `system` preference, so a new theme only has to be classified once
8+
- anything not in here (dark, classic, black) reads as dark. */
9+
const LIGHT_THEMES = new Set<string>(SystemLightTheme.options);
10+
511
/**
612
* The active theme's mode, for colors that can't come from a CSS variable. Resolved in an
713
* effect so server and hydration renders agree; `root.tsx` can flip `data-theme` pre-paint.
@@ -10,7 +16,8 @@ export function useThemeMode(): ThemeMode {
1016
const [mode, setMode] = useState<ThemeMode>("dark");
1117
useEffect(() => {
1218
const resolve = () => {
13-
setMode(document.documentElement.getAttribute("data-theme") === "light" ? "light" : "dark");
19+
const theme = document.documentElement.getAttribute("data-theme");
20+
setMode(theme !== null && LIGHT_THEMES.has(theme) ? "light" : "dark");
1421
};
1522
resolve();
1623
const observer = new MutationObserver(resolve);

0 commit comments

Comments
 (0)