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