Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestRouteScreen.tsx

1,230 lines51.1 KB

1import { Toolbar } from "../../components/ui/Toolbar";
2import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
3import { Chip } from "../../components/ui/Chip";
4import { pullRequestTabOffset } from "./pullRequestTabScroll";
5import { guideFocusedRows, type GuideDiffFocus } from "./guide/guideDiffFocus";
6import { PullRequestGuideContent } from "./guide/PullRequestGuideScreen";
7import { useReviewGuidesEnabled } from "./guide/useReviewGuide";
8import {
9 filterPullRequestActivity,
10 DEFAULT_ACTIVITY_FILTER,
11 type ActivityFilter,
12} from "./pullRequestActivityFilter";
13import { PullRequestActivityFilters } from "./PullRequestActivityFilters";
14import type { LegendListRef } from "@legendapp/list/react-native";
15import { AnimatedLegendList } from "@legendapp/list/reanimated";
16import Animated from "react-native-reanimated";
17import {
18 PR_ROW_LAYOUT,
19 PR_ROW_ENTER,
20 PR_ROW_EXIT,
21 PR_POSITION_LAYOUT,
22} from "./pullRequestAnimations";
23import {
24 canPerformPullRequestAction,
25 openOnProviderLabel,
26 PR_ACTION_ICONS,
27 PR_ACTION_LABELS,
28} from "./pullRequestActions";
29import * as Clipboard from "expo-clipboard";
30import { Menu } from "../../components/ui/Menu";
31import { IconButton } from "../../components/ui/IconButton";
32import { Button } from "../../components/ui/Button";
33import { usePullRequestReviewDraft } from "./usePullRequestReviewDraft";
34import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
35import { usePullRequestPermissions } from "./usePullRequestPermissions";
36import { usePullRequestAction } from "./usePullRequestAction";
37import { annotatePullRequestDiff, reviewPosition } from "./pullRequestDiffComments";
38import { usePullRequestFileFilter } from "./usePullRequestFileFilter";
39import { isPullRequestTestFile } from "./pullRequestFileFilters";
40import {
41 StackActions,
42 useFocusEffect,
43 useNavigation,
44 useRoute,
45 type StaticScreenProps,
46} from "@react-navigation/native";
47import { useAtomRefresh } from "@effect/atom-react";
48import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
49import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";
50import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
51import { pullRequestStatus } from "./pullRequestStatus";
52import { useCallback, useEffect, useMemo, useRef, useState } from "react";
53import {
54 Linking,
55 Platform,
56 Pressable,
57 RefreshControl,
58 ScrollView,
59 type ScrollViewProps,
60 StyleSheet,
61 View,
62} from "react-native";
63import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
64import { useSafeAreaInsets } from "react-native-safe-area-context";
65​
66import { AppText as Text } from "../../components/ui/AppText";
67import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
68import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
69import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
70import { AndroidWorkspaceSidebarButton } from "../layout/workspace-sidebar-toolbar";
71import { useAndroidWorkspaceBack } from "../workspace/useAndroidWorkspaceNavigation";
72import { EmptyState } from "../../components/ui/EmptyState";
73import { SegmentedControl } from "../../components/ui/SegmentedControl";
74import { SymbolView } from "../../components/ui/AppSymbol";
75import { relativeTime } from "../../lib/time";
76import { NativeStackScreenOptions } from "../../native/StackHeader";
77import { usePullRequestConnected } from "./usePullRequestConnected";
78import { composerPullRequests } from "../../state/pull-requests";
79import { useEnvironmentQuery } from "../../state/query";
80import { usePullToRefresh } from "../../state/use-pull-to-refresh";
81import {
82 isNativeReviewDiffDrawEvent,
83 resolveNativeReviewDiffView,
84 type NativeReviewDiffViewHandle,
85 type NativeReviewDiffViewProps,
86} from "../diffs/nativeReviewDiffSurface";
87import {
88 buildNativeReviewDiffData,
89 NATIVE_REVIEW_DIFF_CONTENT_WIDTH,
90} from "../review/nativeReviewDiffAdapter";
91import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
92import { useAppearanceCodeSurface } from "../settings/appearance/useAppearanceCodeSurface";
93import { useNativeReviewDiffBridge } from "../review/useNativeReviewDiffBridge";
94import { pullRequestTimelineRows } from "./PullRequestTimeline";
95import { PullRequestActionToolbar, PullRequestCardGroup } from "./PullRequestControls";
96import {
97 pullRequestTarget as requestTarget,
98 usePullRequestDiff,
99 type PullRequestDiffParams,
100 type PullRequestParams,
101} from "./usePullRequestDiff";
102import {
103 PullRequestAvatar,
104 PullRequestDiffStats,
105 PullRequestReadStatus,
106} from "./PullRequestPresentation";
107import { PullRequestFiles, usePullRequestFilesContent } from "./PullRequestFiles";
108import { PullRequestSheetContent } from "./PullRequestSheetContent";
109import { PullRequestDescription } from "./PullRequestDescription";
110import { PullRequestMarkdownRepository } from "./PullRequestMarkdown";
111import {
112 PullRequestStatusMenu,
113 PullRequestChecksRow,
114 PullRequestBranchRow,
115 PullRequestReviewersRow,
116} from "./PullRequestStatusRows";
117import { PullRequestMergeControls } from "./PullRequestMergeControls";
118import { PullRequestStackCard } from "./PullRequestStackCard";
119import { usePullRequestStack, type PullRequestStackState } from "./usePullRequestStack";
120import { usePullRequestEnvironmentFallback } from "./usePullRequestEnvironmentFallback";
121​
122const EMPTY_IDS: readonly string[] = [];
123​
124function PullRequestTabScrollView(props: ScrollViewProps) {
125 const insets = useSafeAreaInsets();
126 return (
127 <ScrollViewMarker style={{ flex: 1 }}>
128 <ScrollView
129 {...props}
130 automaticallyAdjustContentInsets={false}
131 contentInsetAdjustmentBehavior="never"
132 contentOffset={props.contentOffset ?? { x: 0, y: -insets.top }}
133 />
134 </ScrollViewMarker>
135 );
137​
138function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {
139 const navigation = useNavigation();
140 const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
141 const filtered = useMemo(
142 () => (result.data ? filterPullRequestActivity(result.data, filter) : null),
143 [result.data, filter],
144 );
145 const rows = useMemo(() => {
146 if (!filtered) return [];
147 const rows = pullRequestTimelineRows(filtered.activity, params, navigation);
148 if (filter.newestFirst) {
149 const notice = rows.at(-1)?.key === "truncated" ? rows.pop() : undefined;
150 rows.reverse();
151 if (notice) rows.push(notice);
152 }
153 if (!rows.length)
154 rows.push({
155 key: "empty",
156 date: "",
157 content: (
158 <Text className="py-6 text-sm text-foreground-muted">
159 No activity matches these filters.
160 </Text>
161 ),
162 });
163 return rows;
164 }, [filtered, filter.newestFirst, params, navigation]);
165 return {
166 rows,
167 hiddenCount: filtered?.hiddenCount ?? 0,
168 pending: result.isPending,
169 error: result.error,
170 };
172​
173function PullRequestIdentity(props: {
174 readonly pr: PullRequestDetail | PullRequestListEntry;
175 readonly params: PullRequestParams;
176}) {
177 const { pr } = props;
178 const status = pullRequestStatus(pr);
179 return (
180 <View className="gap-3">
181 <View className="flex-row flex-wrap items-center gap-2">
182 {"capabilities" in pr ? (
183 <PullRequestStatusMenu pr={pr} params={props.params} />
184 ) : (
185 <View className="min-h-8 flex-row items-center gap-1.5">
186 <SymbolView name={status.icon} size={14} tintColorClassName={status.tint} />
187 <Text className={`text-xs font-t3-medium ${status.text}`}>{status.label}</Text>
188 </View>
189 )}
190 <PullRequestDiffStats additions={pr.additions} deletions={pr.deletions} compact />
191 {"changedFiles" in pr ? (
192 <Text className="text-2xs text-foreground-muted">
193 {pr.changedFiles} {pr.changedFiles === 1 ? "file" : "files"}
194 </Text>
195 ) : (
196 <View className="h-3 w-12 rounded bg-subtle-strong" />
197 )}
198 </View>
199 <Text selectable className="text-xl font-t3-bold leading-7">
200 {pr.title}
201 </Text>
202 <View className="flex-row items-center gap-2">
203 <PullRequestAvatar actor={pr.author} size={20} />
204 <Text className="min-w-0 flex-1 text-xs font-t3-medium" numberOfLines={1}>
205 {pr.author?.login ?? "Unknown author"}
206 </Text>
207 <Text className="shrink text-right text-2xs text-foreground-muted" numberOfLines={1}>
208 Updated {relativeTime(pr.updatedAt)} ago
209 </Text>
210 </View>
211 <View className="flex-row items-start gap-1.5">
212 <Pressable
213 accessibilityRole="button"
214 accessibilityLabel={`Copy base branch ${pr.baseBranch}`}
215 onPress={() => void Clipboard.setStringAsync(pr.baseBranch)}
216 className="min-w-0 shrink active:opacity-70"
217 hitSlop={8}
218 >
219 <Text className="font-mono text-2xs text-foreground-muted">{pr.baseBranch}</Text>
220 </Pressable>
221 <View className="pt-0.5">
222 <SymbolView name="arrow.left" size={11} tintColorClassName="accent-icon-muted" />
223 </View>
224 <Pressable
225 accessibilityRole="button"
226 accessibilityLabel={`Copy head branch ${pr.headBranch}`}
227 onPress={() => void Clipboard.setStringAsync(pr.headBranch)}
228 className="min-w-0 shrink active:opacity-70"
229 hitSlop={8}
230 >
231 <Text className="font-mono text-2xs text-foreground-muted">{pr.headBranch}</Text>
232 </Pressable>
233 </View>
234 </View>
235 );
237​
238function PullRequestOverview(props: {
239 readonly pr: PullRequestDetail;
240 readonly params: PullRequestParams;
241 readonly stack: PullRequestStackState;
242 readonly onDescriptionLayout: (y: number) => void;
243 readonly onDescriptionCollapse: () => void;
244 readonly descriptionExpanded: boolean;
245 readonly onDescriptionExpandedChange: (expanded: boolean) => void;
246}) {
247 const { pr } = props;
248 return (
249 <View className="gap-5">
250 <PullRequestStackCard params={props.params} state={props.stack} />
251 <PullRequestCardGroup>
252 <PullRequestChecksRow pr={pr} params={props.params} />
253 <PullRequestReviewersRow pr={pr} params={props.params} />
254 <Animated.View layout={PR_ROW_LAYOUT}>
255 <PullRequestBranchRow pr={pr} params={props.params} />
256 </Animated.View>
257 <Animated.View layout={PR_ROW_LAYOUT}>
258 <PullRequestMergeControls pr={pr} params={props.params} stack={props.stack} />
259 </Animated.View>
260 </PullRequestCardGroup>
261 {pr.labels.length ? (
262 <Animated.View layout={PR_ROW_LAYOUT} className="flex-row flex-wrap gap-2">
263 {pr.labels.map((label) => (
264 <Chip key={label.name} label={label.name} size="small" />
265 ))}
266 </Animated.View>
267 ) : null}
268 <Animated.View
269 layout={PR_POSITION_LAYOUT}
270 onLayout={(event) => props.onDescriptionLayout(event.nativeEvent.layout.y)}
271 >
272 <PullRequestDescription
273 markdown={pr.body}
274 onCollapse={props.onDescriptionCollapse}
275 expanded={props.descriptionExpanded}
276 onExpandedChange={props.onDescriptionExpandedChange}
277 />
278 </Animated.View>
279 </View>
280 );
282​
283function usePullRequestToolbarHeight(bottomInset: number) {
284 const { buttonSize } = useAndroidControlSizing();
285 // Reserve the controls, native toolbar padding, and outer gaps before onLayout measures them.
286 return useState(() => (Platform.OS === "android" ? bottomInset + buttonSize + 40 : 0));
288​
289export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestParams>) {
290 const returnToList = useAndroidWorkspaceBack("pullRequests");
291 const { layout } = useAdaptiveWorkspaceLayout();
292 const navigation = useNavigation();
293 const insets = useSafeAreaInsets();
294 const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
295 const params = route.params;
296 usePullRequestEnvironmentFallback(params);
297 const connected = usePullRequestConnected(params.environmentId);
298 const [section, setSection] = useState<"overview" | "activity" | "guide">("overview");
299 // Keep each tab's native list and measured rows alive when it is hidden.
300 const requestedSection = useRef(section);
301 const [listAnimationsReady, setListAnimationsReady] = useState(false);
302 const [descriptionExpanded, setDescriptionExpanded] = useState(false);
303 const filesContent = usePullRequestFilesContent({ params });
304 const guidesEnabled = useReviewGuidesEnabled(params);
305 const [activityFilter, setActivityFilter] = useState<ActivityFilter>(DEFAULT_ACTIVITY_FILTER);
306 const activityContent = usePullRequestActivityRows(params, activityFilter);
307 const scrollOffsets = useRef<Record<string, number>>({});
308 const currentScrollOffset = useRef(-insets.top);
309 const bodyY = useRef(0);
310 const [headerHeight, setHeaderHeight] = useState(0);
311 const [viewportHeight, setViewportHeight] = useState(0);
312 const scrollViews = useRef<Partial<Record<typeof section, LegendListRef | null>>>({});
313 const selectSection = (next: typeof section) => {
314 if (next === section) return;
315 scrollOffsets.current[section] = currentScrollOffset.current;
316 const headerEnd = Math.max(-insets.top, bodyY.current - insets.top);
317 // The shared header stays in place. Once collapsed, retain each tab's own reading position.
318 const offset = pullRequestTabOffset(
319 currentScrollOffset.current,
320 scrollOffsets.current[next],
321 headerEnd,
322 );
323 requestedSection.current = next;
324 scrollOffsets.current[next] = offset;
325 currentScrollOffset.current = offset;
326 scrollViews.current[next]?.scrollToOffset({ offset, animated: false });
327 setSection(next);
328 };
329 useEffect(() => {
330 if (!guidesEnabled && section === "guide") {
331 requestedSection.current = "overview";
332 currentScrollOffset.current = scrollOffsets.current.overview ?? -insets.top;
333 setSection("overview");
334 }
335 }, [guidesEnabled, section, insets.top]);
336 const tabContent = activityContent;
337 const filesY = useRef(0);
338 const descriptionY = useRef(0);
339 const pendingDescriptionJump = useRef(false);
340 const pendingFilesJump = useRef(false);
341 const detailAtom = composerPullRequests.detail(requestTarget(params));
342 const result = useEnvironmentQuery(detailAtom);
343 const pullRefresh = usePullToRefresh(detailAtom);
344 const { refresh: refreshDetail } = result;
345 useFocusEffect(useCallback(() => refreshDetail(), [refreshDetail]));
346 const pr = result.data;
347 const summary = params.initialSummary;
348 const identity = pr ?? summary;
349 const permissions = usePullRequestPermissions(params, pr);
350 const action = usePullRequestAction(params, pr);
351 const showsDeleteBranch = pr !== null && canPerformPullRequestAction(pr, "delete-branch");
352 const confirmDeleteBranch = () =>
353 pr &&
354 action.confirm(
355 "delete-branch",
356 PR_ACTION_LABELS["delete-branch"],
357 `Delete ${pr.headBranch} from ${pr.headRepositoryNameWithOwner ?? pr.repository}? Local branches and worktrees are not changed.`,
358 );
359 const stack = usePullRequestStack(params, pr);
360 const refreshActivity = useAtomRefresh(composerPullRequests.activity(requestTarget(params)));
361 const refreshGuide = useAtomRefresh(composerPullRequests.reviewGuide(requestTarget(params)));
362 const refresh = () => {
363 pullRefresh.onRefresh();
364 if (guidesEnabled) refreshGuide();
365 stack.refresh();
366 refreshActivity();
367 filesContent.refresh();
368 };
369 const jumpToFiles = () => {
370 scrollViews.current.overview?.scrollToOffset({
371 offset: bodyY.current + filesY.current - insets.top,
372 animated: true,
373 });
374 pendingFilesJump.current = false;
375 };
376 const openFiles = () => {
377 if (section === "overview") jumpToFiles();
378 else {
379 pendingFilesJump.current = true;
380 selectSection("overview");
381 if (filesY.current > 0) requestAnimationFrame(jumpToFiles);
382 }
383 };
384 return (
385 <PullRequestMarkdownRepository
386 params={params}
387 value={pr?.provider === "github" ? pr.url : null}
388 >
389 <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
390 <NativeStackScreenOptions
391 options={{
392 title: `#${params.number}`,
393 headerTitle: `#${params.number}`,
394 unstable_headerSubtitle: connected
395 ? params.repository
396 : `${params.repository} · Offline`,
397 }}
398 />
399 {Platform.OS === "android" ? (
400 <AndroidScreenHeader
401 title={`#${params.number}${connected ? "" : " · Offline"}`}
402 subtitle={params.repository}
403 onBack={layout.usesSplitView ? undefined : returnToList}
404 leading={layout.usesSplitView ? <AndroidWorkspaceSidebarButton /> : undefined}
405 actions={[
406 ...(permissions.verdicts.length
407 ? [
408 {
409 accessibilityLabel: "Submit review",
410 icon: "text.bubble" as const,
411 onPress: () =>
412 navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
413 },
414 ]
415 : []),
416 ...(permissions.canComment
417 ? [
418 {
419 accessibilityLabel: "Add comment",
420 icon: "plus.bubble" as const,
421 onPress: () =>
422 navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
423 },
424 ]
425 : []),
426 ...(pr
427 ? [
428 {
429 accessibilityLabel: openOnProviderLabel(pr.provider),
430 icon: "arrow.up.right" as const,
431 onPress: () => void Linking.openURL(pr.url),
432 },
433 ]
434 : []),
435 ...(showsDeleteBranch
436 ? [
437 {
438 accessibilityLabel: PR_ACTION_LABELS["delete-branch"],
439 icon: PR_ACTION_ICONS["delete-branch"],
440 disabled: !action.available("delete-branch"),
441 destructive: true,
442 overflowOnly: true,
443 onPress: confirmDeleteBranch,
444 },
445 ]
446 : []),
447 ]}
448 />
449 ) : null}
450 <Toolbar placement="right">
451 <Toolbar.Menu
452 title="Pull request"
453 accessibilityLabel="Pull request actions"
454 icon="ellipsis"
455 >
456 {permissions.verdicts.length ? (
457 <Toolbar.MenuAction
458 icon="text.bubble"
459 onPress={() =>
460 navigation.navigate("PullRequestReview", { ...params, mode: "review" })
461 }
462 >
463 <Toolbar.Label>Submit review</Toolbar.Label>
464 </Toolbar.MenuAction>
465 ) : null}
466 {permissions.canComment ? (
467 <Toolbar.MenuAction
468 icon="plus.bubble"
469 onPress={() =>
470 navigation.navigate("PullRequestReview", { ...params, mode: "comment" })
471 }
472 >
473 <Toolbar.Label>Add comment</Toolbar.Label>
474 </Toolbar.MenuAction>
475 ) : null}
476 {pr ? (
477 <Toolbar.MenuAction
478 icon="arrow.up.right"
479 onPress={() => void Linking.openURL(pr.url)}
480 >
481 <Toolbar.Label>{openOnProviderLabel(pr.provider)}</Toolbar.Label>
482 </Toolbar.MenuAction>
483 ) : null}
484 {showsDeleteBranch ? (
485 <Toolbar.MenuAction
486 icon={PR_ACTION_ICONS["delete-branch"]}
487 destructive
488 disabled={!action.available("delete-branch")}
489 subtitle={
490 action.busy
491 ? "Deleting…"
492 : connected
493 ? pr.headBranch
494 : "Reconnect to delete this branch."
495 }
496 onPress={confirmDeleteBranch}
497 >
498 <Toolbar.Label>{PR_ACTION_LABELS["delete-branch"]}</Toolbar.Label>
499 </Toolbar.MenuAction>
500 ) : null}
501 </Toolbar.Menu>
502 </Toolbar>
503 <View
504 style={{
505 flex: 1,
506 marginHorizontal: Platform.OS === "android" && layout.usesSplitView ? 4 : 0,
507 }}
508 className={
509 Platform.OS === "android"
510 ? "overflow-hidden rounded-t-[28px] bg-sheet-solid"
511 : undefined
512 }
513 onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
514 >
515 {(["overview", "guide", "activity"] as const)
516 .filter((tab) => tab !== "guide" || guidesEnabled)
517 .map((tab) => (
518 <View
519 key={tab}
520 style={[StyleSheet.absoluteFill, { opacity: section === tab ? 1 : 0 }]}
521 pointerEvents={section === tab ? "auto" : "none"}
522 accessibilityElementsHidden={section !== tab}
523 importantForAccessibility={section === tab ? "auto" : "no-hide-descendants"}
524 >
525 <AnimatedLegendList
526 ref={(list) => {
527 scrollViews.current[tab] = list;
528 }}
529 initialScrollOffset={-insets.top}
530 onScroll={(event) => {
531 const offset = event.nativeEvent.contentOffset.y;
532 scrollOffsets.current[tab] = offset;
533 if (requestedSection.current === tab) currentScrollOffset.current = offset;
534 }}
535 className="flex-1"
536 renderScrollComponent={
537 Platform.OS === "ios" ? PullRequestTabScrollView : undefined
538 }
539 contentInsetAdjustmentBehavior="never"
540 contentInset={
541 Platform.OS === "ios" ? { top: insets.top, bottom: insets.bottom } : undefined
542 }
543 contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
544 refreshControl={
545 <RefreshControl
546 refreshing={section === tab && pullRefresh.refreshing}
547 onRefresh={refresh}
548 />
549 }
550 alwaysBounceVertical
551 scrollsToTop={section === tab}
552 onContentSizeChange={() => {
553 if (
554 tab !== "overview" ||
555 section !== "overview" ||
556 !pendingDescriptionJump.current
557 )
558 return;
559 pendingDescriptionJump.current = false;
560 // Collapse changes the scroll range; restore the heading after that layout commits.
561 scrollViews.current.overview?.scrollToOffset({
562 offset: bodyY.current + descriptionY.current - insets.top,
563 animated: false,
564 });
565 }}
566 contentContainerStyle={{
567 paddingHorizontal: 16,
568 paddingTop: 8,
569 paddingBottom: 24 + (Platform.OS === "android" ? toolbarHeight : 0),
570 // Short tabs must still be tall enough to preserve the collapsed header.
571 minHeight: Math.max(
572 0,
573 viewportHeight + headerHeight - insets.top - insets.bottom,
574 ),
575 }}
576 data={[
577 {
578 key: `${tab}:body`,
579 content: (
580 <View>
581 {tab === "overview" && identity ? (
582 <View>
583 {pr ? (
584 <PullRequestOverview
585 pr={pr}
586 params={params}
587 stack={stack}
588 descriptionExpanded={descriptionExpanded}
589 onDescriptionExpandedChange={setDescriptionExpanded}
590 onDescriptionLayout={(y) => {
591 descriptionY.current = y;
592 }}
593 onDescriptionCollapse={() => {
594 pendingDescriptionJump.current = true;
595 }}
596 />
597 ) : summary ? (
598 <PullRequestOverviewLoading
599 summary={summary}
600 params={params}
601 stack={stack}
602 />
603 ) : null}
604 <View
605 className="mt-8 border-t border-border-subtle pt-3"
606 onLayout={(event) => {
607 filesY.current = event.nativeEvent.layout.y;
608 if (pendingFilesJump.current) {
609 requestAnimationFrame(() => {
610 if (requestedSection.current === "overview") jumpToFiles();
611 });
612 }
613 }}
614 >
615 {filesContent.header}
616 </View>
617 </View>
618 ) : null}
619 {tab === "guide" ? <PullRequestGuideContent params={params} /> : null}
620 {tab === "activity" ? (
621 <PullRequestActivityFilters
622 value={activityFilter}
623 onChange={setActivityFilter}
624 hiddenCount={tabContent.hiddenCount}
625 />
626 ) : null}
627 {tab === "activity" ? (
628 <PullRequestReadStatus
629 pending={tabContent.pending}
630 error={tabContent.error}
631 />
632 ) : null}
633 </View>
634 ),
635 },
636 ...(tab === "overview"
637 ? identity
638 ? filesContent.rows
639 : []
640 : tab === "activity"
641 ? tabContent.rows
642 : []
643 ).map((row) => ({
644 ...row,
645 key: `${tab}:${row.key}`,
646 content: row.content,
647 })),
648 ]}
649 keyExtractor={(row) => row.key}
650 getItemType={(row) =>
651 row.key.endsWith(":body") ? row.key : row.key.split(":")[0]
652 }
653 // The overview body contains the clipped description and owns collapse scroll
654 // correction. Animating that cell fights both; file rows still fade individually.
655 itemLayoutAnimation={tab === "overview" ? undefined : PR_ROW_LAYOUT}
656 onLoad={() => setListAnimationsReady(true)}
657 renderItem={({ item }) => (
658 <Animated.View
659 key={item.key}
660 entering={
661 listAnimationsReady && !item.key.endsWith(":body")
662 ? PR_ROW_ENTER
663 : undefined
664 }
665 exiting={
666 listAnimationsReady && !item.key.endsWith(":body") ? PR_ROW_EXIT : undefined
667 }
668 >
669 {item.content}
670 </Animated.View>
671 )}
672 recycleItems={false}
673 estimatedItemSize={tab === "overview" ? 64 : 220}
674 maintainVisibleContentPosition={false}
675 ListHeaderComponent={
676 <>
677 <PullRequestReadStatus
678 pending={result.isPending && !identity}
679 error={result.error}
680 />
681 {identity ? (
682 <View
683 className="gap-5 pb-5"
684 onLayout={(event) => {
685 bodyY.current = event.nativeEvent.layout.height;
686 setHeaderHeight(event.nativeEvent.layout.height);
687 }}
688 >
689 <PullRequestIdentity pr={identity} params={params} />
690 <SegmentedControl
691 className={Platform.OS === "android" ? undefined : "bg-grouped-card"}
692 options={[
693 { value: "overview", label: "Overview" },
694 ...(guidesEnabled
695 ? [{ value: "guide" as const, label: "Guide" }]
696 : []),
697 { value: "activity", label: "Activity" },
698 ]}
699 selected={section}
700 onSelect={selectSection}
701 role="tab"
702 size="compact"
703 />
704 </View>
705 ) : null}
706 </>
707 }
708 ListFooterComponent={tab === "overview" ? filesContent.footer : null}
709 />
710 </View>
711 ))}
712 </View>
713 <PullRequestActionToolbar
714 pr={pr}
715 params={params}
716 onOpenFiles={openFiles}
717 onHeightChange={setToolbarHeight}
718 />
719 </View>
720 </PullRequestMarkdownRepository>
721 );
723​
724export function PullRequestFilesRouteScreen({ route }: StaticScreenProps<PullRequestDiffParams>) {
725 const navigation = useNavigation();
726 const fileSelectionId = useRoute().key;
727 return (
728 <PullRequestSheetContent
729 title="Changed files"
730 scrollable={false}
731 subtitle={`#${route.params.number}${route.params.commit ? ` · ${route.params.commit.slice(0, 7)}` : ` · ${route.params.repository}`}`}
732 >
733 <PullRequestFiles
734 params={route.params}
735 groupByDirectory
736 onSelectFile={(path) =>
737 navigation.dispatch(
738 StackActions.popTo("PullRequestFile", {
739 ...route.params,
740 path,
741 fileSelectionId,
742 }),
743 )
744 }
745 />
746 </PullRequestSheetContent>
747 );
749​
750export function PullRequestFileRouteScreen({
751 route,
752}: StaticScreenProps<
753 PullRequestDiffParams & {
754 readonly path: string;
755 readonly fileSelectionId?: string;
756 readonly replacingDraftId?: string;
757 readonly focus?: GuideDiffFocus;
758 }
759>) {
760 const { layout } = useAdaptiveWorkspaceLayout();
761 const navigation = useNavigation();
762 const insets = useSafeAreaInsets();
763 const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
764 const commit = route.params.commit;
765 const result = usePullRequestDiff(route.params);
766 const filter = usePullRequestFileFilter(
767 result.parsed,
768 route.params.focus ? route.params.path : undefined,
769 );
770 const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(route.params)));
771 const { refresh: refreshDetail } = detail;
772 useFocusEffect(useCallback(() => refreshDetail(), [refreshDetail]));
773 const { loadMore } = result;
774 const parsed = filter.parsed;
775 const reviewDraft = usePullRequestReviewDraft(route.params);
776 const viewed = usePullRequestFilesViewed(route.params, commit ? null : detail.data);
777 const [commitViewedPaths, setCommitViewedPaths] = useState<ReadonlySet<string>>(() => new Set());
778 const permissions = usePullRequestPermissions(route.params, detail.data);
779 const scopeKey = pullRequestReviewKey(route.params);
780 const [diffHead, setDiffHead] = useState({ scopeKey, sha: detail.data?.headSha ?? null });
781 if (diffHead.scopeKey !== scopeKey || (!diffHead.sha && detail.data?.headSha))
782 setDiffHead({ scopeKey, sha: detail.data?.headSha ?? null });
783 const staleDiff = Boolean(
784 !commit && diffHead.sha && detail.data?.headSha && diffHead.sha !== detail.data.headSha,
785 );
786 const canCommentOnDiff =
787 permissions.canInlineComment &&
788 !commit &&
789 !staleDiff &&
790 !detail.isPending &&
791 !result.isPending &&
792 !result.error;
793 const activity = useEnvironmentQuery(composerPullRequests.activity(requestTarget(route.params)));
794 const baseData = useMemo(() => buildNativeReviewDiffData(parsed), [parsed]);
795 const data = useMemo(
796 () =>
797 annotatePullRequestDiff(
798 baseData,
799 staleDiff || commit ? [] : (activity.data?.reviewThreads ?? []),
800 commit ? [] : reviewDraft.draft.comments,
801 diffHead.sha ?? undefined,
802 ),
803 [baseData, activity.data, reviewDraft.draft.comments, diffHead.sha, staleDiff, commit],
804 );
805 const viewedIds = data.files
806 .filter((file) => (commit ? commitViewedPaths.has(file.path) : viewed.isViewed(file.path)))
807 .map((file) => file.id);
808 const [selectedRowId, setSelectedRowId] = useState<string | null>(null);
809 const selectedRow = data.rows.find((row) => row.id === selectedRowId);
810 const selectedFile = data.files.find((file) => file.id === selectedRow?.fileId);
811 const commentOnLine = (rowId = selectedRowId) => {
812 const row = data.rows.find((row) => row.id === rowId);
813 const file = data.files.find((file) => file.id === row?.fileId);
814 if (!row || !file || !diffHead.sha || !canCommentOnDiff) return;
815 const position = reviewPosition(row);
816 if (!position) return;
817 const oldPath =
818 parsed.kind === "files"
819 ? parsed.files.find((entry) => entry.id === file.id)?.previousPath
820 : null;
821 if (route.params.replacingDraftId) navigation.setParams({ replacingDraftId: undefined });
822 navigation.navigate("PullRequestInlineComment", {
823 ...route.params,
824 ...(route.params.replacingDraftId ? { draftId: route.params.replacingDraftId } : {}),
825 path: file.path,
826 ...(oldPath ? { oldPath } : {}),
827 position,
828 headSha: diffHead.sha,
829 code: row.content ?? "",
830 });
831 };
832 const [jumpPath, setJumpPath] = useState(route.params.path);
833 const requestedFile =
834 result.parsed.kind === "files"
835 ? result.parsed.files.find((file) => file.path === jumpPath)
836 : undefined;
837 const targetFile =
838 data.files.find((file) => file.path === jumpPath) ??
839 (!jumpPath || requestedFile ? data.files[0] : undefined);
840 const focus = route.params.focus;
841 const focusedRows = guideFocusedRows(data.rows, targetFile?.id, focus);
842 const focusIndex = focusedRows.length
843 ? data.rows.findIndex((row) => row.id === focusedRows[0]?.id)
844 : -1;
845 const [collapsedIds, setCollapsedIds] = useState<readonly string[]>(EMPTY_IDS);
846 const [visibleFileId, setVisibleFileId] = useState<string | null>(null);
847 const nativeView = useRef<NativeReviewDiffViewHandle>(null);
848 const jumpStarted = useRef(false);
849 const lastSelection = useRef({ path: route.params.path, id: route.params.fileSelectionId });
850 // Each sheet selection jumps in this reader, including reselecting its original file.
851 useEffect(() => {
852 if (
853 lastSelection.current.path === route.params.path &&
854 lastSelection.current.id === route.params.fileSelectionId
855 )
856 return;
857 lastSelection.current = { path: route.params.path, id: route.params.fileSelectionId };
858 if (route.params.focus) navigation.setParams({ focus: undefined });
859 setJumpPath(route.params.path);
860 setSelectedRowId(null);
861 jumpStarted.current = false;
862 const file = data.files.find((entry) => entry.path === route.params.path);
863 if (!file || !nativeView.current) return;
864 setCollapsedIds((ids) => ids.filter((id) => id !== file.id));
865 jumpStarted.current = true;
866 void nativeView.current.scrollToFile(file.id, false).catch(() => {
867 jumpStarted.current = false;
868 });
869 }, [route.params.path, route.params.fileSelectionId, route.params.focus, data.files, navigation]);
870 const appliedFilter = useRef(filter.hideTestFiles);
871 useEffect(() => {
872 if (appliedFilter.current === filter.hideTestFiles) return;
873 appliedFilter.current = filter.hideTestFiles;
874 if (
875 result.parsed.kind === "files" &&
876 result.parsed.files.some((file) => isPullRequestTestFile(file.path))
877 ) {
878 jumpStarted.current = false;
879 }
880 }, [filter.hideTestFiles, result.parsed]);
881 const { nativeReviewDiffStyle } = useAppearanceCodeSurface();
882 const { themeAppearance, appearance, setCodeWordBreak } = useAppearancePreferences();
883 const bridge = useNativeReviewDiffBridge({
884 threadKey: null,
885 sectionId: `pull-request:${route.params.repository}:${route.params.number}:${commit ?? "all"}`,
886 diff: result.patch,
887 data,
888 collapsedFileIds: collapsedIds,
889 viewedFileIds: viewedIds,
890 selectedRowIds: selectedRowId ? [selectedRowId] : focusedRows.map((row) => row.id),
891 canHighlight: true,
892 });
893 const [NativeDiffView] = useState(() => resolveNativeReviewDiffView());
894 // A file picked from a later page must be fetched before we can jump to its header.
895 useEffect(() => {
896 if (!targetFile) loadMore();
897 }, [targetFile, loadMore]);
898 const { onDebug: updateVisibleRange } = bridge;
899 const onDebug = useCallback<NonNullable<NativeReviewDiffViewProps["onDebug"]>>(
900 (event) => {
901 const drawn = isNativeReviewDiffDrawEvent(event.nativeEvent);
902 const decoded =
903 event.nativeEvent.message === "rows-decoded" && event.nativeEvent.rows === data.rows.length;
904 if (!drawn && !decoded) return;
905 // Filtering replaces the native row payload asynchronously. Old draw events
906 // must not consume the file jump or highlight the new payload's row indices.
907 if (
908 typeof event.nativeEvent.totalRows === "number" &&
909 event.nativeEvent.totalRows !== data.rows.length
910 )
911 return;
912 if (drawn) updateVisibleRange(event);
913 if (
914 targetFile &&
915 !jumpStarted.current &&
916 nativeView.current &&
917 (Platform.OS !== "ios" || decoded)
918 ) {
919 jumpStarted.current = true;
920 if (focusIndex >= 0) return;
921 void nativeView.current.scrollToFile(targetFile.id, false).catch(() => {
922 jumpStarted.current = false;
923 });
924 return;
925 }
926 if (!drawn) return;
927 const lastRow = event.nativeEvent.lastRowIndex;
928 if (typeof lastRow === "number" && lastRow >= data.rows.length - 40) loadMore();
929 },
930 [updateVisibleRange, data.rows.length, loadMore, targetFile, focusIndex],
931 );
932 const onToggleFile = useCallback<NonNullable<NativeReviewDiffViewProps["onToggleFile"]>>(
933 (event) => {
934 const id = event.nativeEvent.fileId;
935 if (!id) return;
936 setCollapsedIds((ids) =>
937 ids.includes(id) ? ids.filter((value) => value !== id) : [...ids, id],
938 );
939 },
940 [],
941 );
942 const visibleFile = data.files.find((file) => file.id === visibleFileId) ?? targetFile;
943 const toggleTestFiles = () => {
944 setJumpPath(visibleFile?.path ?? route.params.path);
945 setSelectedRowId(null);
946 filter.toggle();
947 };
948 const title = commit ? "Commit changes" : "Changes";
949 const seekingFile = !targetFile && result.nextCursor !== null;
950 const loadingDiff = (result.isPending && !data.rows.length) || (seekingFile && !result.error);
951 return (
952 <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
953 <NativeStackScreenOptions
954 options={{
955 title,
956 headerTitle: title,
957 unstable_headerSubtitle: `${commit ? commit.slice(0, 7) : `#${route.params.number}`} · ${data.files.length} ${data.files.length === 1 ? "file" : "files"}${filter.hideTestFiles && filter.hiddenCount ? ` · ${filter.hiddenCount} ${filter.hiddenCount === 1 ? "test" : "tests"} hidden` : ""}`,
958 }}
959 />
960 {Platform.OS === "android" ? (
961 <AndroidScreenHeader
962 title={title}
963 onBack={() => navigation.goBack()}
964 trailing={
965 <Menu
966 actions={[
967 {
968 id: "word-wrap",
969 title: "Word wrap",
970 image: "text.alignleft",
971 state: appearance.codeWordBreak ? "on" : "off",
972 },
973 {
974 id: "hide-tests",
975 title: "Hide test files",
976 image: "line.3.horizontal.decrease",
977 state: filter.hideTestFiles ? "on" : "off",
978 },
979 ...(permissions.verdicts.length
980 ? [{ id: "submit-review", title: "Submit review", image: "text.bubble" }]
981 : []),
982 ...(permissions.canComment
983 ? [{ id: "comment-on-pr", title: "Add comment", image: "plus.bubble" }]
984 : []),
985 ...(selectedRow && selectedFile
986 ? [
987 ...(canCommentOnDiff ? [{ id: "comment", title: "Add review comment" }] : []),
988 { id: "copy", title: "Copy line" },
989 ]
990 : []),
991 ]}
992 onPressAction={({ nativeEvent }) => {
993 if (nativeEvent.event === "word-wrap") setCodeWordBreak(!appearance.codeWordBreak);
994 else if (nativeEvent.event === "hide-tests") toggleTestFiles();
995 else if (
996 nativeEvent.event === "submit-review" ||
997 nativeEvent.event === "comment-on-pr"
998 )
999 navigation.navigate("PullRequestReview", {
1000 ...route.params,
1001 mode: nativeEvent.event === "submit-review" ? "review" : "comment",
1002 });
1003 else if (nativeEvent.event === "comment") commentOnLine();
1004 else void Clipboard.setStringAsync(selectedRow?.content ?? "");
1005 }}
1007 <View pointerEvents="none">
1008 <IconButton icon="ellipsis" accessibilityLabel="Diff options" />
1009 </View>
1010 </Menu>
1012 />
1013 ) : null}
1014 <Toolbar placement="right">
1015 <Toolbar.Menu title="Diff options" accessibilityLabel="Diff options" icon="ellipsis">
1016 {permissions.verdicts.length ? (
1017 <Toolbar.MenuAction
1018 icon="text.bubble"
1019 onPress={() =>
1020 navigation.navigate("PullRequestReview", { ...route.params, mode: "review" })
1023 <Toolbar.Label>Submit review</Toolbar.Label>
1024 </Toolbar.MenuAction>
1025 ) : null}
1026 {permissions.canComment ? (
1027 <Toolbar.MenuAction
1028 icon="plus.bubble"
1029 onPress={() =>
1030 navigation.navigate("PullRequestReview", { ...route.params, mode: "comment" })
1033 <Toolbar.Label>Add comment</Toolbar.Label>
1034 </Toolbar.MenuAction>
1035 ) : null}
1036 <Toolbar.MenuAction
1037 icon="text.alignleft"
1038 isOn={appearance.codeWordBreak}
1039 onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
1041 <Toolbar.Label>Word wrap</Toolbar.Label>
1042 </Toolbar.MenuAction>
1043 <Toolbar.MenuAction
1044 icon="line.3.horizontal.decrease"
1045 isOn={filter.hideTestFiles}
1046 onPress={toggleTestFiles}
1048 <Toolbar.Label>Hide test files</Toolbar.Label>
1049 </Toolbar.MenuAction>
1050 {selectedRow && selectedFile && canCommentOnDiff ? (
1051 <Toolbar.MenuAction icon="bubble.left" onPress={() => commentOnLine()}>
1052 <Toolbar.Label>
1053 {route.params.replacingDraftId ? "Move draft to this line" : "Add review comment"}
1054 </Toolbar.Label>
1055 </Toolbar.MenuAction>
1056 ) : null}
1057 {selectedRow && selectedFile ? (
1058 <Toolbar.MenuAction
1059 icon="document.on.document"
1060 onPress={() => void Clipboard.setStringAsync(selectedRow.content ?? "")}
1062 <Toolbar.Label>Copy line</Toolbar.Label>
1063 </Toolbar.MenuAction>
1064 ) : null}
1065 </Toolbar.Menu>
1066 </Toolbar>
1067 {route.params.replacingDraftId ? (
1068 <Text className="px-4 py-2 text-xs text-foreground-muted">
1069 Select a current line, then choose “Move draft to this line” from its menu.
1070 </Text>
1071 ) : null}
1072 {viewed.error ? (
1073 <Text className="px-4 py-2 text-xs text-danger-foreground">{viewed.error}</Text>
1074 ) : null}
1075 {staleDiff ? (
1076 <View
1077 className="flex-row items-center gap-2 px-4 py-2"
1078 style={{ paddingTop: Platform.OS === "ios" ? insets.top + 8 : 8 }}
1080 <Text className="min-w-0 flex-1 text-xs text-foreground-muted">
1081 The branch changed. Reload before adding line comments.
1082 </Text>
1083 <Button
1084 label="Reload changes"
1085 onPress={() => {
1086 result.refresh();
1087 setDiffHead({ scopeKey, sha: detail.data?.headSha ?? null });
1088 jumpStarted.current = false;
1089 setSelectedRowId(null);
1090 setCollapsedIds(EMPTY_IDS);
1091 }}
1092 />
1093 </View>
1094 ) : null}
1095 <View
1096 className={
1097 Platform.OS === "android"
1098 ? "flex-1 overflow-hidden rounded-t-[28px] bg-sheet-solid"
1099 : "flex-1"
1101 collapsable={false}
1102 style={{ marginHorizontal: Platform.OS === "android" && layout.usesSplitView ? 4 : 0 }}
1104 {loadingDiff || result.error ? (
1105 <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
1106 <PullRequestReadStatus pending={loadingDiff} error={result.error} />
1107 </View>
1108 ) : null}
1109 {NativeDiffView && data.rows.length && !seekingFile ? (
1110 <View className="flex-1" collapsable={false}>
1111 <NativeDiffView
1112 initialRowIndex={focusIndex >= 0 ? Math.max(0, focusIndex - 3) : undefined}
1113 nativeViewRef={nativeView}
1114 refreshing={result.refreshing}
1115 onPullToRefresh={result.onPullRefresh}
1116 style={StyleSheet.absoluteFill}
1117 rowsJson={bridge.rowsJson}
1118 themeJson={bridge.themeJson}
1119 styleJson={bridge.styleJson}
1120 tokensPatchJson={bridge.tokensPatchJson}
1121 tokensResetKey={bridge.tokensResetKey}
1122 collapsedFileIdsJson={bridge.collapsedFileIdsJson}
1123 onDebug={onDebug}
1124 viewedFileIdsJson={bridge.viewedFileIdsJson}
1125 selectedRowIdsJson={bridge.selectedRowIdsJson}
1126 onPressLine={(event) => {
1127 const rowId = event.nativeEvent.rowId ?? null;
1128 setSelectedRowId(rowId);
1129 if (event.nativeEvent.gesture !== "longPress") commentOnLine(rowId);
1130 }}
1131 onToggleViewedFile={(event) => {
1132 const file = data.files.find((file) => file.id === event.nativeEvent.fileId);
1133 if (!file || (!commit && !viewed.canToggle)) return;
1134 const wasViewed = commit
1135 ? commitViewedPaths.has(file.path)
1136 : viewed.isViewed(file.path);
1137 setCollapsedIds((ids) =>
1138 wasViewed
1139 ? ids.filter((id) => id !== file.id)
1140 : ids.includes(file.id)
1141 ? ids
1142 : [...ids, file.id],
1143 );
1144 if (commit)
1145 setCommitViewedPaths((current) => {
1146 const next = new Set(current);
1147 if (next.has(file.path)) next.delete(file.path);
1148 else next.add(file.path);
1149 return next;
1150 });
1151 else void viewed.toggle(file.path);
1152 }}
1153 onToggleComment={(event) => {
1154 const id = event.nativeEvent.commentId;
1155 if (id?.startsWith("discussion:"))
1156 navigation.navigate("PullRequestDiscussion", {
1157 ...route.params,
1158 discussionId: id.slice("discussion:".length),
1159 });
1160 if (id?.startsWith("draft:")) {
1161 const draft = reviewDraft.draft.comments.find(
1162 (draft) => draft.id === id.slice("draft:".length),
1163 );
1164 if (draft)
1165 navigation.navigate("PullRequestInlineComment", {
1166 ...route.params,
1167 ...draft,
1168 draftId: draft.id,
1169 });
1171 }}
1172 onToggleFile={onToggleFile}
1173 onVisibleFileChange={(event) => setVisibleFileId(event.nativeEvent.fileId ?? null)}
1174 appearanceScheme={themeAppearance}
1175 rowHeight={nativeReviewDiffStyle.rowHeight}
1176 contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
1177 contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
1178 contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
1179 contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
1180 />
1181 </View>
1182 ) : filter.hiddenCount > 0 &&
1183 !data.rows.length &&
1184 !result.isPending &&
1185 !result.error &&
1186 !seekingFile ? (
1187 <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
1188 <EmptyState
1189 title="Only test files changed"
1190 detail="Test files are hidden from this review."
1191 action={<Button label="Show test files" tone="contrast" onPress={filter.showAll} />}
1192 variant="plain"
1193 />
1194 </View>
1195 ) : !result.isPending && !result.error && !seekingFile ? (
1196 <EmptyState
1197 title="Diff unavailable"
1198 detail="Open this pull request on its provider to view the changes."
1199 variant="plain"
1200 />
1201 ) : null}
1202 {result.nextCursor && result.isPending && data.rows.length && !seekingFile ? (
1203 <View className="flex-row items-center justify-center gap-2 py-2">
1204 <AppActivityIndicator size="small" />
1205 <Text className="text-xs text-foreground-muted">Loading more files…</Text>
1206 </View>
1207 ) : null}
1208 {result.error && result.nextCursor ? (
1209 <Pressable
1210 accessibilityRole="button"
1211 onPress={result.refresh}
1212 className="min-h-11 items-center justify-center py-2"
1214 <Text className="text-sm font-t3-medium">Retry loading remaining files</Text>
1215 </Pressable>
1216 ) : null}
1217 {parsed.kind === "files" && parsed.notice ? (
1218 <Text className="px-4 py-2 text-2xs text-foreground-muted">{parsed.notice}</Text>
1219 ) : null}
1220 </View>
1221 <PullRequestActionToolbar
1222 pr={detail.data}
1223 params={route.params}
1224 filePath={visibleFile?.path}
1225 onOpenFiles={() => navigation.navigate("PullRequestFiles", route.params)}
1226 onHeightChange={setToolbarHeight}
1227 />
1228 </View>
1229 );