Skip to content

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

fix(app): keep the deep-link login handler mounted outside the gate

Louis Beaumonta1bc6a7b74ee
diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsx
index 6a076e282..ab4ad4e3a 100644
--- a/apps/screenpipe-app-tauri/app/layout.tsx
+++ b/apps/screenpipe-app-tauri/app/layout.tsx
@@ -9,7 +9,6 @@ import "./globals.css";
import { Providers } from "./providers";
import { Toaster } from "@/components/ui/toaster";
import { Suspense, useEffect } from "react";
-import { DeeplinkHandler } from "@/components/deeplink-handler";
import { ShortcutTracker } from "@/components/shortcut-reminder";
import { PipeInstallDialog } from "@/components/pipe-install-dialog";
import { BrowserPairingDialog } from "@/components/browser-pairing-dialog";
@@ -377,7 +376,9 @@ export default function RootLayout({
React #419 (hydration recovery) → #185 (infinite loop during
recovery render) on every first launch after auto-update. */}
<Providers>
- {!isOverlay && <DeeplinkHandler />}
+ {/* DeeplinkHandler is mounted in Providers (outside the entitlement
+ gate) so the screenpipe:// login callback is always caught, even
+ while the "sign in required" screen is showing. */}
{!isOverlay && <ShortcutTracker />}
{!isOverlay && <PipeInstallDialog />}
{!isOverlay && <BrowserPairingDialog />}
diff --git a/apps/screenpipe-app-tauri/app/providers.tsx b/apps/screenpipe-app-tauri/app/providers.tsx
index aac232096..8b8f830b0 100644
--- a/apps/screenpipe-app-tauri/app/providers.tsx
+++ b/apps/screenpipe-app-tauri/app/providers.tsx
@@ -16,6 +16,8 @@ import { NuqsAdapter } from "nuqs/adapters/next/app";
import { commands } from "@/lib/utils/tauri";
import { useUpdateListener } from "@/components/update-banner";
import { AppEntitlementGate } from "@/components/app-entitlement-gate";
+import { DeeplinkHandler } from "@/components/deeplink-handler";
+import { usePathname } from "next/navigation";
/// Global mount point for the updater event listener. Lives here (not in
/// per-page hooks) so the listener is registered for the lifetime of the
@@ -46,6 +48,12 @@ export const Providers = forwardRef<
// succeeds; the post-mount effect flips mounted=true and the real tree
// renders client-only without a hydration step.
const [mounted, setMounted] = useState(false);
+ // The deep-link handler (which turns the screenpipe:// login callback into a
+ // loadUser call) MUST stay mounted outside the entitlement gate. Otherwise the
+ // "sign in required" screen unmounts it and the login token is dropped, so
+ // sign-in can never complete and the user is locked out for good.
+ const pathname = usePathname();
+ const isOverlay = pathname === "/shortcut-reminder";
useEffect(() => {
setMounted(true);
}, []);
@@ -135,7 +143,12 @@ export const Providers = forwardRef<
<PermissionMonitorProvider>
<UpdateListenerMount />
<PostHogProvider client={posthog}>
- {mounted ? <AppEntitlementGate>{children}</AppEntitlementGate> : null}
+ {mounted ? (
+ <>
+ {!isOverlay && <DeeplinkHandler />}
+ <AppEntitlementGate>{children}</AppEntitlementGate>
+ </>
+ ) : null}
</PostHogProvider>
</PermissionMonitorProvider>
</ChangelogDialogProvider>