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

PullRequestRouteScreen.tsx

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