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): capture top-level webview errors + ship source maps; bump 2.4.255
Louis Beaumontb1c1ea15ded3
diff --git a/apps/screenpipe-app-tauri/app/error.tsx b/apps/screenpipe-app-tauri/app/error.tsxindex 4b4f8cece..abc0b49b6 100644--- a/apps/screenpipe-app-tauri/app/error.tsx+++ b/apps/screenpipe-app-tauri/app/error.tsx@@ -5,6 +5,7 @@"use client";import { useEffect } from "react";+import { invoke } from "@tauri-apps/api/core";export default function GlobalError({error,@@ -24,6 +25,19 @@ export default function GlobalError({stack: error?.stack,};console.error("global error boundary caught:", serialized);+ // Also bypass the buffered console interceptor and write straight to the+ // Rust log — the buffer flush may never fire if the error boundary+ // unmounts Providers before the 2s flush timer (which is what was happening+ // for the enterprise #185 crash on MBP — error.tsx logged but the entry+ // never reached ~/.screenpipe/screenpipe-app.<date>.log).+ invoke("write_browser_logs", {+ entries: [+ {+ level: "error",+ message: `error boundary: ${JSON.stringify(serialized)}`,+ },+ ],+ }).catch(() => {});}, [error]);return (diff --git a/apps/screenpipe-app-tauri/app/global-error.tsx b/apps/screenpipe-app-tauri/app/global-error.tsxindex bd89795ae..506ab3c4e 100644--- a/apps/screenpipe-app-tauri/app/global-error.tsx+++ b/apps/screenpipe-app-tauri/app/global-error.tsx@@ -4,6 +4,9 @@"use client";+import { useEffect } from "react";+import { invoke } from "@tauri-apps/api/core";+export default function GlobalError({error,reset,@@ -11,6 +14,32 @@ export default function GlobalError({error: Error & { digest?: string };reset: () => void;}) {+ useEffect(() => {+ // Bypass the buffered console interceptor in app/providers.tsx and write+ // straight to the Rust log via write_browser_logs. The 2s buffer flush+ // does not reliably fire when an error boundary tears down its parent+ // tree (e.g. the enterprise-build React #185 boot crash), so the stack+ // was never landing in ~/.screenpipe/screenpipe-app.<date>.log.+ const serialized = {+ name: error?.name,+ message: error?.message,+ digest: error?.digest,+ stack: error?.stack,+ };+ try {+ // eslint-disable-next-line no-console+ console.error("global-error boundary caught:", serialized);+ } catch {}+ invoke("write_browser_logs", {+ entries: [+ {+ level: "error",+ message: `global-error boundary: ${JSON.stringify(serialized)}`,+ },+ ],+ }).catch(() => {});+ }, [error]);+return (<html lang="en"><body style={{ margin: 0, backgroundColor: "#0a0a0a", color: "#fff", fontFamily: "system-ui, sans-serif" }}>diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsxindex 989e9535e..ebb60aac7 100644--- a/apps/screenpipe-app-tauri/app/layout.tsx+++ b/apps/screenpipe-app-tauri/app/layout.tsx@@ -116,6 +116,38 @@ export default function RootLayout({}}, 2_000);+ // Top-level error capture for crashes that happen before React's error+ // boundaries mount (or while they're tearing down their parent tree).+ // The buffered console interceptor in app/providers.tsx flushes every+ // 2s — that's enough for steady-state logs but loses entries when the+ // page is mid-teardown. Going straight through __TAURI_INTERNALS__.invoke+ // bypasses the buffer so the stack lands in ~/.screenpipe/screenpipe-app+ // immediately. Wired in layout.tsx specifically because it mounts before+ // providers.tsx finishes its first effect.+ const directInvoke = (level: string, message: string) => {+ try {+ const i = (window as any).__TAURI_INTERNALS__?.invoke;+ if (typeof i === "function") {+ i("write_browser_logs", { entries: [{ level, message }] }).catch(() => {});+ }+ } catch {}+ };+ const handleWindowError = (e: ErrorEvent) => {+ directInvoke(+ "error",+ `window.onerror: ${e.message} @ ${e.filename}:${e.lineno}:${e.colno} :: stack=${e.error?.stack ?? "(no stack)"}`,+ );+ };+ const handleUnhandled = (e: PromiseRejectionEvent) => {+ const reason: any = e.reason;+ directInvoke(+ "error",+ `unhandledrejection: ${reason?.message ?? String(reason)} :: stack=${reason?.stack ?? "(no stack)"}`,+ );+ };+ window.addEventListener("error", handleWindowError);+ window.addEventListener("unhandledrejection", handleUnhandled);+// Auto-reload on IndexedDB disconnect (APP-2E, 27 users on v2.0.379)// WKWebView's IndexedDB server can crash; the page becomes unusable.// PostHog JS SDK uses IndexedDB for session replay — this is a known WebKit bug.@@ -223,6 +255,8 @@ export default function RootLayout({window.removeEventListener("mousedown", handlePointerRecovery, true);window.removeEventListener("keydown", markKeyActivity, true);window.removeEventListener("unhandledrejection", handleUnhandledRejection);+ window.removeEventListener("error", handleWindowError);+ window.removeEventListener("unhandledrejection", handleUnhandled);clearInterval(focusWatchdog);};}, []);diff --git a/apps/screenpipe-app-tauri/next.config.mjs b/apps/screenpipe-app-tauri/next.config.mjsindex 198646f9e..0df3264bf 100644--- a/apps/screenpipe-app-tauri/next.config.mjs+++ b/apps/screenpipe-app-tauri/next.config.mjs@@ -8,6 +8,11 @@ const nextConfig = {// Disable eslint during builds - we run it separately in CIignoreDuringBuilds: true,},+ // Ship sourcemaps with the prod bundle so React #185 / similar minified+ // stack traces decode to real component + file names in the logs (the+ // bundle is shipped only inside the Tauri app, not over a public CDN,+ // so this isn't an information-disclosure concern).+ productionBrowserSourceMaps: true,}export default nextConfig;diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 74d694902..3e239730f 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -2,7 +2,7 @@[package]name = "screenpipe-app"-version = "2.4.254"+version = "2.4.255"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""