TypeScript
perf(mobile): skip showcase subscriptions in normal builds (#16131)
Julius Marminge6651aaab38c6
diff --git a/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx b/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsxindex 6d5df639cbd..48c8f6f1497 100644--- a/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx+++ b/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx@@ -56,7 +56,14 @@ function sceneFromPathname(pathname: string): ShowcaseScene | null {return null;}+// Showcase capture only runs in showcase builds. Gate the mount so normal builds+// never subscribe to workspace, project, or thread shell state.export function ShowcaseCaptureCoordinator(props: { readonly pathname: string }) {+ if (!SHOWCASE_ENABLED) return null;+ return <EnabledShowcaseCaptureCoordinator pathname={props.pathname} />;+}++function EnabledShowcaseCaptureCoordinator(props: { readonly pathname: string }) {const navigation = useNavigation();const { connectPairingUrl } = useConnectionController();const {@@ -92,7 +99,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string }));useEffect(() => {- if (!SHOWCASE_ENABLED || pairingUrls.length > 0) return;+ if (pairingUrls.length > 0) return;const readLaunchRequest = () => {const values = getNativeShowcasePairingUrls();@@ -110,7 +117,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })}, [pairingUrls.length]);useEffect(() => {- if (!SHOWCASE_ENABLED || orientationSettled) return;+ if (orientationSettled) return;const orientation = getNativeShowcaseOrientation();if (orientation === null) {setOrientationSettled(true);@@ -130,8 +137,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })}, [orientationSettled]);useEffect(() => {- if (!SHOWCASE_ENABLED) return;-const readRequestedScene = () => {const value = getNativeShowcaseScene();if (!value || requestedSceneRef.current === value) return;@@ -156,7 +161,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })useEffect(() => {if (- !SHOWCASE_ENABLED ||requestedTheme === null ||themeApplied ||// Writing before stored preferences load would be overwritten by them.@@ -168,7 +172,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })}, [appearancePreferencesReady, requestedTheme, setThemeIdForBothAppearances, themeApplied]);useEffect(() => {- if (!SHOWCASE_ENABLED || pairingUrls.length === 0) return;+ if (pairingUrls.length === 0) return;let cancelled = false;void (async () => {await Promise.all(@@ -201,7 +205,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })const showcaseThread = threads.find((thread) => String(thread.id) === SHOWCASE_THREAD_ID);useEffect(() => {- if (!SHOWCASE_ENABLED || !hasServerFixture || pendingTasksReady) return;+ if (!hasServerFixture || pendingTasksReady) return;const pendingTasks = buildShowcasePendingTasks(projects, Date.now());if (pendingTasks.length !== SHOWCASE_PENDING_TASK_DEFINITIONS.length) return;@@ -232,7 +236,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })}, [hasServerFixture, pendingTasksReady, projects]);useEffect(() => {- if (!SHOWCASE_ENABLED || requestedScene === null || !hasFixture || !showcaseThread) return;+ if (requestedScene === null || !hasFixture || !showcaseThread) return;if (scene === requestedScene) return;const params = {@@ -285,7 +289,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })}, [hasFixture, navigation, requestedScene, scene, showcaseThread]);useEffect(() => {- if (!SHOWCASE_ENABLED || scene !== "agent-activity" || !hasFixture || agentActivityStaged) {+ if (scene !== "agent-activity" || !hasFixture || agentActivityStaged) {return;}let cancelled = false;@@ -319,7 +323,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })useEffect(() => {if (- !SHOWCASE_ENABLED ||scene === null ||requestedScene === null ||scene !== requestedScene ||@@ -363,7 +366,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })themeId,]);- if (!SHOWCASE_ENABLED || readyScene === null) return null;+ if (readyScene === null) return null;return (<View