Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -319,7 +323,6 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })

useEffect(() => {
if (
!SHOWCASE_ENABLED ||
scene === null ||
requestedScene === null ||
scene !== requestedScene ||
Expand Down Expand Up @@ -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
Expand Down
Loading