@devries-cameron20 / t3code-1 / commits / 9434bfd1d9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(web): default theme adoption compiles with the React Compiler (#20574)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 22:05 UTC 9434bfd1d9f53d9d377704955b6d63b5eca8a4af
1 file changed +9 -13
apps/web/src/hooks/useDefaultTheme.ts
+9 -13
@@ -1,10 +1,9 @@
1 import { useAtomValue } from "@effect/atom-react";
2 -import { useEffect } from "react";
2 +import { useEffect, useSyncExternalStore } from "react";
3
4 import { primaryEnvironmentIdAtom } from "../state/primaryEnvironment";
5 import { primaryServerSettingsAtom } from "../state/server";
6 -import { getThemeDefinition, singleAppearanceOf } from "../themePalette";
7 -import { useEnvironmentThemeDefinitions } from "./useEnvironmentTheme";
6 +import { getThemeDefinition, singleAppearanceOf, subscribeToCustomThemes } from "../themePalette";
7 import { useTheme } from "./useTheme";
8
9 const APPLIED_DEFAULT_THEME_STORAGE_PREFIX = "t3code:default-theme-applied:v2:";
@@ -54,12 +53,16 @@ export function useDefaultThemeAdoption(): void {
53 const settings = useAtomValue(primaryServerSettingsAtom);
54 const { defaultTheme, defaultThemeSetAt } = settings;
55 const { setTheme, setAppearanceMode } = useTheme();
57 - const environmentThemes = useEnvironmentThemeDefinitions();
56 + // Re-read when published or custom palettes change, so a theme that resolves late still applies.
57 + const definition = useSyncExternalStore(
58 + subscribeToCustomThemes,
59 + () => getThemeDefinition(defaultTheme),
60 + () => null,
61 + );
62
63 useEffect(() => {
64 if (typeof window === "undefined" || environmentId === null) return;
65 const storageKey = `${APPLIED_DEFAULT_THEME_STORAGE_PREFIX}${environmentId}`;
62 - const definition = getThemeDefinition(defaultTheme);
66 const generation = defaultThemeToApply({
67 environmentId,
68 defaultTheme,
@@ -81,12 +84,5 @@ export function useDefaultThemeAdoption(): void {
84 // light half with no retry.
85 if (half !== null && !setAppearanceMode(half)) return;
86 writeAppliedGeneration(storageKey, generation);
84 - }, [
85 - environmentId,
86 - defaultTheme,
87 - defaultThemeSetAt,
88 - environmentThemes,
89 - setTheme,
90 - setAppearanceMode,
91 - ]);
87 + }, [environmentId, defaultTheme, defaultThemeSetAt, definition, setTheme, setAppearanceMode]);
88 }