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

PullRequestRouteScreen.tsx

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