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

PullRequestRouteScreen.tsx

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