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(app): kill first-launch React #185 boot crash via mount-gate
Louis Beaumontc4db64eabdf4
diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsxindex f4710840e..01da76ebf 100644--- a/apps/screenpipe-app-tauri/app/layout.tsx+++ b/apps/screenpipe-app-tauri/app/layout.tsx@@ -347,8 +347,15 @@ export default function RootLayout({}}/></head>- <Providers>- <body className={`${inter.className} scrollbar-hide ${isSearch ? "bg-transparent" : ""}`}>+ <body className={`${inter.className} scrollbar-hide ${isSearch ? "bg-transparent" : ""}`}>+ {/* Providers sits INSIDE <body> so the body element is present in+ both the static export and the first client render. With Providers+ wrapping <body>, gating Providers' children on a post-mount flag+ (see app/providers.tsx) would also blank the body — the resulting+ shape mismatch with the prerendered HTML is exactly what triggered+ React #419 (hydration recovery) → #185 (infinite loop during+ recovery render) on every first launch after auto-update. */}+ <Providers>{!isOverlay && <DeeplinkHandler />}{!isOverlay && <ShortcutTracker />}{!isOverlay && <PipeInstallDialog />}@@ -360,8 +367,8 @@ export default function RootLayout({{/* {!isOverlay && <VaultLockDialog />} */}{children}{!isOverlay && <Toaster />}- </body>- </Providers>+ </Providers>+ </body></html>);}diff --git a/apps/screenpipe-app-tauri/app/providers.tsx b/apps/screenpipe-app-tauri/app/providers.tsxindex f283ee212..40804c417 100644--- a/apps/screenpipe-app-tauri/app/providers.tsx+++ b/apps/screenpipe-app-tauri/app/providers.tsx@@ -5,7 +5,7 @@"use client";import posthog from "posthog-js";import { PostHogProvider } from "posthog-js/react";-import { useEffect, Suspense } from "react";+import { useEffect, useState, Suspense } from "react";import { ChangelogDialogProvider } from "@/lib/hooks/use-changelog-dialog";import { SettingsProvider } from "@/lib/hooks/use-settings";import { ThemeProvider } from "@/components/theme-provider";@@ -31,6 +31,24 @@ export const Providers = forwardRef<HTMLDivElement,{ children: React.ReactNode }>(({ children }, ref) => {+ // Gate children rendering until after first effect. The Next.js static+ // export prerenders the whole tree at build time, and several boot-path+ // components (settings via createDefaultSettingsObject → platform(),+ // Date.now() initializers in chat-sidebar's useMinuteTick, etc.)+ // produce different output at build time vs first client render. The+ // resulting mismatch surfaces as React #419 (hydration recovery), and+ // React's fallback "re-render the entire root on the client" path then+ // trips React #185 (max update depth) deep in the message list — the+ // symptom users see is the "something went wrong" boundary on every+ // first launch after auto-update. mounted=false on the initial render+ // matches the static prerender (both produce no children), so hydration+ // succeeds; the post-mount effect flips mounted=true and the real tree+ // renders client-only without a hydration step.+ const [mounted, setMounted] = useState(false);+ useEffect(() => {+ setMounted(true);+ }, []);+// Hook console to write to disk — batched to avoid IPC-per-log CPU drainuseEffect(() => {const origLog = console.log;@@ -115,7 +133,7 @@ export const Providers = forwardRef<<ChangelogDialogProvider><PermissionMonitorProvider><UpdateListenerMount />- <PostHogProvider client={posthog}>{children}</PostHogProvider>+ <PostHogProvider client={posthog}>{mounted ? children : null}</PostHogProvider></PermissionMonitorProvider></ChangelogDialogProvider></ThemeProvider>