Skip to content
TypeScript

refactor(mobile): adopt shared loading indicators across screens (#20001)

Julius Marmingef3280793fa50
diff --git a/apps/mobile/src/components/AndroidScreenHeader.tsx b/apps/mobile/src/components/AndroidScreenHeader.tsx
index a64484e123f..cf803d034e2 100644
--- a/apps/mobile/src/components/AndroidScreenHeader.tsx
+++ b/apps/mobile/src/components/AndroidScreenHeader.tsx
@@ -1,6 +1,7 @@
+import { AppActivityIndicator } from "./AppActivityIndicator";
import { Column, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
import { useState, type ReactNode } from "react";
-import { ActivityIndicator, View } from "react-native";
+import { View } from "react-native";
import type { AppSymbolName } from "./AppSymbol";
import { NativeAppBar } from "./NativeAppBar.android";
@@ -127,7 +128,7 @@ export function AndroidScreenHeader(props: {
accessibilityLabel={action.accessibilityLabel}
className="size-12 items-center justify-center"
>
- <ActivityIndicator colorClassName="accent-header-foreground" />
+ <AppActivityIndicator colorClassName="accent-header-foreground" />
</View>
) : (
<AndroidHeaderIconButton
diff --git a/apps/mobile/src/components/AppBar.tsx b/apps/mobile/src/components/AppBar.tsx
index 185a91ea272..36a3659098c 100644
--- a/apps/mobile/src/components/AppBar.tsx
+++ b/apps/mobile/src/components/AppBar.tsx
@@ -1,6 +1,7 @@
+import { AppActivityIndicator } from "./AppActivityIndicator";
import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";
import { useId } from "react";
-import { ActivityIndicator, Platform, View } from "react-native";
+import { Platform, View } from "react-native";
import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";
import { ScreenHeaderButton } from "./ScreenHeaderButton";
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../native/StackHeader";
@@ -155,7 +156,7 @@ export function AppBar(props: AppBarProps) {
accessibilityLabel={action.accessibilityLabel}
className="size-9 items-center justify-center"
>
- <ActivityIndicator color={action.tintColor} />
+ <AppActivityIndicator color={action.tintColor} />
</View>
</NativeHeaderToolbar.Custom>
) : (
diff --git a/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx b/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx
index a18b97c024d..97571294857 100644
--- a/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx
+++ b/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import * as Dialog from "../../components/Dialog";
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
@@ -9,7 +10,7 @@ import {
} from "@t3tools/contracts";
import { normalizePreviewUrl } from "@t3tools/shared/preview";
import { useCallback, useEffect, useRef, useState } from "react";
-import { ActivityIndicator, AppState, Platform, TextInput, View } from "react-native";
+import { AppState, Platform, TextInput, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { ControlPill } from "../../components/ControlPill";
@@ -197,7 +198,7 @@ function BrowserPreviewScreen({
) : (
<View className="flex-1 items-center justify-center">
{focused && foreground ? (
- <ActivityIndicator color={themeVariables["--color-icon"]} />
+ <AppActivityIndicator color={themeVariables["--color-icon"]} />
) : null}
</View>
)}
diff --git a/apps/mobile/src/features/browser/PreviewStreamWebView.tsx b/apps/mobile/src/features/browser/PreviewStreamWebView.tsx
index 83f48be9d35..855378ecb08 100644
--- a/apps/mobile/src/features/browser/PreviewStreamWebView.tsx
+++ b/apps/mobile/src/features/browser/PreviewStreamWebView.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import * as Dialog from "../../components/Dialog";
import previewStreamScript from "@t3tools/mobile-preview-stream";
import {
@@ -19,7 +20,7 @@ import {
useState,
type Ref,
} from "react";
-import { ActivityIndicator, Platform, Pressable, TextInput, View } from "react-native";
+import { Platform, Pressable, TextInput, View } from "react-native";
import { WebView } from "react-native-webview";
import * as Clipboard from "expo-clipboard";
@@ -134,7 +135,7 @@ export function PreviewStreamWebView(
: "flex-1 items-center justify-center gap-4 px-6"
}
>
- {props.compact || !error ? <ActivityIndicator colorClassName="accent-icon" /> : null}
+ {props.compact || !error ? <AppActivityIndicator colorClassName="accent-icon" /> : null}
{!props.compact && (
<>
<AppText
@@ -502,7 +503,7 @@ function PreviewStreamDocumentView({
className="absolute inset-0 items-center justify-center gap-4 px-6"
style={{ backgroundColor: background }}
>
- {status === "connecting" ? <ActivityIndicator colorClassName="accent-icon" /> : null}
+ {status === "connecting" ? <AppActivityIndicator colorClassName="accent-icon" /> : null}
{compact ? null : (
<AppText
accessibilityLiveRegion="polite"
diff --git a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
index 25ff1f09d52..1c6761c883a 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
@@ -1,9 +1,10 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { useAtomRefresh } from "@effect/atom-react";
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import type { PullRequestThreadComment } from "@t3tools/contracts";
import { useRef, useState } from "react";
-import { ActivityIndicator, Platform, ScrollView, View } from "react-native";
+import { Platform, ScrollView, View } from "react-native";
import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -163,7 +164,7 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
paddingBottom: canReply ? composerHeight + bottomInset + 24 : 24,
}}
>
- {activity.isPending && !thread ? <ActivityIndicator /> : null}
+ {activity.isPending && !thread ? <AppActivityIndicator /> : null}
{thread ? (
<View className="gap-2 pb-4">
<Text selectable className="font-mono text-xs text-foreground-muted">
diff --git a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
index cd4ab7dfb94..fec601e88f5 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
@@ -1,10 +1,11 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
import { AnimatedLegendList } from "@legendapp/list/reanimated";
import Animated from "react-native-reanimated";
import { PR_ROW_LAYOUT, PR_ROW_ENTER, PR_ROW_EXIT } from "./pullRequestAnimations";
import { useNavigation } from "@react-navigation/native";
import { useState } from "react";
-import { ActivityIndicator, Pressable, View } from "react-native";
+import { Pressable, View } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { EmptyState } from "../../components/EmptyState";
import { Menu } from "../../components/Menu";
@@ -261,7 +262,7 @@ export function usePullRequestFilesContent(props: {
className="min-h-11 items-center justify-center rounded-xl bg-grouped-card px-4 py-3"
>
{result.isPending ? (
- <ActivityIndicator />
+ <AppActivityIndicator />
) : (
<Text className="text-sm font-t3-medium">
{result.error ? "Retry loading files" : "Load more files"}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx b/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
index 399b9c311f5..aa3bd40c3b6 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
@@ -1,10 +1,11 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import * as Dialog from "../../components/Dialog";
import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react";
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import type { PullRequestDetail, PullRequestMergeMethod } from "@t3tools/contracts";
import { AsyncResult } from "effect/reactivity";
import { useRef, useState } from "react";
-import { ActivityIndicator, Platform, Pressable, View } from "react-native";
+import { Platform, Pressable, View } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { SymbolView } from "../../components/AppSymbol";
import { Menu } from "../../components/Menu";
@@ -196,7 +197,7 @@ export function PullRequestMergeControls(props: {
className="min-h-11 min-w-0 flex-1 flex-row items-center justify-center gap-2 px-3 py-2 active:opacity-70"
>
{busy || checkingStack ? (
- <ActivityIndicator size="small" colorClassName="accent-icon-muted" />
+ <AppActivityIndicator size="small" colorClassName="accent-icon-muted" />
) : (
<SymbolView
name="arrow.triangle.merge"
diff --git a/apps/mobile/src/features/pull-requests/PullRequestPresentation.tsx b/apps/mobile/src/features/pull-requests/PullRequestPresentation.tsx
index 7ccb91a6035..f863ad49718 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestPresentation.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestPresentation.tsx
@@ -1,6 +1,7 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import type { PullRequestActor } from "@t3tools/contracts";
import { Image } from "expo-image";
-import { ActivityIndicator, View } from "react-native";
+import { View } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { cn } from "../../lib/cn";
@@ -11,7 +12,7 @@ export function PullRequestReadStatus(props: {
readonly error: string | null;
}) {
return props.pending ? (
- <ActivityIndicator className="my-12" colorClassName="accent-icon" />
+ <AppActivityIndicator className="my-12" colorClassName="accent-icon" />
) : props.error ? (
<EmptyState title="Couldn't load this pull request" detail={props.error} variant="plain" />
) : null;
diff --git a/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
index 06a99791ae8..5badb635769 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { usePullRequestConnected } from "./usePullRequestConnected";
import { useAtomValue } from "@effect/atom-react";
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
@@ -5,7 +6,6 @@ import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"
import type { PullRequestReviewerCandidate } from "@t3tools/contracts";
import { useEffect, useMemo, useRef, useState } from "react";
import {
- ActivityIndicator,
FlatList,
Platform,
Pressable,
@@ -231,7 +231,7 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
</Text>
</View>
{pending === id ? (
- <ActivityIndicator />
+ <AppActivityIndicator />
) : item.isRequested ? (
<View className="flex-row items-center gap-1.5">
<Text className="text-xs text-foreground-muted">Requested</Text>
@@ -245,7 +245,7 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
}}
ListEmptyComponent={
result.isPending && !result.data ? (
- <ActivityIndicator className="my-8" />
+ <AppActivityIndicator className="my-8" />
) : (
<View className="px-4 py-6">
<EmptyState
@@ -281,7 +281,7 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
>
{!pr ? (
detail.isPending ? (
- <ActivityIndicator />
+ <AppActivityIndicator />
) : (
<Text className="text-danger-foreground">
{detail.error ?? "Couldn't load this pull request."}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 88b7e52ce82..01083ba211f 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { Chip } from "../../components/Chip";
import { pullRequestTabOffset } from "./pullRequestTabScroll";
import { guideFocusedRows, type GuideDiffFocus } from "./guide/guideDiffFocus";
@@ -49,7 +50,6 @@ import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
import { pullRequestStatus } from "./pullRequestStatus";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
- ActivityIndicator,
Linking,
Platform,
Pressable,
@@ -1208,7 +1208,7 @@ export function PullRequestFileRouteScreen({
) : null}
{result.nextCursor && result.isPending && data.rows.length && !seekingFile ? (
<View className="flex-row items-center justify-center gap-2 py-2">
- <ActivityIndicator size="small" />
+ <AppActivityIndicator size="small" />
<Text className="text-xs text-foreground-muted">Loading more files…</Text>
</View>
) : null}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
index d6d55ef563b..6ce2ade103c 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
@@ -1,10 +1,10 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
import { useNavigation } from "@react-navigation/native";
import { use, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { ProjectId } from "@t3tools/contracts";
import { useAtomValue } from "@effect/atom-react";
import {
- ActivityIndicator,
Keyboard,
Platform,
Pressable,
@@ -317,7 +317,7 @@ export function PullRequestsScreen(
ListFooterComponent={
result.loadingMore ? (
<View className="items-center py-5">
- <ActivityIndicator
+ <AppActivityIndicator
colorClassName="accent-icon"
accessibilityLabel="Loading more pull requests"
/>
@@ -337,7 +337,7 @@ export function PullRequestsScreen(
ListEmptyComponent={
result.isPending && connectedTargets.length > 0 ? (
<View className="items-center py-12">
- <ActivityIndicator colorClassName="accent-icon" />
+ <AppActivityIndicator colorClassName="accent-icon" />
</View>
) : (
<View className="px-8 py-12">
diff --git a/apps/mobile/src/features/threads/HtmlRenderWebView.tsx b/apps/mobile/src/features/threads/HtmlRenderWebView.tsx
index 2a8b9fdb883..8c7a316cf62 100644
--- a/apps/mobile/src/features/threads/HtmlRenderWebView.tsx
+++ b/apps/mobile/src/features/threads/HtmlRenderWebView.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { useNavigation } from "@react-navigation/native";
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import {
@@ -9,7 +10,7 @@ import {
type HtmlRenderTheme,
} from "@t3tools/shared/htmlRender";
import { useEffect, useMemo, useRef, useState } from "react";
-import { ActivityIndicator, Platform, Pressable, View, type ColorValue } from "react-native";
+import { Platform, Pressable, View, type ColorValue } from "react-native";
import { WebView, type WebViewMessageEvent } from "react-native-webview";
import { SymbolView } from "../../components/AppSymbol";
@@ -184,7 +185,7 @@ export function HtmlRenderWebView(props: {
/>
{loaded ? null : (
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
- <ActivityIndicator />
+ <AppActivityIndicator />
</View>
)}
</View>
@@ -263,7 +264,7 @@ export function ThreadHtmlRender(props: {
</Pressable>
) : (
<View className="flex-1 items-center justify-center">
- <ActivityIndicator />
+ <AppActivityIndicator />
</View>
)}
{uri !== null && !failed ? (
diff --git a/apps/mobile/src/features/threads/McpAppWebView.tsx b/apps/mobile/src/features/threads/McpAppWebView.tsx
index 17b916610c6..6ae84af9880 100644
--- a/apps/mobile/src/features/threads/McpAppWebView.tsx
+++ b/apps/mobile/src/features/threads/McpAppWebView.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import * as Dialog from "../../components/Dialog";
import type { EnvironmentId, ThreadId, TurnItemId } from "@t3tools/contracts";
import {
@@ -22,7 +23,7 @@ import * as Predicate from "effect/Predicate";
import Constants from "expo-constants";
import { useNavigation } from "@react-navigation/native";
import { useEffect, useMemo, useRef, useState } from "react";
-import { ActivityIndicator, Platform, Pressable, View } from "react-native";
+import { Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { WebView, type WebViewMessageEvent } from "react-native-webview";
@@ -605,7 +606,7 @@ export function ThreadMcpApp(props: {
) : null}
{uri !== null && !loaded && !crashed && !navigatedAway ? (
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
- <ActivityIndicator />
+ <AppActivityIndicator />
</View>
) : null}
</View>
diff --git a/apps/mobile/src/features/usage/UsageRouteScreen.tsx b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
index 2ee0eb8e61d..3c2dd9e23be 100644
--- a/apps/mobile/src/features/usage/UsageRouteScreen.tsx
+++ b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
@@ -1,3 +1,4 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { ChatGptUsageSummary } from "./ChatGptUsageSummary";
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { EnvironmentId, USAGE_CONTRACT_VERSION, type UsageProviderKind } from "@t3tools/contracts";
@@ -27,7 +28,7 @@ import {
makeWindow,
} from "@t3tools/shared/usageFormat";
import { useCallback, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
-import { ActivityIndicator, Platform, Pressable, RefreshControl, View } from "react-native";
+import { Platform, Pressable, RefreshControl, View } from "react-native";
import Animated, {
FadeIn,
ReduceMotion,
@@ -430,7 +431,7 @@ function UsageUpdating({
pointerEvents="none"
className="absolute right-4 top-4 h-5 max-w-[55%] flex-row items-center gap-1.5"
>
- <ActivityIndicator size="small" colorClassName="accent-adaptive-sky-600-400" />
+ <AppActivityIndicator size="small" colorClassName="accent-adaptive-sky-600-400" />
<Text className="shrink text-sm text-adaptive-sky-600-400" numberOfLines={1}>
{label}
</Text>
diff --git a/apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx b/apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx
index e08afc06a15..72c218b807b 100644
--- a/apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx
+++ b/apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx
@@ -1,12 +1,6 @@
+import { AppActivityIndicator } from "../../components/AppActivityIndicator";
import { useEffect, useRef, useState, type ReactNode, type RefObject } from "react";
-import {
- ActivityIndicator,
- Linking,
- Platform,
- Pressable,
- useWindowDimensions,
- View,
-} from "react-native";
+import { Linking, Platform, Pressable, useWindowDimensions, View } from "react-native";
import Animated, {
Easing,
Extrapolation,
@@ -154,7 +148,7 @@ function EdgeDictationPill(props: { readonly collapseRef: RefObject<(() => void)
/>
</>
) : (
- <ActivityIndicator size="small" colorClassName="accent-icon-muted" />
+ <AppActivityIndicator size="small" colorClassName="accent-icon-muted" />
)}
</Pressable>
</Animated.View>
@@ -243,7 +237,7 @@ function EdgeDictationPill(props: { readonly collapseRef: RefObject<(() => void)
accessibilityLabel={presentation.statusLabel ?? undefined}
className="size-[30px] items-center justify-center"
>
- <ActivityIndicator size="small" colorClassName="accent-icon-muted" />
+ <AppActivityIndicator size="small" colorClassName="accent-icon-muted" />
</View>
)}
</Animated.View>