Skip to content

Commit 4a0c6b2

Browse files
perf(mobile): skip showcase subscriptions in normal builds
1 parent bab9fdb commit 4a0c6b2

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ function sceneFromPathname(pathname: string): ShowcaseScene | null {
5656
return null;
5757
}
5858

59+
// Showcase capture only runs in showcase builds. Gate the mount so normal builds
60+
// never subscribe to workspace, project, or thread shell state.
5961
export function ShowcaseCaptureCoordinator(props: { readonly pathname: string }) {
62+
if (!SHOWCASE_ENABLED) return null;
63+
return <EnabledShowcaseCaptureCoordinator pathname={props.pathname} />;
64+
}
65+
66+
function EnabledShowcaseCaptureCoordinator(props: { readonly pathname: string }) {
6067
const navigation = useNavigation();
6168
const { connectPairingUrl } = useConnectionController();
6269
const {
@@ -92,7 +99,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
9299
);
93100

94101
useEffect(() => {
95-
if (!SHOWCASE_ENABLED || pairingUrls.length > 0) return;
102+
if (pairingUrls.length > 0) return;
96103

97104
const readLaunchRequest = () => {
98105
const values = getNativeShowcasePairingUrls();
@@ -110,7 +117,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
110117
}, [pairingUrls.length]);
111118

112119
useEffect(() => {
113-
if (!SHOWCASE_ENABLED || orientationSettled) return;
120+
if (orientationSettled) return;
114121
const orientation = getNativeShowcaseOrientation();
115122
if (orientation === null) {
116123
setOrientationSettled(true);
@@ -130,8 +137,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
130137
}, [orientationSettled]);
131138

132139
useEffect(() => {
133-
if (!SHOWCASE_ENABLED) return;
134-
135140
const readRequestedScene = () => {
136141
const value = getNativeShowcaseScene();
137142
if (!value || requestedSceneRef.current === value) return;
@@ -156,7 +161,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
156161

157162
useEffect(() => {
158163
if (
159-
!SHOWCASE_ENABLED ||
160164
requestedTheme === null ||
161165
themeApplied ||
162166
// Writing before stored preferences load would be overwritten by them.
@@ -168,7 +172,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
168172
}, [appearancePreferencesReady, requestedTheme, setThemeIdForBothAppearances, themeApplied]);
169173

170174
useEffect(() => {
171-
if (!SHOWCASE_ENABLED || pairingUrls.length === 0) return;
175+
if (pairingUrls.length === 0) return;
172176
let cancelled = false;
173177
void (async () => {
174178
await Promise.all(
@@ -201,7 +205,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
201205
const showcaseThread = threads.find((thread) => String(thread.id) === SHOWCASE_THREAD_ID);
202206

203207
useEffect(() => {
204-
if (!SHOWCASE_ENABLED || !hasServerFixture || pendingTasksReady) return;
208+
if (!hasServerFixture || pendingTasksReady) return;
205209

206210
const pendingTasks = buildShowcasePendingTasks(projects, Date.now());
207211
if (pendingTasks.length !== SHOWCASE_PENDING_TASK_DEFINITIONS.length) return;
@@ -232,7 +236,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
232236
}, [hasServerFixture, pendingTasksReady, projects]);
233237

234238
useEffect(() => {
235-
if (!SHOWCASE_ENABLED || requestedScene === null || !hasFixture || !showcaseThread) return;
239+
if (requestedScene === null || !hasFixture || !showcaseThread) return;
236240
if (scene === requestedScene) return;
237241

238242
const params = {
@@ -285,7 +289,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
285289
}, [hasFixture, navigation, requestedScene, scene, showcaseThread]);
286290

287291
useEffect(() => {
288-
if (!SHOWCASE_ENABLED || scene !== "agent-activity" || !hasFixture || agentActivityStaged) {
292+
if (scene !== "agent-activity" || !hasFixture || agentActivityStaged) {
289293
return;
290294
}
291295
let cancelled = false;
@@ -319,7 +323,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
319323

320324
useEffect(() => {
321325
if (
322-
!SHOWCASE_ENABLED ||
323326
scene === null ||
324327
requestedScene === null ||
325328
scene !== requestedScene ||
@@ -363,7 +366,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
363366
themeId,
364367
]);
365368

366-
if (!SHOWCASE_ENABLED || readyScene === null) return null;
369+
if (readyScene === null) return null;
367370

368371
return (
369372
<View

0 commit comments

Comments
 (0)