YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(theme-provider): eliminate React #419 hydration mismatch on boot
Louis Beaumont8b2061e38bd1
diff --git a/apps/screenpipe-app-tauri/components/theme-provider.tsx b/apps/screenpipe-app-tauri/components/theme-provider.tsxindex d5995a000..2e9d5ca28 100644--- a/apps/screenpipe-app-tauri/components/theme-provider.tsx+++ b/apps/screenpipe-app-tauri/components/theme-provider.tsx@@ -35,17 +35,16 @@ export function ThemeProvider({storageKey = "screenpipe-ui-theme",...props}: ThemeProviderProps) {- const [theme, setThemeState] = useState<ColorTheme | undefined>(() => {- // Read theme synchronously on first render to avoid flash- if (typeof window === "undefined") return undefined;- try {- const stored = localStorage?.getItem(storageKey) as ColorTheme;- return stored || "system";- } catch {- return "system";- }- });- const [isLoaded, setIsLoaded] = useState(() => typeof window !== "undefined");+ // Deterministic initial state so the rendered tree matches the build-time+ // HTML. Reading localStorage / `typeof window` in the initializer was the+ // source of React #419 (hydration mismatch falls back to a full client+ // re-render of the entire root). FOUC is already prevented by the inline+ // <script> in app/layout.tsx, which sets the .light/.dark class on <html>+ // before React mounts — so the visible theme is correct on first paint+ // regardless of what React state thinks. The useEffect below reads the+ // stored value and updates state immediately after hydration.+ const [theme, setThemeState] = useState<ColorTheme | undefined>(undefined);+ const [isLoaded, setIsLoaded] = useState(false);const { updateSettings } = useSettings();useEffect(() => {