TypeScript
fix(mobile): use native sheet headers and toolbar filters (#22390)
Julius Marmingebe5a5cd01cb0
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsxindex 16abe358e91..5589ad38235 100644--- a/apps/mobile/src/Stack.tsx+++ b/apps/mobile/src/Stack.tsx@@ -39,8 +39,8 @@ import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorkspimport {PullRequestRouteScreen,PullRequestFileRouteScreen,- PullRequestFilesRouteScreen,} from "./features/pull-requests/PullRequestRouteScreen";+import { PullRequestFilesSheet } from "./features/pull-requests/PullRequestFiles";import { PullRequestReviewSheet } from "./features/pull-requests/PullRequestReviewSheet";import { PullRequestReviewersScreen } from "./features/pull-requests/PullRequestReviewersScreen";import {@@ -729,12 +729,13 @@ const RootStackConfig = createWorkspaceStackNavigator({options: DETAIL_HEADER_OPTIONS,}),PullRequestFiles: createNativeStackScreen({- screen: PullRequestFilesRouteScreen,+ screen: PullRequestFilesSheet,options: {+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),...FORM_SHEET_PRESENTATION_OPTIONS,sheetAllowedDetents: [0.6, 0.92],sheetGrabberVisible: true,- headerShown: false,+ sheetCornerRadius: Platform.OS === "android" ? 28 : undefined,},}),PullRequestReviewers: createNativeStackScreen({@@ -756,19 +757,18 @@ const RootStackConfig = createWorkspaceStackNavigator({options: {...(Platform.OS === "android"? { presentation: "fullScreenModal" as const }- : FORM_SHEET_PRESENTATION_OPTIONS),+ : { ...SHEET_GLASS_HEADER_OPTIONS, ...FORM_SHEET_PRESENTATION_OPTIONS }),sheetAllowedDetents: Platform.OS === "android" ? undefined : [0.75, 0.92],sheetGrabberVisible: Platform.OS !== "android",- headerShown: false,},}),PullRequestReview: createNativeStackScreen({screen: PullRequestReviewSheet,options: {+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),...FORM_SHEET_PRESENTATION_OPTIONS,sheetAllowedDetents: [0.75, 0.92],sheetGrabberVisible: true,- headerShown: false,},}),Thread: createNativeStackScreen({@@ -900,6 +900,7 @@ const RootStackConfig = createWorkspaceStackNavigator({screen: GitCommitSheet,linking: `${THREAD_LINKING_PREFIX}/git/commit`,options: {+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),...FORM_SHEET_PRESENTATION_OPTIONS,sheetAllowedDetents: [0.8, 0.92],sheetGrabberVisible: true,diff --git a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsxindex f9d262e0f2d..ed63aba5b7c 100644--- a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx@@ -1,28 +1,39 @@-import type { PullRequestChangeBreakdown } from "@t3tools/contracts";-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 {+ StackActions,+ useNavigation,+ useRoute,+ type StaticScreenProps,+} from "@react-navigation/native";+import type { PullRequestChangeBreakdown } from "@t3tools/contracts";import { useState } from "react";-import { Pressable, View } from "react-native";+import { Platform, View } from "react-native";+import Animated from "react-native-reanimated";+import { PierreEntryIcon } from "../../components/PierreEntryIcon";import { AppText as Text } from "../../components/ui/AppText";-import { EmptyState } from "../../components/ui/EmptyState";-import { Menu } from "../../components/ui/Menu";+import { SymbolView } from "../../components/ui/AppSymbol";import { Button } from "../../components/ui/Button";+import { EmptyState } from "../../components/ui/EmptyState";import { IconButton } from "../../components/ui/IconButton";-import { SymbolView } from "../../components/ui/AppSymbol";-import { PierreEntryIcon } from "../../components/PierreEntryIcon";+import { Menu } from "../../components/ui/Menu";+import { RowPressable } from "../../components/ui/RowPressable";+import { ScreenContent } from "../../components/ui/ScreenContent";+import { SheetHeader } from "../../components/ui/SheetHeader";+import { Toolbar } from "../../components/ui/Toolbar";import { composerPullRequests } from "../../state/pull-requests";import { useEnvironmentQuery } from "../../state/query";+import type { ReviewParsedDiff, ReviewRenderableFile } from "../review/reviewModel";+import { PR_ROW_ENTER, PR_ROW_EXIT, PR_ROW_LAYOUT } from "./pullRequestAnimations";import { PullRequestDiffStats, PullRequestReadStatus } from "./PullRequestPresentation";+import { PullRequestSectionHeading } from "./PullRequestSectionHeading";import {- pullRequestTarget as requestTarget,+ pullRequestTarget,usePullRequestDiff,type PullRequestDiffParams,+ type PullRequestParams,} from "./usePullRequestDiff";-import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";import { usePullRequestFileFilter } from "./usePullRequestFileFilter";+import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";const BREAKDOWN_LABELS = {code: "Code",@@ -32,7 +43,189 @@ const BREAKDOWN_LABELS = {docs: "Docs",} satisfies Record<keyof NonNullable<PullRequestChangeBreakdown>, string>;-function PullRequestChangeBreakdownLine(props: {+function fileDirectory(path: string) {+ const separator = path.lastIndexOf("/");+ return separator < 0 ? "" : path.slice(0, separator);+}++function useChangedFiles(params: PullRequestDiffParams) {+ const diff = usePullRequestDiff(params);+ const detail = useEnvironmentQuery(composerPullRequests.detail(pullRequestTarget(params)));+ // A commit's diff is part of the pull request, so the PR's file counts and viewed state don't apply.+ const pr = params.commit ? null : detail.data;+ const viewed = usePullRequestFilesViewed(params, pr);+ const filter = usePullRequestFileFilter(diff.parsed);+ const parsed = filter.parsed;+ return {+ diff,+ filter,+ viewed,+ pr,+ parsed,+ loading: diff.isPending && parsed.kind === "empty" && !diff.error,+ };+}++type ChangedFiles = ReturnType<typeof useChangedFiles>;++function loadingRowCount(files: ChangedFiles) {+ return Math.min(files.pr?.changedFiles ?? 4, 6);+}++function describeFiles(+ parsed: Extract<ReviewParsedDiff, { readonly kind: "files" }>,+ { filter, viewed }: ChangedFiles,+) {+ const noun = (count: number) => (count === 1 ? "file" : "files");+ return [+ `${parsed.fileCount} ${filter.hiddenCount ? "visible" : "changed"} ${noun(parsed.fileCount)}`,+ viewed.supported+ ? `${parsed.files.filter((file) => viewed.isViewed(file.path)).length} viewed`+ : null,+ filter.hideTestFiles+ ? `${filter.hiddenCount} test ${noun(filter.hiddenCount)} hidden`+ : "Test files included",+ ]+ .filter(Boolean)+ .join(" · ");+}++function FileRow(props: {+ readonly file: ReviewRenderableFile;+ readonly viewed: boolean;+ /** Shown under the file name where files aren't grouped by directory. */+ readonly directory?: string;+ readonly onPress: () => void;+}) {+ const { file } = props;+ return (+ <RowPressable+ accessibilityRole="button"+ accessibilityLabel={`View diff for ${file.path}, ${file.additions} additions, ${file.deletions} deletions${props.viewed ? ", viewed" : ""}`}+ onPress={props.onPress}+ className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3 active:opacity-70"+ >+ <PierreEntryIcon kind="file" path={file.path} size={20} />+ <View className="min-w-0 flex-1 gap-0.5">+ <Text textRole="footnote" className="font-t3-medium" numberOfLines={2}>+ {file.path.split("/").at(-1)}+ </Text>+ {props.directory ? (+ <Text textRole="caption" className="text-foreground-muted" numberOfLines={1}>+ {props.directory}+ </Text>+ ) : null}+ {file.previousPath ? (+ <Text textRole="caption" className="text-foreground-muted" numberOfLines={1}>+ Renamed from {file.previousPath}+ </Text>+ ) : null}+ </View>+ <PullRequestDiffStats additions={file.additions} deletions={file.deletions} compact />+ {props.viewed ? (+ <SymbolView+ name="checkmark.circle.fill"+ size={18}+ tintColorClassName="accent-adaptive-emerald-600-400"+ />+ ) : null}+ <SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />+ </RowPressable>+ );+}++function FileRowSkeleton(props: { readonly index: number }) {+ return (+ <View+ accessible={false}+ importantForAccessibility="no-hide-descendants"+ className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3"+ >+ <View className="size-5 rounded-md bg-subtle-strong" />+ <View className="flex-1 gap-2">+ <View+ className="h-3.5 rounded bg-subtle-strong"+ style={{ width: props.index % 2 ? "65%" : "80%" }}+ />+ <View className="h-2.5 w-2/5 rounded bg-subtle-strong" />+ </View>+ <View className="h-3 w-7 rounded bg-subtle-strong" />+ </View>+ );+}++function FileFilterMenu({ filter }: { readonly filter: ChangedFiles["filter"] }) {+ return (+ <Menu+ title="Review files"+ actions={[+ {+ id: "hide-tests",+ title: "Hide test files",+ image: "line.3.horizontal.decrease",+ state: filter.hideTestFiles ? "on" : "off",+ },+ ]}+ onPressAction={filter.toggle}+ >+ <View pointerEvents="none">+ <IconButton+ icon="line.3.horizontal.decrease"+ accessibilityLabel="Filter review files"+ selected={filter.hideTestFiles}+ />+ </View>+ </Menu>+ );+}++function NoVisibleFiles({ files }: { readonly files: ChangedFiles }) {+ const { diff, filter, parsed } = files;+ if (parsed.kind === "files") {+ return parsed.files.length === 0 && filter.hiddenCount > 0 ? (+ <EmptyState+ title={diff.nextCursor ? "No non-test files loaded yet" : "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"+ />+ ) : null;+ }+ return !diff.isPending && !diff.error ? (+ <Text textRole="footnote" className="py-6 text-foreground-muted">+ No text changes available.+ </Text>+ ) : null;+}++function FilesFooter({ files }: { readonly files: ChangedFiles }) {+ const { diff, viewed, parsed } = files;+ return (+ <>+ {diff.nextCursor ? (+ <Button+ label={diff.error ? "Retry loading files" : "Load more files"}+ tone="secondary"+ onPress={diff.error ? diff.refresh : diff.loadMore}+ loading={diff.isPending}+ fullWidth+ />+ ) : null}+ {viewed.error ? (+ <Text textRole="label" className="py-2 text-danger-foreground">+ {viewed.error}+ </Text>+ ) : null}+ {parsed.kind === "files" && parsed.notice ? (+ <Text textRole="label" className="py-4 text-foreground-muted">+ {parsed.notice}+ </Text>+ ) : null}+ </>+ );+}++function ChangeBreakdownLine(props: {readonly breakdown: NonNullable<PullRequestChangeBreakdown>;}) {const parts = (Object.keys(BREAKDOWN_LABELS) as Array<keyof typeof BREAKDOWN_LABELS>).flatMap(@@ -46,154 +239,29 @@ function PullRequestChangeBreakdownLine(props: {},);return (- <Text className="text-2xs tabular-nums text-foreground-muted" numberOfLines={2}>+ <Text textRole="caption" className="tabular-nums text-foreground-muted" numberOfLines={2}>{parts.join(" · ")}</Text>);}-function fileDirectory(path: string) {- const separator = path.lastIndexOf("/");- return separator < 0 ? "" : path.slice(0, separator);-}--export function usePullRequestFilesContent(props: {- readonly params: PullRequestDiffParams;- readonly onSelectFile?: (path: string) => void;- readonly groupByDirectory?: boolean;-}) {+/**+ * The changed-files section of the pull request overview. The overview tab is a single list,+ * so the section supplies its header, rows, and footer instead of rendering a list of its own.+ */+export function usePullRequestFilesSection(params: PullRequestParams) {const navigation = useNavigation();- const result = usePullRequestDiff(props.params);- const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(props.params)));- const viewed = usePullRequestFilesViewed(props.params, props.params.commit ? null : detail.data);+ const files = useChangedFiles(params);+ const { diff, filter, viewed, pr, parsed, loading } = files;const breakdown = useEnvironmentQuery(- props.params.commit ? null : composerPullRequests.changeBreakdown(requestTarget(props.params)),+ composerPullRequests.changeBreakdown(pullRequestTarget(params)),).data;- const filter = usePullRequestFileFilter(result.parsed);- const parsed = filter.parsed;- const loading = result.isPending && parsed.kind === "empty" && !result.error;- const fileCount = props.params.commit ? undefined : detail.data?.changedFiles;- const summary = props.params.commit ? undefined : (detail.data ?? props.params.initialSummary);- const [collapsedDirectories, setCollapsedDirectories] = useState<ReadonlySet<string>>(- () => new Set(),- );- const files = parsed.kind === "files" ? parsed.files : [];- const orderedFiles = props.groupByDirectory- ? [...files].sort(- (a, b) =>- fileDirectory(a.path).localeCompare(fileDirectory(b.path)) ||- a.path.localeCompare(b.path),- )- : files;- const rows = orderedFiles.map((file, index) => {- const directory = fileDirectory(file.path);- const previousDirectory = fileDirectory(orderedFiles[index - 1]?.path ?? "");- const showDirectory =- props.groupByDirectory && (index === 0 || directory !== previousDirectory);- const collapsed = props.groupByDirectory && collapsedDirectories.has(directory);- if (collapsed && !showDirectory) return null;- return {- key: file.id,- content: (- <View>- {showDirectory ? (- <Pressable- accessibilityRole="button"- accessibilityLabel={directory || "Repository root"}- accessibilityState={{ expanded: !collapsed }}- onPress={() =>- setCollapsedDirectories((current) => {- const next = new Set(current);- if (next.has(directory)) next.delete(directory);- else next.add(directory);- return next;- })- }- className="min-h-11 flex-row items-center gap-2 pt-4 pb-2 active:opacity-70"- >- <SymbolView- name={collapsed ? "chevron.right" : "chevron.down"}- size={11}- tintColorClassName="accent-icon-muted"- />- <SymbolView name="folder" size={16} tintColorClassName="accent-icon-muted" />- <Text className="min-w-0 flex-1 text-xs text-foreground-muted" numberOfLines={2}>- {directory || "Repository root"}- </Text>- </Pressable>- ) : null}- {!collapsed ? (- <Pressable- accessibilityRole="button"- accessibilityLabel={`View diff for ${file.path}, ${file.additions} additions, ${file.deletions} deletions`}- onPress={() => {- if (props.onSelectFile) props.onSelectFile(file.path);- else- navigation.navigate("PullRequestFile", {- ...props.params,- path: file.path,- });- }}- className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3 active:opacity-70"- >- <PierreEntryIcon kind="file" path={file.path} size={20} />- <View className="min-w-0 flex-1">- <Text className="text-sm font-t3-medium text-foreground" numberOfLines={2}>- {file.path.split("/").at(-1)}- </Text>- {directory && !props.groupByDirectory ? (- <Text className="mt-0.5 text-2xs text-foreground-muted" numberOfLines={1}>- {directory}- </Text>- ) : null}- {file.previousPath ? (- <Text className="mt-0.5 text-2xs text-foreground-muted" numberOfLines={1}>- Renamed from {file.previousPath}- </Text>- ) : null}- </View>- <PullRequestDiffStats additions={file.additions} deletions={file.deletions} compact />- {viewed.isViewed(file.path) ? (- <SymbolView- name="checkmark.circle.fill"- size={18}- tintColorClassName="accent-adaptive-emerald-600-400"- />- ) : null}- <SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />- </Pressable>- ) : null}- </View>- ),- };- });+ const expected = pr ?? params.initialSummary;return {- refresh: result.refresh,- rows: loading- ? Array.from({ length: Math.min(fileCount ?? 4, 6) }, (_, index) => ({- key: `loading-file:${index}`,- content: (- <View- accessible={false}- importantForAccessibility="no-hide-descendants"- className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3"- >- <View className="size-5 rounded-md bg-subtle-strong" />- <View className="flex-1 gap-2">- <View- className="h-3.5 rounded bg-subtle-strong"- style={{ width: index % 2 ? "65%" : "80%" }}- />- <View className="h-2.5 w-2/5 rounded bg-subtle-strong" />- </View>- <View className="h-3 w-7 rounded bg-subtle-strong" />- </View>- ),- }))- : rows.filter((row) => row !== null),+ refresh: diff.refresh,header: (<>- <PullRequestReadStatus pending={false} error={result.error} />+ <PullRequestReadStatus pending={false} error={diff.error} />{loading ? (<ViewaccessibilityLabel="Loading changed files"@@ -202,18 +270,18 @@ export function usePullRequestFilesContent(props: {><View className="min-w-0 flex-1 gap-1"><PullRequestSectionHeading>Changed files</PullRequestSectionHeading>- {fileCount !== undefined ? (- <Text className="text-2xs text-foreground-muted">- {fileCount} {fileCount === 1 ? "file" : "files"}+ {pr ? (+ <Text textRole="caption" className="text-foreground-muted">+ {pr.changedFiles} {pr.changedFiles === 1 ? "file" : "files"}</Text>) : (<View className="h-2.5 w-28 rounded bg-subtle-strong" />)}</View>- {summary?.additions !== undefined && summary.deletions !== undefined ? (+ {expected?.additions !== undefined && expected.deletions !== undefined ? (<PullRequestDiffStats- additions={summary.additions}- deletions={summary.deletions}+ additions={expected.additions}+ deletions={expected.deletions}compact/>) : null}@@ -226,110 +294,219 @@ export function usePullRequestFilesContent(props: {</View></View>) : parsed.kind === "files" ? (- <>- <View className="min-h-17 flex-row items-center gap-2 py-3">- <View className="min-w-0 flex-1 gap-1">- <PullRequestSectionHeading>Changed files</PullRequestSectionHeading>- <Text className="text-2xs text-foreground-muted">- {parsed.fileCount} {filter.hiddenCount ? "visible" : "changed"}{" "}- {parsed.fileCount === 1 ? "file" : "files"}- {viewed.supported- ? ` · ${parsed.files.filter((file) => viewed.isViewed(file.path)).length} viewed`- : ""}- {" · "}- {filter.hideTestFiles- ? `${filter.hiddenCount} test ${filter.hiddenCount === 1 ? "file" : "files"} hidden`- : "Test files included"}- </Text>- {breakdown ? <PullRequestChangeBreakdownLine breakdown={breakdown} /> : null}- </View>- <PullRequestDiffStats- additions={parsed.additions}- deletions={parsed.deletions}- compact- />- <Menu- title="Review files"- actions={[- {- id: "hide-tests",- title: "Hide test files",- image: "line.3.horizontal.decrease",- state: filter.hideTestFiles ? "on" : "off",- },- ]}- onPressAction={filter.toggle}- >- <View pointerEvents="none">- <IconButton- icon="line.3.horizontal.decrease"- accessibilityLabel="Filter review files"- selected={filter.hideTestFiles}- />- </View>- </Menu>+ <View className="min-h-17 flex-row items-center gap-2 py-3">+ <View className="min-w-0 flex-1 gap-1">+ <PullRequestSectionHeading>Changed files</PullRequestSectionHeading>+ <Text textRole="caption" className="text-foreground-muted">+ {describeFiles(parsed, files)}+ </Text>+ {breakdown ? <ChangeBreakdownLine breakdown={breakdown} /> : null}</View>- {parsed.files.length === 0 && filter.hiddenCount > 0 ? (- <EmptyState- title={- result.nextCursor ? "No non-test files loaded yet" : "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"- />- ) : null}- </>- ) : !result.isPending && !result.error ? (- <Text className="py-6 text-sm text-foreground-muted">No text changes available.</Text>- ) : null}- </>- ),- footer: (- <>- {result.nextCursor ? (- <Button- label={result.error ? "Retry loading files" : "Load more files"}- tone="secondary"- onPress={result.error ? result.refresh : result.loadMore}- loading={result.isPending}- fullWidth- />- ) : null}- {viewed.error ? (- <Text className="py-2 text-xs text-danger-foreground">{viewed.error}</Text>- ) : null}- {parsed.kind === "files" && parsed.notice ? (- <Text className="py-4 text-xs text-foreground-muted">{parsed.notice}</Text>+ <PullRequestDiffStats+ additions={parsed.additions}+ deletions={parsed.deletions}+ compact+ />+ <FileFilterMenu filter={filter} />+ </View>) : null}+ <NoVisibleFiles files={files} /></>),+ rows: loading+ ? Array.from({ length: loadingRowCount(files) }, (_, index) => ({+ key: `loading-file:${index}`,+ content: <FileRowSkeleton index={index} />,+ }))+ : (parsed.kind === "files" ? parsed.files : []).map((file) => ({+ key: file.id,+ content: (+ <FileRow+ file={file}+ directory={fileDirectory(file.path)}+ viewed={viewed.isViewed(file.path)}+ onPress={() => navigation.navigate("PullRequestFile", { ...params, path: file.path })}+ />+ ),+ })),+ footer: <FilesFooter files={files} />,};}-export function PullRequestFiles(props: Parameters<typeof usePullRequestFilesContent>[0]) {- const content = usePullRequestFilesContent(props);+type SheetItem =+ | {+ readonly kind: "directory";+ readonly key: string;+ readonly directory: string;+ readonly collapsed: boolean;+ }+ | { readonly kind: "file"; readonly key: string; readonly file: ReviewRenderableFile };++function groupByDirectory(+ files: ReadonlyArray<ReviewRenderableFile>,+ collapsed: ReadonlySet<string>,+) {+ const sorted = files+ .map((file) => ({ file, directory: fileDirectory(file.path) }))+ .sort(+ (a, b) => a.directory.localeCompare(b.directory) || a.file.path.localeCompare(b.file.path),+ );+ const items: SheetItem[] = [];+ sorted.forEach(({ file, directory }, index) => {+ if (directory !== sorted[index - 1]?.directory) {+ items.push({+ kind: "directory",+ key: `directory:${directory}`,+ directory,+ collapsed: collapsed.has(directory),+ });+ }+ if (!collapsed.has(directory)) items.push({ kind: "file", key: file.id, file });+ });+ return items;+}++function DirectoryRow(props: {+ readonly directory: string;+ readonly collapsed: boolean;+ readonly onPress: () => void;+}) {+ const label = props.directory || "Repository root";+ return (+ <RowPressable+ accessibilityRole="button"+ accessibilityLabel={label}+ accessibilityState={{ expanded: !props.collapsed }}+ onPress={props.onPress}+ className="min-h-11 flex-row items-center gap-2 pt-4 pb-2 active:opacity-70"+ >+ <SymbolView+ name={props.collapsed ? "chevron.right" : "chevron.down"}+ size={11}+ tintColorClassName="accent-icon-muted"+ />+ <SymbolView name="folder" size={16} tintColorClassName="accent-icon-muted" />+ <Text textRole="label" className="min-w-0 flex-1 text-foreground-muted" numberOfLines={2}>+ {label}+ </Text>+ </RowPressable>+ );+}++/** The `PullRequestFiles` sheet: a changed-file picker presented over a file diff. */+export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDiffParams>) {+ const params = route.params;+ const navigation = useNavigation();+ const fileSelectionId = useRoute().key;+ const files = useChangedFiles(params);+ const { diff, filter, viewed, parsed, loading } = files;+ const [collapsed, setCollapsed] = useState<ReadonlySet<string>>(() => new Set());const [animationsReady, setAnimationsReady] = useState(false);+ const toggleDirectory = (directory: string) =>+ setCollapsed((current) => {+ const next = new Set(current);+ if (!next.delete(directory)) next.add(directory);+ return next;+ });return (- <AnimatedLegendList- data={content.rows}- keyExtractor={(row) => row.key}- itemLayoutAnimation={PR_ROW_LAYOUT}- onLoad={() => setAnimationsReady(true)}- renderItem={({ item }) => (- <Animated.View- key={item.key}- entering={animationsReady ? PR_ROW_ENTER : undefined}- exiting={animationsReady ? PR_ROW_EXIT : undefined}+ <View collapsable={false} className="flex-1 bg-sheet">+ <SheetHeader+ presentation={Platform.OS === "android" ? "inline" : "native"}+ title="Changed files"+ subtitle={`#${params.number} · ${params.commit?.slice(0, 7) ?? params.repository}`}+ onClose={() => navigation.goBack()}+ // iOS gets the native menu below; SheetHeader would render this as a custom bar item.+ trailing={Platform.OS === "android" ? <FileFilterMenu filter={filter} /> : undefined}+ />+ <Toolbar placement="right">+ <Toolbar.Menu+ title="Review files"+ accessibilityLabel="Filter review files"+ icon="line.3.horizontal.decrease">- {item.content}- </Animated.View>- )}- recycleItems={false}- estimatedItemSize={64}- ListHeaderComponent={content.header}- ListFooterComponent={content.footer}- contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 20 }}- />+ <Toolbar.MenuAction+ icon="line.3.horizontal.decrease"+ isOn={filter.hideTestFiles}+ onPress={filter.toggle}+ >+ <Toolbar.Label>Hide test files</Toolbar.Label>+ </Toolbar.MenuAction>+ </Toolbar.Menu>+ </Toolbar>+ <ScreenContent>+ <AnimatedLegendList+ className="flex-1"+ data={parsed.kind === "files" ? groupByDirectory(parsed.files, collapsed) : []}+ keyExtractor={(item) => item.key}+ getItemType={(item) => item.kind}+ itemLayoutAnimation={PR_ROW_LAYOUT}+ onLoad={() => setAnimationsReady(true)}+ renderItem={({ item }) => (+ <Animated.View+ entering={animationsReady ? PR_ROW_ENTER : undefined}+ exiting={animationsReady ? PR_ROW_EXIT : undefined}+ >+ {item.kind === "directory" ? (+ <DirectoryRow+ directory={item.directory}+ collapsed={item.collapsed}+ onPress={() => toggleDirectory(item.directory)}+ />+ ) : (+ <FileRow+ file={item.file}+ viewed={viewed.isViewed(item.file.path)}+ onPress={() =>+ navigation.dispatch(+ StackActions.popTo("PullRequestFile", {+ ...params,+ path: item.file.path,+ fileSelectionId,+ }),+ )+ }+ />+ )}+ </Animated.View>+ )}+ contentInsetAdjustmentBehavior="automatic"+ recycleItems={false}+ estimatedItemSize={64}+ ListHeaderComponent={+ <>+ <PullRequestReadStatus pending={false} error={diff.error} />+ {parsed.kind === "files" ? (+ <View className="flex-row items-center gap-2 py-2">+ <Text textRole="caption" className="min-w-0 flex-1 text-foreground-muted">+ {describeFiles(parsed, files)}+ </Text>+ <PullRequestDiffStats+ additions={parsed.additions}+ deletions={parsed.deletions}+ compact+ />+ </View>+ ) : null}+ <NoVisibleFiles files={files} />+ </>+ }+ ListEmptyComponent={+ loading ? (+ <View+ accessible+ accessibilityLabel="Loading changed files"+ accessibilityState={{ busy: true }}+ >+ {Array.from({ length: loadingRowCount(files) }, (_, index) => (+ <FileRowSkeleton key={index} index={index} />+ ))}+ </View>+ ) : null+ }+ ListFooterComponent={<FilesFooter files={files} />}+ contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 20 }}+ />+ </ScreenContent>+ </View>);}diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsxindex dcc1f66cd2b..10cb2d7a372 100644--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx@@ -37,13 +37,7 @@ import { usePullRequestAction } from "./usePullRequestAction";import { annotatePullRequestDiff, reviewPosition } from "./pullRequestDiffComments";import { usePullRequestFileFilter } from "./usePullRequestFileFilter";import { isPullRequestTestFile } from "./pullRequestFileFilters";-import {- StackActions,- useFocusEffect,- useNavigation,- useRoute,- type StaticScreenProps,-} from "@react-navigation/native";+import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";import { RegistryContext, useAtomRefresh } from "@effect/atom-react";import { pullRequestReviewKey } from "./pullRequestReviewDrafts";import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";@@ -105,8 +99,7 @@ import {PullRequestDiffStats,PullRequestReadStatus,} from "./PullRequestPresentation";-import { PullRequestFiles, usePullRequestFilesContent } from "./PullRequestFiles";-import { PullRequestSheetContent } from "./PullRequestSheetContent";+import { usePullRequestFilesSection } from "./PullRequestFiles";import { PullRequestDescription } from "./PullRequestDescription";import { PullRequestMarkdownRepository } from "./PullRequestMarkdown";import {@@ -296,7 +289,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestPconst requestedSection = useRef(section);const [listAnimationsReady, setListAnimationsReady] = useState(false);const [descriptionExpanded, setDescriptionExpanded] = useState(false);- const filesContent = usePullRequestFilesContent({ params });+ const filesContent = usePullRequestFilesSection(params);const guidesEnabled = useReviewGuidesEnabled(params);const [activityFilter, setActivityFilter] = useState<ActivityFilter>(DEFAULT_ACTIVITY_FILTER);const activityContent = usePullRequestActivityRows(params, activityFilter);@@ -749,32 +742,6 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP);}-export function PullRequestFilesRouteScreen({ route }: StaticScreenProps<PullRequestDiffParams>) {- const navigation = useNavigation();- const fileSelectionId = useRoute().key;- return (- <PullRequestSheetContent- title="Changed files"- scrollable={false}- subtitle={`#${route.params.number}${route.params.commit ? ` · ${route.params.commit.slice(0, 7)}` : ` · ${route.params.repository}`}`}- >- <PullRequestFiles- params={route.params}- groupByDirectory- onSelectFile={(path) =>- navigation.dispatch(- StackActions.popTo("PullRequestFile", {- ...route.params,- path,- fileSelectionId,- }),- )- }- />- </PullRequestSheetContent>- );-}-export function PullRequestFileRouteScreen({route,}: StaticScreenProps<diff --git a/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx b/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsxindex cf566e99dc1..e13fb7e3cf1 100644--- a/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx@@ -13,76 +13,56 @@ export function PullRequestSheetContent(props: {readonly busy?: boolean;readonly children: ReactNode;readonly footer?: ReactNode;- readonly scrollable?: boolean;}) {const navigation = useNavigation();const insets = useSafeAreaInsets();const { height: windowHeight } = useWindowDimensions();const android = Platform.OS === "android";- const fitToContents = android && props.scrollable !== false;const footer = props.footer ? (<View- className={- android && props.scrollable !== false ? "bg-sheet-solid pt-3" : "bg-sheet px-4 pt-3"- }+ className={android ? "bg-sheet-solid pt-3" : "bg-sheet px-4 pt-3"}style={{ paddingBottom: Math.max(insets.bottom, 16) }}>{android ? <View style={{ minHeight: 48 }}>{props.footer}</View> : props.footer}</View>) : null;- const content = (- <>- <SheetHeader- presentation="inline"- title={props.title}- subtitle={props.subtitle}- onCancel={() => navigation.goBack()}- dismissDisabled={props.busy}- />- <ScreenContent fitToContents={fitToContents}>- {props.scrollable === false ? (- <View className="flex-1" pointerEvents={props.busy ? "none" : "auto"}>- {props.children}- </View>- ) : (- <ScrollView- nestedScrollEnabled- className="android:shrink android:grow-0 ios:flex-1"- keyboardShouldPersistTaps="handled"- contentContainerStyle={{- paddingHorizontal: 16,- paddingTop: android ? 16 : 0,- paddingBottom: 20,- }}- >- <View className="gap-4" pointerEvents={props.busy ? "none" : "auto"}>- {props.children}- {/* Android partial-height sheets keep submit actions within the scrollable form. */}- {android ? footer : null}- </View>- </ScrollView>- )}-- {!android || props.scrollable === false ? footer : null}- </ScreenContent>- </>- );return (<KeyboardAvoidingViewautomaticOffsetbehavior="padding"collapsable={false}- className={props.scrollable === false ? "flex-1 bg-sheet" : "bg-sheet ios:flex-1"}- style={fitToContents ? { maxHeight: windowHeight * 0.92 } : undefined}+ className="bg-sheet ios:flex-1"+ style={android ? { maxHeight: windowHeight * 0.92 } : undefined}><NativeStackScreenOptionsoptions={{gestureEnabled: !props.busy,- ...(android ? { sheetCornerRadius: 28 } : {}),- ...(fitToContents ? { sheetAllowedDetents: "fitToContents" } : {}),+ ...(android ? { sheetCornerRadius: 28, sheetAllowedDetents: "fitToContents" } : {}),}}/>- {content}+ <SheetHeader+ presentation={android ? "inline" : "native"}+ title={props.title}+ subtitle={props.subtitle}+ onCancel={() => navigation.goBack()}+ dismissDisabled={props.busy}+ />+ <ScreenContent fitToContents={android}>+ <ScrollView+ nestedScrollEnabled+ className="android:shrink android:grow-0 ios:flex-1"+ contentInsetAdjustmentBehavior="automatic"+ keyboardShouldPersistTaps="handled"+ contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 16, paddingBottom: 20 }}+ >+ <View className="gap-4" pointerEvents={props.busy ? "none" : "auto"}>+ {props.children}+ {/* Android partial-height sheets keep submit actions within the scrollable form. */}+ {android ? footer : null}+ </View>+ </ScrollView>+ {android ? null : footer}+ </ScreenContent></KeyboardAvoidingView>);}diff --git a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx b/apps/mobile/src/features/threads/git/GitCommitSheet.tsxindex 7bc5105805b..be0912a6ebe 100644--- a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx@@ -78,7 +78,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {/>) : null}<SheetHeader- presentation="inline"+ presentation={Platform.OS === "android" ? "inline" : "native"}title="Commit changes"subtitle={gitStatus.data?.refName ?? "(detached HEAD)"}onCancel={() => navigation.goBack()}@@ -86,6 +86,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {/><ScrollViewnestedScrollEnabled+ contentInsetAdjustmentBehavior="automatic"className="android:shrink android:grow-0 ios:flex-1"keyboardShouldPersistTaps="handled"keyboardDismissMode="on-drag"