From ed6bb7dc0ac8285ee8d1b0eb94e1e5586b737bab Mon Sep 17 00:00:00 2001 From: Wes Date: Tue, 7 Apr 2026 15:42:30 -0700 Subject: [PATCH] [codex] Lazy-load desktop E2E bridge (#262) --- desktop/src/main.tsx | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/desktop/src/main.tsx b/desktop/src/main.tsx index 41fc67cb4..301c15504 100644 --- a/desktop/src/main.tsx +++ b/desktop/src/main.tsx @@ -4,9 +4,10 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { App } from "@/app/App"; import "@/shared/styles/globals.css"; import { ThemeProvider } from "@/shared/theme/ThemeProvider"; -import { maybeInstallE2eTauriMocks } from "@/testing/e2eBridge"; -maybeInstallE2eTauriMocks(); +type E2eWindow = Window & { + __SPROUT_E2E__?: unknown; +}; const queryClient = new QueryClient({ defaultOptions: { @@ -22,12 +23,32 @@ const queryClient = new QueryClient({ }, }); -ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - - - - - - - , -); +function renderApp() { + ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( + + + + + + + , + ); +} + +async function installE2eBridgeIfConfigured() { + // Keep the large E2E bridge out of the normal startup path and production + // bundle; only load it when tests explicitly inject an E2E config. + if (!(window as E2eWindow).__SPROUT_E2E__) { + return; + } + + const { maybeInstallE2eTauriMocks } = await import("@/testing/e2eBridge"); + maybeInstallE2eTauriMocks(); +} + +async function bootstrap() { + await installE2eBridgeIfConfigured(); + renderApp(); +} + +void bootstrap();