The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 20:45 UTC
fix(mobile): use native sheet headers and toolbar filters (#22390)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 20, 2026 at 10:49 UTC
be5a5cd01cb0c2519963a65b277f5905d8c3109c
5 files changed
+467
-341
apps/mobile/src/Stack.tsx
+7
-6
@@ -39,8 +39,8 @@ import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorksp
39
import {
40
PullRequestRouteScreen,
41
PullRequestFileRouteScreen,
42
- PullRequestFilesRouteScreen,
42
} from "./features/pull-requests/PullRequestRouteScreen";
43
+import { PullRequestFilesSheet } from "./features/pull-requests/PullRequestFiles";
44
import { PullRequestReviewSheet } from "./features/pull-requests/PullRequestReviewSheet";
45
import { PullRequestReviewersScreen } from "./features/pull-requests/PullRequestReviewersScreen";
46
import {
@@ -729,12 +729,13 @@ const RootStackConfig = createWorkspaceStackNavigator({
729
options: DETAIL_HEADER_OPTIONS,
730
}),
731
PullRequestFiles: createNativeStackScreen({
732
- screen: PullRequestFilesRouteScreen,
732
+ screen: PullRequestFilesSheet,
733
options: {
734
+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),
735
...FORM_SHEET_PRESENTATION_OPTIONS,
736
sheetAllowedDetents: [0.6, 0.92],
737
sheetGrabberVisible: true,
737
- headerShown: false,
738
+ sheetCornerRadius: Platform.OS === "android" ? 28 : undefined,
739
},
740
}),
741
PullRequestReviewers: createNativeStackScreen({
@@ -756,19 +757,18 @@ const RootStackConfig = createWorkspaceStackNavigator({
757
options: {
758
...(Platform.OS === "android"
759
? { presentation: "fullScreenModal" as const }
759
- : FORM_SHEET_PRESENTATION_OPTIONS),
760
+ : { ...SHEET_GLASS_HEADER_OPTIONS, ...FORM_SHEET_PRESENTATION_OPTIONS }),
761
sheetAllowedDetents: Platform.OS === "android" ? undefined : [0.75, 0.92],
762
sheetGrabberVisible: Platform.OS !== "android",
762
- headerShown: false,
763
},
764
}),
765
PullRequestReview: createNativeStackScreen({
766
screen: PullRequestReviewSheet,
767
options: {
768
+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),
769
...FORM_SHEET_PRESENTATION_OPTIONS,
770
sheetAllowedDetents: [0.75, 0.92],
771
sheetGrabberVisible: true,
771
- headerShown: false,
772
},
773
}),
774
Thread: createNativeStackScreen({
@@ -900,6 +900,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
900
screen: GitCommitSheet,
901
linking: `${THREAD_LINKING_PREFIX}/git/commit`,
902
options: {
903
+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),
904
...FORM_SHEET_PRESENTATION_OPTIONS,
905
sheetAllowedDetents: [0.8, 0.92],
906
sheetGrabberVisible: true,
apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
+428
-251
@@ -1,28 +1,39 @@
1
-import type { PullRequestChangeBreakdown } from "@t3tools/contracts";
2
-import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
1
import { AnimatedLegendList } from "@legendapp/list/reanimated";
4
-import Animated from "react-native-reanimated";
5
-import { PR_ROW_LAYOUT, PR_ROW_ENTER, PR_ROW_EXIT } from "./pullRequestAnimations";
6
-import { useNavigation } from "@react-navigation/native";
2
+import {
3
+ StackActions,
4
+ useNavigation,
5
+ useRoute,
6
+ type StaticScreenProps,
7
+} from "@react-navigation/native";
8
+import type { PullRequestChangeBreakdown } from "@t3tools/contracts";
9
import { useState } from "react";
8
-import { Pressable, View } from "react-native";
10
+import { Platform, View } from "react-native";
11
+import Animated from "react-native-reanimated";
12
+import { PierreEntryIcon } from "../../components/PierreEntryIcon";
13
import { AppText as Text } from "../../components/ui/AppText";
10
-import { EmptyState } from "../../components/ui/EmptyState";
11
-import { Menu } from "../../components/ui/Menu";
14
+import { SymbolView } from "../../components/ui/AppSymbol";
15
import { Button } from "../../components/ui/Button";
16
+import { EmptyState } from "../../components/ui/EmptyState";
17
import { IconButton } from "../../components/ui/IconButton";
14
-import { SymbolView } from "../../components/ui/AppSymbol";
15
-import { PierreEntryIcon } from "../../components/PierreEntryIcon";
18
+import { Menu } from "../../components/ui/Menu";
19
+import { RowPressable } from "../../components/ui/RowPressable";
20
+import { ScreenContent } from "../../components/ui/ScreenContent";
21
+import { SheetHeader } from "../../components/ui/SheetHeader";
22
+import { Toolbar } from "../../components/ui/Toolbar";
23
import { composerPullRequests } from "../../state/pull-requests";
24
import { useEnvironmentQuery } from "../../state/query";
25
+import type { ReviewParsedDiff, ReviewRenderableFile } from "../review/reviewModel";
26
+import { PR_ROW_ENTER, PR_ROW_EXIT, PR_ROW_LAYOUT } from "./pullRequestAnimations";
27
import { PullRequestDiffStats, PullRequestReadStatus } from "./PullRequestPresentation";
28
+import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
29
import {
20
- pullRequestTarget as requestTarget,
30
+ pullRequestTarget,
31
usePullRequestDiff,
32
type PullRequestDiffParams,
33
+ type PullRequestParams,
34
} from "./usePullRequestDiff";
24
-import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
35
import { usePullRequestFileFilter } from "./usePullRequestFileFilter";
36
+import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
37
38
const BREAKDOWN_LABELS = {
39
code: "Code",
@@ -32,7 +43,189 @@ const BREAKDOWN_LABELS = {
43
docs: "Docs",
44
} satisfies Record<keyof NonNullable<PullRequestChangeBreakdown>, string>;
45
35
-function PullRequestChangeBreakdownLine(props: {
46
+function fileDirectory(path: string) {
47
+ const separator = path.lastIndexOf("/");
48
+ return separator < 0 ? "" : path.slice(0, separator);
49
+}
50
+
51
+function useChangedFiles(params: PullRequestDiffParams) {
52
+ const diff = usePullRequestDiff(params);
53
+ const detail = useEnvironmentQuery(composerPullRequests.detail(pullRequestTarget(params)));
54
+ // A commit's diff is part of the pull request, so the PR's file counts and viewed state don't apply.
55
+ const pr = params.commit ? null : detail.data;
56
+ const viewed = usePullRequestFilesViewed(params, pr);
57
+ const filter = usePullRequestFileFilter(diff.parsed);
58
+ const parsed = filter.parsed;
59
+ return {
60
+ diff,
61
+ filter,
62
+ viewed,
63
+ pr,
64
+ parsed,
65
+ loading: diff.isPending && parsed.kind === "empty" && !diff.error,
66
+ };
67
+}
68
+
69
+type ChangedFiles = ReturnType<typeof useChangedFiles>;
70
+
71
+function loadingRowCount(files: ChangedFiles) {
72
+ return Math.min(files.pr?.changedFiles ?? 4, 6);
73
+}
74
+
75
+function describeFiles(
76
+ parsed: Extract<ReviewParsedDiff, { readonly kind: "files" }>,
77
+ { filter, viewed }: ChangedFiles,
78
+) {
79
+ const noun = (count: number) => (count === 1 ? "file" : "files");
80
+ return [
81
+ `${parsed.fileCount} ${filter.hiddenCount ? "visible" : "changed"} ${noun(parsed.fileCount)}`,
82
+ viewed.supported
83
+ ? `${parsed.files.filter((file) => viewed.isViewed(file.path)).length} viewed`
84
+ : null,
85
+ filter.hideTestFiles
86
+ ? `${filter.hiddenCount} test ${noun(filter.hiddenCount)} hidden`
87
+ : "Test files included",
88
+ ]
89
+ .filter(Boolean)
90
+ .join(" · ");
91
+}
92
+
93
+function FileRow(props: {
94
+ readonly file: ReviewRenderableFile;
95
+ readonly viewed: boolean;
96
+ /** Shown under the file name where files aren't grouped by directory. */
97
+ readonly directory?: string;
98
+ readonly onPress: () => void;
99
+}) {
100
+ const { file } = props;
101
+ return (
102
+ <RowPressable
103
+ accessibilityRole="button"
104
+ accessibilityLabel={`View diff for ${file.path}, ${file.additions} additions, ${file.deletions} deletions${props.viewed ? ", viewed" : ""}`}
105
+ onPress={props.onPress}
106
+ className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3 active:opacity-70"
107
+ >
108
+ <PierreEntryIcon kind="file" path={file.path} size={20} />
109
+ <View className="min-w-0 flex-1 gap-0.5">
110
+ <Text textRole="footnote" className="font-t3-medium" numberOfLines={2}>
111
+ {file.path.split("/").at(-1)}
112
+ </Text>
113
+ {props.directory ? (
114
+ <Text textRole="caption" className="text-foreground-muted" numberOfLines={1}>
115
+ {props.directory}
116
+ </Text>
117
+ ) : null}
118
+ {file.previousPath ? (
119
+ <Text textRole="caption" className="text-foreground-muted" numberOfLines={1}>
120
+ Renamed from {file.previousPath}
121
+ </Text>
122
+ ) : null}
123
+ </View>
124
+ <PullRequestDiffStats additions={file.additions} deletions={file.deletions} compact />
125
+ {props.viewed ? (
126
+ <SymbolView
127
+ name="checkmark.circle.fill"
128
+ size={18}
129
+ tintColorClassName="accent-adaptive-emerald-600-400"
130
+ />
131
+ ) : null}
132
+ <SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />
133
+ </RowPressable>
134
+ );
135
+}
136
+
137
+function FileRowSkeleton(props: { readonly index: number }) {
138
+ return (
139
+ <View
140
+ accessible={false}
141
+ importantForAccessibility="no-hide-descendants"
142
+ className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3"
143
+ >
144
+ <View className="size-5 rounded-md bg-subtle-strong" />
145
+ <View className="flex-1 gap-2">
146
+ <View
147
+ className="h-3.5 rounded bg-subtle-strong"
148
+ style={{ width: props.index % 2 ? "65%" : "80%" }}
149
+ />
150
+ <View className="h-2.5 w-2/5 rounded bg-subtle-strong" />
151
+ </View>
152
+ <View className="h-3 w-7 rounded bg-subtle-strong" />
153
+ </View>
154
+ );
155
+}
156
+
157
+function FileFilterMenu({ filter }: { readonly filter: ChangedFiles["filter"] }) {
158
+ return (
159
+ <Menu
160
+ title="Review files"
161
+ actions={[
162
+ {
163
+ id: "hide-tests",
164
+ title: "Hide test files",
165
+ image: "line.3.horizontal.decrease",
166
+ state: filter.hideTestFiles ? "on" : "off",
167
+ },
168
+ ]}
169
+ onPressAction={filter.toggle}
170
+ >
171
+ <View pointerEvents="none">
172
+ <IconButton
173
+ icon="line.3.horizontal.decrease"
174
+ accessibilityLabel="Filter review files"
175
+ selected={filter.hideTestFiles}
176
+ />
177
+ </View>
178
+ </Menu>
179
+ );
180
+}
181
+
182
+function NoVisibleFiles({ files }: { readonly files: ChangedFiles }) {
183
+ const { diff, filter, parsed } = files;
184
+ if (parsed.kind === "files") {
185
+ return parsed.files.length === 0 && filter.hiddenCount > 0 ? (
186
+ <EmptyState
187
+ title={diff.nextCursor ? "No non-test files loaded yet" : "Only test files changed"}
188
+ detail="Test files are hidden from this review."
189
+ action={<Button label="Show test files" tone="contrast" onPress={filter.showAll} />}
190
+ variant="plain"
191
+ />
192
+ ) : null;
193
+ }
194
+ return !diff.isPending && !diff.error ? (
195
+ <Text textRole="footnote" className="py-6 text-foreground-muted">
196
+ No text changes available.
197
+ </Text>
198
+ ) : null;
199
+}
200
+
201
+function FilesFooter({ files }: { readonly files: ChangedFiles }) {
202
+ const { diff, viewed, parsed } = files;
203
+ return (
204
+ <>
205
+ {diff.nextCursor ? (
206
+ <Button
207
+ label={diff.error ? "Retry loading files" : "Load more files"}
208
+ tone="secondary"
209
+ onPress={diff.error ? diff.refresh : diff.loadMore}
210
+ loading={diff.isPending}
211
+ fullWidth
212
+ />
213
+ ) : null}
214
+ {viewed.error ? (
215
+ <Text textRole="label" className="py-2 text-danger-foreground">
216
+ {viewed.error}
217
+ </Text>
218
+ ) : null}
219
+ {parsed.kind === "files" && parsed.notice ? (
220
+ <Text textRole="label" className="py-4 text-foreground-muted">
221
+ {parsed.notice}
222
+ </Text>
223
+ ) : null}
224
+ </>
225
+ );
226
+}
227
+
228
+function ChangeBreakdownLine(props: {
229
readonly breakdown: NonNullable<PullRequestChangeBreakdown>;
230
}) {
231
const parts = (Object.keys(BREAKDOWN_LABELS) as Array<keyof typeof BREAKDOWN_LABELS>).flatMap(
@@ -46,154 +239,29 @@ function PullRequestChangeBreakdownLine(props: {
239
},
240
);
241
return (
49
- <Text className="text-2xs tabular-nums text-foreground-muted" numberOfLines={2}>
242
+ <Text textRole="caption" className="tabular-nums text-foreground-muted" numberOfLines={2}>
243
{parts.join(" · ")}
244
</Text>
245
);
246
}
247
55
-function fileDirectory(path: string) {
56
- const separator = path.lastIndexOf("/");
57
- return separator < 0 ? "" : path.slice(0, separator);
58
-}
59
-
60
-export function usePullRequestFilesContent(props: {
61
- readonly params: PullRequestDiffParams;
62
- readonly onSelectFile?: (path: string) => void;
63
- readonly groupByDirectory?: boolean;
64
-}) {
248
+/**
249
+ * The changed-files section of the pull request overview. The overview tab is a single list,
250
+ * so the section supplies its header, rows, and footer instead of rendering a list of its own.
251
+ */
252
+export function usePullRequestFilesSection(params: PullRequestParams) {
253
const navigation = useNavigation();
66
- const result = usePullRequestDiff(props.params);
67
- const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(props.params)));
68
- const viewed = usePullRequestFilesViewed(props.params, props.params.commit ? null : detail.data);
254
+ const files = useChangedFiles(params);
255
+ const { diff, filter, viewed, pr, parsed, loading } = files;
256
const breakdown = useEnvironmentQuery(
70
- props.params.commit ? null : composerPullRequests.changeBreakdown(requestTarget(props.params)),
257
+ composerPullRequests.changeBreakdown(pullRequestTarget(params)),
258
).data;
72
- const filter = usePullRequestFileFilter(result.parsed);
73
- const parsed = filter.parsed;
74
- const loading = result.isPending && parsed.kind === "empty" && !result.error;
75
- const fileCount = props.params.commit ? undefined : detail.data?.changedFiles;
76
- const summary = props.params.commit ? undefined : (detail.data ?? props.params.initialSummary);
77
- const [collapsedDirectories, setCollapsedDirectories] = useState<ReadonlySet<string>>(
78
- () => new Set(),
79
- );
80
- const files = parsed.kind === "files" ? parsed.files : [];
81
- const orderedFiles = props.groupByDirectory
82
- ? [...files].sort(
83
- (a, b) =>
84
- fileDirectory(a.path).localeCompare(fileDirectory(b.path)) ||
85
- a.path.localeCompare(b.path),
86
- )
87
- : files;
88
- const rows = orderedFiles.map((file, index) => {
89
- const directory = fileDirectory(file.path);
90
- const previousDirectory = fileDirectory(orderedFiles[index - 1]?.path ?? "");
91
- const showDirectory =
92
- props.groupByDirectory && (index === 0 || directory !== previousDirectory);
93
- const collapsed = props.groupByDirectory && collapsedDirectories.has(directory);
94
- if (collapsed && !showDirectory) return null;
95
- return {
96
- key: file.id,
97
- content: (
98
- <View>
99
- {showDirectory ? (
100
- <Pressable
101
- accessibilityRole="button"
102
- accessibilityLabel={directory || "Repository root"}
103
- accessibilityState={{ expanded: !collapsed }}
104
- onPress={() =>
105
- setCollapsedDirectories((current) => {
106
- const next = new Set(current);
107
- if (next.has(directory)) next.delete(directory);
108
- else next.add(directory);
109
- return next;
110
- })
111
- }
112
- className="min-h-11 flex-row items-center gap-2 pt-4 pb-2 active:opacity-70"
113
- >
114
- <SymbolView
115
- name={collapsed ? "chevron.right" : "chevron.down"}
116
- size={11}
117
- tintColorClassName="accent-icon-muted"
118
- />
119
- <SymbolView name="folder" size={16} tintColorClassName="accent-icon-muted" />
120
- <Text className="min-w-0 flex-1 text-xs text-foreground-muted" numberOfLines={2}>
121
- {directory || "Repository root"}
122
- </Text>
123
- </Pressable>
124
- ) : null}
125
- {!collapsed ? (
126
- <Pressable
127
- accessibilityRole="button"
128
- accessibilityLabel={`View diff for ${file.path}, ${file.additions} additions, ${file.deletions} deletions`}
129
- onPress={() => {
130
- if (props.onSelectFile) props.onSelectFile(file.path);
131
- else
132
- navigation.navigate("PullRequestFile", {
133
- ...props.params,
134
- path: file.path,
135
- });
136
- }}
137
- className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3 active:opacity-70"
138
- >
139
- <PierreEntryIcon kind="file" path={file.path} size={20} />
140
- <View className="min-w-0 flex-1">
141
- <Text className="text-sm font-t3-medium text-foreground" numberOfLines={2}>
142
- {file.path.split("/").at(-1)}
143
- </Text>
144
- {directory && !props.groupByDirectory ? (
145
- <Text className="mt-0.5 text-2xs text-foreground-muted" numberOfLines={1}>
146
- {directory}
147
- </Text>
148
- ) : null}
149
- {file.previousPath ? (
150
- <Text className="mt-0.5 text-2xs text-foreground-muted" numberOfLines={1}>
151
- Renamed from {file.previousPath}
152
- </Text>
153
- ) : null}
154
- </View>
155
- <PullRequestDiffStats additions={file.additions} deletions={file.deletions} compact />
156
- {viewed.isViewed(file.path) ? (
157
- <SymbolView
158
- name="checkmark.circle.fill"
159
- size={18}
160
- tintColorClassName="accent-adaptive-emerald-600-400"
161
- />
162
- ) : null}
163
- <SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />
164
- </Pressable>
165
- ) : null}
166
- </View>
167
- ),
168
- };
169
- });
259
+ const expected = pr ?? params.initialSummary;
260
return {
171
- refresh: result.refresh,
172
- rows: loading
173
- ? Array.from({ length: Math.min(fileCount ?? 4, 6) }, (_, index) => ({
174
- key: `loading-file:${index}`,
175
- content: (
176
- <View
177
- accessible={false}
178
- importantForAccessibility="no-hide-descendants"
179
- className="min-h-14 flex-row items-center gap-3 border-b border-border-subtle py-3"
180
- >
181
- <View className="size-5 rounded-md bg-subtle-strong" />
182
- <View className="flex-1 gap-2">
183
- <View
184
- className="h-3.5 rounded bg-subtle-strong"
185
- style={{ width: index % 2 ? "65%" : "80%" }}
186
- />
187
- <View className="h-2.5 w-2/5 rounded bg-subtle-strong" />
188
- </View>
189
- <View className="h-3 w-7 rounded bg-subtle-strong" />
190
- </View>
191
- ),
192
- }))
193
- : rows.filter((row) => row !== null),
261
+ refresh: diff.refresh,
262
header: (
263
<>
196
- <PullRequestReadStatus pending={false} error={result.error} />
264
+ <PullRequestReadStatus pending={false} error={diff.error} />
265
{loading ? (
266
<View
267
accessibilityLabel="Loading changed files"
@@ -202,18 +270,18 @@ export function usePullRequestFilesContent(props: {
270
>
271
<View className="min-w-0 flex-1 gap-1">
272
<PullRequestSectionHeading>Changed files</PullRequestSectionHeading>
205
- {fileCount !== undefined ? (
206
- <Text className="text-2xs text-foreground-muted">
207
- {fileCount} {fileCount === 1 ? "file" : "files"}
273
+ {pr ? (
274
+ <Text textRole="caption" className="text-foreground-muted">
275
+ {pr.changedFiles} {pr.changedFiles === 1 ? "file" : "files"}
276
</Text>
277
) : (
278
<View className="h-2.5 w-28 rounded bg-subtle-strong" />
279
)}
280
</View>
213
- {summary?.additions !== undefined && summary.deletions !== undefined ? (
281
+ {expected?.additions !== undefined && expected.deletions !== undefined ? (
282
<PullRequestDiffStats
215
- additions={summary.additions}
216
- deletions={summary.deletions}
283
+ additions={expected.additions}
284
+ deletions={expected.deletions}
285
compact
286
/>
287
) : null}
@@ -226,110 +294,219 @@ export function usePullRequestFilesContent(props: {
294
</View>
295
</View>
296
) : parsed.kind === "files" ? (
229
- <>
230
- <View className="min-h-17 flex-row items-center gap-2 py-3">
231
- <View className="min-w-0 flex-1 gap-1">
232
- <PullRequestSectionHeading>Changed files</PullRequestSectionHeading>
233
- <Text className="text-2xs text-foreground-muted">
234
- {parsed.fileCount} {filter.hiddenCount ? "visible" : "changed"}{" "}
235
- {parsed.fileCount === 1 ? "file" : "files"}
236
- {viewed.supported
237
- ? ` · ${parsed.files.filter((file) => viewed.isViewed(file.path)).length} viewed`
238
- : ""}
239
- {" · "}
240
- {filter.hideTestFiles
241
- ? `${filter.hiddenCount} test ${filter.hiddenCount === 1 ? "file" : "files"} hidden`
242
- : "Test files included"}
243
- </Text>
244
- {breakdown ? <PullRequestChangeBreakdownLine breakdown={breakdown} /> : null}
245
- </View>
246
- <PullRequestDiffStats
247
- additions={parsed.additions}
248
- deletions={parsed.deletions}
249
- compact
250
- />
251
- <Menu
252
- title="Review files"
253
- actions={[
254
- {
255
- id: "hide-tests",
256
- title: "Hide test files",
257
- image: "line.3.horizontal.decrease",
258
- state: filter.hideTestFiles ? "on" : "off",
259
- },
260
- ]}
261
- onPressAction={filter.toggle}
262
- >
263
- <View pointerEvents="none">
264
- <IconButton
265
- icon="line.3.horizontal.decrease"
266
- accessibilityLabel="Filter review files"
267
- selected={filter.hideTestFiles}
268
- />
269
- </View>
270
- </Menu>
297
+ <View className="min-h-17 flex-row items-center gap-2 py-3">
298
+ <View className="min-w-0 flex-1 gap-1">
299
+ <PullRequestSectionHeading>Changed files</PullRequestSectionHeading>
300
+ <Text textRole="caption" className="text-foreground-muted">
301
+ {describeFiles(parsed, files)}
302
+ </Text>
303
+ {breakdown ? <ChangeBreakdownLine breakdown={breakdown} /> : null}
304
</View>
272
- {parsed.files.length === 0 && filter.hiddenCount > 0 ? (
273
- <EmptyState
274
- title={
275
- result.nextCursor ? "No non-test files loaded yet" : "Only test files changed"
276
- }
277
- detail="Test files are hidden from this review."
278
- action={<Button label="Show test files" tone="contrast" onPress={filter.showAll} />}
279
- variant="plain"
280
- />
281
- ) : null}
282
- </>
283
- ) : !result.isPending && !result.error ? (
284
- <Text className="py-6 text-sm text-foreground-muted">No text changes available.</Text>
285
- ) : null}
286
- </>
287
- ),
288
- footer: (
289
- <>
290
- {result.nextCursor ? (
291
- <Button
292
- label={result.error ? "Retry loading files" : "Load more files"}
293
- tone="secondary"
294
- onPress={result.error ? result.refresh : result.loadMore}
295
- loading={result.isPending}
296
- fullWidth
297
- />
298
- ) : null}
299
- {viewed.error ? (
300
- <Text className="py-2 text-xs text-danger-foreground">{viewed.error}</Text>
301
- ) : null}
302
- {parsed.kind === "files" && parsed.notice ? (
303
- <Text className="py-4 text-xs text-foreground-muted">{parsed.notice}</Text>
305
+ <PullRequestDiffStats
306
+ additions={parsed.additions}
307
+ deletions={parsed.deletions}
308
+ compact
309
+ />
310
+ <FileFilterMenu filter={filter} />
311
+ </View>
312
) : null}
313
+ <NoVisibleFiles files={files} />
314
</>
315
),
316
+ rows: loading
317
+ ? Array.from({ length: loadingRowCount(files) }, (_, index) => ({
318
+ key: `loading-file:${index}`,
319
+ content: <FileRowSkeleton index={index} />,
320
+ }))
321
+ : (parsed.kind === "files" ? parsed.files : []).map((file) => ({
322
+ key: file.id,
323
+ content: (
324
+ <FileRow
325
+ file={file}
326
+ directory={fileDirectory(file.path)}
327
+ viewed={viewed.isViewed(file.path)}
328
+ onPress={() => navigation.navigate("PullRequestFile", { ...params, path: file.path })}
329
+ />
330
+ ),
331
+ })),
332
+ footer: <FilesFooter files={files} />,
333
};
334
}
335
310
-export function PullRequestFiles(props: Parameters<typeof usePullRequestFilesContent>[0]) {
311
- const content = usePullRequestFilesContent(props);
336
+type SheetItem =
337
+ | {
338
+ readonly kind: "directory";
339
+ readonly key: string;
340
+ readonly directory: string;
341
+ readonly collapsed: boolean;
342
+ }
343
+ | { readonly kind: "file"; readonly key: string; readonly file: ReviewRenderableFile };
344
+
345
+function groupByDirectory(
346
+ files: ReadonlyArray<ReviewRenderableFile>,
347
+ collapsed: ReadonlySet<string>,
348
+) {
349
+ const sorted = files
350
+ .map((file) => ({ file, directory: fileDirectory(file.path) }))
351
+ .sort(
352
+ (a, b) => a.directory.localeCompare(b.directory) || a.file.path.localeCompare(b.file.path),
353
+ );
354
+ const items: SheetItem[] = [];
355
+ sorted.forEach(({ file, directory }, index) => {
356
+ if (directory !== sorted[index - 1]?.directory) {
357
+ items.push({
358
+ kind: "directory",
359
+ key: `directory:${directory}`,
360
+ directory,
361
+ collapsed: collapsed.has(directory),
362
+ });
363
+ }
364
+ if (!collapsed.has(directory)) items.push({ kind: "file", key: file.id, file });
365
+ });
366
+ return items;
367
+}
368
+
369
+function DirectoryRow(props: {
370
+ readonly directory: string;
371
+ readonly collapsed: boolean;
372
+ readonly onPress: () => void;
373
+}) {
374
+ const label = props.directory || "Repository root";
375
+ return (
376
+ <RowPressable
377
+ accessibilityRole="button"
378
+ accessibilityLabel={label}
379
+ accessibilityState={{ expanded: !props.collapsed }}
380
+ onPress={props.onPress}
381
+ className="min-h-11 flex-row items-center gap-2 pt-4 pb-2 active:opacity-70"
382
+ >
383
+ <SymbolView
384
+ name={props.collapsed ? "chevron.right" : "chevron.down"}
385
+ size={11}
386
+ tintColorClassName="accent-icon-muted"
387
+ />
388
+ <SymbolView name="folder" size={16} tintColorClassName="accent-icon-muted" />
389
+ <Text textRole="label" className="min-w-0 flex-1 text-foreground-muted" numberOfLines={2}>
390
+ {label}
391
+ </Text>
392
+ </RowPressable>
393
+ );
394
+}
395
+
396
+/** The `PullRequestFiles` sheet: a changed-file picker presented over a file diff. */
397
+export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDiffParams>) {
398
+ const params = route.params;
399
+ const navigation = useNavigation();
400
+ const fileSelectionId = useRoute().key;
401
+ const files = useChangedFiles(params);
402
+ const { diff, filter, viewed, parsed, loading } = files;
403
+ const [collapsed, setCollapsed] = useState<ReadonlySet<string>>(() => new Set());
404
const [animationsReady, setAnimationsReady] = useState(false);
405
+ const toggleDirectory = (directory: string) =>
406
+ setCollapsed((current) => {
407
+ const next = new Set(current);
408
+ if (!next.delete(directory)) next.add(directory);
409
+ return next;
410
+ });
411
return (
314
- <AnimatedLegendList
315
- data={content.rows}
316
- keyExtractor={(row) => row.key}
317
- itemLayoutAnimation={PR_ROW_LAYOUT}
318
- onLoad={() => setAnimationsReady(true)}
319
- renderItem={({ item }) => (
320
- <Animated.View
321
- key={item.key}
322
- entering={animationsReady ? PR_ROW_ENTER : undefined}
323
- exiting={animationsReady ? PR_ROW_EXIT : undefined}
412
+ <View collapsable={false} className="flex-1 bg-sheet">
413
+ <SheetHeader
414
+ presentation={Platform.OS === "android" ? "inline" : "native"}
415
+ title="Changed files"
416
+ subtitle={`#${params.number} · ${params.commit?.slice(0, 7) ?? params.repository}`}
417
+ onClose={() => navigation.goBack()}
418
+ // iOS gets the native menu below; SheetHeader would render this as a custom bar item.
419
+ trailing={Platform.OS === "android" ? <FileFilterMenu filter={filter} /> : undefined}
420
+ />
421
+ <Toolbar placement="right">
422
+ <Toolbar.Menu
423
+ title="Review files"
424
+ accessibilityLabel="Filter review files"
425
+ icon="line.3.horizontal.decrease"
426
>
325
- {item.content}
326
- </Animated.View>
327
- )}
328
- recycleItems={false}
329
- estimatedItemSize={64}
330
- ListHeaderComponent={content.header}
331
- ListFooterComponent={content.footer}
332
- contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 20 }}
333
- />
427
+ <Toolbar.MenuAction
428
+ icon="line.3.horizontal.decrease"
429
+ isOn={filter.hideTestFiles}
430
+ onPress={filter.toggle}
431
+ >
432
+ <Toolbar.Label>Hide test files</Toolbar.Label>
433
+ </Toolbar.MenuAction>
434
+ </Toolbar.Menu>
435
+ </Toolbar>
436
+ <ScreenContent>
437
+ <AnimatedLegendList
438
+ className="flex-1"
439
+ data={parsed.kind === "files" ? groupByDirectory(parsed.files, collapsed) : []}
440
+ keyExtractor={(item) => item.key}
441
+ getItemType={(item) => item.kind}
442
+ itemLayoutAnimation={PR_ROW_LAYOUT}
443
+ onLoad={() => setAnimationsReady(true)}
444
+ renderItem={({ item }) => (
445
+ <Animated.View
446
+ entering={animationsReady ? PR_ROW_ENTER : undefined}
447
+ exiting={animationsReady ? PR_ROW_EXIT : undefined}
448
+ >
449
+ {item.kind === "directory" ? (
450
+ <DirectoryRow
451
+ directory={item.directory}
452
+ collapsed={item.collapsed}
453
+ onPress={() => toggleDirectory(item.directory)}
454
+ />
455
+ ) : (
456
+ <FileRow
457
+ file={item.file}
458
+ viewed={viewed.isViewed(item.file.path)}
459
+ onPress={() =>
460
+ navigation.dispatch(
461
+ StackActions.popTo("PullRequestFile", {
462
+ ...params,
463
+ path: item.file.path,
464
+ fileSelectionId,
465
+ }),
466
+ )
467
+ }
468
+ />
469
+ )}
470
+ </Animated.View>
471
+ )}
472
+ contentInsetAdjustmentBehavior="automatic"
473
+ recycleItems={false}
474
+ estimatedItemSize={64}
475
+ ListHeaderComponent={
476
+ <>
477
+ <PullRequestReadStatus pending={false} error={diff.error} />
478
+ {parsed.kind === "files" ? (
479
+ <View className="flex-row items-center gap-2 py-2">
480
+ <Text textRole="caption" className="min-w-0 flex-1 text-foreground-muted">
481
+ {describeFiles(parsed, files)}
482
+ </Text>
483
+ <PullRequestDiffStats
484
+ additions={parsed.additions}
485
+ deletions={parsed.deletions}
486
+ compact
487
+ />
488
+ </View>
489
+ ) : null}
490
+ <NoVisibleFiles files={files} />
491
+ </>
492
+ }
493
+ ListEmptyComponent={
494
+ loading ? (
495
+ <View
496
+ accessible
497
+ accessibilityLabel="Loading changed files"
498
+ accessibilityState={{ busy: true }}
499
+ >
500
+ {Array.from({ length: loadingRowCount(files) }, (_, index) => (
501
+ <FileRowSkeleton key={index} index={index} />
502
+ ))}
503
+ </View>
504
+ ) : null
505
+ }
506
+ ListFooterComponent={<FilesFooter files={files} />}
507
+ contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 20 }}
508
+ />
509
+ </ScreenContent>
510
+ </View>
511
);
512
}
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+3
-36
@@ -37,13 +37,7 @@ import { usePullRequestAction } from "./usePullRequestAction";
37
import { annotatePullRequestDiff, reviewPosition } from "./pullRequestDiffComments";
38
import { usePullRequestFileFilter } from "./usePullRequestFileFilter";
39
import { isPullRequestTestFile } from "./pullRequestFileFilters";
40
-import {
41
- StackActions,
42
- useFocusEffect,
43
- useNavigation,
44
- useRoute,
45
- type StaticScreenProps,
46
-} from "@react-navigation/native";
40
+import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
41
import { RegistryContext, useAtomRefresh } from "@effect/atom-react";
42
import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
43
import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";
@@ -105,8 +99,7 @@ import {
99
PullRequestDiffStats,
100
PullRequestReadStatus,
101
} from "./PullRequestPresentation";
108
-import { PullRequestFiles, usePullRequestFilesContent } from "./PullRequestFiles";
109
-import { PullRequestSheetContent } from "./PullRequestSheetContent";
102
+import { usePullRequestFilesSection } from "./PullRequestFiles";
103
import { PullRequestDescription } from "./PullRequestDescription";
104
import { PullRequestMarkdownRepository } from "./PullRequestMarkdown";
105
import {
@@ -296,7 +289,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
289
const requestedSection = useRef(section);
290
const [listAnimationsReady, setListAnimationsReady] = useState(false);
291
const [descriptionExpanded, setDescriptionExpanded] = useState(false);
299
- const filesContent = usePullRequestFilesContent({ params });
292
+ const filesContent = usePullRequestFilesSection(params);
293
const guidesEnabled = useReviewGuidesEnabled(params);
294
const [activityFilter, setActivityFilter] = useState<ActivityFilter>(DEFAULT_ACTIVITY_FILTER);
295
const activityContent = usePullRequestActivityRows(params, activityFilter);
@@ -749,32 +742,6 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
742
);
743
}
744
752
-export function PullRequestFilesRouteScreen({ route }: StaticScreenProps<PullRequestDiffParams>) {
753
- const navigation = useNavigation();
754
- const fileSelectionId = useRoute().key;
755
- return (
756
- <PullRequestSheetContent
757
- title="Changed files"
758
- scrollable={false}
759
- subtitle={`#${route.params.number}${route.params.commit ? ` · ${route.params.commit.slice(0, 7)}` : ` · ${route.params.repository}`}`}
760
- >
761
- <PullRequestFiles
762
- params={route.params}
763
- groupByDirectory
764
- onSelectFile={(path) =>
765
- navigation.dispatch(
766
- StackActions.popTo("PullRequestFile", {
767
- ...route.params,
768
- path,
769
- fileSelectionId,
770
- }),
771
- )
772
- }
773
- />
774
- </PullRequestSheetContent>
775
- );
776
-}
777
-
745
export function PullRequestFileRouteScreen({
746
route,
747
}: StaticScreenProps<
apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx
+27
-47
@@ -13,76 +13,56 @@ export function PullRequestSheetContent(props: {
13
readonly busy?: boolean;
14
readonly children: ReactNode;
15
readonly footer?: ReactNode;
16
- readonly scrollable?: boolean;
16
}) {
17
const navigation = useNavigation();
18
const insets = useSafeAreaInsets();
19
const { height: windowHeight } = useWindowDimensions();
20
const android = Platform.OS === "android";
22
- const fitToContents = android && props.scrollable !== false;
21
const footer = props.footer ? (
22
<View
25
- className={
26
- android && props.scrollable !== false ? "bg-sheet-solid pt-3" : "bg-sheet px-4 pt-3"
27
- }
23
+ className={android ? "bg-sheet-solid pt-3" : "bg-sheet px-4 pt-3"}
24
style={{ paddingBottom: Math.max(insets.bottom, 16) }}
25
>
26
{android ? <View style={{ minHeight: 48 }}>{props.footer}</View> : props.footer}
27
</View>
28
) : null;
33
- const content = (
34
- <>
35
- <SheetHeader
36
- presentation="inline"
37
- title={props.title}
38
- subtitle={props.subtitle}
39
- onCancel={() => navigation.goBack()}
40
- dismissDisabled={props.busy}
41
- />
42
- <ScreenContent fitToContents={fitToContents}>
43
- {props.scrollable === false ? (
44
- <View className="flex-1" pointerEvents={props.busy ? "none" : "auto"}>
45
- {props.children}
46
- </View>
47
- ) : (
48
- <ScrollView
49
- nestedScrollEnabled
50
- className="android:shrink android:grow-0 ios:flex-1"
51
- keyboardShouldPersistTaps="handled"
52
- contentContainerStyle={{
53
- paddingHorizontal: 16,
54
- paddingTop: android ? 16 : 0,
55
- paddingBottom: 20,
56
- }}
57
- >
58
- <View className="gap-4" pointerEvents={props.busy ? "none" : "auto"}>
59
- {props.children}
60
- {/* Android partial-height sheets keep submit actions within the scrollable form. */}
61
- {android ? footer : null}
62
- </View>
63
- </ScrollView>
64
- )}
65
-
66
- {!android || props.scrollable === false ? footer : null}
67
- </ScreenContent>
68
- </>
69
- );
29
return (
30
<KeyboardAvoidingView
31
automaticOffset
32
behavior="padding"
33
collapsable={false}
75
- className={props.scrollable === false ? "flex-1 bg-sheet" : "bg-sheet ios:flex-1"}
76
- style={fitToContents ? { maxHeight: windowHeight * 0.92 } : undefined}
34
+ className="bg-sheet ios:flex-1"
35
+ style={android ? { maxHeight: windowHeight * 0.92 } : undefined}
36
>
37
<NativeStackScreenOptions
38
options={{
39
gestureEnabled: !props.busy,
81
- ...(android ? { sheetCornerRadius: 28 } : {}),
82
- ...(fitToContents ? { sheetAllowedDetents: "fitToContents" } : {}),
40
+ ...(android ? { sheetCornerRadius: 28, sheetAllowedDetents: "fitToContents" } : {}),
41
}}
42
/>
85
- {content}
43
+ <SheetHeader
44
+ presentation={android ? "inline" : "native"}
45
+ title={props.title}
46
+ subtitle={props.subtitle}
47
+ onCancel={() => navigation.goBack()}
48
+ dismissDisabled={props.busy}
49
+ />
50
+ <ScreenContent fitToContents={android}>
51
+ <ScrollView
52
+ nestedScrollEnabled
53
+ className="android:shrink android:grow-0 ios:flex-1"
54
+ contentInsetAdjustmentBehavior="automatic"
55
+ keyboardShouldPersistTaps="handled"
56
+ contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 16, paddingBottom: 20 }}
57
+ >
58
+ <View className="gap-4" pointerEvents={props.busy ? "none" : "auto"}>
59
+ {props.children}
60
+ {/* Android partial-height sheets keep submit actions within the scrollable form. */}
61
+ {android ? footer : null}
62
+ </View>
63
+ </ScrollView>
64
+ {android ? null : footer}
65
+ </ScreenContent>
66
</KeyboardAvoidingView>
67
);
68
}
apps/mobile/src/features/threads/git/GitCommitSheet.tsx
+2
-1
@@ -78,7 +78,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
78
/>
79
) : null}
80
<SheetHeader
81
- presentation="inline"
81
+ presentation={Platform.OS === "android" ? "inline" : "native"}
82
title="Commit changes"
83
subtitle={gitStatus.data?.refName ?? "(detached HEAD)"}
84
onCancel={() => navigation.goBack()}
@@ -86,6 +86,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
86
/>
87
<ScrollView
88
nestedScrollEnabled
89
+ contentInsetAdjustmentBehavior="automatic"
90
className="android:shrink android:grow-0 ios:flex-1"
91
keyboardShouldPersistTaps="handled"
92
keyboardDismissMode="on-drag"