Skip to content
TypeScript

fix(mobile): every Android content pane gets its rounded card from ScreenContent (#30500)

Julius Marmingee68e19d60548
diff --git a/apps/mobile/src/components/ui/ScreenContent.tsx b/apps/mobile/src/components/ui/ScreenContent.tsx
index b526c7b6d3c..554f5d964d9 100644
--- a/apps/mobile/src/components/ui/ScreenContent.tsx
+++ b/apps/mobile/src/components/ui/ScreenContent.tsx
@@ -1,21 +1,46 @@
import type { ReactNode } from "react";
-import { Platform, View } from "react-native";
+import { Platform, View, type LayoutChangeEvent } from "react-native";
+const SURFACE_CLASS_NAMES = {
+ sheet: "bg-sheet-solid",
+ screen: "bg-screen",
+ canvas: "bg-thread-canvas",
+ drawer: "bg-drawer",
+} as const;
+
+/**
+ * The body below a screen's AppBar. On Android it is the rounded card every pane and sheet
+ * draws under its bar; a screen picks only the card's surface.
+ */
export function ScreenContent({
children,
+ surface = "sheet",
insetHorizontal = false,
fitToContents = false,
+ onLayout,
}: {
readonly children: ReactNode;
+ readonly surface?: keyof typeof SURFACE_CLASS_NAMES;
readonly insetHorizontal?: boolean;
readonly fitToContents?: boolean;
+ readonly onLayout?: (event: LayoutChangeEvent) => void;
}) {
- if (Platform.OS !== "android") return children;
+ if (Platform.OS !== "android") {
+ return onLayout ? (
+ <View className="flex-1" onLayout={onLayout}>
+ {children}
+ </View>
+ ) : (
+ children
+ );
+ }
return (
<View className={fitToContents ? "shrink bg-header" : "flex-1 bg-header"}>
<View
- className="overflow-hidden rounded-t-[28px] bg-sheet-solid"
+ className={`overflow-hidden rounded-t-[28px] ${SURFACE_CLASS_NAMES[surface]}`}
+ collapsable={false}
+ onLayout={onLayout}
style={{
flexShrink: 1,
flexGrow: fitToContents ? 0 : 1,
diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index 0883e819bd8..94e5327e45e 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -1,4 +1,5 @@
import { usePaneRole } from "../../components/ui/Pane";
+import { ScreenContent } from "../../components/ui/ScreenContent";
import { useActiveNewTask } from "../../state/active-new-task";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
@@ -672,45 +673,51 @@ export function HomeScreen(props: HomeScreenProps) {
if (!hasAnyThreads) {
return (
<View className={containerClassName}>
- <View
- className={cn(
- "flex-1 items-center justify-center px-8",
- contentBackground,
- Platform.OS === "android" && "overflow-hidden rounded-t-[28px]",
- )}
- style={{
- paddingBottom: Platform.OS === "ios" ? iosBottomClearance : Math.max(insets.bottom, 24),
- paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
- paddingLeft: 32 + (contentSideInsets?.left ?? 0),
- paddingRight: 32 + (contentSideInsets?.right ?? 0),
- }}
- >
- <View className="w-full max-w-[430px]">
- <EmptyState
- title={emptyState.title}
- detail={emptyState.detail}
- actionLabel={!props.catalogState.hasReadyEnvironment ? "Add environment" : undefined}
- onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
- action={
- Platform.OS === "android" && !props.catalogState.hasReadyEnvironment ? (
- <FloatingActionButton
- label="Add environment"
- icon="plus"
- variant="extended"
- tone="primary"
- onPress={props.onAddConnection}
- />
- ) : undefined
- }
- variant="plain"
- />
- {emptyState.loading ? (
- <View className="mt-4 items-center">
- <AppActivityIndicator colorClassName="accent-icon-muted" />
- </View>
- ) : null}
+ <ScreenContent surface={sidebarSurface ? "drawer" : "screen"}>
+ <View
+ className={cn(
+ "flex-1 items-center justify-center px-8",
+ Platform.OS !== "android" && contentBackground,
+ )}
+ style={{
+ paddingBottom:
+ Platform.OS === "ios" ? iosBottomClearance : Math.max(insets.bottom, 24),
+ paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
+ paddingLeft: 32 + (contentSideInsets?.left ?? 0),
+ paddingRight: 32 + (contentSideInsets?.right ?? 0),
+ }}
+ >
+ <View className="w-full max-w-[430px]">
+ <EmptyState
+ title={emptyState.title}
+ detail={emptyState.detail}
+ actionLabel={
+ !props.catalogState.hasReadyEnvironment ? "Add environment" : undefined
+ }
+ onAction={
+ !props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined
+ }
+ action={
+ Platform.OS === "android" && !props.catalogState.hasReadyEnvironment ? (
+ <FloatingActionButton
+ label="Add environment"
+ icon="plus"
+ variant="extended"
+ tone="primary"
+ onPress={props.onAddConnection}
+ />
+ ) : undefined
+ }
+ variant="plain"
+ />
+ {emptyState.loading ? (
+ <View className="mt-4 items-center">
+ <AppActivityIndicator colorClassName="accent-icon-muted" />
+ </View>
+ ) : null}
+ </View>
</View>
- </View>
+ </ScreenContent>
</View>
);
}
@@ -766,97 +773,93 @@ export function HomeScreen(props: HomeScreenProps) {
if (Platform.OS === "android" && threadListV2Items.length === 0) {
return (
- <View className="flex-1 bg-header">
+ <ScreenContent surface="screen">
<View
- className="flex-1 items-center justify-center overflow-hidden rounded-t-[28px] bg-screen px-4"
+ className="flex-1 items-center justify-center px-4"
style={{ paddingBottom: insets.bottom }}
>
{v2ListEmpty}
</View>
- </View>
+ </ScreenContent>
);
}
return (
<View className={containerClassName}>
- <View
- className={
- Platform.OS === "android"
- ? "flex-1 overflow-hidden rounded-t-[28px] bg-screen"
- : cn("flex-1", contentBackground)
- }
- >
- <SwipeableScrollGateProvider enabled={swipeEnabled} activation={swipeRowActivation}>
- <GestureDetector gesture={homeScrollGesture}>
- <AnimatedLegendList
- itemLayoutAnimation={sidebarSurface ? THREAD_SIDEBAR_ROW_LAYOUT : undefined}
- ref={listRef}
- onLoad={() => activateVisibleRows(threadListV2Items)}
- onTouchStart={(event) => trackListTouches(event, true)}
- onTouchEnd={(event) => trackListTouches(event, false)}
- onTouchCancel={(event) => trackListTouches(event, false)}
- renderScrollComponent={Platform.OS === "ios" ? renderHomeScrollView : undefined}
- data={threadListV2Items}
- renderItem={renderV2Item}
- keyExtractor={v2KeyExtractor}
- getItemType={(item) => item.type}
- itemsAreEqual={threadListV2ListItemsAreEqual}
- estimatedItemSize={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
- drawDistance={THREAD_LIST_V2_DRAW_DISTANCE}
- recycleItems
- extraData={v2ExtraData}
- ListHeaderComponent={v2ListHeader}
- ListFooterComponent={
- settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
- <ThreadListV2ShowMoreRow
- hiddenCount={threadListV2Layout.hiddenSettledCount}
- {...(olderSettledShelf.loading
- ? { state: "loading" as const }
- : olderSettledShelf.failed
- ? { state: "failed" as const }
- : {})}
- onPress={() => {
- olderSettledShelf.retry();
- showMoreSettled();
- }}
- />
- ) : null
- }
- ListEmptyComponent={v2ListEmpty}
- style={{ flex: 1 }}
- automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
- // UIKit owns the bar's inset, so a minimizing bar and a resized column move
- // the list in the same frame as the bar.
- contentInsetAdjustmentBehavior="automatic"
- contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
- // RN scrollTo clamps against raw insets and ignores the automatic bar inset.
- scrollToOverflowEnabled
- initialScrollOffset={
- initialScrollOffset > 0
- ? initialScrollOffset - (Platform.OS === "ios" ? insets.top : 0)
- : undefined
- }
- showsVerticalScrollIndicator={false}
- keyboardDismissMode="on-drag"
- keyboardShouldPersistTaps="handled"
- {...scrollGateHandlers}
- scrollEventThrottle={16}
- contentContainerStyle={{
- paddingLeft:
- (contentSideInsets?.left ?? 0) + (sidebarSurface ? 8 : 0) + androidListGutter,
- paddingRight:
- (contentSideInsets?.right ?? 0) + (sidebarSurface ? 8 : 0) + androidListGutter,
- paddingBottom:
- Platform.OS === "ios"
- ? iosBottomClearance - (columnMetrics?.safeArea.bottom ?? insets.bottom)
- : (workspace?.bottomClearance ??
- Math.max(insets.bottom, 16) +
- (Platform.OS === "android" ? fabClearance : 88)),
- }}
- />
- </GestureDetector>
- </SwipeableScrollGateProvider>
- </View>
+ <ScreenContent surface="screen">
+ <View className={cn("flex-1", Platform.OS !== "android" && contentBackground)}>
+ <SwipeableScrollGateProvider enabled={swipeEnabled} activation={swipeRowActivation}>
+ <GestureDetector gesture={homeScrollGesture}>
+ <AnimatedLegendList
+ itemLayoutAnimation={sidebarSurface ? THREAD_SIDEBAR_ROW_LAYOUT : undefined}
+ ref={listRef}
+ onLoad={() => activateVisibleRows(threadListV2Items)}
+ onTouchStart={(event) => trackListTouches(event, true)}
+ onTouchEnd={(event) => trackListTouches(event, false)}
+ onTouchCancel={(event) => trackListTouches(event, false)}
+ renderScrollComponent={Platform.OS === "ios" ? renderHomeScrollView : undefined}
+ data={threadListV2Items}
+ renderItem={renderV2Item}
+ keyExtractor={v2KeyExtractor}
+ getItemType={(item) => item.type}
+ itemsAreEqual={threadListV2ListItemsAreEqual}
+ estimatedItemSize={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
+ drawDistance={THREAD_LIST_V2_DRAW_DISTANCE}
+ recycleItems
+ extraData={v2ExtraData}
+ ListHeaderComponent={v2ListHeader}
+ ListFooterComponent={
+ settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
+ <ThreadListV2ShowMoreRow
+ hiddenCount={threadListV2Layout.hiddenSettledCount}
+ {...(olderSettledShelf.loading
+ ? { state: "loading" as const }
+ : olderSettledShelf.failed
+ ? { state: "failed" as const }
+ : {})}
+ onPress={() => {
+ olderSettledShelf.retry();
+ showMoreSettled();
+ }}
+ />
+ ) : null
+ }
+ ListEmptyComponent={v2ListEmpty}
+ style={{ flex: 1 }}
+ automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
+ // UIKit owns the bar's inset, so a minimizing bar and a resized column move
+ // the list in the same frame as the bar.
+ contentInsetAdjustmentBehavior="automatic"
+ contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
+ // RN scrollTo clamps against raw insets and ignores the automatic bar inset.
+ scrollToOverflowEnabled
+ initialScrollOffset={
+ initialScrollOffset > 0
+ ? initialScrollOffset - (Platform.OS === "ios" ? insets.top : 0)
+ : undefined
+ }
+ showsVerticalScrollIndicator={false}
+ keyboardDismissMode="on-drag"
+ keyboardShouldPersistTaps="handled"
+ {...scrollGateHandlers}
+ scrollEventThrottle={16}
+ contentContainerStyle={{
+ paddingLeft:
+ (contentSideInsets?.left ?? 0) + (sidebarSurface ? 8 : 0) + androidListGutter,
+ paddingRight:
+ (contentSideInsets?.right ?? 0) + (sidebarSurface ? 8 : 0) + androidListGutter,
+ paddingBottom:
+ Platform.OS === "ios"
+ ? iosBottomClearance - (columnMetrics?.safeArea.bottom ?? insets.bottom)
+ : (workspace?.bottomClearance ??
+ Math.max(insets.bottom, 16) +
+ (Platform.OS === "android" ? fabClearance : 88)),
+ }}
+ />
+ </GestureDetector>
+ </SwipeableScrollGateProvider>
+ </View>
+ </ScreenContent>
</View>
);
}
diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
index ed71919e736..7196929b8a8 100644
--- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
@@ -933,10 +933,11 @@ function AdaptiveWorkspaceLayoutContent(
// Android can resize the native row before React removes its split panes on a fold.
const androidSplit = Platform.OS === "android" && layout.usesSplitView;
// In the strip the column itself slides with the sidebar: Android only delivers touches inside a
- // parent's bounds, so content may not slide out of its column.
+ // parent's bounds, so content may not slide out of its column. Every branch sets every key:
+ // Reanimated keeps a key a branch drops, so a fold mid-slide would leave the column shifted.
const androidContentSlotStyle = useAnimatedStyle(() =>
!androidSplit
- ? { width: "100%" as const }
+ ? { width: "100%" as const, marginRight: 0, transform: [{ translateX: 0 }] }
: stripSidebar
? {
// Wide enough for the pane at either width; the margin gives the sidebar's share
@@ -948,7 +949,7 @@ function AdaptiveWorkspaceLayoutContent(
marginRight: -sidebarSlotWidth,
transform: [{ translateX: stripOffset.value }],
}
- : { width: renderedContentWidth.value },
+ : { width: renderedContentWidth.value, marginRight: 0, transform: [{ translateX: 0 }] },
);
// While the sidebar animates, clip the settled navigator instead of reflowing its text every frame.
// In the strip it lifts entirely: the content outgrows its column, and a cap that follows
diff --git a/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx b/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
index aa33effa936..7a7d717259c 100644
--- a/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
+++ b/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
@@ -5,6 +5,7 @@ import { AppText as Text } from "../../components/ui/AppText";
import { NewThreadButton } from "../../components/NewThreadButton";
import { FloatingActionButton } from "../../components/ui/FloatingActionButton";
import { EmptyState } from "../../components/ui/EmptyState";
+import { ScreenContent } from "../../components/ui/ScreenContent";
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
export function WorkspaceEmptyDetail(props: {
@@ -16,69 +17,71 @@ export function WorkspaceEmptyDetail(props: {
const settings = props.tab === "settings";
if (props.tab === "usage") return <View className="flex-1 bg-screen" />;
return (
- <View
- className={
- Platform.OS === "android"
- ? "flex-1 items-center justify-center px-10"
- : "flex-1 items-center justify-center bg-screen px-10"
- }
- >
- {props.onAddConnection ? (
- <View className="w-full max-w-[430px]">
- <EmptyState
- title="No environments connected"
- detail="Add an environment to load projects and start coding sessions."
- variant="plain"
- action={
- <FloatingActionButton
- label="Add environment"
- icon="plus"
- variant="extended"
- tone="primary"
- onPress={props.onAddConnection}
- />
- }
- />
- </View>
- ) : (
- <View className="max-w-[360px] items-center gap-3">
- <SymbolView
- name="sidebar.left"
- size={34}
- tintColorClassName="accent-icon-subtle"
- type="hierarchical"
- />
- <Text className="text-center text-xl font-t3-bold">
- {settings
- ? "Select a setting"
- : pullRequests
- ? "Select a pull request"
- : "Select a thread"}
- </Text>
- <Text className="text-center text-base text-foreground-muted">
- {settings
- ? "Choose a page from the sidebar."
- : pullRequests
- ? "Choose a pull request from the sidebar to review it."
- : Platform.OS === "android"
- ? "Choose a thread from the sidebar or start a new thread."
- : "Choose a thread from the sidebar or start a new task."}
- </Text>
- {props.onStartNewTask && !pullRequests && !settings ? (
- Platform.OS === "android" ? (
- <NewThreadButton extended className="mt-2" onPress={props.onStartNewTask} />
- ) : (
- <Pressable
- accessibilityRole="button"
- className="mt-2 flex-row items-center gap-2 rounded-full bg-primary px-5 py-3 active:opacity-70"
- onPress={props.onStartNewTask}
- >
- <Text className="text-base font-t3-bold text-primary-foreground">New thread</Text>
- </Pressable>
- )
- ) : null}
- </View>
- )}
- </View>
+ <ScreenContent surface="screen">
+ <View
+ className={
+ Platform.OS === "android"
+ ? "flex-1 items-center justify-center px-10"
+ : "flex-1 items-center justify-center bg-screen px-10"
+ }
+ >
+ {props.onAddConnection ? (
+ <View className="w-full max-w-[430px]">
+ <EmptyState
+ title="No environments connected"
+ detail="Add an environment to load projects and start coding sessions."
+ variant="plain"
+ action={
+ <FloatingActionButton
+ label="Add environment"
+ icon="plus"
+ variant="extended"
+ tone="primary"
+ onPress={props.onAddConnection}
+ />
+ }
+ />
+ </View>
+ ) : (
+ <View className="max-w-[360px] items-center gap-3">
+ <SymbolView
+ name="sidebar.left"
+ size={34}
+ tintColorClassName="accent-icon-subtle"
+ type="hierarchical"
+ />
+ <Text className="text-center text-xl font-t3-bold">
+ {settings
+ ? "Select a setting"
+ : pullRequests
+ ? "Select a pull request"
+ : "Select a thread"}
+ </Text>
+ <Text className="text-center text-base text-foreground-muted">
+ {settings
+ ? "Choose a page from the sidebar."
+ : pullRequests
+ ? "Choose a pull request from the sidebar to review it."
+ : Platform.OS === "android"
+ ? "Choose a thread from the sidebar or start a new thread."
+ : "Choose a thread from the sidebar or start a new task."}
+ </Text>
+ {props.onStartNewTask && !pullRequests && !settings ? (
+ Platform.OS === "android" ? (
+ <NewThreadButton extended className="mt-2" onPress={props.onStartNewTask} />
+ ) : (
+ <Pressable
+ accessibilityRole="button"
+ className="mt-2 flex-row items-center gap-2 rounded-full bg-primary px-5 py-3 active:opacity-70"
+ onPress={props.onStartNewTask}
+ >
+ <Text className="text-base font-t3-bold text-primary-foreground">New thread</Text>
+ </Pressable>
+ )
+ ) : null}
+ </View>
+ )}
+ </View>
+ </ScreenContent>
);
}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 7e5885ace10..15f823185a6 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -73,6 +73,7 @@ import { useAndroidWorkspaceBack } from "../workspace/useAndroidWorkspaceNavigat
import { EmptyState } from "../../components/ui/EmptyState";
import { SegmentedControl } from "../../components/ui/SegmentedControl";
import { SymbolView } from "../../components/ui/AppSymbol";
+import { ScreenContent } from "../../components/ui/ScreenContent";
import { RelativeTime } from "../../components/RelativeTime";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { usePullRequestConnected } from "./usePullRequestConnected";
@@ -695,16 +696,8 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
) : null}
</Toolbar.Menu>
</Toolbar>
- <View
- style={{
- flex: 1,
- marginHorizontal: Platform.OS === "android" && layout.usesSplitView ? 4 : 0,
- }}
- className={
- Platform.OS === "android"
- ? "overflow-hidden rounded-t-[28px] bg-sheet-solid"
- : undefined
- }
+ <ScreenContent
+ insetHorizontal={layout.usesSplitView}
onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
>
{(["overview", "guide", "activity"] as const)
@@ -926,7 +919,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
/>
</View>
))}
- </View>
+ </ScreenContent>
<PullRequestActionToolbar
pr={pr}
params={params}
@@ -1288,132 +1281,126 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
/>
</View>
) : null}
- <View
- className={
- Platform.OS === "android"
- ? "flex-1 overflow-hidden rounded-t-[28px] bg-sheet-solid"
- : "flex-1"
- }
- collapsable={false}
- style={{ marginHorizontal: Platform.OS === "android" && layout.usesSplitView ? 4 : 0 }}
- >
- {loadingDiff || result.error ? (
- <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
- <PullRequestReadStatus
- pending={loadingDiff}
- error={result.error}
- terminology={terminology}
- />
- </View>
- ) : null}
- {NativeDiffView && data.rows.length && !seekingFile ? (
- <View className="flex-1" collapsable={false}>
- <NativeDiffView
- {...pullRequestDiffInitialPosition(targetFile?.id, focusIndex)}
- nativeViewRef={nativeView}
- refreshing={result.refreshing}
- onPullToRefresh={result.onPullRefresh}
- style={StyleSheet.absoluteFill}
- rowsJson={bridge.rowsJson}
- themeJson={bridge.themeJson}
- styleJson={bridge.styleJson}
- tokensPatchJson={bridge.tokensPatchJson}
- tokensResetKey={bridge.tokensResetKey}
- collapsedFileIdsJson={bridge.collapsedFileIdsJson}
- onDebug={onDebug}
- viewedFileIdsJson={bridge.viewedFileIdsJson}
- selectedRowIdsJson={bridge.selectedRowIdsJson}
- onPressLine={(event) => {
- const rowId = event.nativeEvent.rowId ?? null;
- setSelectedRowId(rowId);
- if (event.nativeEvent.gesture !== "longPress") commentOnLine(rowId);
- }}
- onToggleViewedFile={(event) => {
- const file = data.files.find((file) => file.id === event.nativeEvent.fileId);
- if (!file || (!commit && !viewed.canToggle)) return;
- const wasViewed = commit
- ? commitViewedPaths.has(file.path)
- : viewed.isViewed(file.path);
- setCollapsedIds((ids) =>
- wasViewed
- ? ids.filter((id) => id !== file.id)
- : ids.includes(file.id)
- ? ids
- : [...ids, file.id],
- );
- if (commit)
- setCommitViewedPaths((current) => {
- const next = new Set(current);
- if (next.has(file.path)) next.delete(file.path);
- else next.add(file.path);
- return next;
- });
- else void viewed.toggle(file.path);
- }}
- onToggleComment={(event) => {
- const id = event.nativeEvent.commentId;
- if (id?.startsWith("discussion:"))
- navigation.navigate("PullRequestDiscussion", {
- ...route.params,
- discussionId: id.slice("discussion:".length),
- });
- if (id?.startsWith("draft:")) {
- const draft = reviewDraft.draft.comments.find(
- (draft) => draft.id === id.slice("draft:".length),
+ <ScreenContent insetHorizontal={layout.usesSplitView}>
+ <View className="flex-1" collapsable={false}>
+ {loadingDiff || result.error ? (
+ <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
+ <PullRequestReadStatus
+ pending={loadingDiff}
+ error={result.error}
+ terminology={terminology}
+ />
+ </View>
+ ) : null}
+ {NativeDiffView && data.rows.length && !seekingFile ? (
+ <View className="flex-1" collapsable={false}>
+ <NativeDiffView
+ {...pullRequestDiffInitialPosition(targetFile?.id, focusIndex)}
+ nativeViewRef={nativeView}
+ refreshing={result.refreshing}
+ onPullToRefresh={result.onPullRefresh}
+ style={StyleSheet.absoluteFill}
+ rowsJson={bridge.rowsJson}
+ themeJson={bridge.themeJson}
+ styleJson={bridge.styleJson}
+ tokensPatchJson={bridge.tokensPatchJson}
+ tokensResetKey={bridge.tokensResetKey}
+ collapsedFileIdsJson={bridge.collapsedFileIdsJson}
+ onDebug={onDebug}
+ viewedFileIdsJson={bridge.viewedFileIdsJson}
+ selectedRowIdsJson={bridge.selectedRowIdsJson}
+ onPressLine={(event) => {
+ const rowId = event.nativeEvent.rowId ?? null;
+ setSelectedRowId(rowId);
+ if (event.nativeEvent.gesture !== "longPress") commentOnLine(rowId);
+ }}
+ onToggleViewedFile={(event) => {
+ const file = data.files.find((file) => file.id === event.nativeEvent.fileId);
+ if (!file || (!commit && !viewed.canToggle)) return;
+ const wasViewed = commit
+ ? commitViewedPaths.has(file.path)
+ : viewed.isViewed(file.path);
+ setCollapsedIds((ids) =>
+ wasViewed
+ ? ids.filter((id) => id !== file.id)
+ : ids.includes(file.id)
+ ? ids
+ : [...ids, file.id],
);
- if (draft)
- navigation.navigate("PullRequestInlineComment", {
+ if (commit)
+ setCommitViewedPaths((current) => {
+ const next = new Set(current);
+ if (next.has(file.path)) next.delete(file.path);
+ else next.add(file.path);
+ return next;
+ });
+ else void viewed.toggle(file.path);
+ }}
+ onToggleComment={(event) => {
+ const id = event.nativeEvent.commentId;
+ if (id?.startsWith("discussion:"))
+ navigation.navigate("PullRequestDiscussion", {
...route.params,
- ...draft,
- draftId: draft.id,
+ discussionId: id.slice("discussion:".length),
});
- }
- }}
- onToggleFile={onToggleFile}
- onVisibleFileChange={(event) => setVisibleFileId(event.nativeEvent.fileId ?? null)}
- appearanceScheme={themeAppearance}
- rowHeight={nativeReviewDiffStyle.rowHeight}
- contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
- contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
- contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
- contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
- />
- </View>
- ) : filter.hiddenCount > 0 &&
- !data.rows.length &&
- !result.isPending &&
- !result.error &&
- !seekingFile ? (
- <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
+ if (id?.startsWith("draft:")) {
+ const draft = reviewDraft.draft.comments.find(
+ (draft) => draft.id === id.slice("draft:".length),
+ );
+ if (draft)
+ navigation.navigate("PullRequestInlineComment", {
+ ...route.params,
+ ...draft,
+ draftId: draft.id,
+ });
+ }
+ }}
+ onToggleFile={onToggleFile}
+ onVisibleFileChange={(event) => setVisibleFileId(event.nativeEvent.fileId ?? null)}
+ appearanceScheme={themeAppearance}
+ rowHeight={nativeReviewDiffStyle.rowHeight}
+ contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
+ contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
+ contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
+ contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
+ />
+ </View>
+ ) : filter.hiddenCount > 0 &&
+ !data.rows.length &&
+ !result.isPending &&
+ !result.error &&
+ !seekingFile ? (
+ <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
+ <EmptyState
+ title="Only test files changed"
+ detail="Test files are hidden from this review."
+ action={<Button label="Show test files" tone="contrast" onPress={filter.showAll} />}
+ variant="plain"
+ />
+ </View>
+ ) : !result.isPending && !result.error && !seekingFile ? (
<EmptyState
- title="Only test files changed"
- detail="Test files are hidden from this review."
- action={<Button label="Show test files" tone="contrast" onPress={filter.showAll} />}
+ title="Diff unavailable"
+ detail={`Open this ${terminology.singular} on its provider to view the changes.`}
variant="plain"
/>
- </View>
- ) : !result.isPending && !result.error && !seekingFile ? (
- <EmptyState
- title="Diff unavailable"
- detail={`Open this ${terminology.singular} on its provider to view the changes.`}
- variant="plain"
- />
- ) : null}
- {result.nextCursor && result.isPending && data.rows.length && !seekingFile ? (
- <View className="flex-row items-center justify-center gap-2 py-2">
- <AppActivityIndicator size="small" />
- <Text className="text-xs text-foreground-muted">Loading more files…</Text>
- </View>
- ) : null}
- {result.error && result.nextCursor ? (
- <View className="self-center">
- <Button label="Retry loading remaining files" tone="text" onPress={result.refresh} />
- </View>
- ) : null}
- {parsed.kind === "files" && parsed.notice ? (
- <Text className="px-4 py-2 text-2xs text-foreground-muted">{parsed.notice}</Text>
- ) : null}
- </View>
+ ) : null}
+ {result.nextCursor && result.isPending && data.rows.length && !seekingFile ? (
+ <View className="flex-row items-center justify-center gap-2 py-2">
+ <AppActivityIndicator size="small" />
+ <Text className="text-xs text-foreground-muted">Loading more files…</Text>
+ </View>
+ ) : null}
+ {result.error && result.nextCursor ? (
+ <View className="self-center">
+ <Button label="Retry loading remaining files" tone="text" onPress={result.refresh} />
+ </View>
+ ) : null}
+ {parsed.kind === "files" && parsed.notice ? (
+ <Text className="px-4 py-2 text-2xs text-foreground-muted">{parsed.notice}</Text>
+ ) : null}
+ </View>
+ </ScreenContent>
<PullRequestActionToolbar
pr={detail.data}
params={route.params}
diff --git a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
index 73e1ffa9358..b4fe58a5919 100644
--- a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
@@ -1,19 +1,16 @@
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/reactivity";
-import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AppBar } from "../../components/ui/AppBar";
-import { useSettingsPageBack } from "./useSettingsPageBack";
import { AppText as Text } from "../../components/ui/AppText";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import {
DEFAULT_COMPOSER_ENTER_BEHAVIOR,
type ComposerEnterBehavior,
} from "../../lib/composerEnterBehavior";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
+import { SettingsScreen } from "./components/SettingsScreen";
import { SettingsSection } from "./components/SettingsSection";
const ENTER_BEHAVIOR_OPTIONS: ReadonlyArray<{
@@ -34,7 +31,6 @@ const ENTER_BEHAVIOR_OPTIONS: ReadonlyArray<{
];
export function SettingsKeyboardRouteScreen() {
- const back = useSettingsPageBack();
const insets = useSafeAreaInsets();
const preferencesResult = useAtomValue(mobilePreferencesAtom);
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
@@ -44,13 +40,7 @@ export function SettingsKeyboardRouteScreen() {
: null;
return (
- <View collapsable={false} className="flex-1 bg-sheet">
- {Platform.OS === "android" ? (
- <>
- <NativeStackScreenOptions options={{ headerShown: false }} />
- <AppBar embedded title="Keyboard" onBack={back} />
- </>
- ) : null}
+ <SettingsScreen title="Keyboard">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
@@ -75,6 +65,6 @@ export function SettingsKeyboardRouteScreen() {
Applies to the composer when a hardware keyboard is connected.
</Text>
</ScrollView>
- </View>
+ </SettingsScreen>
);
}
diff --git a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
index be236d80cce..e911ca7b43d 100644
--- a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
@@ -22,6 +22,7 @@ import { ListRowLayout } from "../../components/ui/ListRowLayout";
import { ThreadSwipeable } from "../home/thread-swipe-actions";
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
import { SettingsDragHandle } from "./components/SettingsDragHandle";
+import { SettingsScreen } from "./components/SettingsScreen";
import { SettingsSection } from "./components/SettingsSection";
import {
deviceMicrophoneOrder,
@@ -102,14 +103,14 @@ const UNAVAILABLE_EXPLANATION =
export function SettingsMicrophoneRouteScreen() {
const transcriber = useAtomValue(localVoiceTranscriberAtom);
// Android's probe is asynchronous; an empty sheet avoids flashing "unavailable" first.
- if (transcriber === "checking") return <View collapsable={false} className="flex-1 bg-sheet" />;
+ if (transcriber === "checking") return <SettingsScreen title="Microphone">{null}</SettingsScreen>;
return transcriber === null ? <VoiceInputUnavailable /> : <MicrophoneSettings />;
}
function VoiceInputUnavailable() {
const insets = useSafeAreaInsets();
return (
- <View collapsable={false} className="flex-1 bg-sheet">
+ <SettingsScreen title="Microphone">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
@@ -122,7 +123,7 @@ function VoiceInputUnavailable() {
</SettingsSection>
<Text className="px-2 text-sm text-foreground-muted">{UNAVAILABLE_EXPLANATION}</Text>
</ScrollView>
- </View>
+ </SettingsScreen>
);
}
@@ -174,7 +175,7 @@ function MicrophoneSettings() {
const dragTo = drag === null ? -1 : dragFrom + dropSteps(dragFrom, drag.translation);
return (
- <View collapsable={false} className="flex-1 bg-sheet">
+ <SettingsScreen title="Microphone">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
@@ -243,7 +244,7 @@ function MicrophoneSettings() {
: null}
</Text>
</ScrollView>
- </View>
+ </SettingsScreen>
);
}
diff --git a/apps/mobile/src/features/threads/ThreadScreenHost.tsx b/apps/mobile/src/features/threads/ThreadScreenHost.tsx
index 46626eea071..ff94ad39bd5 100644
--- a/apps/mobile/src/features/threads/ThreadScreenHost.tsx
+++ b/apps/mobile/src/features/threads/ThreadScreenHost.tsx
@@ -6,7 +6,9 @@ import {
useSyncExternalStore,
type ReactNode,
} from "react";
-import { Platform, View } from "react-native";
+import { View } from "react-native";
+
+import { ScreenContent } from "../../components/ui/ScreenContent";
import { ThreadDetailScreen, type ThreadDetailScreenProps } from "./ThreadDetailScreen";
type ThreadScreenContent =
@@ -40,11 +42,7 @@ function ThreadScreenOutlet() {
return (
<>
{"props" in content ? content.props.header : content.header}
- {Platform.OS === "android" ? (
- <View className="flex-1 overflow-hidden rounded-t-[28px] bg-thread-canvas">{body}</View>
- ) : (
- body
- )}
+ <ScreenContent surface="canvas">{body}</ScreenContent>
</>
);
}
diff --git a/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx b/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
index ca27287dcf7..ec7a3bb8dcf 100644
--- a/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
@@ -8,7 +8,7 @@ import { View } from "react-native";
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { AppBar } from "../../components/ui/AppBar";
-import { EmptyState } from "../../components/ui/EmptyState";
+import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
import { HomeRouteScreen } from "../home/HomeRouteScreen";
@@ -89,13 +89,7 @@ function WorkspaceRoot() {
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AppBar embedded title="Pull requests" />
- <View className="flex-1 items-center justify-center px-10">
- <EmptyState
- title="Select a pull request"
- detail="Choose a pull request from the sidebar to review it."
- variant="plain"
- />
- </View>
+ <WorkspaceEmptyDetail tab="pullRequests" />
</>
) : (
<PullRequestsScreen
diff --git a/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts b/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
index 2838de7543d..06d4a49e05f 100644
--- a/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
+++ b/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
@@ -213,7 +213,7 @@ vi.mock("./WorkspaceExtraTab", () => ({
}));
vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
-vi.mock("../../components/ui/EmptyState", () => ({ EmptyState: () => null }));
+vi.mock("../layout/WorkspaceEmptyDetail", () => ({ WorkspaceEmptyDetail: () => null }));
vi.mock("../../components/ui/ScreenContent", () => ({
ScreenContent: ({ children }: { children: ReactNode }) => createElement("div", null, children),
}));