feat(mobile): guided reviews for pull requests (#18267)
This commit is contained in:
1 parent
5495cc4445
commit
bed923986f
42 files changed
+1697
-310
No files matched your search
+3
@@ -41,6 +41,9 @@ class T3ReviewDiffModule : Module() {
|
||||
Prop("contentWidth") { view: T3ReviewDiffView, contentWidth: Double ->
|
||||
view.setContentWidth(contentWidth.toFloat())
|
||||
}
|
||||
Prop("scrollEnabled") { view: T3ReviewDiffView, enabled: Boolean ->
|
||||
view.setScrollEnabled(enabled)
|
||||
}
|
||||
Prop("initialRowIndex") { view: T3ReviewDiffView, initialRowIndex: Double ->
|
||||
view.setInitialRowIndex(initialRowIndex)
|
||||
}
|
||||
|
||||
+23
-10
@@ -50,12 +50,21 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
private val verticalScroller = OverScroller(context)
|
||||
private val horizontalScroller = OverScroller(context)
|
||||
private var dragAxis: DragAxis? = null
|
||||
private var scrollEnabled = true
|
||||
private var horizontalDragTarget: HorizontalPanTarget? = null
|
||||
private var lastTouchX = 0f
|
||||
private var lastTouchY = 0f
|
||||
private var velocityTracker: VelocityTracker? = null
|
||||
|
||||
init {
|
||||
canvasView.onContentHeightChanged = { height ->
|
||||
onDebug(
|
||||
mapOf(
|
||||
"message" to "metrics",
|
||||
"contentHeight" to height / resources.displayMetrics.density
|
||||
)
|
||||
)
|
||||
}
|
||||
canvasView.onRowTap = { row, gesture, target -> handleRowTap(row, gesture, target) }
|
||||
canvasView.onVisibleRowsChanged = { first, last ->
|
||||
onDebug(
|
||||
@@ -198,6 +207,14 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
scrollToY(canvasView.rowTop(index), animated)
|
||||
}
|
||||
|
||||
fun setScrollEnabled(enabled: Boolean) {
|
||||
scrollEnabled = enabled
|
||||
if (!enabled) {
|
||||
verticalScroller.forceFinished(true)
|
||||
canvasView.setVerticalOffset(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun scrollToTop(animated: Boolean) {
|
||||
scrollToY(0, animated)
|
||||
}
|
||||
@@ -212,7 +229,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
horizontalDragTarget = canvasView.horizontalPanTarget(event.y)
|
||||
lastTouchX = event.x
|
||||
lastTouchY = event.y
|
||||
parent?.requestDisallowInterceptTouchEvent(true)
|
||||
parent?.requestDisallowInterceptTouchEvent(scrollEnabled)
|
||||
return false
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
@@ -221,7 +238,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
val deltaY = event.y - lastTouchY
|
||||
if (max(abs(deltaX), abs(deltaY)) > touchSlop) {
|
||||
dragAxis = if (abs(deltaY) >= abs(deltaX)) {
|
||||
DragAxis.VERTICAL
|
||||
if (scrollEnabled) DragAxis.VERTICAL else null
|
||||
} else {
|
||||
horizontalDragTarget
|
||||
?.takeIf { canvasView.maxHorizontalOffset(it) > 0 }
|
||||
@@ -229,6 +246,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dragAxis == DragAxis.HORIZONTAL) parent?.requestDisallowInterceptTouchEvent(true)
|
||||
return dragAxis != null
|
||||
}
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> return dragAxis != null
|
||||
@@ -751,6 +769,7 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
}
|
||||
var onRowTap: ((DiffRow, String, RowTapTarget) -> Unit)? = null
|
||||
var onVisibleRowsChanged: ((Int, Int) -> Unit)? = null
|
||||
var onContentHeightChanged: ((Int) -> Unit)? = null
|
||||
|
||||
fun prepareRows() = drawing.prepareRows(tokensByRowId, style, width)
|
||||
fun useCodeLayouts(layouts: CodeLayoutCache) {
|
||||
@@ -876,6 +895,7 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
setVerticalOffset(verticalOffset)
|
||||
setHorizontalOffset(horizontalOffset)
|
||||
clampHeaderPathOffsets()
|
||||
onContentHeightChanged?.invoke(rowOffsets.last())
|
||||
}
|
||||
|
||||
private fun rowHeight(row: DiffRow): Int = when (row.kind) {
|
||||
@@ -1198,14 +1218,7 @@ private class DiffCanvasView(context: Context) : View(context) {
|
||||
}
|
||||
val selected = selectedRowIds.contains(row.id)
|
||||
if (selected) {
|
||||
fill(
|
||||
canvas,
|
||||
withAlpha(theme.hunkText, 56),
|
||||
0f,
|
||||
top.toFloat(),
|
||||
width.toFloat(),
|
||||
bottom.toFloat(),
|
||||
)
|
||||
// Keep the diff and syntax colors intact; selection lives in the gutter.
|
||||
fill(
|
||||
canvas,
|
||||
withAlpha(theme.hunkText, 242),
|
||||
|
||||
@@ -61,6 +61,18 @@ public class T3ReviewDiffModule: Module {
|
||||
view.setInitialRowIndex(initialRowIndex)
|
||||
}
|
||||
|
||||
Prop("scrollEnabled") { (view: T3ReviewDiffView, enabled: Bool) in
|
||||
view.setScrollEnabled(enabled)
|
||||
}
|
||||
|
||||
Prop("bounces") { (view: T3ReviewDiffView, bounces: Bool) in
|
||||
view.setBounces(bounces)
|
||||
}
|
||||
|
||||
Prop("refreshEnabled") { (view: T3ReviewDiffView, enabled: Bool) in
|
||||
view.setRefreshEnabled(enabled)
|
||||
}
|
||||
|
||||
Prop("refreshing") { (view: T3ReviewDiffView, refreshing: Bool) in
|
||||
view.setRefreshing(refreshing)
|
||||
}
|
||||
|
||||
@@ -365,7 +365,6 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
|
||||
scrollView.showsHorizontalScrollIndicator = false
|
||||
scrollView.backgroundColor = contentView.theme.background
|
||||
pullRefreshControl.addTarget(self, action: #selector(handlePullToRefresh), for: .valueChanged)
|
||||
scrollView.refreshControl = pullRefreshControl
|
||||
addSubview(scrollView)
|
||||
|
||||
contentView.backgroundColor = contentView.theme.background
|
||||
@@ -701,14 +700,14 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
|
||||
applyPendingScrollIfNeeded()
|
||||
emitVisibleFileIfNeeded()
|
||||
|
||||
let debugKey = "\(rows.count):\(Int(bounds.width)):\(Int(bounds.height)):\(Int(height))"
|
||||
let debugKey = "\(rows.count):\(Int(bounds.width)):\(Int(bounds.height)):\(Int(contentView.contentHeight))"
|
||||
if debugKey != lastMetricsDebugKey {
|
||||
lastMetricsDebugKey = debugKey
|
||||
emitDebug("metrics", [
|
||||
"rows": rows.count,
|
||||
"boundsWidth": Double(bounds.width),
|
||||
"boundsHeight": Double(bounds.height),
|
||||
"contentHeight": Double(height),
|
||||
"contentHeight": Double(contentView.contentHeight),
|
||||
"contentWidth": Double(style.contentWidth),
|
||||
"fileHeaderHeight": Double(style.fileHeaderHeight),
|
||||
"rowHeight": Double(style.rowHeight),
|
||||
@@ -840,6 +839,20 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
|
||||
setVerticalContentOffset(0, animated: animated)
|
||||
}
|
||||
|
||||
func setScrollEnabled(_ enabled: Bool) {
|
||||
scrollView.isScrollEnabled = enabled
|
||||
}
|
||||
|
||||
func setBounces(_ bounces: Bool) {
|
||||
scrollView.bounces = bounces
|
||||
scrollView.alwaysBounceVertical = bounces
|
||||
}
|
||||
|
||||
func setRefreshEnabled(_ enabled: Bool) {
|
||||
if !enabled { pullRefreshControl.endRefreshing() }
|
||||
scrollView.refreshControl = enabled ? pullRefreshControl : nil
|
||||
}
|
||||
|
||||
@objc private func handlePullToRefresh() {
|
||||
onPullToRefresh([:])
|
||||
}
|
||||
@@ -2429,10 +2442,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
let selectionColor = theme.hunkText.withAlphaComponent(0.22)
|
||||
selectionColor.setFill()
|
||||
context.fill(rect)
|
||||
|
||||
// Keep the diff and syntax colors intact; selection lives in the gutter.
|
||||
theme.hunkText.withAlphaComponent(0.95).setFill()
|
||||
context.fill(CGRect(x: 0, y: rect.minY, width: style.changeBarWidth, height: rect.height))
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { PullRequestGuideStopScreen } from "./features/pull-requests/guide/PullRequestGuideScreen";
|
||||
import { PullRequestInlineCommentScreen } from "./features/pull-requests/PullRequestInlineCommentScreen";
|
||||
import { PullRequestDiscussionScreen } from "./features/pull-requests/PullRequestDiscussionScreen";
|
||||
import {
|
||||
@@ -722,6 +723,10 @@ const RootStackConfig = createWorkspaceStackNavigator({
|
||||
},
|
||||
options: GLASS_HEADER_OPTIONS,
|
||||
}),
|
||||
PullRequestGuideStop: createNativeStackScreen({
|
||||
screen: PullRequestGuideStopScreen,
|
||||
options: GLASS_HEADER_OPTIONS,
|
||||
}),
|
||||
PullRequestFile: createNativeStackScreen({
|
||||
screen: PullRequestFileRouteScreen,
|
||||
options: GLASS_HEADER_OPTIONS,
|
||||
|
||||
@@ -124,6 +124,9 @@ export interface NativeReviewDiffViewProps extends ViewProps {
|
||||
readonly rowHeight: number;
|
||||
readonly contentWidth: number;
|
||||
readonly initialRowIndex?: number;
|
||||
/** Disable the native vertical scroller when an excerpt grows inside a page. */
|
||||
readonly scrollEnabled?: boolean;
|
||||
readonly bounces?: boolean;
|
||||
readonly refreshing?: boolean;
|
||||
readonly nativeViewRef?: Ref<NativeReviewDiffViewHandle>;
|
||||
readonly onPullToRefresh?: (event: NativeSyntheticEvent<Record<string, never>>) => void;
|
||||
@@ -167,6 +170,7 @@ type NativeReviewDiffRawViewProps = Omit<
|
||||
NativeReviewDiffViewProps,
|
||||
"nativeViewRef" | "rowsJson" | "tokensJson" | "tokensPatchJson"
|
||||
> & {
|
||||
readonly refreshEnabled: boolean;
|
||||
readonly ref?: Ref<NativeReviewDiffViewRef>;
|
||||
};
|
||||
|
||||
@@ -270,7 +274,11 @@ function NativeReviewDiffView(props: NativeReviewDiffViewProps) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return createElement(RawNativeView, { ...nativeProps, ref: nativeRef });
|
||||
return createElement(RawNativeView, {
|
||||
...nativeProps,
|
||||
refreshEnabled: props.onPullToRefresh !== undefined,
|
||||
ref: nativeRef,
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveNativeReviewDiffView(): ComponentType<NativeReviewDiffViewProps> | null {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import { Pressable, View } from "react-native";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { ControlPillMenu } from "../../components/ControlPillMenu";
|
||||
import type { ActivityFilter } from "./pullRequestActivityFilter";
|
||||
|
||||
export function PullRequestActivityFilters({
|
||||
value,
|
||||
onChange,
|
||||
hiddenCount,
|
||||
}: {
|
||||
readonly value: ActivityFilter;
|
||||
readonly onChange: (value: ActivityFilter) => void;
|
||||
readonly hiddenCount: number;
|
||||
}) {
|
||||
const kinds = [
|
||||
{ id: "all", title: "All activity" },
|
||||
{ id: "comments", title: "Comments" },
|
||||
{ id: "commits", title: "Commits" },
|
||||
] as const;
|
||||
return (
|
||||
<View className="mb-4 flex-row items-center justify-between gap-3">
|
||||
<ControlPillMenu
|
||||
title="Activity"
|
||||
actions={kinds.map((kind) => ({ ...kind, state: value.kind === kind.id ? "on" : "off" }))}
|
||||
onPressAction={({ nativeEvent }) => {
|
||||
const kind = kinds.find((item) => item.id === nativeEvent.event);
|
||||
if (kind) onChange({ ...value, kind: kind.id });
|
||||
}}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Activity type, ${kinds.find((kind) => kind.id === value.kind)?.title}`}
|
||||
className="min-h-11 flex-row items-center gap-2 active:opacity-60"
|
||||
>
|
||||
<Text className="text-sm font-t3-semibold">
|
||||
{kinds.find((kind) => kind.id === value.kind)?.title}
|
||||
</Text>
|
||||
<SymbolView name="chevron.down" size={11} tintColorClassName="accent-icon-muted" />
|
||||
</Pressable>
|
||||
</ControlPillMenu>
|
||||
<View className="flex-row items-center gap-3">
|
||||
<ControlPillMenu
|
||||
title="Show in activity"
|
||||
actions={[
|
||||
{ id: "bots", title: "Bot comments", state: value.bots ? "on" : "off" },
|
||||
{
|
||||
id: "resolved",
|
||||
title: "Resolved or dismissed",
|
||||
state: value.resolved ? "on" : "off",
|
||||
},
|
||||
]}
|
||||
onPressAction={({ nativeEvent: { event } }) => {
|
||||
if (event === "bots" || event === "resolved")
|
||||
onChange({ ...value, [event]: !value[event] });
|
||||
}}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Filter activity, ${hiddenCount} hidden`}
|
||||
className="min-h-11 flex-row items-center gap-1.5 active:opacity-60"
|
||||
>
|
||||
{hiddenCount > 0 ? (
|
||||
<Text className="text-xs text-foreground-muted">{hiddenCount} hidden</Text>
|
||||
) : null}
|
||||
<SymbolView
|
||||
name="line.3.horizontal.decrease"
|
||||
size={18}
|
||||
tintColorClassName="accent-icon-muted"
|
||||
/>
|
||||
</Pressable>
|
||||
</ControlPillMenu>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={value.newestFirst ? "Newest first" : "Oldest first"}
|
||||
onPress={() => onChange({ ...value, newestFirst: !value.newestFirst })}
|
||||
className="h-11 flex-row items-center gap-1 active:opacity-60"
|
||||
>
|
||||
<SymbolView
|
||||
name={value.newestFirst ? "arrow.down" : "arrow.up"}
|
||||
size={18}
|
||||
tintColorClassName="accent-icon-muted"
|
||||
/>
|
||||
<Text className="text-xs text-foreground-muted">
|
||||
{value.newestFirst ? "Newest" : "Oldest"}
|
||||
</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import Animated from "react-native-reanimated";
|
||||
import { PR_ROW_LAYOUT } from "./pullRequestAnimations";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import type { PullRequestDetail } from "@t3tools/contracts";
|
||||
import type { ReactNode } from "react";
|
||||
@@ -21,9 +23,12 @@ import { usePullRequestAgentActions } from "./usePullRequestAgentActions";
|
||||
|
||||
export function PullRequestCardGroup(props: { readonly children: ReactNode }) {
|
||||
return (
|
||||
<View className="overflow-hidden rounded-[22px] border-continuous bg-grouped-card">
|
||||
<Animated.View
|
||||
layout={PR_ROW_LAYOUT}
|
||||
className="overflow-hidden rounded-[22px] border-continuous bg-grouped-card"
|
||||
>
|
||||
{props.children}
|
||||
</View>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { LegendList } from "@legendapp/list/react-native";
|
||||
import { AnimatedLegendList } from "@legendapp/list/reanimated";
|
||||
import Animated from "react-native-reanimated";
|
||||
import { PR_ROW_LAYOUT, PR_ROW_ENTER, PR_ROW_EXIT } from "./pullRequestAnimations";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { useState } from "react";
|
||||
import { ActivityIndicator, Pressable, View } from "react-native";
|
||||
@@ -192,7 +194,7 @@ export function usePullRequestFilesContent(props: {
|
||||
</View>
|
||||
) : parsed.kind === "files" ? (
|
||||
<>
|
||||
<View className="flex-row items-center gap-2 py-3">
|
||||
<View className="min-h-17 flex-row items-center gap-2 py-3">
|
||||
<View className="min-w-0 flex-1 gap-1">
|
||||
<Text className="text-base font-t3-semibold">
|
||||
{parsed.fileCount} {filter.hiddenCount ? "visible" : "changed"}{" "}
|
||||
@@ -201,11 +203,11 @@ export function usePullRequestFilesContent(props: {
|
||||
? ` · ${parsed.files.filter((file) => viewed.isViewed(file.path)).length} viewed`
|
||||
: ""}
|
||||
</Text>
|
||||
{filter.hideTestFiles ? (
|
||||
<Text className="text-2xs text-foreground-muted">
|
||||
{filter.hiddenCount} test {filter.hiddenCount === 1 ? "file" : "files"} hidden
|
||||
</Text>
|
||||
) : null}
|
||||
<Text className="text-2xs text-foreground-muted">
|
||||
{filter.hideTestFiles
|
||||
? `${filter.hiddenCount} test ${filter.hiddenCount === 1 ? "file" : "files"} hidden`
|
||||
: "Test files included"}
|
||||
</Text>
|
||||
</View>
|
||||
<PullRequestDiffStats
|
||||
additions={parsed.additions}
|
||||
@@ -285,11 +287,22 @@ export function usePullRequestFilesContent(props: {
|
||||
|
||||
export function PullRequestFiles(props: Parameters<typeof usePullRequestFilesContent>[0]) {
|
||||
const content = usePullRequestFilesContent(props);
|
||||
const [animationsReady, setAnimationsReady] = useState(false);
|
||||
return (
|
||||
<LegendList
|
||||
<AnimatedLegendList
|
||||
data={content.rows}
|
||||
keyExtractor={(row) => row.key}
|
||||
renderItem={({ item }) => item.content}
|
||||
itemLayoutAnimation={PR_ROW_LAYOUT}
|
||||
onLoad={() => setAnimationsReady(true)}
|
||||
renderItem={({ item }) => (
|
||||
<Animated.View
|
||||
key={item.key}
|
||||
entering={animationsReady ? PR_ROW_ENTER : undefined}
|
||||
exiting={animationsReady ? PR_ROW_EXIT : undefined}
|
||||
>
|
||||
{item.content}
|
||||
</Animated.View>
|
||||
)}
|
||||
recycleItems={false}
|
||||
estimatedItemSize={64}
|
||||
ListHeaderComponent={content.header}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
import { PullRequestEntryRow } from "./PullRequestEntryRow";
|
||||
import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
|
||||
import { pullRequestTabOffset } from "./pullRequestTabScroll";
|
||||
import { guideFocusedRows, type GuideDiffFocus } from "./guide/guideDiffFocus";
|
||||
import { PullRequestGuideContent } from "./guide/PullRequestGuideScreen";
|
||||
import { useReviewGuidesEnabled } from "./guide/useReviewGuide";
|
||||
import {
|
||||
filterPullRequestActivity,
|
||||
DEFAULT_ACTIVITY_FILTER,
|
||||
type ActivityFilter,
|
||||
} from "./pullRequestActivityFilter";
|
||||
import { PullRequestActivityFilters } from "./PullRequestActivityFilters";
|
||||
import type { LegendListRef } from "@legendapp/list/react-native";
|
||||
import { AnimatedLegendList } from "@legendapp/list/reanimated";
|
||||
import Animated from "react-native-reanimated";
|
||||
import {
|
||||
PR_ROW_LAYOUT,
|
||||
PR_ROW_ENTER,
|
||||
PR_ROW_EXIT,
|
||||
PR_POSITION_LAYOUT,
|
||||
} from "./pullRequestAnimations";
|
||||
import { openOnProviderLabel } from "./pullRequestActions";
|
||||
import * as Clipboard from "expo-clipboard";
|
||||
import { ControlPillMenu } from "../../components/ControlPillMenu";
|
||||
@@ -23,7 +40,7 @@ import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
|
||||
import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";
|
||||
import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
|
||||
import { pullRequestStatus } from "./pullRequestStatus";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, type ReactElement } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Linking,
|
||||
@@ -104,76 +121,39 @@ function PullRequestTabScrollView(props: ScrollViewProps) {
|
||||
);
|
||||
}
|
||||
|
||||
function usePullRequestActivityRows(params: PullRequestParams, commitsOnly: boolean) {
|
||||
function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {
|
||||
const navigation = useNavigation();
|
||||
const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
|
||||
const filtered = useMemo(
|
||||
() => (result.data ? filterPullRequestActivity(result.data, filter) : null),
|
||||
[result.data, filter],
|
||||
);
|
||||
const rows = useMemo(() => {
|
||||
const rows: { key: string; content: ReactElement }[] = [];
|
||||
if (commitsOnly) {
|
||||
for (const commit of result.data?.commits ?? [])
|
||||
rows.push({
|
||||
key: `commit:${commit.oid}`,
|
||||
content: (
|
||||
<Pressable
|
||||
key={commit.oid}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`View changes in commit ${commit.oid.slice(0, 7)}, ${commit.messageHeadline}`}
|
||||
onPress={() =>
|
||||
navigation.dispatch(
|
||||
StackActions.push("PullRequestFile", {
|
||||
...params,
|
||||
commit: commit.oid,
|
||||
path: "",
|
||||
}),
|
||||
)
|
||||
}
|
||||
className={`border-b border-border-subtle pb-3 active:opacity-70 ${rows.length ? "pt-3" : ""}`}
|
||||
>
|
||||
<PullRequestEntryRow
|
||||
leading={
|
||||
<View className="h-8 items-center justify-center">
|
||||
<PullRequestAvatar actor={commit.authors?.[0] ?? null} size={24} />
|
||||
</View>
|
||||
}
|
||||
>
|
||||
<View className="gap-1">
|
||||
<View className="min-h-8 flex-row items-center gap-2">
|
||||
<Text className="min-w-0 flex-1 text-sm" numberOfLines={1}>
|
||||
{commit.messageHeadline}
|
||||
</Text>
|
||||
<Text className="font-mono text-2xs text-foreground-muted">
|
||||
{commit.oid.slice(0, 7)}
|
||||
</Text>
|
||||
<SymbolView
|
||||
name="chevron.right"
|
||||
size={11}
|
||||
tintColorClassName="accent-icon-muted"
|
||||
/>
|
||||
</View>
|
||||
<Text className="text-2xs text-foreground-muted">
|
||||
{commit.authors?.map((author) => author.login).join(", ") || "Commit"} ·{" "}
|
||||
{relativeTime(commit.committedDate)}
|
||||
</Text>
|
||||
</View>
|
||||
</PullRequestEntryRow>
|
||||
</Pressable>
|
||||
),
|
||||
});
|
||||
} else if (result.data) {
|
||||
rows.push(...pullRequestTimelineRows(result.data, params, navigation));
|
||||
if (!filtered) return [];
|
||||
const rows = pullRequestTimelineRows(filtered.activity, params, navigation);
|
||||
if (filter.newestFirst) {
|
||||
const notice = rows.at(-1)?.key === "truncated" ? rows.pop() : undefined;
|
||||
rows.reverse();
|
||||
if (notice) rows.push(notice);
|
||||
}
|
||||
if (!rows.length && result.data)
|
||||
if (!rows.length)
|
||||
rows.push({
|
||||
key: "empty",
|
||||
date: "",
|
||||
content: (
|
||||
<Text className="py-6 text-sm text-foreground-muted">
|
||||
{commitsOnly ? "No commits reported." : "No comments yet."}
|
||||
No activity matches these filters.
|
||||
</Text>
|
||||
),
|
||||
});
|
||||
return rows;
|
||||
}, [commitsOnly, navigation, params, result.data]);
|
||||
return { rows, pending: result.isPending, error: result.error };
|
||||
}, [filtered, filter.newestFirst, params, navigation]);
|
||||
return {
|
||||
rows,
|
||||
hiddenCount: filtered?.hiddenCount ?? 0,
|
||||
pending: result.isPending,
|
||||
error: result.error,
|
||||
};
|
||||
}
|
||||
|
||||
function PullRequestIdentity(props: {
|
||||
@@ -257,26 +237,33 @@ function PullRequestOverview(props: {
|
||||
<PullRequestCardGroup>
|
||||
<PullRequestChecksRow pr={pr} params={props.params} />
|
||||
<PullRequestReviewersRow pr={pr} params={props.params} />
|
||||
<PullRequestBranchRow pr={pr} params={props.params} />
|
||||
<PullRequestMergeControls pr={pr} params={props.params} stack={props.stack} />
|
||||
<Animated.View layout={PR_ROW_LAYOUT}>
|
||||
<PullRequestBranchRow pr={pr} params={props.params} />
|
||||
</Animated.View>
|
||||
<Animated.View layout={PR_ROW_LAYOUT}>
|
||||
<PullRequestMergeControls pr={pr} params={props.params} stack={props.stack} />
|
||||
</Animated.View>
|
||||
</PullRequestCardGroup>
|
||||
{pr.labels.length ? (
|
||||
<View className="flex-row flex-wrap gap-2">
|
||||
<Animated.View layout={PR_ROW_LAYOUT} className="flex-row flex-wrap gap-2">
|
||||
{pr.labels.map((label) => (
|
||||
<View key={label.name} className="rounded-full bg-grouped-card px-3 py-1">
|
||||
<Text className="text-2xs text-foreground-muted">{label.name}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
<View onLayout={(event) => props.onDescriptionLayout(event.nativeEvent.layout.y)}>
|
||||
<Animated.View
|
||||
layout={PR_POSITION_LAYOUT}
|
||||
onLayout={(event) => props.onDescriptionLayout(event.nativeEvent.layout.y)}
|
||||
>
|
||||
<PullRequestDescription
|
||||
markdown={pr.body}
|
||||
onCollapse={props.onDescriptionCollapse}
|
||||
expanded={props.descriptionExpanded}
|
||||
onExpandedChange={props.onDescriptionExpandedChange}
|
||||
/>
|
||||
</View>
|
||||
</Animated.View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -285,43 +272,45 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
|
||||
const navigation = useNavigation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const params = route.params;
|
||||
const [section, setSection] = useState<"overview" | "activity" | "commits">("overview");
|
||||
// LegendList commits replacement rows after the header. Keep selection with the visible content.
|
||||
const [displayedSection, setDisplayedSection] = useState(section);
|
||||
const [section, setSection] = useState<"overview" | "activity" | "guide">("overview");
|
||||
// Keep each tab's native list and measured rows alive when it is hidden.
|
||||
const requestedSection = useRef(section);
|
||||
const [listAnimationsReady, setListAnimationsReady] = useState(false);
|
||||
const [descriptionExpanded, setDescriptionExpanded] = useState(false);
|
||||
const filesContent = usePullRequestFilesContent({ params });
|
||||
const activityContent = usePullRequestActivityRows(params, false);
|
||||
const commitsContent = usePullRequestActivityRows(params, true);
|
||||
const guidesEnabled = useReviewGuidesEnabled(params);
|
||||
const [activityFilter, setActivityFilter] = useState<ActivityFilter>(DEFAULT_ACTIVITY_FILTER);
|
||||
const activityContent = usePullRequestActivityRows(params, activityFilter);
|
||||
const scrollOffsets = useRef<Record<string, number>>({});
|
||||
const currentScrollOffset = useRef(-insets.top);
|
||||
const bodyY = useRef(0);
|
||||
const pendingScrollOffset = useRef<number | null>(null);
|
||||
const selectSection = (next: "overview" | "activity" | "commits") => {
|
||||
const [headerHeight, setHeaderHeight] = useState(0);
|
||||
const [viewportHeight, setViewportHeight] = useState(0);
|
||||
const scrollViews = useRef<Partial<Record<typeof section, LegendListRef | null>>>({});
|
||||
const selectSection = (next: typeof section) => {
|
||||
if (next === section) return;
|
||||
requestedSection.current = next;
|
||||
scrollOffsets.current[section] = currentScrollOffset.current;
|
||||
if (scrollOffsets.current[next] === undefined) {
|
||||
scrollOffsets.current[next] = Math.min(
|
||||
currentScrollOffset.current,
|
||||
bodyY.current - insets.top,
|
||||
);
|
||||
}
|
||||
pendingScrollOffset.current = scrollOffsets.current[next] ?? -insets.top;
|
||||
const headerEnd = Math.max(-insets.top, bodyY.current - insets.top);
|
||||
// The shared header stays in place. Once collapsed, retain each tab's own reading position.
|
||||
const offset = pullRequestTabOffset(
|
||||
currentScrollOffset.current,
|
||||
scrollOffsets.current[next],
|
||||
headerEnd,
|
||||
);
|
||||
requestedSection.current = next;
|
||||
scrollOffsets.current[next] = offset;
|
||||
currentScrollOffset.current = offset;
|
||||
scrollViews.current[next]?.scrollToOffset({ offset, animated: false });
|
||||
setSection(next);
|
||||
};
|
||||
const tab = section;
|
||||
const tabContent = section === "commits" ? commitsContent : activityContent;
|
||||
const scrollView = useRef<LegendListRef>(null);
|
||||
const commitSectionLayout = () => {
|
||||
if (requestedSection.current !== section) return;
|
||||
setDisplayedSection(section);
|
||||
const offset = pendingScrollOffset.current;
|
||||
if (offset !== null) {
|
||||
pendingScrollOffset.current = null;
|
||||
scrollView.current?.scrollToOffset({ offset, animated: false });
|
||||
useEffect(() => {
|
||||
if (!guidesEnabled && section === "guide") {
|
||||
requestedSection.current = "overview";
|
||||
currentScrollOffset.current = scrollOffsets.current.overview ?? -insets.top;
|
||||
setSection("overview");
|
||||
}
|
||||
};
|
||||
}, [guidesEnabled, section, insets.top]);
|
||||
const tabContent = activityContent;
|
||||
const filesY = useRef(0);
|
||||
const descriptionY = useRef(0);
|
||||
const pendingDescriptionJump = useRef(false);
|
||||
@@ -329,7 +318,6 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
|
||||
const detailAtom = composerPullRequests.detail(requestTarget(params));
|
||||
const result = useEnvironmentQuery(detailAtom);
|
||||
const pullRefresh = usePullToRefresh(detailAtom);
|
||||
const activity = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
|
||||
const { refresh: refreshDetail } = result;
|
||||
useFocusEffect(useCallback(() => refreshDetail(), [refreshDetail]));
|
||||
const pr = result.data;
|
||||
@@ -338,24 +326,27 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
|
||||
const permissions = usePullRequestPermissions(params, pr);
|
||||
const stack = usePullRequestStack(params, pr);
|
||||
const refreshActivity = useAtomRefresh(composerPullRequests.activity(requestTarget(params)));
|
||||
const refreshGuide = useAtomRefresh(composerPullRequests.reviewGuide(requestTarget(params)));
|
||||
const refresh = () => {
|
||||
pullRefresh.onRefresh();
|
||||
if (guidesEnabled) refreshGuide();
|
||||
stack.refresh();
|
||||
refreshActivity();
|
||||
filesContent.refresh();
|
||||
};
|
||||
const jumpToFiles = useCallback(() => {
|
||||
scrollView.current?.scrollToOffset({
|
||||
const jumpToFiles = () => {
|
||||
scrollViews.current.overview?.scrollToOffset({
|
||||
offset: bodyY.current + filesY.current - insets.top,
|
||||
animated: true,
|
||||
});
|
||||
pendingFilesJump.current = false;
|
||||
}, [insets.top]);
|
||||
};
|
||||
const openFiles = () => {
|
||||
if (section === "overview") jumpToFiles();
|
||||
else {
|
||||
pendingFilesJump.current = true;
|
||||
selectSection("overview");
|
||||
if (filesY.current > 0) requestAnimationFrame(jumpToFiles);
|
||||
}
|
||||
};
|
||||
return (
|
||||
@@ -443,155 +434,207 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
|
||||
) : null}
|
||||
</NativeHeaderToolbar.Menu>
|
||||
</NativeHeaderToolbar>
|
||||
<View style={{ flex: 1 }}>
|
||||
<LegendList
|
||||
ref={scrollView}
|
||||
initialScrollOffset={-insets.top}
|
||||
onScroll={(event) => {
|
||||
currentScrollOffset.current = event.nativeEvent.contentOffset.y;
|
||||
}}
|
||||
className="flex-1"
|
||||
renderScrollComponent={Platform.OS === "ios" ? PullRequestTabScrollView : undefined}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
contentInset={
|
||||
Platform.OS === "ios" ? { top: insets.top, bottom: insets.bottom } : undefined
|
||||
}
|
||||
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={pullRefresh.refreshing} onRefresh={refresh} />
|
||||
}
|
||||
alwaysBounceVertical
|
||||
scrollsToTop
|
||||
onContentSizeChange={() => {
|
||||
if (tab !== "overview" || !pendingDescriptionJump.current) return;
|
||||
pendingDescriptionJump.current = false;
|
||||
// Collapse changes the scroll range; restore the heading after that layout commits.
|
||||
scrollView.current?.scrollToOffset({
|
||||
offset: bodyY.current + descriptionY.current - insets.top,
|
||||
animated: false,
|
||||
});
|
||||
}}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 16,
|
||||
paddingTop: 8,
|
||||
paddingBottom: 24,
|
||||
}}
|
||||
data={[
|
||||
{
|
||||
key: `${tab}:body`,
|
||||
content: (
|
||||
<View
|
||||
onLayout={
|
||||
tab === "overview" || tabContent.rows.length === 0
|
||||
? commitSectionLayout
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{tab === "overview" && identity ? (
|
||||
<View>
|
||||
{pr ? (
|
||||
<PullRequestOverview
|
||||
pr={pr}
|
||||
params={params}
|
||||
stack={stack}
|
||||
descriptionExpanded={descriptionExpanded}
|
||||
onDescriptionExpandedChange={setDescriptionExpanded}
|
||||
onDescriptionLayout={(y) => {
|
||||
descriptionY.current = y;
|
||||
}}
|
||||
onDescriptionCollapse={() => {
|
||||
pendingDescriptionJump.current = true;
|
||||
}}
|
||||
/>
|
||||
) : summary ? (
|
||||
<PullRequestOverviewLoading
|
||||
summary={summary}
|
||||
params={params}
|
||||
stack={stack}
|
||||
/>
|
||||
) : null}
|
||||
<View
|
||||
style={{ flex: 1 }}
|
||||
onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
|
||||
>
|
||||
{(["overview", "guide", "activity"] as const)
|
||||
.filter((tab) => tab !== "guide" || guidesEnabled)
|
||||
.map((tab) => (
|
||||
<View
|
||||
key={tab}
|
||||
style={[StyleSheet.absoluteFill, { opacity: section === tab ? 1 : 0 }]}
|
||||
pointerEvents={section === tab ? "auto" : "none"}
|
||||
accessibilityElementsHidden={section !== tab}
|
||||
importantForAccessibility={section === tab ? "auto" : "no-hide-descendants"}
|
||||
>
|
||||
<AnimatedLegendList
|
||||
ref={(list) => {
|
||||
scrollViews.current[tab] = list;
|
||||
}}
|
||||
initialScrollOffset={-insets.top}
|
||||
onScroll={(event) => {
|
||||
const offset = event.nativeEvent.contentOffset.y;
|
||||
scrollOffsets.current[tab] = offset;
|
||||
if (requestedSection.current === tab) currentScrollOffset.current = offset;
|
||||
}}
|
||||
className="flex-1"
|
||||
renderScrollComponent={
|
||||
Platform.OS === "ios" ? PullRequestTabScrollView : undefined
|
||||
}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
contentInset={
|
||||
Platform.OS === "ios" ? { top: insets.top, bottom: insets.bottom } : undefined
|
||||
}
|
||||
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={section === tab && pullRefresh.refreshing}
|
||||
onRefresh={refresh}
|
||||
/>
|
||||
}
|
||||
alwaysBounceVertical
|
||||
scrollsToTop={section === tab}
|
||||
onContentSizeChange={() => {
|
||||
if (
|
||||
tab !== "overview" ||
|
||||
section !== "overview" ||
|
||||
!pendingDescriptionJump.current
|
||||
)
|
||||
return;
|
||||
pendingDescriptionJump.current = false;
|
||||
// Collapse changes the scroll range; restore the heading after that layout commits.
|
||||
scrollViews.current.overview?.scrollToOffset({
|
||||
offset: bodyY.current + descriptionY.current - insets.top,
|
||||
animated: false,
|
||||
});
|
||||
}}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 16,
|
||||
paddingTop: 8,
|
||||
paddingBottom: 24,
|
||||
// Short tabs must still be tall enough to preserve the collapsed header.
|
||||
minHeight: Math.max(
|
||||
0,
|
||||
viewportHeight + headerHeight - insets.top - insets.bottom,
|
||||
),
|
||||
}}
|
||||
data={[
|
||||
{
|
||||
key: `${tab}:body`,
|
||||
content: (
|
||||
<View>
|
||||
{tab === "overview" && identity ? (
|
||||
<View>
|
||||
{pr ? (
|
||||
<PullRequestOverview
|
||||
pr={pr}
|
||||
params={params}
|
||||
stack={stack}
|
||||
descriptionExpanded={descriptionExpanded}
|
||||
onDescriptionExpandedChange={setDescriptionExpanded}
|
||||
onDescriptionLayout={(y) => {
|
||||
descriptionY.current = y;
|
||||
}}
|
||||
onDescriptionCollapse={() => {
|
||||
pendingDescriptionJump.current = true;
|
||||
}}
|
||||
/>
|
||||
) : summary ? (
|
||||
<PullRequestOverviewLoading
|
||||
summary={summary}
|
||||
params={params}
|
||||
stack={stack}
|
||||
/>
|
||||
) : null}
|
||||
<View
|
||||
className="mt-8 border-t border-border-subtle pt-3"
|
||||
onLayout={(event) => {
|
||||
filesY.current = event.nativeEvent.layout.y;
|
||||
if (pendingFilesJump.current) {
|
||||
requestAnimationFrame(() => {
|
||||
if (requestedSection.current === "overview") jumpToFiles();
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
{filesContent.header}
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
{tab === "guide" ? <PullRequestGuideContent params={params} /> : null}
|
||||
{tab === "activity" ? (
|
||||
<PullRequestActivityFilters
|
||||
value={activityFilter}
|
||||
onChange={setActivityFilter}
|
||||
hiddenCount={tabContent.hiddenCount}
|
||||
/>
|
||||
) : null}
|
||||
{tab === "activity" ? (
|
||||
<PullRequestReadStatus
|
||||
pending={tabContent.pending}
|
||||
error={tabContent.error}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
),
|
||||
},
|
||||
...(tab === "overview"
|
||||
? identity
|
||||
? filesContent.rows
|
||||
: []
|
||||
: tab === "activity"
|
||||
? tabContent.rows
|
||||
: []
|
||||
).map((row) => ({
|
||||
...row,
|
||||
key: `${tab}:${row.key}`,
|
||||
content: row.content,
|
||||
})),
|
||||
]}
|
||||
keyExtractor={(row) => row.key}
|
||||
getItemType={(row) =>
|
||||
row.key.endsWith(":body") ? row.key : row.key.split(":")[0]
|
||||
}
|
||||
// The overview body contains the clipped description and owns collapse scroll
|
||||
// correction. Animating that cell fights both; file rows still fade individually.
|
||||
itemLayoutAnimation={tab === "overview" ? undefined : PR_ROW_LAYOUT}
|
||||
onLoad={() => setListAnimationsReady(true)}
|
||||
renderItem={({ item }) => (
|
||||
<Animated.View
|
||||
key={item.key}
|
||||
entering={
|
||||
listAnimationsReady && !item.key.endsWith(":body")
|
||||
? PR_ROW_ENTER
|
||||
: undefined
|
||||
}
|
||||
exiting={
|
||||
listAnimationsReady && !item.key.endsWith(":body") ? PR_ROW_EXIT : undefined
|
||||
}
|
||||
>
|
||||
{item.content}
|
||||
</Animated.View>
|
||||
)}
|
||||
recycleItems={false}
|
||||
estimatedItemSize={tab === "overview" ? 64 : 220}
|
||||
maintainVisibleContentPosition={false}
|
||||
ListHeaderComponent={
|
||||
<>
|
||||
<PullRequestReadStatus
|
||||
pending={result.isPending && !identity}
|
||||
error={result.error}
|
||||
/>
|
||||
{identity ? (
|
||||
<View
|
||||
className="mt-8 border-t border-border-subtle pt-3"
|
||||
className="gap-5 pb-5"
|
||||
onLayout={(event) => {
|
||||
filesY.current = event.nativeEvent.layout.y;
|
||||
if (pendingFilesJump.current) {
|
||||
// The explicit file jump supersedes the tab's restored offset.
|
||||
pendingScrollOffset.current = null;
|
||||
requestAnimationFrame(() => {
|
||||
if (requestedSection.current === "overview") jumpToFiles();
|
||||
});
|
||||
}
|
||||
bodyY.current = event.nativeEvent.layout.height;
|
||||
setHeaderHeight(event.nativeEvent.layout.height);
|
||||
}}
|
||||
>
|
||||
{filesContent.header}
|
||||
<PullRequestIdentity pr={identity} params={params} />
|
||||
<SegmentedControl
|
||||
className="bg-grouped-card"
|
||||
options={[
|
||||
{ value: "overview", label: "Overview" },
|
||||
...(guidesEnabled
|
||||
? [{ value: "guide" as const, label: "Guide" }]
|
||||
: []),
|
||||
{ value: "activity", label: "Activity" },
|
||||
]}
|
||||
selected={section}
|
||||
onSelect={selectSection}
|
||||
role="tab"
|
||||
size="compact"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
{tab !== "overview" ? (
|
||||
<PullRequestReadStatus
|
||||
pending={tabContent.pending}
|
||||
error={tabContent.error}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
),
|
||||
},
|
||||
...(tab === "overview" ? (identity ? filesContent.rows : []) : tabContent.rows).map(
|
||||
(row) => ({
|
||||
...row,
|
||||
key: `${tab}:${row.key}`,
|
||||
content:
|
||||
tab !== "overview" ? (
|
||||
<View onLayout={commitSectionLayout}>{row.content}</View>
|
||||
) : (
|
||||
row.content
|
||||
),
|
||||
}),
|
||||
),
|
||||
]}
|
||||
keyExtractor={(row) => row.key}
|
||||
getItemType={(row) => (row.key.endsWith(":body") ? row.key : row.key.split(":")[0])}
|
||||
renderItem={({ item }) => item.content}
|
||||
recycleItems={false}
|
||||
estimatedItemSize={tab === "overview" ? 64 : tab === "commits" ? 80 : 220}
|
||||
maintainVisibleContentPosition={false}
|
||||
ListHeaderComponent={
|
||||
<>
|
||||
<PullRequestReadStatus
|
||||
pending={result.isPending && !identity}
|
||||
error={result.error}
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
ListFooterComponent={tab === "overview" ? filesContent.footer : null}
|
||||
/>
|
||||
{identity ? (
|
||||
<View
|
||||
className="gap-5 pb-5"
|
||||
onLayout={(event) => {
|
||||
bodyY.current = event.nativeEvent.layout.height;
|
||||
}}
|
||||
>
|
||||
<PullRequestIdentity pr={identity} params={params} />
|
||||
<SegmentedControl
|
||||
className="bg-grouped-card"
|
||||
options={[
|
||||
{ value: "overview", label: "Overview" },
|
||||
{ value: "activity", label: "Activity" },
|
||||
{
|
||||
value: "commits",
|
||||
label: activity.data
|
||||
? `Commits ${activity.data.commits.length}`
|
||||
: "Commits",
|
||||
},
|
||||
]}
|
||||
selected={displayedSection}
|
||||
onSelect={selectSection}
|
||||
role="tab"
|
||||
size="compact"
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
ListFooterComponent={tab === "overview" ? filesContent.footer : null}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
<PullRequestActionToolbar pr={pr} params={params} onOpenFiles={openFiles} />
|
||||
</View>
|
||||
@@ -632,13 +675,17 @@ export function PullRequestFileRouteScreen({
|
||||
readonly path: string;
|
||||
readonly fileSelectionId?: string;
|
||||
readonly replacingDraftId?: string;
|
||||
readonly focus?: GuideDiffFocus;
|
||||
}
|
||||
>) {
|
||||
const navigation = useNavigation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const commit = route.params.commit;
|
||||
const result = usePullRequestDiff(route.params);
|
||||
const filter = usePullRequestFileFilter(result.parsed);
|
||||
const filter = usePullRequestFileFilter(
|
||||
result.parsed,
|
||||
route.params.focus ? route.params.path : undefined,
|
||||
);
|
||||
const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(route.params)));
|
||||
const { refresh: refreshDetail } = detail;
|
||||
useFocusEffect(useCallback(() => refreshDetail(), [refreshDetail]));
|
||||
@@ -709,6 +756,11 @@ export function PullRequestFileRouteScreen({
|
||||
const targetFile =
|
||||
data.files.find((file) => file.path === jumpPath) ??
|
||||
(!jumpPath || requestedFile ? data.files[0] : undefined);
|
||||
const focus = route.params.focus;
|
||||
const focusedRows = guideFocusedRows(data.rows, targetFile?.id, focus);
|
||||
const focusIndex = focusedRows.length
|
||||
? data.rows.findIndex((row) => row.id === focusedRows[0]?.id)
|
||||
: -1;
|
||||
const [collapsedIds, setCollapsedIds] = useState<readonly string[]>(EMPTY_IDS);
|
||||
const [visibleFileId, setVisibleFileId] = useState<string | null>(null);
|
||||
const nativeView = useRef<NativeReviewDiffViewHandle>(null);
|
||||
@@ -722,6 +774,7 @@ export function PullRequestFileRouteScreen({
|
||||
)
|
||||
return;
|
||||
lastSelection.current = { path: route.params.path, id: route.params.fileSelectionId };
|
||||
if (route.params.focus) navigation.setParams({ focus: undefined });
|
||||
setJumpPath(route.params.path);
|
||||
setSelectedRowId(null);
|
||||
jumpStarted.current = false;
|
||||
@@ -732,7 +785,7 @@ export function PullRequestFileRouteScreen({
|
||||
void nativeView.current.scrollToFile(file.id, false).catch(() => {
|
||||
jumpStarted.current = false;
|
||||
});
|
||||
}, [route.params.path, route.params.fileSelectionId, data.files]);
|
||||
}, [route.params.path, route.params.fileSelectionId, route.params.focus, data.files, navigation]);
|
||||
const appliedFilter = useRef(filter.hideTestFiles);
|
||||
useEffect(() => {
|
||||
if (appliedFilter.current === filter.hideTestFiles) return;
|
||||
@@ -745,7 +798,7 @@ export function PullRequestFileRouteScreen({
|
||||
}
|
||||
}, [filter.hideTestFiles, result.parsed]);
|
||||
const { nativeReviewDiffStyle } = useAppearanceCodeSurface();
|
||||
const { themeAppearance } = useAppearancePreferences();
|
||||
const { themeAppearance, appearance, setCodeWordBreak } = useAppearancePreferences();
|
||||
const bridge = useNativeReviewDiffBridge({
|
||||
threadKey: null,
|
||||
sectionId: `pull-request:${route.params.repository}:${route.params.number}:${commit ?? "all"}`,
|
||||
@@ -753,7 +806,7 @@ export function PullRequestFileRouteScreen({
|
||||
data,
|
||||
collapsedFileIds: collapsedIds,
|
||||
viewedFileIds: viewedIds,
|
||||
selectedRowIds: selectedRowId ? [selectedRowId] : EMPTY_IDS,
|
||||
selectedRowIds: selectedRowId ? [selectedRowId] : focusedRows.map((row) => row.id),
|
||||
canHighlight: true,
|
||||
});
|
||||
const [NativeDiffView] = useState(() => resolveNativeReviewDiffView());
|
||||
@@ -783,6 +836,7 @@ export function PullRequestFileRouteScreen({
|
||||
(Platform.OS !== "ios" || decoded)
|
||||
) {
|
||||
jumpStarted.current = true;
|
||||
if (focusIndex >= 0) return;
|
||||
void nativeView.current.scrollToFile(targetFile.id, false).catch(() => {
|
||||
jumpStarted.current = false;
|
||||
});
|
||||
@@ -792,7 +846,7 @@ export function PullRequestFileRouteScreen({
|
||||
const lastRow = event.nativeEvent.lastRowIndex;
|
||||
if (typeof lastRow === "number" && lastRow >= data.rows.length - 40) loadMore();
|
||||
},
|
||||
[updateVisibleRange, data.rows.length, loadMore, targetFile],
|
||||
[updateVisibleRange, data.rows.length, loadMore, targetFile, focusIndex],
|
||||
);
|
||||
const onToggleFile = useCallback<NonNullable<NativeReviewDiffViewProps["onToggleFile"]>>(
|
||||
(event) => {
|
||||
@@ -829,6 +883,12 @@ export function PullRequestFileRouteScreen({
|
||||
trailing={
|
||||
<ControlPillMenu
|
||||
actions={[
|
||||
{
|
||||
id: "word-wrap",
|
||||
title: "Word wrap",
|
||||
image: "text.alignleft",
|
||||
state: appearance.codeWordBreak ? "on" : "off",
|
||||
},
|
||||
{
|
||||
id: "hide-tests",
|
||||
title: "Hide test files",
|
||||
@@ -849,7 +909,8 @@ export function PullRequestFileRouteScreen({
|
||||
: []),
|
||||
]}
|
||||
onPressAction={({ nativeEvent }) => {
|
||||
if (nativeEvent.event === "hide-tests") toggleTestFiles();
|
||||
if (nativeEvent.event === "word-wrap") setCodeWordBreak(!appearance.codeWordBreak);
|
||||
else if (nativeEvent.event === "hide-tests") toggleTestFiles();
|
||||
else if (
|
||||
nativeEvent.event === "submit-review" ||
|
||||
nativeEvent.event === "comment-on-pr"
|
||||
@@ -895,6 +956,13 @@ export function PullRequestFileRouteScreen({
|
||||
<NativeHeaderToolbar.Label>Add comment</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
) : null}
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
icon="text.alignleft"
|
||||
isOn={appearance.codeWordBreak}
|
||||
onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
|
||||
>
|
||||
<NativeHeaderToolbar.Label>Word wrap</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
icon="line.3.horizontal.decrease"
|
||||
isOn={filter.hideTestFiles}
|
||||
@@ -956,6 +1024,7 @@ export function PullRequestFileRouteScreen({
|
||||
{NativeDiffView && data.rows.length && !seekingFile ? (
|
||||
<View className="flex-1" collapsable={false}>
|
||||
<NativeDiffView
|
||||
initialRowIndex={focusIndex >= 0 ? Math.max(0, focusIndex - 3) : undefined}
|
||||
nativeViewRef={nativeView}
|
||||
refreshing={result.refreshing}
|
||||
onPullToRefresh={result.onPullRefresh}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import type { PullRequestAction, PullRequestDetail } from "@t3tools/contracts";
|
||||
import Animated from "react-native-reanimated";
|
||||
import { PR_ROW_LAYOUT, PR_DISCLOSURE_ENTER, PR_ROW_EXIT } from "./pullRequestAnimations";
|
||||
import { useState } from "react";
|
||||
import { Linking, Pressable, View } from "react-native";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
@@ -97,7 +99,7 @@ export function PullRequestChecksRow(props: RowProps) {
|
||||
const checks = pullRequestChecksSummary(props.pr);
|
||||
const action = usePullRequestAction(props.params, props.pr);
|
||||
return (
|
||||
<>
|
||||
<Animated.View layout={PR_ROW_LAYOUT}>
|
||||
<PullRequestCardRow
|
||||
title={checks.title}
|
||||
icon={checks.icon}
|
||||
@@ -109,7 +111,12 @@ export function PullRequestChecksRow(props: RowProps) {
|
||||
onPress={() => setExpanded(!expanded)}
|
||||
/>
|
||||
{expanded ? (
|
||||
<View className="pl-8">
|
||||
<Animated.View
|
||||
layout={PR_ROW_LAYOUT}
|
||||
entering={PR_DISCLOSURE_ENTER}
|
||||
exiting={PR_ROW_EXIT}
|
||||
className="pl-8"
|
||||
>
|
||||
{props.pr.state === "open" &&
|
||||
props.pr.checks.some((check) => check.status === "failure") ? (
|
||||
<PullRequestAgentRow {...props} task="feedback" title="Fix failing checks" />
|
||||
@@ -157,9 +164,9 @@ export function PullRequestChecksRow(props: RowProps) {
|
||||
)
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
</>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -236,7 +243,7 @@ export function PullRequestReviewersRow(props: RowProps) {
|
||||
props.pr.capabilities.reviewers.request &&
|
||||
props.pr.viewerPermissions.requestReviewers;
|
||||
return (
|
||||
<>
|
||||
<Animated.View layout={PR_ROW_LAYOUT}>
|
||||
<PullRequestCardRow
|
||||
title={summary.title}
|
||||
icon={summary.icon}
|
||||
@@ -247,7 +254,12 @@ export function PullRequestReviewersRow(props: RowProps) {
|
||||
onPress={() => setExpanded(!expanded)}
|
||||
/>
|
||||
{expanded ? (
|
||||
<View className="pl-8">
|
||||
<Animated.View
|
||||
layout={PR_ROW_LAYOUT}
|
||||
entering={PR_DISCLOSURE_ENTER}
|
||||
exiting={PR_ROW_EXIT}
|
||||
className="pl-8"
|
||||
>
|
||||
{summary.reviews.map((review) => (
|
||||
<View
|
||||
key={review.id}
|
||||
@@ -308,8 +320,8 @@ export function PullRequestReviewersRow(props: RowProps) {
|
||||
onPress={() => void Linking.openURL(props.pr.url)}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
</>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import type { PullRequestReviewGuide } from "@t3tools/contracts";
|
||||
import { stopFilePaths } from "@t3tools/client-runtime/review-guide-tour";
|
||||
import { Pressable, View } from "react-native";
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { SymbolView } from "../../../components/AppSymbol";
|
||||
import { PullRequestMarkdown } from "../PullRequestMarkdown";
|
||||
import { ControlPillMenu } from "../../../components/ControlPillMenu";
|
||||
|
||||
import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider";
|
||||
|
||||
/** The stops are a reading sequence, with file context kept beside each idea. */
|
||||
export function GuideOutline({
|
||||
guide,
|
||||
onOpen,
|
||||
onRewrite,
|
||||
}: {
|
||||
readonly guide: PullRequestReviewGuide;
|
||||
readonly onOpen: (position: number) => void;
|
||||
readonly onRewrite?: () => void;
|
||||
}) {
|
||||
const { appearance, setCodeWordBreak } = useAppearancePreferences();
|
||||
const files = new Set(guide.stops.flatMap(stopFilePaths));
|
||||
return (
|
||||
<View>
|
||||
<View className="mb-5 flex-row items-center justify-between">
|
||||
<View className="flex-row items-baseline gap-2">
|
||||
<Text className="text-base font-t3-semibold">{guide.stops.length} stops</Text>
|
||||
<Text className="text-sm text-foreground-muted">
|
||||
through {files.size} {files.size === 1 ? "file" : "files"}
|
||||
</Text>
|
||||
</View>
|
||||
<ControlPillMenu
|
||||
title="Guide options"
|
||||
actions={[
|
||||
{
|
||||
id: "word-wrap",
|
||||
title: "Word wrap",
|
||||
image: "text.alignleft",
|
||||
state: appearance.codeWordBreak ? "on" : "off",
|
||||
},
|
||||
...(onRewrite
|
||||
? [{ id: "rewrite", title: "Rewrite guide", image: "arrow.clockwise" }]
|
||||
: []),
|
||||
]}
|
||||
onPressAction={({ nativeEvent }) =>
|
||||
nativeEvent.event === "word-wrap"
|
||||
? setCodeWordBreak(!appearance.codeWordBreak)
|
||||
: onRewrite?.()
|
||||
}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Guide options"
|
||||
className="h-11 w-11 items-center justify-center rounded-full active:bg-grouped-card"
|
||||
>
|
||||
<SymbolView name="ellipsis" size={20} tintColorClassName="accent-icon-muted" />
|
||||
</Pressable>
|
||||
</ControlPillMenu>
|
||||
</View>
|
||||
{guide.stops[0]?.summary ? (
|
||||
<View className="mb-6">
|
||||
<PullRequestMarkdown markdown={guide.stops[0].summary} />
|
||||
</View>
|
||||
) : null}
|
||||
{guide.stops.map((stop, position) => {
|
||||
const paths = stopFilePaths(stop);
|
||||
const firstPath = paths[0];
|
||||
const filename = firstPath?.split("/").at(-1);
|
||||
return (
|
||||
<Pressable
|
||||
key={`${guide.headSha}:${JSON.stringify(stop)}`}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Stop ${position + 1}: ${stop.title}`}
|
||||
onPress={() => onOpen(position)}
|
||||
className="flex-row gap-4 active:opacity-60"
|
||||
>
|
||||
<View className="w-8 items-center">
|
||||
<View className="h-8 w-8 items-center justify-center rounded-full border border-border bg-grouped-card">
|
||||
<Text className="text-sm font-t3-medium tabular-nums">{position + 1}</Text>
|
||||
</View>
|
||||
{position < guide.stops.length - 1 ? (
|
||||
<View className="min-h-5 w-px flex-1 bg-border-subtle" />
|
||||
) : null}
|
||||
</View>
|
||||
<View className="min-w-0 flex-1 gap-2 pb-7 pt-0.5">
|
||||
<Text className="text-base leading-6 font-t3-medium">{stop.title}</Text>
|
||||
<View className="flex-row items-center gap-1.5">
|
||||
{stop.attention ? (
|
||||
<SymbolView name="eye" size={14} tintColorClassName="accent-warning-foreground" />
|
||||
) : null}
|
||||
<Text className="shrink text-xs text-foreground-muted" numberOfLines={1}>
|
||||
{filename ?? "Context"}
|
||||
{paths.length > 1 ? ` +${paths.length - 1}` : ""}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="pt-2">
|
||||
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
{guide.stops.length ? (
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
onPress={() => onOpen(0)}
|
||||
className="min-h-11 flex-row items-center justify-end gap-2 active:opacity-60"
|
||||
>
|
||||
<Text className="text-sm font-t3-medium">Start tour</Text>
|
||||
<SymbolView name="arrow.right" size={17} tintColorClassName="accent-foreground" />
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
import { parsePatchFiles } from "@pierre/diffs/utils/parsePatchFiles";
|
||||
import type { FileDiffMetadata } from "@pierre/diffs";
|
||||
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { Platform, Pressable, View } from "react-native";
|
||||
import { AndroidScreenHeader } from "../../../components/AndroidScreenHeader";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import {
|
||||
letterStopNotes,
|
||||
stepTourPosition,
|
||||
stopFilePaths,
|
||||
} from "@t3tools/client-runtime/review-guide-tour";
|
||||
import { SymbolView } from "../../../components/AppSymbol";
|
||||
import { GuideOutline } from "./GuideOutline";
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { MaterialButton } from "../../../components/MaterialButton";
|
||||
import { ScreenScrollView } from "../../../components/ScreenScrollView";
|
||||
import { ControlPillMenu } from "../../../components/ControlPillMenu";
|
||||
import { MaterialIconButton } from "../../../components/MaterialIconButton";
|
||||
import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../../native/StackHeader";
|
||||
import { PullRequestCardGroup, PullRequestCardRow } from "../PullRequestControls";
|
||||
import { PullRequestMarkdown, PullRequestMarkdownRepository } from "../PullRequestMarkdown";
|
||||
import { usePullRequestDiff, type PullRequestParams } from "../usePullRequestDiff";
|
||||
import { ReviewGuideExcerpt } from "./ReviewGuideExcerpt";
|
||||
import { reviewGuideState } from "./reviewGuideState";
|
||||
import { useEnvironmentQuery } from "../../../state/query";
|
||||
import { composerPullRequests } from "../../../state/pull-requests";
|
||||
import { usePullRequestPermissions } from "../usePullRequestPermissions";
|
||||
import { pullRequestTarget } from "../usePullRequestDiff";
|
||||
import { useReviewGuide } from "./useReviewGuide";
|
||||
|
||||
export type GuideStopParams = PullRequestParams & {
|
||||
readonly position: number;
|
||||
readonly guideHeadSha: string;
|
||||
readonly guideGeneratedAt: string;
|
||||
};
|
||||
|
||||
const attentionLabels = {
|
||||
tradeoff: "A tradeoff to weigh",
|
||||
contract: "A contract to check",
|
||||
product: "A product call",
|
||||
risk: "A risk to judge",
|
||||
accessibility: "An accessibility call",
|
||||
};
|
||||
|
||||
function GuideNotice({ state }: { readonly state: ReturnType<typeof useReviewGuide> }) {
|
||||
const { guide, stale, failure } = reviewGuideState(state.data);
|
||||
const error = state.startError ?? failure ?? state.error;
|
||||
const label = state.running
|
||||
? guide
|
||||
? "Rewriting review guide"
|
||||
: "Writing review guide"
|
||||
: error
|
||||
? "Could not write guide"
|
||||
: stale
|
||||
? "Guide is out of date"
|
||||
: "No review guide yet";
|
||||
if (guide && !stale && !error && !state.running) return null;
|
||||
return (
|
||||
<View
|
||||
className={guide ? "gap-3 border-l-2 border-border pl-4 py-1" : "gap-4 py-4"}
|
||||
accessibilityLiveRegion="polite"
|
||||
>
|
||||
<View className="flex-row items-center gap-2">
|
||||
<SymbolView
|
||||
name={
|
||||
state.running
|
||||
? "clock"
|
||||
: error
|
||||
? "exclamationmark.circle"
|
||||
: stale
|
||||
? "arrow.clockwise"
|
||||
: "list.number"
|
||||
}
|
||||
size={20}
|
||||
tintColorClassName={
|
||||
error
|
||||
? "accent-danger-foreground"
|
||||
: stale
|
||||
? "accent-warning-foreground"
|
||||
: "accent-icon-muted"
|
||||
}
|
||||
/>
|
||||
<Text className={guide ? "text-base font-t3-semibold" : "text-xl font-t3-semibold"}>
|
||||
{label}
|
||||
</Text>
|
||||
</View>
|
||||
<Text className="text-sm leading-6 text-foreground-muted">
|
||||
{error ??
|
||||
(state.running
|
||||
? "An agent is reading the change. You can leave this screen and return when it’s ready."
|
||||
: stale
|
||||
? "There are new changes since this guide was written. Rewrite it to see the latest code."
|
||||
: "Walk through the important code in order, with notes on what changed and where to look closely.")}
|
||||
</Text>
|
||||
{state.running ? (
|
||||
<Text className="text-xs text-foreground-muted">
|
||||
{state.data?.run?._tag === "Running"
|
||||
? `Started at ${new Date(state.data.run.startedAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`
|
||||
: "Starting the guide…"}
|
||||
</Text>
|
||||
) : state.canWrite ? (
|
||||
<MaterialButton
|
||||
label={error ? "Try again" : guide ? "Rewrite guide" : "Write guide"}
|
||||
tone={guide ? "secondary" : "contrast"}
|
||||
onPress={() => void state.write()}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function PullRequestGuideContent({ params }: { readonly params: PullRequestParams }) {
|
||||
const navigation = useNavigation();
|
||||
const state = useReviewGuide(params);
|
||||
const { guide, stale } = reviewGuideState(state.data);
|
||||
return (
|
||||
<View className="w-full max-w-[760px] self-center gap-5">
|
||||
{!state.enabled ? (
|
||||
<Text>Review guides are disabled for this server.</Text>
|
||||
) : (
|
||||
<>
|
||||
{state.isPending && !state.data ? (
|
||||
<Text className="text-foreground-muted">Loading review guide…</Text>
|
||||
) : (
|
||||
<GuideNotice state={state} />
|
||||
)}
|
||||
{guide ? (
|
||||
<GuideOutline
|
||||
guide={guide}
|
||||
onOpen={(position) =>
|
||||
navigation.dispatch(
|
||||
StackActions.push("PullRequestGuideStop", {
|
||||
...params,
|
||||
position,
|
||||
guideHeadSha: guide.headSha,
|
||||
guideGeneratedAt: guide.generatedAt,
|
||||
}),
|
||||
)
|
||||
}
|
||||
onRewrite={
|
||||
state.canWrite && !state.running && !stale && !state.startError && !state.error
|
||||
? () => void state.write()
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideStopParams>) {
|
||||
const navigation = useNavigation();
|
||||
const state = useReviewGuide(route.params);
|
||||
const detail = useEnvironmentQuery(composerPullRequests.detail(pullRequestTarget(route.params)));
|
||||
const permissions = usePullRequestPermissions(route.params, detail.data);
|
||||
const canReview =
|
||||
permissions.verdicts.length > 0 && detail.data?.headSha === route.params.guideHeadSha;
|
||||
const { guide, stale } = reviewGuideState(state.data);
|
||||
const position = Math.max(0, Math.min(route.params.position, (guide?.stops.length ?? 1) - 1));
|
||||
const stop = guide?.stops[Math.max(0, position)];
|
||||
const diff = usePullRequestDiff(route.params);
|
||||
const excerptFiles = useMemo(() => {
|
||||
const files = new Map<string, FileDiffMetadata>();
|
||||
try {
|
||||
for (const patch of parsePatchFiles(diff.patch)) {
|
||||
for (const file of patch.files) {
|
||||
files.set(file.name, file);
|
||||
if (file.prevName) files.set(file.prevName, file);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// An omitted or unparseable patch is shown as unavailable by the excerpt.
|
||||
}
|
||||
return files;
|
||||
}, [diff.patch]);
|
||||
const wanted = useMemo(() => (stop ? stopFilePaths(stop) : []), [stop]);
|
||||
const loadedPaths = new Set(
|
||||
diff.parsed.kind === "files" ? diff.parsed.files.map((file) => file.path) : [],
|
||||
);
|
||||
const missing = wanted.some((path) => !loadedPaths.has(path));
|
||||
const { error: diffError, loadMore } = diff;
|
||||
useEffect(() => {
|
||||
if (state.enabled && missing && !diffError) loadMore();
|
||||
}, [state.enabled, missing, diffError, loadMore]);
|
||||
const insets = useSafeAreaInsets();
|
||||
const changedGuide =
|
||||
guide !== null &&
|
||||
(guide.headSha !== route.params.guideHeadSha ||
|
||||
guide.generatedAt !== route.params.guideGeneratedAt);
|
||||
const { appearance, setCodeWordBreak } = useAppearancePreferences();
|
||||
const notes = stop ? letterStopNotes(stop).lettered : [];
|
||||
return (
|
||||
<View className="flex-1 bg-screen">
|
||||
<NativeStackScreenOptions
|
||||
options={{
|
||||
title: `Stop ${route.params.position + 1}`,
|
||||
headerTitle: `Stop ${route.params.position + 1} of ${guide?.stops.length ?? "…"}`,
|
||||
}}
|
||||
/>
|
||||
{Platform.OS === "android" ? (
|
||||
<AndroidScreenHeader
|
||||
title={`Stop ${route.params.position + 1}`}
|
||||
onBack={() => navigation.goBack()}
|
||||
trailing={
|
||||
<ControlPillMenu
|
||||
actions={[
|
||||
{
|
||||
id: "word-wrap",
|
||||
title: "Word wrap",
|
||||
image: "text.alignleft",
|
||||
state: appearance.codeWordBreak ? "on" : "off",
|
||||
},
|
||||
]}
|
||||
onPressAction={() => setCodeWordBreak(!appearance.codeWordBreak)}
|
||||
>
|
||||
<View pointerEvents="none">
|
||||
<MaterialIconButton icon="ellipsis" accessibilityLabel="Guide options" />
|
||||
</View>
|
||||
</ControlPillMenu>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
<NativeHeaderToolbar placement="right">
|
||||
<NativeHeaderToolbar.Menu
|
||||
title="Guide options"
|
||||
accessibilityLabel="Guide options"
|
||||
icon="ellipsis"
|
||||
>
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
icon="text.alignleft"
|
||||
isOn={appearance.codeWordBreak}
|
||||
onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
|
||||
>
|
||||
<NativeHeaderToolbar.Label>Word wrap</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
</NativeHeaderToolbar.Menu>
|
||||
</NativeHeaderToolbar>
|
||||
<PullRequestMarkdownRepository
|
||||
value={`https://${route.params.host ?? "github.com"}/${route.params.repository}`}
|
||||
>
|
||||
<ScreenScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
contentContainerStyle={{ padding: 16, paddingBottom: insets.bottom + 24, gap: 20 }}
|
||||
>
|
||||
<View className="w-full max-w-[760px] self-center gap-5">
|
||||
{!state.enabled ? (
|
||||
<Text>Review guides are disabled for this server.</Text>
|
||||
) : changedGuide ? (
|
||||
<Text>This guide was rewritten. Go back to start the new tour.</Text>
|
||||
) : !stop ? (
|
||||
<Text>{state.error ?? "Loading stop…"}</Text>
|
||||
) : (
|
||||
<>
|
||||
<GuideNotice state={state} />
|
||||
<Text className="text-2xl leading-8 font-t3-semibold">{stop.title}</Text>
|
||||
<PullRequestMarkdown markdown={stop.summary} />
|
||||
{stop.attention ? (
|
||||
<View className="gap-3 rounded-xl border border-border bg-grouped-card p-4">
|
||||
<View className="flex-row items-center gap-2">
|
||||
<SymbolView name="eye" size={17} tintColorClassName="accent-icon-muted" />
|
||||
<Text className="text-sm font-t3-semibold">
|
||||
{attentionLabels[stop.attention.kind]}
|
||||
</Text>
|
||||
</View>
|
||||
<PullRequestMarkdown markdown={stop.attention.note} />
|
||||
</View>
|
||||
) : null}
|
||||
{stale ? (
|
||||
<Text className="text-sm text-foreground-muted">
|
||||
Excerpts are hidden until the guide is rewritten for the current head.
|
||||
</Text>
|
||||
) : (
|
||||
stop.excerpts.map((excerpt) => (
|
||||
<ReviewGuideExcerpt
|
||||
key={`${guide?.headSha}:${JSON.stringify(excerpt)}`}
|
||||
onOpen={() =>
|
||||
navigation.dispatch(
|
||||
StackActions.push("PullRequestFile", {
|
||||
...route.params,
|
||||
path: excerpt.path,
|
||||
focus: { side: excerpt.side, start: excerpt.start, end: excerpt.end },
|
||||
fileSelectionId: `guide:${position}:${excerpt.path}:${excerpt.start}`,
|
||||
}),
|
||||
)
|
||||
}
|
||||
excerpt={excerpt}
|
||||
file={excerptFiles.get(excerpt.path)}
|
||||
loading={diff.isPending || (missing && diff.nextCursor !== null)}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
{diff.error ? <Text className="text-danger-foreground">{diff.error}</Text> : null}
|
||||
{notes.length ? (
|
||||
<View className="gap-4">
|
||||
<Text className="font-t3-semibold">Notes on this stop</Text>
|
||||
{notes.map(({ marker, note }) => (
|
||||
<View key={marker} className="flex-row gap-3">
|
||||
<View className="h-7 w-7 items-center justify-center rounded-lg bg-grouped-card">
|
||||
<Text className="text-xs font-t3-semibold">{marker}</Text>
|
||||
</View>
|
||||
<View className="min-w-0 flex-1 gap-2">
|
||||
<Text className="font-t3-semibold">{note.title}</Text>
|
||||
<Text className="text-xs text-foreground-muted">
|
||||
{note.path.split("/").at(-1)}:{note.line}
|
||||
</Text>
|
||||
<PullRequestMarkdown markdown={note.body} />
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
{stop.files.length ? (
|
||||
<PullRequestCardGroup>
|
||||
{stop.files.map((file, index) => (
|
||||
<PullRequestCardRow
|
||||
key={file.path}
|
||||
title={file.path}
|
||||
detail={file.note}
|
||||
icon="doc"
|
||||
last={index === stop.files.length - 1}
|
||||
onPress={() =>
|
||||
navigation.navigate("PullRequestFile", {
|
||||
...route.params,
|
||||
path: file.path,
|
||||
})
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</PullRequestCardGroup>
|
||||
) : null}
|
||||
{stop.questions.length ? (
|
||||
<View className="gap-3">
|
||||
<Text className="font-t3-semibold">Questions to consider</Text>
|
||||
{stop.questions.map((question) => (
|
||||
<PullRequestMarkdown key={question} markdown={question} />
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={
|
||||
guide && position < guide.stops.length - 1
|
||||
? "Next stop"
|
||||
: canReview
|
||||
? "Finish review"
|
||||
: "Finish tour"
|
||||
}
|
||||
className="mt-2 flex-row items-center gap-4 border-t border-border-subtle pt-5 pb-2 active:opacity-60"
|
||||
onPress={() =>
|
||||
guide && position < guide.stops.length - 1
|
||||
? navigation.dispatch(
|
||||
StackActions.push("PullRequestGuideStop", {
|
||||
...route.params,
|
||||
position: stepTourPosition(position, 1, guide.stops.length),
|
||||
}),
|
||||
)
|
||||
: canReview
|
||||
? navigation.navigate("PullRequestReview", {
|
||||
...route.params,
|
||||
mode: "review",
|
||||
})
|
||||
: navigation.dispatch(StackActions.popTo("PullRequest", route.params))
|
||||
}
|
||||
>
|
||||
<View className="min-w-0 flex-1 gap-1">
|
||||
<Text className="text-xs text-foreground-muted">
|
||||
{guide && position < guide.stops.length - 1
|
||||
? `Next · ${position + 2} of ${guide.stops.length}`
|
||||
: "End of guide"}
|
||||
</Text>
|
||||
<Text className="text-base font-t3-semibold">
|
||||
{guide && position < guide.stops.length - 1
|
||||
? guide.stops[position + 1]?.title
|
||||
: canReview
|
||||
? "Finish review"
|
||||
: "Finish tour"}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="h-11 w-11 items-center justify-center rounded-full bg-foreground">
|
||||
<SymbolView
|
||||
name={
|
||||
guide && position < guide.stops.length - 1 ? "arrow.right" : "checkmark"
|
||||
}
|
||||
size={20}
|
||||
tintColorClassName="accent-screen"
|
||||
/>
|
||||
</View>
|
||||
</Pressable>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</ScreenScrollView>
|
||||
</PullRequestMarkdownRepository>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Pressable, View } from "react-native";
|
||||
import type { FileDiffMetadata } from "@pierre/diffs";
|
||||
import type { PullRequestReviewGuideExcerpt } from "@t3tools/contracts";
|
||||
import { excerptRows, fileDiffRows, rowsToPatch } from "@t3tools/client-runtime/review-guide-tour";
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { SymbolView } from "../../../components/AppSymbol";
|
||||
import { resolveNativeReviewDiffView } from "../../diffs/nativeReviewDiffSurface";
|
||||
import { buildNativeReviewDiffData } from "../../review/nativeReviewDiffAdapter";
|
||||
import { buildReviewParsedDiff } from "../../review/reviewModel";
|
||||
import { useNativeReviewDiffBridge } from "../../review/useNativeReviewDiffBridge";
|
||||
import { useAppearanceCodeSurface } from "../../settings/appearance/useAppearanceCodeSurface";
|
||||
import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider";
|
||||
import { PullRequestMarkdown } from "../PullRequestMarkdown";
|
||||
|
||||
const EMPTY_IDS: readonly string[] = [];
|
||||
|
||||
export function ReviewGuideExcerpt({
|
||||
excerpt,
|
||||
file,
|
||||
loading,
|
||||
onOpen,
|
||||
}: {
|
||||
readonly excerpt: PullRequestReviewGuideExcerpt;
|
||||
readonly file: FileDiffMetadata | undefined;
|
||||
readonly loading: boolean;
|
||||
readonly onOpen: () => void;
|
||||
}) {
|
||||
const { nativeReviewDiffStyle, codeWordBreak } = useAppearanceCodeSurface();
|
||||
const { themeAppearance } = useAppearancePreferences();
|
||||
const slice = useMemo(() => {
|
||||
try {
|
||||
if (!file) return "";
|
||||
return rowsToPatch(
|
||||
excerpt.path,
|
||||
file.prevName ?? excerpt.path,
|
||||
excerptRows(fileDiffRows(file), excerpt),
|
||||
);
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}, [file, excerpt]);
|
||||
const data = useMemo(() => {
|
||||
const parsed = buildNativeReviewDiffData(
|
||||
buildReviewParsedDiff(slice, `guide:${excerpt.path}:${excerpt.start}`),
|
||||
);
|
||||
// The compact header and real line numbers provide context without file/hunk chrome.
|
||||
return {
|
||||
...parsed,
|
||||
rows: parsed.rows.filter((row) => row.kind !== "file" && row.kind !== "hunk"),
|
||||
};
|
||||
}, [slice, excerpt.path, excerpt.start]);
|
||||
const bridge = useNativeReviewDiffBridge({
|
||||
threadKey: null,
|
||||
sectionId: `guide:${excerpt.path}:${excerpt.start}`,
|
||||
diff: slice,
|
||||
data,
|
||||
collapsedFileIds: EMPTY_IDS,
|
||||
viewedFileIds: EMPTY_IDS,
|
||||
selectedRowIds: EMPTY_IDS,
|
||||
canHighlight: true,
|
||||
});
|
||||
const [measuredHeight, setMeasuredHeight] = useState<{ key: string; height: number } | null>(
|
||||
null,
|
||||
);
|
||||
const measurementKey = `${slice}:${codeWordBreak}:${nativeReviewDiffStyle.rowHeight}`;
|
||||
const [NativeDiff] = useState(() => resolveNativeReviewDiffView());
|
||||
return (
|
||||
<View className="gap-3">
|
||||
{excerpt.caption.trim() ? <PullRequestMarkdown markdown={excerpt.caption} /> : null}
|
||||
<View className="overflow-hidden rounded-lg border border-border-subtle">
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Open ${excerpt.path} at line ${excerpt.start} in full diff`}
|
||||
onPress={onOpen}
|
||||
className="min-h-11 flex-row items-center gap-3 border-b border-border-subtle px-3 py-2 active:opacity-60"
|
||||
>
|
||||
<Text
|
||||
className="min-w-0 flex-1 text-xs text-foreground-muted"
|
||||
numberOfLines={1}
|
||||
ellipsizeMode="middle"
|
||||
>
|
||||
{excerpt.path}
|
||||
</Text>
|
||||
<Text className="text-2xs text-foreground-muted">
|
||||
{excerpt.start}–{excerpt.end}
|
||||
</Text>
|
||||
<SymbolView name="arrow.up.right" size={13} tintColorClassName="accent-icon-muted" />
|
||||
</Pressable>
|
||||
{NativeDiff && data.rows.length ? (
|
||||
<View
|
||||
style={{
|
||||
height:
|
||||
measuredHeight?.key === measurementKey
|
||||
? measuredHeight.height
|
||||
: data.rows.length * nativeReviewDiffStyle.rowHeight,
|
||||
}}
|
||||
>
|
||||
<NativeDiff
|
||||
scrollEnabled={false}
|
||||
bounces={false}
|
||||
appearanceScheme={themeAppearance}
|
||||
rowHeight={nativeReviewDiffStyle.rowHeight}
|
||||
contentWidth={2800}
|
||||
style={{ flex: 1 }}
|
||||
rowsJson={bridge.rowsJson}
|
||||
themeJson={bridge.themeJson}
|
||||
styleJson={bridge.styleJson}
|
||||
tokensPatchJson={bridge.tokensPatchJson}
|
||||
tokensResetKey={bridge.tokensResetKey}
|
||||
onDebug={(event) => {
|
||||
bridge.onDebug(event);
|
||||
const { message, contentHeight } = event.nativeEvent;
|
||||
if (message === "metrics" && typeof contentHeight === "number") {
|
||||
setMeasuredHeight((current) =>
|
||||
current?.key === measurementKey && current.height === contentHeight
|
||||
? current
|
||||
: { key: measurementKey, height: contentHeight },
|
||||
);
|
||||
}
|
||||
}}
|
||||
onPressLine={onOpen}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<Text className="p-3 text-xs text-foreground-muted">
|
||||
{loading
|
||||
? `Loading ${excerpt.path}…`
|
||||
: `${excerpt.path}:${excerpt.start}–${excerpt.end} is not in the loaded diff.`}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { guideFocusedRows } from "./guideDiffFocus";
|
||||
|
||||
describe("guide diff focus", () => {
|
||||
const rows = [
|
||||
{ id: "old", kind: "line" as const, fileId: "a", oldLineNumber: 10, change: "delete" as const },
|
||||
{ id: "new", kind: "line" as const, fileId: "a", newLineNumber: 20, change: "add" as const },
|
||||
{ id: "context", kind: "line" as const, fileId: "a", oldLineNumber: 11, newLineNumber: 21 },
|
||||
{ id: "other", kind: "line" as const, fileId: "b", newLineNumber: 20 },
|
||||
];
|
||||
it("uses the requested side and includes both range boundaries only in the target file", () => {
|
||||
expect(
|
||||
guideFocusedRows(rows, "a", { side: "old", start: 10, end: 11 }).map((r) => r.id),
|
||||
).toEqual(["old", "context"]);
|
||||
expect(
|
||||
guideFocusedRows(rows, "a", { side: "new", start: 20, end: 21 }).map((r) => r.id),
|
||||
).toEqual(["new", "context"]);
|
||||
});
|
||||
it("does not select unrelated rows while a later file is loading", () => {
|
||||
expect(guideFocusedRows(rows, undefined, { side: "new", start: 20, end: 21 })).toEqual([]);
|
||||
expect(guideFocusedRows(rows, "a", undefined)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { NativeReviewDiffRow } from "../../diffs/nativeReviewDiffSurface";
|
||||
|
||||
export type GuideDiffFocus = {
|
||||
readonly side: "old" | "new";
|
||||
readonly start: number;
|
||||
readonly end: number;
|
||||
};
|
||||
|
||||
/** Match original diff coordinates, including deletions and renamed files. */
|
||||
export function guideFocusedRows(
|
||||
rows: readonly NativeReviewDiffRow[],
|
||||
fileId: string | undefined,
|
||||
focus: GuideDiffFocus | undefined,
|
||||
) {
|
||||
if (!fileId || !focus) return [];
|
||||
return rows.filter((row) => {
|
||||
const line = focus.side === "old" ? row.oldLineNumber : row.newLineNumber;
|
||||
return (
|
||||
row.fileId === fileId &&
|
||||
row.kind === "line" &&
|
||||
line != null &&
|
||||
line >= focus.start &&
|
||||
line <= focus.end
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import {
|
||||
IsoDateTime,
|
||||
ProviderInstanceId,
|
||||
type PullRequestReviewGuideResult,
|
||||
} from "@t3tools/contracts";
|
||||
import { reviewGuideState } from "./reviewGuideState";
|
||||
|
||||
const guide: NonNullable<PullRequestReviewGuideResult["guide"]> = {
|
||||
headSha: "old-head",
|
||||
generatedAt: IsoDateTime.make("2026-10-11T00:00:00.000Z"),
|
||||
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
|
||||
stops: [],
|
||||
};
|
||||
|
||||
describe("mobile review guide state", () => {
|
||||
it("keeps a previous guide readable during a rewrite", () => {
|
||||
const state = reviewGuideState({
|
||||
guide,
|
||||
currentHeadSha: "new-head",
|
||||
run: { _tag: "Running", headSha: "new-head", startedAt: guide.generatedAt },
|
||||
});
|
||||
expect(state).toMatchObject({ guide, stale: true, running: true, failure: null });
|
||||
});
|
||||
it("does not label an unknown head stale", () => {
|
||||
expect(reviewGuideState({ guide, currentHeadSha: null, run: null }).stale).toBe(false);
|
||||
});
|
||||
it("shows only failures for the current head", () => {
|
||||
const run = {
|
||||
_tag: "Failed" as const,
|
||||
headSha: "old-head",
|
||||
failedAt: guide.generatedAt,
|
||||
detail: "The writer disconnected.",
|
||||
};
|
||||
expect(reviewGuideState({ guide: null, currentHeadSha: "old-head", run }).failure).toBe(
|
||||
run.detail,
|
||||
);
|
||||
expect(reviewGuideState({ guide: null, currentHeadSha: "new-head", run }).failure).toBeNull();
|
||||
});
|
||||
it("starts empty without claiming a job is running", () => {
|
||||
expect(reviewGuideState(null)).toEqual({
|
||||
guide: null,
|
||||
stale: false,
|
||||
running: false,
|
||||
failure: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { PullRequestReviewGuideResult } from "@t3tools/contracts";
|
||||
|
||||
/** Old failures must not follow a PR onto a different head. */
|
||||
export function reviewGuideState(data: PullRequestReviewGuideResult | null) {
|
||||
const guide = data?.guide ?? null;
|
||||
return {
|
||||
guide,
|
||||
running: data?.run?._tag === "Running",
|
||||
stale: guide !== null && data?.currentHeadSha != null && guide.headSha !== data.currentHeadSha,
|
||||
failure:
|
||||
data?.run?._tag === "Failed" && data.run.headSha === data.currentHeadSha
|
||||
? data.run.detail
|
||||
: null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { composerPullRequests } from "../../../state/pull-requests";
|
||||
import { useEnvironmentQuery } from "../../../state/query";
|
||||
import { serverEnvironment } from "../../../state/server";
|
||||
import { useAtomCommand } from "../../../state/use-atom-command";
|
||||
import { pullRequestTarget, type PullRequestParams } from "../usePullRequestDiff";
|
||||
|
||||
export function useReviewGuidesEnabled(params: PullRequestParams) {
|
||||
const settings = useAtomValue(
|
||||
serverEnvironment.settingsValueAtom(pullRequestTarget(params).environmentId),
|
||||
);
|
||||
return settings?.reviewGuidesEnabled === true;
|
||||
}
|
||||
|
||||
export function useReviewGuide(params: PullRequestParams) {
|
||||
const target = pullRequestTarget(params);
|
||||
const enabled = useReviewGuidesEnabled(params);
|
||||
const query = useEnvironmentQuery(enabled ? composerPullRequests.reviewGuide(target) : null);
|
||||
const canWrite = useAtomValue(
|
||||
composerPullRequests.generateReviewGuide.permissionAtom(target.environmentId),
|
||||
);
|
||||
const generate = useAtomCommand(composerPullRequests.generateReviewGuide, {
|
||||
reportFailure: false,
|
||||
});
|
||||
const [starting, setStarting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const pending = useRef(false);
|
||||
const running = starting || query.data?.run?._tag === "Running";
|
||||
const refresh = query.refresh;
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
if (!enabled) return;
|
||||
refresh();
|
||||
if (!running) return;
|
||||
const timer = setInterval(refresh, 5_000);
|
||||
return () => clearInterval(timer);
|
||||
}, [enabled, refresh, running]),
|
||||
);
|
||||
const write = async () => {
|
||||
if (!enabled || !canWrite || running || pending.current) return;
|
||||
pending.current = true;
|
||||
setStarting(true);
|
||||
setError(null);
|
||||
try {
|
||||
const result = await generate(target);
|
||||
if (result._tag === "Failure") {
|
||||
const cause = squashAtomCommandFailure(result);
|
||||
setError(cause instanceof Error ? cause.message : "Could not start the review guide.");
|
||||
} else {
|
||||
refresh();
|
||||
}
|
||||
} finally {
|
||||
pending.current = false;
|
||||
setStarting(false);
|
||||
}
|
||||
};
|
||||
return { ...query, enabled, canWrite, running, write, startError: error };
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { IsoDateTime, type PullRequestActivity, type PullRequestActor } from "@t3tools/contracts";
|
||||
import { DEFAULT_ACTIVITY_FILTER, filterPullRequestActivity } from "./pullRequestActivityFilter";
|
||||
|
||||
const date = IsoDateTime.make("2026-10-11T00:00:00.000Z");
|
||||
const human: PullRequestActor = { login: "reader", name: null, avatarUrl: null };
|
||||
const bot: PullRequestActor = { ...human, login: "reviewer[bot]" };
|
||||
const comment = (id: string, author = human, reviewState: string | null = null) => ({
|
||||
id,
|
||||
author,
|
||||
reviewState,
|
||||
kind: "issue-comment" as const,
|
||||
body: "A comment",
|
||||
createdAt: date,
|
||||
url: null,
|
||||
path: null,
|
||||
});
|
||||
const activity: PullRequestActivity = {
|
||||
comments: [
|
||||
comment("human"),
|
||||
comment("bot", bot),
|
||||
comment("dismissed", human, "DISMISSED"),
|
||||
comment("reply"),
|
||||
],
|
||||
commentCount: 4,
|
||||
commentsTruncated: false,
|
||||
commits: [{ oid: "abcdef", messageHeadline: "A change", committedDate: date }],
|
||||
reviewThreads: [
|
||||
{
|
||||
id: "thread",
|
||||
path: "file.ts",
|
||||
line: 1,
|
||||
side: "right",
|
||||
isResolved: true,
|
||||
isOutdated: false,
|
||||
comments: [comment("reply")],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("mobile activity filters", () => {
|
||||
it("hides bots and finished conversations by default, counting each thread once", () => {
|
||||
const result = filterPullRequestActivity(activity, DEFAULT_ACTIVITY_FILTER);
|
||||
expect(result.activity.comments.map((item) => item.id)).toEqual(["human"]);
|
||||
expect(result.activity.reviewThreads).toEqual([]);
|
||||
expect(result.activity.commits).toHaveLength(1);
|
||||
expect(result.hiddenCount).toBe(3);
|
||||
});
|
||||
it("restores bot comments and finished conversations without duplicate thread replies", () => {
|
||||
const result = filterPullRequestActivity(activity, {
|
||||
...DEFAULT_ACTIVITY_FILTER,
|
||||
bots: true,
|
||||
resolved: true,
|
||||
});
|
||||
expect(result.activity.comments.map((item) => item.id)).toEqual(["human", "bot", "dismissed"]);
|
||||
expect(result.activity.reviewThreads).toHaveLength(1);
|
||||
expect(result.hiddenCount).toBe(0);
|
||||
});
|
||||
it("keeps partially loaded bot discussions visible", () => {
|
||||
const thread = {
|
||||
...activity.reviewThreads[0]!,
|
||||
isResolved: false,
|
||||
comments: [comment("bot-reply", bot)],
|
||||
};
|
||||
for (const incomplete of [{ commentCount: 2 }, { nextCommentsCursor: "next" }]) {
|
||||
const result = filterPullRequestActivity(
|
||||
{ ...activity, reviewThreads: [{ ...thread, ...incomplete }] },
|
||||
DEFAULT_ACTIVITY_FILTER,
|
||||
);
|
||||
expect(result.activity.reviewThreads).toHaveLength(1);
|
||||
}
|
||||
expect(
|
||||
filterPullRequestActivity({ ...activity, reviewThreads: [thread] }, DEFAULT_ACTIVITY_FILTER)
|
||||
.activity.reviewThreads,
|
||||
).toEqual([]);
|
||||
});
|
||||
it("provides a commits-only view and a comments-only view", () => {
|
||||
const commits = filterPullRequestActivity(activity, {
|
||||
...DEFAULT_ACTIVITY_FILTER,
|
||||
kind: "commits",
|
||||
}).activity;
|
||||
expect(commits.comments).toEqual([]);
|
||||
expect(commits.reviewThreads).toEqual([]);
|
||||
expect(commits.commits).toHaveLength(1);
|
||||
expect(
|
||||
filterPullRequestActivity(activity, { ...DEFAULT_ACTIVITY_FILTER, kind: "comments" }).activity
|
||||
.commits,
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import type { PullRequestActivity, PullRequestActor } from "@t3tools/contracts";
|
||||
|
||||
export interface ActivityFilter {
|
||||
readonly kind: "all" | "comments" | "commits";
|
||||
readonly bots: boolean;
|
||||
readonly resolved: boolean;
|
||||
readonly newestFirst: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_ACTIVITY_FILTER: ActivityFilter = {
|
||||
kind: "all",
|
||||
bots: false,
|
||||
resolved: false,
|
||||
newestFirst: true,
|
||||
};
|
||||
|
||||
function isBot(actor: PullRequestActor | null) {
|
||||
return actor?.isBot === true || actor?.login.endsWith("[bot]") === true;
|
||||
}
|
||||
|
||||
function eventCount(activity: PullRequestActivity) {
|
||||
const discussionIds = new Set(
|
||||
activity.reviewThreads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
|
||||
);
|
||||
return (
|
||||
activity.comments.filter((comment) => !discussionIds.has(comment.id)).length +
|
||||
activity.reviewThreads.length +
|
||||
activity.commits.length
|
||||
);
|
||||
}
|
||||
|
||||
export function filterPullRequestActivity(activity: PullRequestActivity, filter: ActivityFilter) {
|
||||
// A discussion's replies stay together, even when a bot replies to a human.
|
||||
const reviewThreads =
|
||||
filter.kind === "commits"
|
||||
? []
|
||||
: activity.reviewThreads.filter(
|
||||
(thread) =>
|
||||
(filter.resolved || !thread.isResolved) &&
|
||||
(filter.bots ||
|
||||
(thread.commentCount ?? 0) > thread.comments.length ||
|
||||
thread.nextCommentsCursor != null ||
|
||||
thread.comments.some((comment) => !isBot(comment.author))),
|
||||
);
|
||||
const allDiscussionIds = new Set(
|
||||
activity.reviewThreads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
|
||||
);
|
||||
const comments =
|
||||
filter.kind === "commits"
|
||||
? []
|
||||
: activity.comments.filter(
|
||||
(comment) =>
|
||||
!allDiscussionIds.has(comment.id) &&
|
||||
(filter.bots || !isBot(comment.author)) &&
|
||||
(filter.resolved || comment.reviewState?.trim().toLowerCase() !== "dismissed"),
|
||||
);
|
||||
const filtered = {
|
||||
...activity,
|
||||
comments,
|
||||
reviewThreads,
|
||||
commits: filter.kind === "comments" ? [] : activity.commits,
|
||||
commentsTruncated: filter.kind !== "commits" && activity.commentsTruncated,
|
||||
reviewThreadsTruncated: filter.kind !== "commits" && activity.reviewThreadsTruncated,
|
||||
};
|
||||
return { activity: filtered, hiddenCount: eventCount(activity) - eventCount(filtered) };
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
FadeIn,
|
||||
FadeOut,
|
||||
LinearTransition,
|
||||
ReduceMotion,
|
||||
withTiming,
|
||||
type LayoutAnimationFunction,
|
||||
} from "react-native-reanimated";
|
||||
|
||||
// Match the model picker: move existing rows, briefly fade additions and removals.
|
||||
export const PR_ROW_LAYOUT = LinearTransition.duration(180).reduceMotion(ReduceMotion.System);
|
||||
export const PR_ROW_ENTER = FadeIn.duration(140).reduceMotion(ReduceMotion.System);
|
||||
export const PR_ROW_EXIT = FadeOut.duration(100).reduceMotion(ReduceMotion.System);
|
||||
|
||||
export const PR_DISCLOSURE_ENTER = FadeIn.delay(80).duration(120).reduceMotion(ReduceMotion.System);
|
||||
|
||||
// Follow expanding status rows without interpolating the clipped markdown's height.
|
||||
export const PR_POSITION_LAYOUT: LayoutAnimationFunction = (values) => {
|
||||
"worklet";
|
||||
return {
|
||||
initialValues: {
|
||||
originX: values.targetOriginX,
|
||||
originY: values.currentOriginY,
|
||||
width: values.targetWidth,
|
||||
height: values.targetHeight,
|
||||
},
|
||||
animations: {
|
||||
originX: values.targetOriginX,
|
||||
originY: withTiming(values.targetOriginY, {
|
||||
duration: 180,
|
||||
reduceMotion: ReduceMotion.System,
|
||||
}),
|
||||
width: values.targetWidth,
|
||||
height: values.targetHeight,
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -67,6 +67,17 @@ describe("mobile PR test file filter", () => {
|
||||
expect(parsed.files).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("keeps a guide's target test file visible without exposing other hidden tests", () => {
|
||||
const parsed = buildReviewParsedDiff(
|
||||
["src/first.test.ts", "src/app.ts", "src/second.test.ts"].map(patch).join("\n"),
|
||||
"pr",
|
||||
);
|
||||
const visible = filterPullRequestTestFiles(parsed, true, "src/second.test.ts");
|
||||
if (parsed.kind !== "files" || visible.kind !== "files") throw new Error("Expected files");
|
||||
expect(visible.files.map((file) => file.path)).toEqual(["src/app.ts", "src/second.test.ts"]);
|
||||
expect(visible.files[1]).toBe(parsed.files[2]);
|
||||
});
|
||||
|
||||
it("uses the current path when a file is renamed out of a test directory", () => {
|
||||
const parsed = buildReviewParsedDiff(
|
||||
"diff --git a/tests/helper.ts b/src/helper.ts\nsimilarity index 100%\nrename from tests/helper.ts\nrename to src/helper.ts\n",
|
||||
|
||||
@@ -21,9 +21,12 @@ export function isPullRequestTestFile(path: string): boolean {
|
||||
export function filterPullRequestTestFiles(
|
||||
parsed: ReviewParsedDiff,
|
||||
hideTestFiles: boolean,
|
||||
includePath?: string,
|
||||
): ReviewParsedDiff {
|
||||
if (!hideTestFiles || parsed.kind !== "files") return parsed;
|
||||
const files = parsed.files.filter((file) => !isPullRequestTestFile(file.path));
|
||||
const files = parsed.files.filter(
|
||||
(file) => file.path === includePath || !isPullRequestTestFile(file.path),
|
||||
);
|
||||
if (files.length === parsed.files.length) return parsed;
|
||||
return {
|
||||
...parsed,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { pullRequestTabOffset } from "./pullRequestTabScroll";
|
||||
|
||||
describe("pull request tab scroll", () => {
|
||||
it("keeps the header fixed while switching, even if the destination was scrolled deeply", () => {
|
||||
expect(pullRequestTabOffset(-100, 900, 200)).toBe(-100);
|
||||
expect(pullRequestTabOffset(75, 900, 200)).toBe(75);
|
||||
});
|
||||
it("resumes the destination body only when the shared header is already collapsed", () => {
|
||||
expect(pullRequestTabOffset(600, 900, 200)).toBe(900);
|
||||
expect(pullRequestTabOffset(600, 50, 200)).toBe(200);
|
||||
expect(pullRequestTabOffset(600, undefined, 200)).toBe(200);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
/** Preserve the shared header's position, then each tab's own reading position. */
|
||||
export function pullRequestTabOffset(
|
||||
current: number,
|
||||
saved: number | undefined,
|
||||
headerEnd: number,
|
||||
) {
|
||||
return current < headerEnd ? current : Math.max(headerEnd, saved ?? headerEnd);
|
||||
}
|
||||
@@ -5,14 +5,14 @@ import type { ReviewParsedDiff } from "../review/reviewModel";
|
||||
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
|
||||
import { filterPullRequestTestFiles } from "./pullRequestFileFilters";
|
||||
|
||||
export function usePullRequestFileFilter(parsed: ReviewParsedDiff) {
|
||||
export function usePullRequestFileFilter(parsed: ReviewParsedDiff, includePath?: string) {
|
||||
const preferences = useAtomValue(mobilePreferencesAtom);
|
||||
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
|
||||
const hideTestFiles =
|
||||
AsyncResult.isSuccess(preferences) && preferences.value.pullRequestHideTestFiles === true;
|
||||
const visible = useMemo(
|
||||
() => filterPullRequestTestFiles(parsed, hideTestFiles),
|
||||
[parsed, hideTestFiles],
|
||||
() => filterPullRequestTestFiles(parsed, hideTestFiles, includePath),
|
||||
[parsed, hideTestFiles, includePath],
|
||||
);
|
||||
const hiddenCount =
|
||||
parsed.kind === "files" && visible.kind === "files" ? parsed.fileCount - visible.fileCount : 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
|
||||
import { useCallback, useMemo, useState, type ReactNode } from "react";
|
||||
import { Keyboard, Platform, View, type NativeSyntheticEvent } from "react-native";
|
||||
import { Tabs, type TabSelectedEvent } from "react-native-screens";
|
||||
import { Tabs, type TabSelectedEvent, type TabSelectionRejectedEvent } from "react-native-screens";
|
||||
|
||||
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
|
||||
import type { WorkspaceTab } from "./workspace-tabs-state";
|
||||
@@ -70,11 +70,16 @@ export function WorkspaceNativeTabs(props: {
|
||||
tabBarMinimizeBehavior: "never",
|
||||
tabBarLeadingWidth: phoneBar ? 220 : 0,
|
||||
}}
|
||||
onTabSelectionRejected={({
|
||||
nativeEvent,
|
||||
}: NativeSyntheticEvent<TabSelectionRejectedEvent>) => {
|
||||
setProvenance(nativeEvent.provenance);
|
||||
}}
|
||||
onTabSelected={({ nativeEvent }: NativeSyntheticEvent<TabSelectedEvent>) => {
|
||||
const tab = nativeEvent.selectedScreenKey;
|
||||
if (tab !== "threads" && tab !== "pullRequests") return;
|
||||
setProvenance(nativeEvent.provenance);
|
||||
if (tab === selectedTab) return;
|
||||
if (nativeEvent.actionOrigin === "programmatic-js" || tab === selectedTab) return;
|
||||
Keyboard.dismiss();
|
||||
props.onSelect();
|
||||
workspace.dispatch({ type: "select", tab });
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useNavigation } from "@react-navigation/native";
|
||||
import { use, useCallback, useMemo } from "react";
|
||||
import { Platform, View, useWindowDimensions } from "react-native";
|
||||
import { useKeyboardState } from "react-native-keyboard-controller";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
|
||||
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
|
||||
@@ -24,7 +24,8 @@ import {
|
||||
} from "./WorkspaceTabsContext";
|
||||
import { WorkspaceToolbar } from "./WorkspaceToolbar";
|
||||
import { WORKSPACE_DOCK, workspaceToolbarHeight } from "./workspace-tabs-state";
|
||||
import { useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
|
||||
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
|
||||
import { useSidebarWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
|
||||
|
||||
const TAB_TITLES = {
|
||||
threads: "Threads",
|
||||
@@ -58,6 +59,7 @@ function WorkspaceRootContent() {
|
||||
const columnMetrics = useNativeColumnLayoutMetrics();
|
||||
const nativeMetrics = useNativeLayoutMetrics();
|
||||
const systemTabBar = useSystemWorkspaceTabBar();
|
||||
const sidebarTabs = useSidebarWorkspaceTabs();
|
||||
const sidebarNavigation =
|
||||
primaryColumn !== null &&
|
||||
(layout.usesSplitView ||
|
||||
@@ -86,7 +88,7 @@ function WorkspaceRootContent() {
|
||||
const bottomClearance =
|
||||
Platform.OS === "ios"
|
||||
? Math.max(insets.bottom, keyboardHeight) +
|
||||
(systemTabBar || tab.searchMode !== "resting"
|
||||
(systemTabBar || sidebarTabs || tab.searchMode !== "resting"
|
||||
? 16
|
||||
: WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
|
||||
: keyboardHeight > 0 && tab.searchMode !== "resting"
|
||||
@@ -96,7 +98,10 @@ function WorkspaceRootContent() {
|
||||
|
||||
return (
|
||||
<WorkspaceTabsContext value={context}>
|
||||
<View className="flex-1 bg-screen">
|
||||
<View
|
||||
className="flex-1 bg-screen"
|
||||
style={sidebarTabs ? { paddingTop: insets.top } : undefined}
|
||||
>
|
||||
{Platform.OS === "ios" ? (
|
||||
<NativeStackScreenOptions
|
||||
optionsVersion={[state.selectedTab, state.selectionRevision, width, sidebarNavigation]}
|
||||
@@ -132,7 +137,11 @@ function WorkspaceRootContent() {
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
{state.selectedTab === "threads" ? <HomeRouteScreen /> : <PullRequestsScreen />}
|
||||
{sidebarTabs ? <WorkspaceSidebarTabs /> : null}
|
||||
{/* The pinned picker already clears the navigation bar; lists must not inset it again. */}
|
||||
<SafeAreaInsetsContext value={sidebarTabs ? { ...insets, top: 0 } : insets}>
|
||||
{state.selectedTab === "threads" ? <HomeRouteScreen /> : <PullRequestsScreen />}
|
||||
</SafeAreaInsetsContext>
|
||||
<WorkspaceToolbar
|
||||
sidebar={sidebarNavigation}
|
||||
onNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Host, Picker, Text } from "@expo/ui/swift-ui";
|
||||
import { pickerStyle, tag } from "@expo/ui/swift-ui/modifiers";
|
||||
import { StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { Keyboard, View } from "react-native";
|
||||
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
|
||||
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
|
||||
import type { WorkspaceTab } from "./workspace-tabs-state";
|
||||
|
||||
/** Wide iPad navigation belongs to the sidebar, leaving the detail's header unobstructed. */
|
||||
export function WorkspaceSidebarTabs() {
|
||||
const workspace = useWorkspaceTabs()!;
|
||||
const navigation = useNavigation();
|
||||
const { themeAppearance } = useAppearancePreferences();
|
||||
return (
|
||||
<View className="px-4 pb-3 pt-2">
|
||||
<Host
|
||||
matchContents={{ vertical: true }}
|
||||
colorScheme={themeAppearance}
|
||||
style={{ width: "100%" }}
|
||||
>
|
||||
<Picker
|
||||
label="Workspace"
|
||||
selection={workspace.state.selectedTab}
|
||||
onSelectionChange={(tab: WorkspaceTab) => {
|
||||
if (tab === workspace.state.selectedTab) return;
|
||||
Keyboard.dismiss();
|
||||
if (navigation.getState()?.index) navigation.dispatch(StackActions.popToTop());
|
||||
workspace.dispatch({ type: "select", tab });
|
||||
}}
|
||||
modifiers={[pickerStyle("segmented")]}
|
||||
>
|
||||
<Text modifiers={[tag("threads")]}>Threads</Text>
|
||||
<Text modifiers={[tag("pullRequests")]}>Pull requests</Text>
|
||||
</Picker>
|
||||
</Host>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/** The sidebar workspace picker is native to wide iPad layouts. */
|
||||
export function WorkspaceSidebarTabs() {
|
||||
return null;
|
||||
}
|
||||
@@ -9,20 +9,17 @@ import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-con
|
||||
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
|
||||
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
|
||||
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
|
||||
import { useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
|
||||
|
||||
/** Root actions stay in the header; UIKit owns the tab bar and bottom compose button. */
|
||||
/** Root actions stay in the header; UIKit owns the bottom compose button. */
|
||||
export function WorkspaceToolbar(props: {
|
||||
readonly onNewTask: () => void;
|
||||
readonly sidebar?: boolean;
|
||||
}) {
|
||||
const workspace = useWorkspaceTabs()!;
|
||||
const navigation = useNavigation();
|
||||
const systemTabBar = useSystemWorkspaceTabBar();
|
||||
const metrics = useNativeLayoutMetrics();
|
||||
const nativeToolbarCompose =
|
||||
systemTabBar &&
|
||||
((Platform.OS === "ios" && Platform.isPad) || (metrics?.verticalBarEdge ?? "none") !== "none");
|
||||
Platform.OS === "ios" && (Platform.isPad || (metrics?.verticalBarEdge ?? "none") !== "none");
|
||||
const { isTabActive } = workspace;
|
||||
const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
|
||||
const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { Platform } from "react-native";
|
||||
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
|
||||
|
||||
/** UIKit owns workspace tab navigation on every iOS size class. */
|
||||
export function useSystemWorkspaceTabBar() {
|
||||
return Platform.OS === "ios";
|
||||
export function useSidebarWorkspaceTabs() {
|
||||
const { layout } = useAdaptiveWorkspaceLayout();
|
||||
return Platform.OS === "ios" && Platform.isPad && layout.usesSplitView;
|
||||
}
|
||||
|
||||
/** Compact iOS windows use UIKit tabs; wide iPad windows use the sidebar picker. */
|
||||
export function useSystemWorkspaceTabBar() {
|
||||
const sidebarTabs = useSidebarWorkspaceTabs();
|
||||
return Platform.OS === "ios" && !sidebarTabs;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
excerptRows,
|
||||
fileDiffRows,
|
||||
rowsToPatch,
|
||||
} from "./guideTour.logic";
|
||||
} from "@t3tools/client-runtime/review-guide-tour";
|
||||
import { GuideNoteMarker } from "./GuideNotes";
|
||||
import { GuideProse } from "./GuideProse";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CheckIcon } from "lucide-react";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
import { Badge } from "../../ui/badge";
|
||||
import { stopSubline } from "./guideTour.logic";
|
||||
import { stopSubline } from "@t3tools/client-runtime/review-guide-tour";
|
||||
|
||||
/**
|
||||
* The tour's table of contents: where the reader is and which stops they have read past. A stop
|
||||
|
||||
@@ -28,7 +28,7 @@ import { GuideExcerpt, type ExcerptCommenting } from "./GuideExcerpt";
|
||||
import { GuideFileDiff } from "./GuideFileDiff";
|
||||
import { GuideNotes } from "./GuideNotes";
|
||||
import { GuideProse } from "./GuideProse";
|
||||
import { letterStopNotes } from "./guideTour.logic";
|
||||
import { letterStopNotes } from "@t3tools/client-runtime/review-guide-tour";
|
||||
|
||||
const ATTENTION_LABELS = {
|
||||
tradeoff: "A tradeoff to weigh",
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
useGuideRunStore,
|
||||
type GuideProgress,
|
||||
} from "./guideRunStore";
|
||||
import { stepTourPosition, stopFilePaths } from "./guideTour.logic";
|
||||
import { stepTourPosition, stopFilePaths } from "@t3tools/client-runtime/review-guide-tour";
|
||||
import { useGuideDiffFiles } from "./useGuideDiffFiles";
|
||||
|
||||
/**
|
||||
|
||||
@@ -193,7 +193,9 @@ declined pull request.
|
||||
### Review guides
|
||||
|
||||
Review guides are in beta. Turn on **Review guides** in Settings → Source Control to add the
|
||||
**Guide** tab to pull requests on that server.
|
||||
**Guide** tab to pull requests on that server. On mobile, move between stops with **Next**
|
||||
and the back button; a stale guide offers a rewrite and hides excerpts that no longer match
|
||||
the current change.
|
||||
|
||||
The **Guide** tab gives you a tour of a pull request without reading it line by line: stops
|
||||
through the change in reading order. Each stop points at the lines worth reading, and a stop marked
|
||||
@@ -205,11 +207,12 @@ covers that layer only, and may point out what a lower layer introduced or what
|
||||
Choose **Write guide** to have the review guide model from Settings → Source Control read the
|
||||
change in a temporary checkout; without one set, the source control writer model is used. Nothing
|
||||
in the checkout is changed, and a large pull request takes a few minutes; you can go elsewhere in
|
||||
the app and you are told when the guide is ready. Claude and Codex can write guides. The guide is
|
||||
the app. On web, you are told when the guide is ready; on mobile, return to the guide to check
|
||||
its progress. Claude and Codex can write guides. The guide is
|
||||
kept for everyone using this server. To write it again, for example after a push or after changing
|
||||
the model or instructions, choose **Rewrite guide** from the pull request's **⋯** menu.
|
||||
|
||||
While reading a stop, select lines in an excerpt to add a comment to your review or ask an agent
|
||||
On web, while reading a stop, select lines in an excerpt to add a comment to your review or ask an agent
|
||||
about them; comments wait with the ones from the **Code** tab until you send the review. Choose a
|
||||
suggested question, or **Ask about this stop**, to open a thread that already knows which stop you
|
||||
are on. **Finish review** on the last stop opens the review with everything you collected.
|
||||
|
||||
@@ -398,6 +398,10 @@
|
||||
"./source-control-clients": {
|
||||
"types": "./src/sourceControlClients.ts",
|
||||
"default": "./src/sourceControlClients.ts"
|
||||
},
|
||||
"./review-guide-tour": {
|
||||
"types": "./src/reviewGuideTour.ts",
|
||||
"default": "./src/reviewGuideTour.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@@ -405,6 +409,7 @@
|
||||
"test": "vp test run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pierre/diffs": "catalog:",
|
||||
"@t3tools/contracts": "workspace:*",
|
||||
"@t3tools/shared": "workspace:*",
|
||||
"@t3tools/source-control-azure-devops": "workspace:*",
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import {
|
||||
letterStopNotes,
|
||||
rowsToPatch,
|
||||
stepTourPosition,
|
||||
} from "./guideTour.logic";
|
||||
} from "./reviewGuideTour.js";
|
||||
|
||||
const PATCH = `diff --git a/src/tray.ts b/src/tray.ts
|
||||
--- a/src/tray.ts
|
||||
File renamed without changes.
Generated
+26
@@ -1073,6 +1073,9 @@ importers:
|
||||
|
||||
packages/client-runtime:
|
||||
dependencies:
|
||||
'@pierre/diffs':
|
||||
specifier: 'catalog:'
|
||||
version: 1.5.2(patch_hash=298e94372dbd51846a4e26ece2ecc3e22eb1f94b0450b1f1a9c6fec127809be7)(@shikijs/[email protected])([email protected]([email protected]))([email protected])
|
||||
'@t3tools/contracts':
|
||||
specifier: workspace:*
|
||||
version: link:../contracts
|
||||
@@ -15766,6 +15769,21 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- '@shikijs/themes'
|
||||
|
||||
'@pierre/[email protected](patch_hash=298e94372dbd51846a4e26ece2ecc3e22eb1f94b0450b1f1a9c6fec127809be7)(@shikijs/[email protected])([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@pierre/theme': 2.0.0
|
||||
'@pierre/theming': 1.0.1(@pierre/[email protected])(@shikijs/[email protected])([email protected]([email protected]))([email protected])([email protected])
|
||||
'@shikijs/transformers': 4.2.0
|
||||
diff: 9.0.0
|
||||
hast-util-to-html: 9.0.5
|
||||
lru_map: 0.4.1
|
||||
shiki: 4.2.0
|
||||
optionalDependencies:
|
||||
react: 19.3.0
|
||||
react-dom: 19.3.0([email protected])
|
||||
transitivePeerDependencies:
|
||||
- '@shikijs/themes'
|
||||
|
||||
'@pierre/[email protected]':
|
||||
optional: true
|
||||
|
||||
@@ -15803,6 +15821,14 @@ snapshots:
|
||||
react-dom: 19.2.6([email protected])
|
||||
shiki: 4.2.0
|
||||
|
||||
'@pierre/[email protected](@pierre/[email protected])(@shikijs/[email protected])([email protected]([email protected]))([email protected])([email protected])':
|
||||
optionalDependencies:
|
||||
'@pierre/theme': 2.0.0
|
||||
'@shikijs/themes': 4.3.0
|
||||
react: 19.3.0
|
||||
react-dom: 19.3.0([email protected])
|
||||
shiki: 4.2.0
|
||||
|
||||
'@pierre/[email protected](@pierre/[email protected])(@shikijs/[email protected])([email protected]([email protected]))([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@pierre/theming': 1.0.0(@pierre/[email protected])(@shikijs/[email protected])([email protected]([email protected]))([email protected])([email protected])
|
||||
|
||||
Reference in new issue
Block a user