- Add a debug diff scratch route with fixture-driven highlighting - Wrap review screen in a shared highlighter provider - Document profiling steps and add a Hermes profiling script
3209 lines
112 KiB
Diff
3209 lines
112 KiB
Diff
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
|
|
index 08329e1d4..36ac93a0f 100644
|
|
--- a/apps/mobile/package.json
|
|
+++ b/apps/mobile/package.json
|
|
@@ -30,6 +30,7 @@
|
|
"config:dev": "APP_VARIANT=development expo config",
|
|
"config:preview": "APP_VARIANT=preview expo config",
|
|
"config:prod": "APP_VARIANT=production expo config",
|
|
+ "profile:android:hermes": "mkdir -p profiles/review && react-native profile-hermes profiles/review",
|
|
"test": "vitest run",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
diff --git a/apps/mobile/src/app/index.tsx b/apps/mobile/src/app/index.tsx
|
|
index f153db701..f6095c051 100644
|
|
--- a/apps/mobile/src/app/index.tsx
|
|
+++ b/apps/mobile/src/app/index.tsx
|
|
@@ -43,28 +43,50 @@ export default function HomeRouteScreen() {
|
|
headerTintColor: iconColor,
|
|
headerTitle: "",
|
|
headerRight: () => (
|
|
- <Pressable
|
|
- onPress={() => router.push("/connections")}
|
|
- hitSlop={8}
|
|
- style={{
|
|
- flexDirection: "row",
|
|
- alignItems: "center",
|
|
- gap: 8,
|
|
- paddingHorizontal: 4,
|
|
- paddingVertical: 4,
|
|
- }}
|
|
- >
|
|
- <ConnectionStatusDot state={connectionState} pulse={hasRemoteActivity} size={7} />
|
|
- <RNText
|
|
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 12 }}>
|
|
+ <Pressable
|
|
+ onPress={() => router.push("/debug/syntax-highlight")}
|
|
+ hitSlop={8}
|
|
style={{
|
|
- fontFamily: "DMSans_700Bold",
|
|
- fontSize: 12,
|
|
- color: secondaryFg,
|
|
+ borderRadius: 999,
|
|
+ backgroundColor: isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.06)",
|
|
+ paddingHorizontal: 10,
|
|
+ paddingVertical: 5,
|
|
}}
|
|
>
|
|
- {CONNECTION_LABEL[connectionState]}
|
|
- </RNText>
|
|
- </Pressable>
|
|
+ <RNText
|
|
+ style={{
|
|
+ fontFamily: "DMSans_700Bold",
|
|
+ fontSize: 12,
|
|
+ color: secondaryFg,
|
|
+ }}
|
|
+ >
|
|
+ Debug
|
|
+ </RNText>
|
|
+ </Pressable>
|
|
+ <Pressable
|
|
+ onPress={() => router.push("/connections")}
|
|
+ hitSlop={8}
|
|
+ style={{
|
|
+ flexDirection: "row",
|
|
+ alignItems: "center",
|
|
+ gap: 8,
|
|
+ paddingHorizontal: 4,
|
|
+ paddingVertical: 4,
|
|
+ }}
|
|
+ >
|
|
+ <ConnectionStatusDot state={connectionState} pulse={hasRemoteActivity} size={7} />
|
|
+ <RNText
|
|
+ style={{
|
|
+ fontFamily: "DMSans_700Bold",
|
|
+ fontSize: 12,
|
|
+ color: secondaryFg,
|
|
+ }}
|
|
+ >
|
|
+ {CONNECTION_LABEL[connectionState]}
|
|
+ </RNText>
|
|
+ </Pressable>
|
|
+ </View>
|
|
),
|
|
headerSearchBarOptions: {
|
|
placeholder: "Search threads",
|
|
diff --git a/apps/mobile/src/app/threads/[environmentId]/[threadId]/review.tsx b/apps/mobile/src/app/threads/[environmentId]/[threadId]/review.tsx
|
|
index 84c48c6ed..ee993ee7c 100644
|
|
--- a/apps/mobile/src/app/threads/[environmentId]/[threadId]/review.tsx
|
|
+++ b/apps/mobile/src/app/threads/[environmentId]/[threadId]/review.tsx
|
|
@@ -1,5 +1,10 @@
|
|
+import { ReviewHighlighterProvider } from "../../../../features/review/ReviewHighlighterProvider";
|
|
import { ReviewSheet } from "../../../../features/review/ReviewSheet";
|
|
|
|
export default function ReviewRoute() {
|
|
- return <ReviewSheet />;
|
|
+ return (
|
|
+ <ReviewHighlighterProvider>
|
|
+ <ReviewSheet />
|
|
+ </ReviewHighlighterProvider>
|
|
+ );
|
|
}
|
|
diff --git a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
|
|
index 076a2286d..9a173224a 100644
|
|
--- a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
|
|
+++ b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
|
|
@@ -2,15 +2,8 @@ import { useLocalSearchParams, useRouter } from "expo-router";
|
|
import { SymbolView } from "expo-symbols";
|
|
import { TextInputWrapper } from "expo-paste-input";
|
|
import { useEffect, useMemo, useState } from "react";
|
|
-import {
|
|
- KeyboardAvoidingView,
|
|
- Platform,
|
|
- Pressable,
|
|
- ScrollView,
|
|
- View,
|
|
- useColorScheme,
|
|
- useWindowDimensions,
|
|
-} from "react-native";
|
|
+import { Pressable, ScrollView, View, useColorScheme, useWindowDimensions } from "react-native";
|
|
+import { KeyboardStickyView } from "react-native-keyboard-controller";
|
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
import ImageViewing from "react-native-image-viewing";
|
|
|
|
@@ -34,6 +27,7 @@ import {
|
|
import {
|
|
changeTone,
|
|
DiffTokenText,
|
|
+ REVIEW_DIFF_LINE_HEIGHT,
|
|
REVIEW_MONO_FONT_FAMILY,
|
|
ReviewChangeBar,
|
|
} from "./reviewDiffRendering";
|
|
@@ -44,7 +38,6 @@ import {
|
|
} from "./shikiReviewHighlighter";
|
|
|
|
const REVIEW_COMMENT_PREVIEW_MAX_LINES = 5;
|
|
-const REVIEW_COMMENT_LINE_HEIGHT = 26;
|
|
|
|
export function ReviewCommentComposerSheet() {
|
|
const router = useRouter();
|
|
@@ -84,8 +77,8 @@ export function ReviewCommentComposerSheet() {
|
|
? `Lines ${firstNumber}-${lastNumber}`
|
|
: `${selectedLines.length} lines selected`;
|
|
const previewHeight = Math.max(
|
|
- Math.min(selectedLines.length, REVIEW_COMMENT_PREVIEW_MAX_LINES) * REVIEW_COMMENT_LINE_HEIGHT,
|
|
- REVIEW_COMMENT_LINE_HEIGHT,
|
|
+ Math.min(selectedLines.length, REVIEW_COMMENT_PREVIEW_MAX_LINES) * REVIEW_DIFF_LINE_HEIGHT,
|
|
+ REVIEW_DIFF_LINE_HEIGHT,
|
|
);
|
|
const previewViewportWidth = Math.max(width - 40, 280);
|
|
const handleNativePaste = useNativePaste((uris) => {
|
|
@@ -143,17 +136,13 @@ export function ReviewCommentComposerSheet() {
|
|
}
|
|
|
|
return (
|
|
- <KeyboardAvoidingView
|
|
- behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
- keyboardVerticalOffset={Platform.OS === "ios" ? 12 : 0}
|
|
- style={{ flex: 1 }}
|
|
- >
|
|
+ <View style={{ flex: 1 }}>
|
|
<View
|
|
style={{
|
|
flex: 1,
|
|
paddingHorizontal: 20,
|
|
paddingTop: 8,
|
|
- paddingBottom: Math.max(insets.bottom, 18) + 18,
|
|
+ paddingBottom: Math.max(insets.bottom, 18) + 82,
|
|
}}
|
|
>
|
|
<View className="flex-row items-center justify-between py-2">
|
|
@@ -219,7 +208,7 @@ export function ReviewCommentComposerSheet() {
|
|
<View
|
|
key={line.id}
|
|
className={cn("flex-row items-start", changeTone(line.change))}
|
|
- style={{ height: REVIEW_COMMENT_LINE_HEIGHT }}
|
|
+ style={{ height: REVIEW_DIFF_LINE_HEIGHT }}
|
|
>
|
|
<ReviewChangeBar change={line.change} />
|
|
<Text
|
|
@@ -280,35 +269,41 @@ export function ReviewCommentComposerSheet() {
|
|
) : null}
|
|
</View>
|
|
</View>
|
|
-
|
|
- <View className="flex-row items-center gap-3 pt-1">
|
|
- <ControlPill icon="plus" onPress={() => void handlePickImages()} />
|
|
- <View className="flex-1" />
|
|
- <ControlPill
|
|
- icon="arrow.up"
|
|
- label="Comment"
|
|
- variant="primary"
|
|
- disabled={!canSubmit}
|
|
- onPress={() => {
|
|
- if (!target || !environmentId || !threadId || commentText.trim().length === 0) {
|
|
- return;
|
|
- }
|
|
-
|
|
- appendReviewCommentToDraft({
|
|
- environmentId,
|
|
- threadId,
|
|
- text: formatReviewCommentContext(target, commentText),
|
|
- attachments,
|
|
- });
|
|
- setAttachments([]);
|
|
- clearReviewCommentTarget();
|
|
- router.dismiss();
|
|
- }}
|
|
- />
|
|
- </View>
|
|
</View>
|
|
)}
|
|
</View>
|
|
+ {target ? (
|
|
+ <KeyboardStickyView style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}>
|
|
+ <View
|
|
+ className="flex-row items-center gap-3 bg-sheet px-5 pt-3"
|
|
+ style={{ paddingBottom: Math.max(insets.bottom, 18) }}
|
|
+ >
|
|
+ <ControlPill icon="plus" onPress={() => void handlePickImages()} />
|
|
+ <View className="flex-1" />
|
|
+ <ControlPill
|
|
+ icon="arrow.up"
|
|
+ label="Comment"
|
|
+ variant="primary"
|
|
+ disabled={!canSubmit}
|
|
+ onPress={() => {
|
|
+ if (!target || !environmentId || !threadId || commentText.trim().length === 0) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ appendReviewCommentToDraft({
|
|
+ environmentId,
|
|
+ threadId,
|
|
+ text: formatReviewCommentContext(target, commentText),
|
|
+ attachments,
|
|
+ });
|
|
+ setAttachments([]);
|
|
+ clearReviewCommentTarget();
|
|
+ router.dismiss();
|
|
+ }}
|
|
+ />
|
|
+ </View>
|
|
+ </KeyboardStickyView>
|
|
+ ) : null}
|
|
<ImageViewing
|
|
images={previewImageUri ? [{ uri: previewImageUri }] : []}
|
|
imageIndex={0}
|
|
@@ -317,6 +312,6 @@ export function ReviewCommentComposerSheet() {
|
|
swipeToCloseEnabled
|
|
doubleTapToZoomEnabled
|
|
/>
|
|
- </KeyboardAvoidingView>
|
|
+ </View>
|
|
);
|
|
}
|
|
diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsx
|
|
index 82c28e81e..e148a8da2 100644
|
|
--- a/apps/mobile/src/features/review/ReviewSheet.tsx
|
|
+++ b/apps/mobile/src/features/review/ReviewSheet.tsx
|
|
@@ -1,17 +1,31 @@
|
|
import { EnvironmentId, ThreadId, type OrchestrationCheckpointSummary } from "@t3tools/contracts";
|
|
+import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
+import Animated, {
|
|
+ makeMutable,
|
|
+ type SharedValue,
|
|
+ useAnimatedStyle,
|
|
+ useSharedValue,
|
|
+} from "react-native-reanimated";
|
|
import { useLocalSearchParams, useRouter } from "expo-router";
|
|
import Stack from "expo-router/stack";
|
|
import { SymbolView } from "expo-symbols";
|
|
-import { memo, type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
+import {
|
|
+ memo,
|
|
+ type ReactElement,
|
|
+ useCallback,
|
|
+ useDeferredValue,
|
|
+ useEffect,
|
|
+ useMemo,
|
|
+ useRef,
|
|
+ useState,
|
|
+} from "react";
|
|
import {
|
|
ActivityIndicator,
|
|
FlatList,
|
|
- InteractionManager,
|
|
type ListRenderItemInfo,
|
|
Pressable,
|
|
ScrollView,
|
|
Text as NativeText,
|
|
- type ViewToken,
|
|
useColorScheme,
|
|
useWindowDimensions,
|
|
View,
|
|
@@ -32,6 +46,7 @@ import {
|
|
setReviewTurnDiff,
|
|
updateReviewExpandedFileIds,
|
|
updateReviewRevealedLargeFileIds,
|
|
+ updateReviewViewedFileIds,
|
|
useReviewCacheForThread,
|
|
} from "./reviewState";
|
|
import {
|
|
@@ -45,11 +60,12 @@ import {
|
|
type ReviewParsedDiff,
|
|
type ReviewRenderableFile,
|
|
type ReviewRenderableLineRow,
|
|
+ type ReviewRenderableRow,
|
|
} from "./reviewModel";
|
|
import {
|
|
clearReviewHighlightFileCache,
|
|
getCachedHighlightedReviewFile,
|
|
- highlightReviewFile,
|
|
+ streamHighlightReviewFile,
|
|
type ReviewDiffTheme,
|
|
type ReviewHighlightedFile,
|
|
type ReviewHighlightedToken,
|
|
@@ -67,9 +83,12 @@ import {
|
|
import {
|
|
changeTone,
|
|
DiffTokenText,
|
|
+ REVIEW_DIFF_LINE_HEIGHT,
|
|
REVIEW_MONO_FONT_FAMILY,
|
|
ReviewChangeBar,
|
|
} from "./reviewDiffRendering";
|
|
+import { markReviewEvent, measureReviewWork } from "./reviewPerf";
|
|
+import { useReviewHighlighterStatus } from "./ReviewHighlighterProvider";
|
|
|
|
interface PendingCommentSelection {
|
|
readonly sectionTitle: string;
|
|
@@ -87,14 +106,21 @@ interface ReviewLineActionInput {
|
|
|
|
const IOS_NAV_BAR_HEIGHT = 44;
|
|
const REVIEW_HEADER_SPACING = 0;
|
|
-const REVIEW_LINE_GUTTER_WIDTH = 62;
|
|
+const REVIEW_CHANGE_BAR_WIDTH = 5;
|
|
+const REVIEW_MIN_LINE_NUMBER_WIDTH = 27;
|
|
+const REVIEW_LINE_NUMBER_DIGIT_WIDTH_ESTIMATE = 8;
|
|
+const REVIEW_LINE_NUMBER_HORIZONTAL_PADDING = 6;
|
|
const REVIEW_CHARACTER_WIDTH_ESTIMATE = 8.4;
|
|
const REVIEW_MAX_CONTENT_WIDTH = 4_800;
|
|
-const REVIEW_INITIAL_HIGHLIGHT_FILE_COUNT = 2;
|
|
-const REVIEW_HIGHLIGHT_BACKTRACK_COUNT = 0;
|
|
-const REVIEW_HIGHLIGHT_LOOKAHEAD_COUNT = 1;
|
|
+const REVIEW_HUNK_ROW_HEIGHT = 35;
|
|
+const REVIEW_FILE_HEADER_HEIGHT = 43;
|
|
+const REVIEW_SUPPRESSED_ROW_HEIGHT = 92;
|
|
const loggedMissingReviewTokenKeys = new Set<string>();
|
|
|
|
+function waitForReviewDelay(durationMs: number): Promise<void> {
|
|
+ return new Promise((resolve) => setTimeout(resolve, durationMs));
|
|
+}
|
|
+
|
|
function isReviewDiffDebugLoggingEnabled(): boolean {
|
|
return typeof __DEV__ !== "undefined" ? __DEV__ : false;
|
|
}
|
|
@@ -113,33 +139,27 @@ function logReviewDiffDiagnostic(message: string, details?: Record<string, unkno
|
|
}
|
|
|
|
function getFileHeaderChrome(changeType: ReviewRenderableFile["changeType"]): {
|
|
- readonly rail: string;
|
|
readonly dot: string;
|
|
} {
|
|
switch (changeType) {
|
|
case "new":
|
|
return {
|
|
- rail: "bg-emerald-400",
|
|
dot: "bg-emerald-400",
|
|
};
|
|
case "deleted":
|
|
return {
|
|
- rail: "bg-rose-400",
|
|
dot: "bg-rose-400",
|
|
};
|
|
case "rename-pure":
|
|
return {
|
|
- rail: "bg-amber-400",
|
|
dot: "bg-amber-400",
|
|
};
|
|
case "rename-changed":
|
|
return {
|
|
- rail: "bg-sky-400",
|
|
dot: "bg-sky-400",
|
|
};
|
|
default:
|
|
return {
|
|
- rail: "bg-sky-400",
|
|
dot: "bg-sky-400",
|
|
};
|
|
}
|
|
@@ -159,51 +179,72 @@ function formatHeaderDiffSummary(parsedDiff: ReviewParsedDiff): {
|
|
};
|
|
}
|
|
|
|
-function computeReviewListContentWidth(
|
|
- items: ReadonlyArray<ReviewListItem>,
|
|
+function computeReviewFileContentWidth(
|
|
+ rows: ReadonlyArray<ReviewRenderableRow>,
|
|
viewportWidth: number,
|
|
+ gutterWidth: number,
|
|
): number {
|
|
let maxTextLength = 0;
|
|
|
|
- items.forEach((item) => {
|
|
- switch (item.kind) {
|
|
- case "file-header":
|
|
- maxTextLength = Math.max(
|
|
- maxTextLength,
|
|
- item.file.path.length,
|
|
- item.file.previousPath?.length ?? 0,
|
|
- );
|
|
- break;
|
|
- case "file-suppressed":
|
|
- maxTextLength = Math.max(maxTextLength, item.message.length, item.actionLabel?.length ?? 0);
|
|
- break;
|
|
- case "hunk":
|
|
- maxTextLength = Math.max(
|
|
- maxTextLength,
|
|
- item.row.header.length + (item.row.context ? item.row.context.length + 1 : 0),
|
|
- );
|
|
- break;
|
|
- case "line":
|
|
- maxTextLength = Math.max(maxTextLength, item.row.content.length);
|
|
- break;
|
|
+ rows.forEach((row) => {
|
|
+ if (row.kind === "hunk") {
|
|
+ maxTextLength = Math.max(
|
|
+ maxTextLength,
|
|
+ row.header.length + (row.context ? row.context.length + 1 : 0),
|
|
+ );
|
|
+ return;
|
|
}
|
|
+
|
|
+ maxTextLength = Math.max(maxTextLength, row.content.length);
|
|
});
|
|
|
|
return Math.max(
|
|
- viewportWidth,
|
|
+ Math.max(0, viewportWidth - gutterWidth),
|
|
Math.min(
|
|
REVIEW_MAX_CONTENT_WIDTH,
|
|
- Math.ceil(REVIEW_LINE_GUTTER_WIDTH + 48 + maxTextLength * REVIEW_CHARACTER_WIDTH_ESTIMATE),
|
|
+ Math.ceil(48 + maxTextLength * REVIEW_CHARACTER_WIDTH_ESTIMATE),
|
|
),
|
|
);
|
|
}
|
|
|
|
+function computeReviewFileGutterWidth(rows: ReadonlyArray<ReviewRenderableRow>): number {
|
|
+ let maxLineNumber = 0;
|
|
+
|
|
+ rows.forEach((row) => {
|
|
+ if (row.kind !== "line") {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ maxLineNumber = Math.max(maxLineNumber, row.oldLineNumber ?? 0, row.newLineNumber ?? 0);
|
|
+ });
|
|
+
|
|
+ const digitCount = Math.max(1, String(maxLineNumber).length);
|
|
+ const lineNumberWidth = Math.max(
|
|
+ REVIEW_MIN_LINE_NUMBER_WIDTH,
|
|
+ digitCount * REVIEW_LINE_NUMBER_DIGIT_WIDTH_ESTIMATE + REVIEW_LINE_NUMBER_HORIZONTAL_PADDING,
|
|
+ );
|
|
+
|
|
+ return REVIEW_CHANGE_BAR_WIDTH + lineNumberWidth;
|
|
+}
|
|
+
|
|
function getDefaultExpandedFileIds(
|
|
files: ReadonlyArray<ReviewRenderableFile>,
|
|
): ReadonlyArray<string> {
|
|
return files.map((file) => file.id);
|
|
}
|
|
|
|
+function getValidReviewExpandedFileIds(
|
|
+ files: ReadonlyArray<ReviewRenderableFile>,
|
|
+ cachedExpandedFileIds: ReadonlyArray<string> | undefined,
|
|
+): ReadonlyArray<string> {
|
|
+ if (cachedExpandedFileIds === undefined) {
|
|
+ return getDefaultExpandedFileIds(files);
|
|
+ }
|
|
+
|
|
+ const fileIdSet = new Set(files.map((file) => file.id));
|
|
+ return cachedExpandedFileIds.filter((id) => fileIdSet.has(id));
|
|
+}
|
|
+
|
|
function getHighlightedTokensForLine(
|
|
line: ReviewRenderableLineRow,
|
|
highlightedFile: ReviewHighlightedFile | null,
|
|
@@ -252,16 +293,13 @@ const ReviewLineRow = memo(function ReviewLineRow(props: {
|
|
delayLongPress={220}
|
|
onLongPress={props.onStartRangeSelection}
|
|
onPress={props.onComment}
|
|
- style={{ minWidth: props.viewportWidth }}
|
|
+ style={{
|
|
+ height: REVIEW_DIFF_LINE_HEIGHT,
|
|
+ width: props.viewportWidth,
|
|
+ overflow: "hidden",
|
|
+ }}
|
|
>
|
|
- <ReviewChangeBar change={props.line.change} />
|
|
- <Text
|
|
- className="w-9 py-1 pr-1 text-right text-[11px] font-t3-medium text-foreground-muted"
|
|
- style={{ fontFamily: REVIEW_MONO_FONT_FAMILY }}
|
|
- >
|
|
- {lineNumber ?? ""}
|
|
- </Text>
|
|
- <View className="min-w-0 flex-1 shrink-0 px-1 py-1">
|
|
+ <View className="min-w-0 flex-1 shrink-0 px-1 py-1" style={{ width: props.viewportWidth }}>
|
|
<DiffTokenText
|
|
tokens={props.tokens}
|
|
fallback={props.line.content}
|
|
@@ -272,62 +310,135 @@ const ReviewLineRow = memo(function ReviewLineRow(props: {
|
|
);
|
|
});
|
|
|
|
+const ReviewLineGutter = memo(function ReviewLineGutter(props: {
|
|
+ readonly change: ReviewRenderableLineRow["change"];
|
|
+ readonly gutterWidth: number;
|
|
+ readonly lineNumber: number | null;
|
|
+}) {
|
|
+ const lineNumberWidth = Math.max(0, props.gutterWidth - REVIEW_CHANGE_BAR_WIDTH);
|
|
+
|
|
+ return (
|
|
+ <View className={cn("flex-row", changeTone(props.change))} style={{ width: props.gutterWidth }}>
|
|
+ <ReviewChangeBar change={props.change} />
|
|
+ <Text
|
|
+ className="py-1 pr-1 text-right text-[11px] font-t3-medium text-foreground-muted"
|
|
+ style={[{ fontFamily: REVIEW_MONO_FONT_FAMILY }, { width: lineNumberWidth }]}
|
|
+ >
|
|
+ {props.lineNumber ?? ""}
|
|
+ </Text>
|
|
+ </View>
|
|
+ );
|
|
+});
|
|
+
|
|
+const ReviewHunkGutter = memo(function ReviewHunkGutter(props: { readonly gutterWidth: number }) {
|
|
+ return (
|
|
+ <View
|
|
+ className="border-b border-border/60 bg-sky-500/10"
|
|
+ style={{ width: props.gutterWidth }}
|
|
+ />
|
|
+ );
|
|
+});
|
|
+
|
|
const ReviewFileCard = memo(function ReviewFileCard(props: {
|
|
readonly file: ReviewRenderableFile;
|
|
readonly fileId: string;
|
|
readonly expanded: boolean;
|
|
+ readonly viewed: boolean;
|
|
readonly viewportWidth: number;
|
|
readonly onToggleFile: (fileId: string) => void;
|
|
+ readonly onToggleViewed: (fileId: string) => void;
|
|
}) {
|
|
- const chrome = getFileHeaderChrome(props.file.changeType);
|
|
+ const { expanded, file, fileId, onToggleFile, onToggleViewed, viewed, viewportWidth } = props;
|
|
+ const chrome = getFileHeaderChrome(file.changeType);
|
|
+ const iconColor = String(useThemeColor("--color-icon-muted"));
|
|
+ const handleToggleFile = useCallback(() => {
|
|
+ onToggleFile(fileId);
|
|
+ }, [fileId, onToggleFile]);
|
|
+ const handleToggleViewed = useCallback(() => {
|
|
+ onToggleViewed(fileId);
|
|
+ }, [fileId, onToggleViewed]);
|
|
|
|
return (
|
|
<View
|
|
- className="border-b border-border/70 bg-card"
|
|
- style={{
|
|
- zIndex: 1,
|
|
- width: props.viewportWidth,
|
|
- shadowColor: "#000000",
|
|
- shadowOpacity: 0.08,
|
|
- shadowRadius: 10,
|
|
- shadowOffset: { width: 0, height: 6 },
|
|
- elevation: 4,
|
|
- }}
|
|
+ className="border-b border-border bg-card"
|
|
+ style={{ height: REVIEW_FILE_HEADER_HEIGHT, overflow: "hidden", width: viewportWidth }}
|
|
>
|
|
- <Pressable className="flex-row items-center" onPress={() => props.onToggleFile(props.fileId)}>
|
|
- <View className={cn("w-1 self-stretch", chrome.rail)} />
|
|
- <View className="flex-1 flex-row items-center px-3 py-1.5">
|
|
- <View className="size-7 items-center justify-center rounded-full bg-subtle">
|
|
- <SymbolView
|
|
- name={props.expanded ? "chevron.down" : "chevron.right"}
|
|
- size={12}
|
|
- tintColor="#8a8a8a"
|
|
- type="monochrome"
|
|
- />
|
|
- </View>
|
|
- <View className="ml-2 min-w-0 flex-1 flex-row items-center gap-2">
|
|
- <View className={cn("size-2 rounded-full", chrome.dot)} />
|
|
- <View className="min-w-0 flex-1">
|
|
- <Text className="font-mono text-[13px] leading-[18px] text-foreground">
|
|
- {props.file.path}
|
|
+ <View className="min-h-[42px] flex-row items-center gap-1.5 px-2">
|
|
+ <Pressable
|
|
+ className="size-9 items-center justify-center"
|
|
+ accessibilityRole="button"
|
|
+ accessibilityLabel={expanded ? "Collapse file" : "Expand file"}
|
|
+ hitSlop={{ bottom: 8, left: 8, right: 8, top: 8 }}
|
|
+ onTouchEnd={handleToggleFile}
|
|
+ >
|
|
+ <SymbolView
|
|
+ name={expanded ? "chevron.down" : "chevron.right"}
|
|
+ size={13}
|
|
+ tintColor={iconColor}
|
|
+ type="monochrome"
|
|
+ />
|
|
+ </Pressable>
|
|
+ <Pressable
|
|
+ className="min-w-0 flex-1 flex-row items-center gap-2 py-2"
|
|
+ accessibilityRole="button"
|
|
+ accessibilityLabel={expanded ? "Collapse file" : "Expand file"}
|
|
+ onTouchEnd={handleToggleFile}
|
|
+ >
|
|
+ <View className={cn("size-2.5 rounded-full", chrome.dot)} />
|
|
+ <View className="min-w-0 flex-1">
|
|
+ <Text
|
|
+ className="font-mono text-[13px] leading-[18px] text-foreground"
|
|
+ numberOfLines={1}
|
|
+ >
|
|
+ {file.path}
|
|
+ </Text>
|
|
+ {file.previousPath && file.previousPath !== file.path ? (
|
|
+ <Text
|
|
+ className="font-mono text-[10px] leading-[14px] text-foreground-muted"
|
|
+ numberOfLines={1}
|
|
+ >
|
|
+ {file.previousPath}
|
|
</Text>
|
|
- {props.file.previousPath && props.file.previousPath !== props.file.path ? (
|
|
- <Text className="font-mono text-[10px] leading-[14px] text-foreground-muted">
|
|
- {props.file.previousPath}
|
|
- </Text>
|
|
+ ) : null}
|
|
+ </View>
|
|
+ </Pressable>
|
|
+ <View className="flex-row items-center justify-end gap-1.5">
|
|
+ <Text className="font-mono text-[12px] font-t3-bold text-rose-400">
|
|
+ -{file.deletions}
|
|
+ </Text>
|
|
+ <Text className="font-mono text-[12px] font-t3-bold text-emerald-400">
|
|
+ +{file.additions}
|
|
+ </Text>
|
|
+ <Pressable
|
|
+ className="ml-0.5 min-h-[40px] min-w-[82px] flex-row items-center justify-center gap-1.5 px-1.5"
|
|
+ accessibilityRole="checkbox"
|
|
+ accessibilityState={{ checked: viewed }}
|
|
+ accessibilityLabel={viewed ? "Mark file as unviewed" : "Mark file as viewed"}
|
|
+ hitSlop={{ bottom: 8, left: 4, right: 8, top: 8 }}
|
|
+ onTouchEnd={handleToggleViewed}
|
|
+ >
|
|
+ <View
|
|
+ className={cn(
|
|
+ "size-[18px] items-center justify-center rounded border",
|
|
+ viewed ? "border-sky-500 bg-sky-500" : "border-icon-muted",
|
|
+ )}
|
|
+ >
|
|
+ {viewed ? (
|
|
+ <SymbolView name="checkmark" size={11} tintColor="#ffffff" type="monochrome" />
|
|
) : null}
|
|
</View>
|
|
- </View>
|
|
- <View className="ml-3 flex-row items-center justify-end gap-2">
|
|
- <Text className="font-mono text-[12px] font-t3-bold text-emerald-600 dark:text-emerald-300">
|
|
- +{props.file.additions}
|
|
- </Text>
|
|
- <Text className="font-mono text-[12px] font-t3-bold text-rose-600 dark:text-rose-300">
|
|
- -{props.file.deletions}
|
|
+ <Text
|
|
+ className={cn(
|
|
+ "text-[12px] font-t3-medium",
|
|
+ viewed ? "text-foreground" : "text-foreground-muted",
|
|
+ )}
|
|
+ numberOfLines={1}
|
|
+ >
|
|
+ Viewed
|
|
</Text>
|
|
- </View>
|
|
+ </Pressable>
|
|
</View>
|
|
- </Pressable>
|
|
+ </View>
|
|
</View>
|
|
);
|
|
});
|
|
@@ -342,7 +453,11 @@ const ReviewFileSuppressedBody = memo(function ReviewFileSuppressedBody(props: {
|
|
return (
|
|
<View
|
|
className="gap-2 border-b border-border bg-card px-4 py-3"
|
|
- style={{ minWidth: props.viewportWidth }}
|
|
+ style={{
|
|
+ height: REVIEW_SUPPRESSED_ROW_HEIGHT,
|
|
+ overflow: "hidden",
|
|
+ width: props.viewportWidth,
|
|
+ }}
|
|
>
|
|
<Text className="text-[12px] leading-[18px] text-foreground-muted">{props.message}</Text>
|
|
{props.actionLabel && props.onLoadDiffFile ? (
|
|
@@ -364,10 +479,13 @@ const ReviewHunkRow = memo(function ReviewHunkRow(props: {
|
|
}) {
|
|
return (
|
|
<View
|
|
- className="border-b border-border/60 bg-sky-500/10 px-2 py-2"
|
|
- style={{ minWidth: props.viewportWidth }}
|
|
+ className="border-b border-border/60 bg-sky-500/10 py-2"
|
|
+ style={{ height: REVIEW_HUNK_ROW_HEIGHT, width: props.viewportWidth, overflow: "hidden" }}
|
|
>
|
|
- <Text className="font-mono text-[12px] leading-[18px] text-sky-700 dark:text-sky-300">
|
|
+ <Text
|
|
+ className="px-2 font-mono text-[12px] leading-[18px] text-sky-700 dark:text-sky-300"
|
|
+ numberOfLines={1}
|
|
+ >
|
|
{props.header}
|
|
{props.context ? ` ${props.context}` : ""}
|
|
</Text>
|
|
@@ -375,6 +493,61 @@ const ReviewHunkRow = memo(function ReviewHunkRow(props: {
|
|
);
|
|
});
|
|
|
|
+const ReviewCodePanRow = memo(function ReviewCodePanRow(props: {
|
|
+ readonly contentWidth: number;
|
|
+ readonly horizontalOffset: SharedValue<number>;
|
|
+ readonly gutterWidth?: number;
|
|
+ readonly viewportWidth: number;
|
|
+ readonly leftGutter?: ReactElement;
|
|
+ readonly children: ReactElement;
|
|
+}) {
|
|
+ const {
|
|
+ children,
|
|
+ contentWidth,
|
|
+ gutterWidth = 0,
|
|
+ horizontalOffset,
|
|
+ leftGutter,
|
|
+ viewportWidth,
|
|
+ } = props;
|
|
+ const dragStartOffset = useSharedValue(0);
|
|
+ const visibleContentWidth = leftGutter ? viewportWidth - gutterWidth : viewportWidth;
|
|
+ const maxOffset = Math.max(0, contentWidth - visibleContentWidth);
|
|
+
|
|
+ const panGesture = useMemo(
|
|
+ () =>
|
|
+ Gesture.Pan()
|
|
+ .activeOffsetX([-8, 8])
|
|
+ .failOffsetY([-10, 10])
|
|
+ .onBegin(() => {
|
|
+ dragStartOffset.value = horizontalOffset.value;
|
|
+ })
|
|
+ .onUpdate((event) => {
|
|
+ "worklet";
|
|
+ const nextOffset = dragStartOffset.value - event.translationX;
|
|
+ horizontalOffset.value = Math.min(maxOffset, Math.max(0, nextOffset));
|
|
+ }),
|
|
+ [dragStartOffset, horizontalOffset, maxOffset],
|
|
+ );
|
|
+
|
|
+ const contentStyle = useAnimatedStyle(
|
|
+ () => ({
|
|
+ transform: [{ translateX: -horizontalOffset.value }],
|
|
+ }),
|
|
+ [horizontalOffset],
|
|
+ );
|
|
+
|
|
+ return (
|
|
+ <GestureDetector gesture={panGesture}>
|
|
+ <View style={{ flexDirection: "row", overflow: "hidden", width: viewportWidth }}>
|
|
+ {leftGutter ?? null}
|
|
+ <View style={{ flex: 1, overflow: "hidden" }}>
|
|
+ <Animated.View style={[{ width: contentWidth }, contentStyle]}>{children}</Animated.View>
|
|
+ </View>
|
|
+ </View>
|
|
+ </GestureDetector>
|
|
+ );
|
|
+});
|
|
+
|
|
const ReviewNotice = memo(function ReviewNotice(props: { readonly notice: string }) {
|
|
return (
|
|
<View className="border-b border-amber-200 bg-amber-50 px-4 py-3 dark:border-amber-900/60 dark:bg-amber-950/40">
|
|
@@ -454,15 +627,19 @@ export function ReviewSheet() {
|
|
const [highlightedFilesById, setHighlightedFilesById] = useState<
|
|
Record<string, ReviewHighlightedFile | null>
|
|
>({});
|
|
- const [visibleFileIds, setVisibleFileIds] = useState<ReadonlyArray<string>>([]);
|
|
+ const deferredHighlightedFilesById = useDeferredValue(highlightedFilesById);
|
|
+ const [localExpandedFileIdsBySection, setLocalExpandedFileIdsBySection] = useState<
|
|
+ Record<string, ReadonlyArray<string>>
|
|
+ >({});
|
|
+ const [localViewedFileIdsBySection, setLocalViewedFileIdsBySection] = useState<
|
|
+ Record<string, ReadonlyArray<string>>
|
|
+ >({});
|
|
const activeCommentTarget = useReviewCommentTarget();
|
|
const selectedTheme = (colorScheme === "dark" ? "dark" : "light") satisfies ReviewDiffTheme;
|
|
- const highlightQueueRef = useRef<string[]>([]);
|
|
- const highlightRequestedFileIdsRef = useRef<Set<string>>(new Set());
|
|
- const highlightQueueGenerationRef = useRef(0);
|
|
- const highlightQueueActiveRef = useRef(false);
|
|
- const highlightableFilesByIdRef = useRef<ReadonlyMap<string, ReviewRenderableFile>>(new Map());
|
|
- const selectedThemeRef = useRef<ReviewDiffTheme>(selectedTheme);
|
|
+ const reviewHighlighter = useReviewHighlighterStatus();
|
|
+ const highlightRunIdRef = useRef(0);
|
|
+ const highlightableFilesRef = useRef<ReadonlyArray<ReviewRenderableFile>>([]);
|
|
+ const horizontalOffsetByFileIdRef = useRef<Map<string, SharedValue<number>>>(new Map());
|
|
const { selectedThreadCwd } = useSelectedThreadWorktree();
|
|
|
|
const cwd = selectedThreadCwd;
|
|
@@ -498,11 +675,13 @@ export function ReviewSheet() {
|
|
const topContentInset = insets.top + IOS_NAV_BAR_HEIGHT;
|
|
const parsedDiff = useMemo(
|
|
() =>
|
|
- getCachedReviewParsedDiff({
|
|
- threadKey: reviewCache.threadKey,
|
|
- sectionId: selectedSection?.id ?? null,
|
|
- diff: selectedSection?.diff,
|
|
- }),
|
|
+ measureReviewWork("parse-diff", () =>
|
|
+ getCachedReviewParsedDiff({
|
|
+ threadKey: reviewCache.threadKey,
|
|
+ sectionId: selectedSection?.id ?? null,
|
|
+ diff: selectedSection?.diff,
|
|
+ }),
|
|
+ ),
|
|
[reviewCache.threadKey, selectedSection?.diff, selectedSection?.id],
|
|
);
|
|
const headerDiffSummary = useMemo(() => formatHeaderDiffSummary(parsedDiff), [parsedDiff]);
|
|
@@ -510,14 +689,53 @@ export function ReviewSheet() {
|
|
() => countReviewCommentContexts(draftMessage),
|
|
[draftMessage],
|
|
);
|
|
+ const viewportWidth = Math.max(width, 280);
|
|
+
|
|
+ useEffect(() => {
|
|
+ if (!selectedSection?.id || parsedDiff.kind !== "files") {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ setLocalExpandedFileIdsBySection((current) => {
|
|
+ if (current[selectedSection.id] !== undefined) {
|
|
+ return current;
|
|
+ }
|
|
+
|
|
+ return {
|
|
+ ...current,
|
|
+ [selectedSection.id]: getValidReviewExpandedFileIds(
|
|
+ parsedDiff.files,
|
|
+ reviewCache.expandedFileIdsBySection[selectedSection.id],
|
|
+ ),
|
|
+ };
|
|
+ });
|
|
+
|
|
+ setLocalViewedFileIdsBySection((current) => {
|
|
+ if (current[selectedSection.id] !== undefined) {
|
|
+ return current;
|
|
+ }
|
|
+
|
|
+ return {
|
|
+ ...current,
|
|
+ [selectedSection.id]: reviewCache.viewedFileIdsBySection[selectedSection.id] ?? [],
|
|
+ };
|
|
+ });
|
|
+ }, [
|
|
+ parsedDiff,
|
|
+ reviewCache.expandedFileIdsBySection,
|
|
+ reviewCache.viewedFileIdsBySection,
|
|
+ selectedSection?.id,
|
|
+ ]);
|
|
|
|
const expandedFileIds = useMemo(
|
|
() =>
|
|
selectedSection?.id && parsedDiff.kind === "files"
|
|
- ? (reviewCache.expandedFileIdsBySection[selectedSection.id] ??
|
|
- getDefaultExpandedFileIds(parsedDiff.files))
|
|
+ ? getValidReviewExpandedFileIds(
|
|
+ parsedDiff.files,
|
|
+ localExpandedFileIdsBySection[selectedSection.id],
|
|
+ )
|
|
: [],
|
|
- [parsedDiff, reviewCache.expandedFileIdsBySection, selectedSection?.id],
|
|
+ [localExpandedFileIdsBySection, parsedDiff, selectedSection?.id],
|
|
);
|
|
const revealedLargeFileIds = useMemo(
|
|
() =>
|
|
@@ -526,47 +744,96 @@ export function ReviewSheet() {
|
|
: [],
|
|
[reviewCache.revealedLargeFileIdsBySection, selectedSection?.id],
|
|
);
|
|
+ const viewedFileIds = useMemo(
|
|
+ () => (selectedSection?.id ? (localViewedFileIdsBySection[selectedSection.id] ?? []) : []),
|
|
+ [localViewedFileIdsBySection, selectedSection?.id],
|
|
+ );
|
|
+ const viewedFileIdSet = useMemo(() => new Set(viewedFileIds), [viewedFileIds]);
|
|
const reviewListItems = useMemo(
|
|
() =>
|
|
selectedSection && parsedDiff.kind === "files"
|
|
- ? buildReviewListItems({
|
|
- files: parsedDiff.files,
|
|
- expandedFileIds,
|
|
- revealedLargeFileIds,
|
|
- })
|
|
+ ? measureReviewWork("build-list-items", () =>
|
|
+ buildReviewListItems({
|
|
+ files: parsedDiff.files,
|
|
+ expandedFileIds,
|
|
+ revealedLargeFileIds,
|
|
+ }),
|
|
+ )
|
|
: [],
|
|
[expandedFileIds, parsedDiff, revealedLargeFileIds, selectedSection],
|
|
);
|
|
- const reviewFileById = useMemo(() => {
|
|
+ const reviewLineRowsByFileId = useMemo(() => {
|
|
if (parsedDiff.kind !== "files") {
|
|
- return new Map<string, ReviewRenderableFile>();
|
|
+ return new Map<string, ReadonlyArray<ReviewRenderableLineRow>>();
|
|
}
|
|
|
|
- return new Map(parsedDiff.files.map((file) => [file.id, file] as const));
|
|
+ return measureReviewWork(
|
|
+ "index-line-rows",
|
|
+ () =>
|
|
+ new Map(
|
|
+ parsedDiff.files.map((file) => [
|
|
+ file.id,
|
|
+ file.rows.filter((row): row is ReviewRenderableLineRow => row.kind === "line"),
|
|
+ ]),
|
|
+ ),
|
|
+ );
|
|
}, [parsedDiff]);
|
|
- const reviewLineRowsByFileId = useMemo(() => {
|
|
+ const reviewContentWidthByFileId = useMemo(() => {
|
|
if (parsedDiff.kind !== "files") {
|
|
- return new Map<string, ReadonlyArray<ReviewRenderableLineRow>>();
|
|
+ return new Map<string, number>();
|
|
+ }
|
|
+
|
|
+ return measureReviewWork(
|
|
+ "measure-file-widths",
|
|
+ () =>
|
|
+ new Map(
|
|
+ parsedDiff.files.map((file) => [
|
|
+ file.id,
|
|
+ computeReviewFileContentWidth(
|
|
+ file.rows,
|
|
+ viewportWidth,
|
|
+ computeReviewFileGutterWidth(file.rows),
|
|
+ ),
|
|
+ ]),
|
|
+ ),
|
|
+ );
|
|
+ }, [parsedDiff, viewportWidth]);
|
|
+ const reviewGutterWidthByFileId = useMemo(() => {
|
|
+ if (parsedDiff.kind !== "files") {
|
|
+ return new Map<string, number>();
|
|
}
|
|
|
|
return new Map(
|
|
- parsedDiff.files.map((file) => [
|
|
- file.id,
|
|
- file.rows.filter((row): row is ReviewRenderableLineRow => row.kind === "line"),
|
|
- ]),
|
|
+ parsedDiff.files.map((file) => [file.id, computeReviewFileGutterWidth(file.rows)]),
|
|
);
|
|
}, [parsedDiff]);
|
|
- const reviewLineIndexByRowId = useMemo(() => {
|
|
- const map = new Map<string, number>();
|
|
+ const getReviewFileHorizontalOffset = useCallback((fileId: string) => {
|
|
+ let offset = horizontalOffsetByFileIdRef.current.get(fileId);
|
|
+ if (!offset) {
|
|
+ offset = makeMutable(0);
|
|
+ horizontalOffsetByFileIdRef.current.set(fileId, offset);
|
|
+ }
|
|
|
|
- reviewLineRowsByFileId.forEach((rows) => {
|
|
- rows.forEach((row, index) => {
|
|
- map.set(row.id, index);
|
|
- });
|
|
- });
|
|
+ return offset;
|
|
+ }, []);
|
|
+ useEffect(() => {
|
|
+ const knownFileIds =
|
|
+ parsedDiff.kind === "files" ? new Set(parsedDiff.files.map((file) => file.id)) : new Set();
|
|
|
|
- return map;
|
|
- }, [reviewLineRowsByFileId]);
|
|
+ horizontalOffsetByFileIdRef.current.forEach((offset, fileId) => {
|
|
+ if (!knownFileIds.has(fileId)) {
|
|
+ horizontalOffsetByFileIdRef.current.delete(fileId);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const contentWidth = reviewContentWidthByFileId.get(fileId) ?? viewportWidth;
|
|
+ const gutterWidth = reviewGutterWidthByFileId.get(fileId) ?? 0;
|
|
+ offset.value = Math.min(
|
|
+ offset.value,
|
|
+ Math.max(0, contentWidth - (viewportWidth - gutterWidth)),
|
|
+ );
|
|
+ });
|
|
+ }, [parsedDiff, reviewContentWidthByFileId, reviewGutterWidthByFileId, viewportWidth]);
|
|
const highlightableFiles = useMemo(() => {
|
|
if (parsedDiff.kind !== "files") {
|
|
return [] as ReadonlyArray<ReviewRenderableFile>;
|
|
@@ -587,59 +854,13 @@ export function ReviewSheet() {
|
|
);
|
|
});
|
|
}, [expandedFileIds, parsedDiff, revealedLargeFileIds]);
|
|
- const highlightableFileIds = useMemo(
|
|
- () => new Set(highlightableFiles.map((file) => file.id)),
|
|
+ const highlightableFilesKey = useMemo(
|
|
+ () => highlightableFiles.map((file) => `${file.id}:${file.cacheKey}`).join("\n"),
|
|
[highlightableFiles],
|
|
);
|
|
- const priorityHighlightFileIds = useMemo(() => {
|
|
- if (parsedDiff.kind !== "files" || highlightableFiles.length === 0) {
|
|
- return [] as ReadonlyArray<string>;
|
|
- }
|
|
-
|
|
- const fileIdsInPriorityOrder =
|
|
- visibleFileIds.length > 0
|
|
- ? visibleFileIds.filter((fileId) => highlightableFileIds.has(fileId))
|
|
- : parsedDiff.files
|
|
- .slice(0, REVIEW_INITIAL_HIGHLIGHT_FILE_COUNT)
|
|
- .map((file) => file.id)
|
|
- .filter((fileId) => highlightableFileIds.has(fileId));
|
|
-
|
|
- if (fileIdsInPriorityOrder.length === 0) {
|
|
- return [] as ReadonlyArray<string>;
|
|
- }
|
|
-
|
|
- const firstVisibleIndex = parsedDiff.files.findIndex(
|
|
- (file) => file.id === fileIdsInPriorityOrder[0],
|
|
- );
|
|
- const lastVisibleIndex = parsedDiff.files.findIndex(
|
|
- (file) => file.id === fileIdsInPriorityOrder[fileIdsInPriorityOrder.length - 1],
|
|
- );
|
|
-
|
|
- if (firstVisibleIndex < 0 || lastVisibleIndex < 0) {
|
|
- return fileIdsInPriorityOrder;
|
|
- }
|
|
-
|
|
- const startIndex = Math.max(0, firstVisibleIndex - REVIEW_HIGHLIGHT_BACKTRACK_COUNT);
|
|
- const endIndex = Math.min(
|
|
- parsedDiff.files.length - 1,
|
|
- lastVisibleIndex + REVIEW_HIGHLIGHT_LOOKAHEAD_COUNT,
|
|
- );
|
|
-
|
|
- const queuedIds: string[] = [];
|
|
- for (let index = startIndex; index <= endIndex; index += 1) {
|
|
- const fileId = parsedDiff.files[index]?.id;
|
|
- if (fileId && highlightableFileIds.has(fileId)) {
|
|
- queuedIds.push(fileId);
|
|
- }
|
|
- }
|
|
-
|
|
- return queuedIds;
|
|
- }, [highlightableFileIds, highlightableFiles.length, parsedDiff, visibleFileIds]);
|
|
- const viewportWidth = Math.max(width, 280);
|
|
- const reviewListContentWidth = useMemo(
|
|
- () => computeReviewListContentWidth(reviewListItems, viewportWidth),
|
|
- [reviewListItems, viewportWidth],
|
|
- );
|
|
+ useEffect(() => {
|
|
+ highlightableFilesRef.current = highlightableFiles;
|
|
+ }, [highlightableFiles]);
|
|
const loadGitDiffs = useCallback(async () => {
|
|
if (!cwd) {
|
|
return;
|
|
@@ -714,100 +935,6 @@ export function ReviewSheet() {
|
|
void loadGitDiffs();
|
|
}, [loadGitDiffs]);
|
|
|
|
- useEffect(() => {
|
|
- selectedThemeRef.current = selectedTheme;
|
|
- }, [selectedTheme]);
|
|
-
|
|
- useEffect(() => {
|
|
- highlightableFilesByIdRef.current = new Map(highlightableFiles.map((file) => [file.id, file]));
|
|
- }, [highlightableFiles]);
|
|
-
|
|
- const startHighlightQueueRunner = useCallback(function startHighlightQueueRunner() {
|
|
- if (highlightQueueActiveRef.current) {
|
|
- return;
|
|
- }
|
|
-
|
|
- const generation = highlightQueueGenerationRef.current;
|
|
- highlightQueueActiveRef.current = true;
|
|
-
|
|
- void (async () => {
|
|
- try {
|
|
- while (generation === highlightQueueGenerationRef.current) {
|
|
- const nextFileId = highlightQueueRef.current.shift();
|
|
- if (!nextFileId) {
|
|
- break;
|
|
- }
|
|
-
|
|
- const file = highlightableFilesByIdRef.current.get(nextFileId);
|
|
- if (!file) {
|
|
- continue;
|
|
- }
|
|
-
|
|
- const theme = selectedThemeRef.current;
|
|
- const cached = getCachedHighlightedReviewFile(file, theme);
|
|
- if (cached) {
|
|
- logReviewDiffDiagnostic("using cached highlighted file", {
|
|
- fileId: file.id,
|
|
- filePath: file.path,
|
|
- theme,
|
|
- });
|
|
- setHighlightedFilesById((current) =>
|
|
- current[file.id] === cached ? current : { ...current, [file.id]: cached },
|
|
- );
|
|
- continue;
|
|
- }
|
|
-
|
|
- logReviewDiffDiagnostic("requesting highlighted file", {
|
|
- fileId: file.id,
|
|
- filePath: file.path,
|
|
- theme,
|
|
- });
|
|
-
|
|
- try {
|
|
- await new Promise<void>((resolve) => {
|
|
- InteractionManager.runAfterInteractions(() => resolve());
|
|
- });
|
|
- const result = await highlightReviewFile(file, theme);
|
|
- if (generation !== highlightQueueGenerationRef.current) {
|
|
- logReviewDiffDiagnostic("discarding highlighted file after cancellation", {
|
|
- fileId: file.id,
|
|
- filePath: file.path,
|
|
- });
|
|
- return;
|
|
- }
|
|
-
|
|
- logReviewDiffDiagnostic("received highlighted file", {
|
|
- fileId: file.id,
|
|
- filePath: file.path,
|
|
- additionLines: result.additionLines.length,
|
|
- deletionLines: result.deletionLines.length,
|
|
- });
|
|
- setHighlightedFilesById((current) => {
|
|
- if (current[file.id] === result) {
|
|
- return current;
|
|
- }
|
|
- return { ...current, [file.id]: result };
|
|
- });
|
|
- } catch (error) {
|
|
- logReviewDiffDiagnostic("highlight request failed", {
|
|
- fileId: file.id,
|
|
- filePath: file.path,
|
|
- error: error instanceof Error ? error.message : String(error),
|
|
- });
|
|
- }
|
|
- }
|
|
- } finally {
|
|
- highlightQueueActiveRef.current = false;
|
|
- if (
|
|
- generation === highlightQueueGenerationRef.current &&
|
|
- highlightQueueRef.current.length > 0
|
|
- ) {
|
|
- startHighlightQueueRunner();
|
|
- }
|
|
- }
|
|
- })();
|
|
- }, []);
|
|
-
|
|
useEffect(() => {
|
|
if (reviewSections.length === 0) {
|
|
return;
|
|
@@ -854,15 +981,15 @@ export function ReviewSheet() {
|
|
}
|
|
|
|
updateReviewExpandedFileIds(reviewCache.threadKey, selectedSection.id, (existing) => {
|
|
- if (existing !== undefined) {
|
|
- const validIds = existing.filter((id) => parsedDiff.files.some((file) => file.id === id));
|
|
- if (validIds.length === existing.length) {
|
|
- return existing;
|
|
- }
|
|
- return validIds;
|
|
+ const validIds = getValidReviewExpandedFileIds(parsedDiff.files, existing);
|
|
+ if (
|
|
+ existing !== undefined &&
|
|
+ validIds.length === existing.length &&
|
|
+ validIds.every((id, index) => id === existing[index])
|
|
+ ) {
|
|
+ return existing;
|
|
}
|
|
-
|
|
- return getDefaultExpandedFileIds(parsedDiff.files);
|
|
+ return validIds;
|
|
});
|
|
}, [parsedDiff, reviewCache.threadKey, selectedSection?.id]);
|
|
|
|
@@ -887,11 +1014,7 @@ export function ReviewSheet() {
|
|
|
|
useEffect(() => {
|
|
setHighlightedFilesById({});
|
|
- setVisibleFileIds([]);
|
|
- highlightQueueGenerationRef.current += 1;
|
|
- highlightQueueRef.current = [];
|
|
- highlightRequestedFileIdsRef.current = new Set();
|
|
- highlightQueueActiveRef.current = false;
|
|
+ highlightRunIdRef.current += 1;
|
|
clearReviewHighlightFileCache();
|
|
loggedMissingReviewTokenKeys.clear();
|
|
logReviewDiffDiagnostic("reset highlighted files", {
|
|
@@ -905,15 +1028,23 @@ export function ReviewSheet() {
|
|
return;
|
|
}
|
|
|
|
+ markReviewEvent("parsed-diff-ready", {
|
|
+ sectionId: selectedSection?.id ?? null,
|
|
+ fileCount: parsedDiff.fileCount,
|
|
+ additions: parsedDiff.additions,
|
|
+ deletions: parsedDiff.deletions,
|
|
+ renderedItems: reviewListItems.length,
|
|
+ });
|
|
logReviewDiffDiagnostic("parsed diff files", {
|
|
selectedSectionId: selectedSection?.id ?? null,
|
|
fileCount: parsedDiff.fileCount,
|
|
renderableFileCount: parsedDiff.files.length,
|
|
});
|
|
- }, [parsedDiff, selectedSection?.id]);
|
|
+ }, [parsedDiff, reviewListItems.length, selectedSection?.id]);
|
|
|
|
useEffect(() => {
|
|
- if (priorityHighlightFileIds.length === 0) {
|
|
+ const files = highlightableFilesRef.current;
|
|
+ if (files.length === 0) {
|
|
logReviewDiffDiagnostic("no highlightable files", {
|
|
selectedSectionId: selectedSection?.id ?? null,
|
|
parsedDiffKind: parsedDiff.kind,
|
|
@@ -922,33 +1053,98 @@ export function ReviewSheet() {
|
|
return;
|
|
}
|
|
|
|
- const queuedFileIds: string[] = [];
|
|
- priorityHighlightFileIds.forEach((fileId) => {
|
|
- if (highlightRequestedFileIdsRef.current.has(fileId)) {
|
|
- return;
|
|
- }
|
|
-
|
|
- const file = highlightableFilesByIdRef.current.get(fileId);
|
|
- if (!file) {
|
|
- return;
|
|
- }
|
|
-
|
|
- highlightRequestedFileIdsRef.current.add(fileId);
|
|
- highlightQueueRef.current.push(fileId);
|
|
- queuedFileIds.push(fileId);
|
|
- });
|
|
-
|
|
- if (queuedFileIds.length === 0) {
|
|
+ if (reviewHighlighter.status !== "ready") {
|
|
+ logReviewDiffDiagnostic("waiting for highlighter provider", {
|
|
+ selectedSectionId: selectedSection?.id ?? null,
|
|
+ status: reviewHighlighter.status,
|
|
+ error: reviewHighlighter.error,
|
|
+ });
|
|
return;
|
|
}
|
|
|
|
- logReviewDiffDiagnostic("scheduling file highlights", {
|
|
+ const runId = highlightRunIdRef.current;
|
|
+ let cancelled = false;
|
|
+
|
|
+ logReviewDiffDiagnostic("streaming file highlights", {
|
|
selectedSectionId: selectedSection?.id ?? null,
|
|
- fileCount: queuedFileIds.length,
|
|
- fileIds: queuedFileIds,
|
|
+ fileCount: files.length,
|
|
});
|
|
- startHighlightQueueRunner();
|
|
- }, [parsedDiff.kind, priorityHighlightFileIds, selectedSection?.id, startHighlightQueueRunner]);
|
|
+
|
|
+ void (async () => {
|
|
+ for (const file of files) {
|
|
+ if (cancelled || runId !== highlightRunIdRef.current) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const cached = getCachedHighlightedReviewFile(file, selectedTheme);
|
|
+ if (cached) {
|
|
+ setHighlightedFilesById((current) =>
|
|
+ current[file.id] === cached ? current : { ...current, [file.id]: cached },
|
|
+ );
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ logReviewDiffDiagnostic("requesting highlighted file", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ theme: selectedTheme,
|
|
+ });
|
|
+
|
|
+ try {
|
|
+ const highlightStartedAt = performance.now();
|
|
+ const result = await streamHighlightReviewFile(file, selectedTheme, (progress) => {
|
|
+ if (cancelled || runId !== highlightRunIdRef.current) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (!progress.complete) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ logReviewDiffDiagnostic("received streamed highlighted file", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ highlightedLineCount: progress.highlightedLineCount,
|
|
+ durationMs: Math.round(performance.now() - highlightStartedAt),
|
|
+ });
|
|
+ });
|
|
+
|
|
+ if (cancelled || runId !== highlightRunIdRef.current) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ logReviewDiffDiagnostic("received highlighted file", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ additionLines: result.additionLines.length,
|
|
+ deletionLines: result.deletionLines.length,
|
|
+ });
|
|
+ setHighlightedFilesById((current) =>
|
|
+ current[file.id] === result ? current : { ...current, [file.id]: result },
|
|
+ );
|
|
+ } catch (error) {
|
|
+ logReviewDiffDiagnostic("highlight request failed", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ error: error instanceof Error ? error.message : String(error),
|
|
+ });
|
|
+ }
|
|
+
|
|
+ await waitForReviewDelay(0);
|
|
+ }
|
|
+ })();
|
|
+
|
|
+ return () => {
|
|
+ cancelled = true;
|
|
+ };
|
|
+ }, [
|
|
+ highlightableFilesKey,
|
|
+ parsedDiff.kind,
|
|
+ reviewHighlighter.error,
|
|
+ reviewHighlighter.status,
|
|
+ selectedSection?.id,
|
|
+ selectedTheme,
|
|
+ ]);
|
|
|
|
const refreshSelectedSection = useCallback(async () => {
|
|
if (!selectedSection) {
|
|
@@ -968,20 +1164,68 @@ export function ReviewSheet() {
|
|
|
|
const handleToggleExpandedFile = useCallback(
|
|
(fileId: string) => {
|
|
- if (!reviewCache.threadKey || !selectedSection?.id || parsedDiff.kind !== "files") {
|
|
+ if (!selectedSection?.id || parsedDiff.kind !== "files") {
|
|
return;
|
|
}
|
|
|
|
- updateReviewExpandedFileIds(reviewCache.threadKey, selectedSection.id, (existing) => {
|
|
- const currentIds = existing ?? getDefaultExpandedFileIds(parsedDiff.files);
|
|
- return currentIds.includes(fileId)
|
|
+ const sectionId = selectedSection.id;
|
|
+
|
|
+ setLocalExpandedFileIdsBySection((current) => {
|
|
+ const currentIds = getValidReviewExpandedFileIds(parsedDiff.files, current[sectionId]);
|
|
+ const nextIds = currentIds.includes(fileId)
|
|
? currentIds.filter((id) => id !== fileId)
|
|
: [...currentIds, fileId];
|
|
+
|
|
+ return {
|
|
+ ...current,
|
|
+ [sectionId]: nextIds,
|
|
+ };
|
|
});
|
|
+
|
|
+ if (reviewCache.threadKey) {
|
|
+ updateReviewExpandedFileIds(reviewCache.threadKey, sectionId, (existing) => {
|
|
+ const currentIds = getValidReviewExpandedFileIds(parsedDiff.files, existing);
|
|
+ return currentIds.includes(fileId)
|
|
+ ? currentIds.filter((id) => id !== fileId)
|
|
+ : [...currentIds, fileId];
|
|
+ });
|
|
+ }
|
|
},
|
|
[parsedDiff, reviewCache.threadKey, selectedSection?.id],
|
|
);
|
|
|
|
+ const handleToggleViewedFile = useCallback(
|
|
+ (fileId: string) => {
|
|
+ if (!selectedSection?.id) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const sectionId = selectedSection.id;
|
|
+
|
|
+ setLocalViewedFileIdsBySection((current) => {
|
|
+ const currentIds = current[sectionId] ?? [];
|
|
+ const nextIds = currentIds.includes(fileId)
|
|
+ ? currentIds.filter((id) => id !== fileId)
|
|
+ : [...currentIds, fileId];
|
|
+
|
|
+ return {
|
|
+ ...current,
|
|
+ [sectionId]: nextIds,
|
|
+ };
|
|
+ });
|
|
+
|
|
+ if (reviewCache.threadKey) {
|
|
+ updateReviewViewedFileIds(reviewCache.threadKey, sectionId, (existing) => {
|
|
+ const currentIds = existing ?? [];
|
|
+ return currentIds.includes(fileId)
|
|
+ ? currentIds.filter((id) => id !== fileId)
|
|
+ : [...currentIds, fileId];
|
|
+ });
|
|
+ }
|
|
+ },
|
|
+ [reviewCache.threadKey, selectedSection?.id],
|
|
+ );
|
|
+
|
|
const handleRevealLargeDiff = useCallback(
|
|
(fileId: string) => {
|
|
if (!reviewCache.threadKey || !selectedSection?.id) {
|
|
@@ -1080,35 +1324,6 @@ export function ReviewSheet() {
|
|
|
|
return <>{children}</>;
|
|
}, [error, parsedDiffNotice]);
|
|
- const stickyHeaderIndices = useMemo(() => {
|
|
- const itemOffset = listHeader ? 1 : 0;
|
|
-
|
|
- return reviewListItems.flatMap((item, index) =>
|
|
- item.kind === "file-header" ? [index + itemOffset] : [],
|
|
- );
|
|
- }, [listHeader, reviewListItems]);
|
|
-
|
|
- const viewabilityConfigRef = useRef({
|
|
- itemVisiblePercentThreshold: 10,
|
|
- });
|
|
- const onViewableItemsChangedRef = useRef(
|
|
- ({
|
|
- viewableItems,
|
|
- }: {
|
|
- readonly viewableItems: Array<ViewToken<ReviewListItem>>;
|
|
- readonly changed: Array<ViewToken<ReviewListItem>>;
|
|
- }) => {
|
|
- const nextVisibleFileIds = Array.from(
|
|
- new Set(
|
|
- viewableItems
|
|
- .filter((token) => token.isViewable && token.item !== undefined)
|
|
- .map((token) => token.item.fileId),
|
|
- ),
|
|
- );
|
|
-
|
|
- setVisibleFileIds(nextVisibleFileIds);
|
|
- },
|
|
- );
|
|
|
|
const renderReviewListItem = useCallback(
|
|
({ item }: ListRenderItemInfo<ReviewListItem>) => {
|
|
@@ -1116,112 +1331,142 @@ export function ReviewSheet() {
|
|
return null;
|
|
}
|
|
|
|
+ let renderedItem: ReactElement | null = null;
|
|
switch (item.kind) {
|
|
case "file-header":
|
|
- return (
|
|
+ renderedItem = (
|
|
<ReviewFileCard
|
|
file={item.file}
|
|
fileId={item.fileId}
|
|
expanded={item.expanded}
|
|
- viewportWidth={reviewListContentWidth}
|
|
+ viewed={viewedFileIdSet.has(item.fileId)}
|
|
+ viewportWidth={viewportWidth}
|
|
onToggleFile={handleToggleExpandedFile}
|
|
+ onToggleViewed={handleToggleViewedFile}
|
|
/>
|
|
);
|
|
+ break;
|
|
case "file-suppressed":
|
|
- return (
|
|
+ renderedItem = (
|
|
<ReviewFileSuppressedBody
|
|
message={item.message}
|
|
actionLabel={item.actionLabel}
|
|
fileId={item.fileId}
|
|
- viewportWidth={reviewListContentWidth}
|
|
+ viewportWidth={viewportWidth}
|
|
onLoadDiffFile={handleRevealLargeDiff}
|
|
/>
|
|
);
|
|
- case "hunk":
|
|
- return (
|
|
- <ReviewHunkRow
|
|
- header={item.row.header}
|
|
- context={item.row.context}
|
|
- viewportWidth={reviewListContentWidth}
|
|
- />
|
|
+ break;
|
|
+ case "hunk": {
|
|
+ const contentWidth = reviewContentWidthByFileId.get(item.fileId) ?? viewportWidth;
|
|
+ const gutterWidth = reviewGutterWidthByFileId.get(item.fileId) ?? 0;
|
|
+
|
|
+ renderedItem = (
|
|
+ <ReviewCodePanRow
|
|
+ key={item.id}
|
|
+ contentWidth={contentWidth}
|
|
+ gutterWidth={gutterWidth}
|
|
+ horizontalOffset={getReviewFileHorizontalOffset(item.fileId)}
|
|
+ leftGutter={<ReviewHunkGutter gutterWidth={gutterWidth} />}
|
|
+ viewportWidth={viewportWidth}
|
|
+ >
|
|
+ <ReviewHunkRow
|
|
+ header={item.row.header}
|
|
+ context={item.row.context}
|
|
+ viewportWidth={contentWidth}
|
|
+ />
|
|
+ </ReviewCodePanRow>
|
|
);
|
|
+ break;
|
|
+ }
|
|
case "line": {
|
|
- const file = reviewFileById.get(item.fileId);
|
|
- if (!file) {
|
|
- return null;
|
|
- }
|
|
-
|
|
- const fileLineRows = reviewLineRowsByFileId.get(file.id) ?? [];
|
|
- const lineIndex = reviewLineIndexByRowId.get(item.row.id);
|
|
- if (lineIndex === undefined) {
|
|
- return null;
|
|
- }
|
|
-
|
|
+ const fileLineRows = reviewLineRowsByFileId.get(item.file.id) ?? [];
|
|
const pendingSelectionForFile =
|
|
pendingCommentSelection &&
|
|
pendingCommentSelection.sectionTitle === selectedSection.title &&
|
|
- pendingCommentSelection.filePath === file.path
|
|
+ pendingCommentSelection.filePath === item.file.path
|
|
? pendingCommentSelection
|
|
: null;
|
|
const selectedTargetForFile =
|
|
activeCommentTarget &&
|
|
activeCommentTarget.sectionTitle === selectedSection.title &&
|
|
- activeCommentTarget.filePath === file.path
|
|
+ activeCommentTarget.filePath === item.file.path
|
|
? activeCommentTarget
|
|
: null;
|
|
const highlightedFile =
|
|
- highlightedFilesById[file.id] ??
|
|
- getCachedHighlightedReviewFile(file, selectedTheme) ??
|
|
+ deferredHighlightedFilesById[item.file.id] ??
|
|
+ getCachedHighlightedReviewFile(item.file, selectedTheme) ??
|
|
null;
|
|
+ const contentWidth = reviewContentWidthByFileId.get(item.fileId) ?? viewportWidth;
|
|
+ const gutterWidth = reviewGutterWidthByFileId.get(item.fileId) ?? 0;
|
|
|
|
if (highlightedFile === null) {
|
|
- const missingTokenKey = `${selectedSection.id}:${file.id}`;
|
|
+ const missingTokenKey = `${selectedSection.id}:${item.file.id}`;
|
|
if (!loggedMissingReviewTokenKeys.has(missingTokenKey)) {
|
|
loggedMissingReviewTokenKeys.add(missingTokenKey);
|
|
logReviewDiffDiagnostic("rendering file without tokens", {
|
|
sectionId: selectedSection.id,
|
|
- fileId: file.id,
|
|
- filePath: file.path,
|
|
- highlightedFileKnownInState: highlightedFilesById[file.id] !== undefined,
|
|
+ fileId: item.file.id,
|
|
+ filePath: item.file.path,
|
|
+ highlightedFileKnownInState:
|
|
+ deferredHighlightedFilesById[item.file.id] !== undefined,
|
|
});
|
|
}
|
|
}
|
|
|
|
const selectionState =
|
|
- pendingSelectionForFile?.anchorIndex === lineIndex
|
|
+ pendingSelectionForFile?.anchorIndex === item.lineIndex
|
|
? ("anchor" as const)
|
|
: selectedTargetForFile &&
|
|
- lineIndex >= selectedTargetForFile.startIndex &&
|
|
- lineIndex <= selectedTargetForFile.endIndex
|
|
+ item.lineIndex >= selectedTargetForFile.startIndex &&
|
|
+ item.lineIndex <= selectedTargetForFile.endIndex
|
|
? ("selected" as const)
|
|
: null;
|
|
|
|
- return (
|
|
- <ReviewLineRow
|
|
- line={item.row}
|
|
- tokens={getHighlightedTokensForLine(item.row, highlightedFile)}
|
|
- viewportWidth={reviewListContentWidth}
|
|
- selectionState={selectionState}
|
|
- onComment={() =>
|
|
- handlePressLine({
|
|
- sectionTitle: selectedSection.title,
|
|
- filePath: file.path,
|
|
- lines: fileLineRows,
|
|
- lineIndex,
|
|
- })
|
|
- }
|
|
- onStartRangeSelection={() =>
|
|
- handleStartRangeSelection({
|
|
- sectionTitle: selectedSection.title,
|
|
- filePath: file.path,
|
|
- lines: fileLineRows,
|
|
- lineIndex,
|
|
- })
|
|
+ renderedItem = (
|
|
+ <ReviewCodePanRow
|
|
+ key={item.id}
|
|
+ contentWidth={contentWidth}
|
|
+ gutterWidth={gutterWidth}
|
|
+ horizontalOffset={getReviewFileHorizontalOffset(item.fileId)}
|
|
+ leftGutter={
|
|
+ <ReviewLineGutter
|
|
+ change={item.row.change}
|
|
+ gutterWidth={gutterWidth}
|
|
+ lineNumber={getReviewUnifiedLineNumber(item.row)}
|
|
+ />
|
|
}
|
|
- />
|
|
+ viewportWidth={viewportWidth}
|
|
+ >
|
|
+ <ReviewLineRow
|
|
+ line={item.row}
|
|
+ tokens={getHighlightedTokensForLine(item.row, highlightedFile)}
|
|
+ viewportWidth={contentWidth}
|
|
+ selectionState={selectionState}
|
|
+ onComment={() =>
|
|
+ handlePressLine({
|
|
+ sectionTitle: selectedSection.title,
|
|
+ filePath: item.file.path,
|
|
+ lines: fileLineRows,
|
|
+ lineIndex: item.lineIndex,
|
|
+ })
|
|
+ }
|
|
+ onStartRangeSelection={() =>
|
|
+ handleStartRangeSelection({
|
|
+ sectionTitle: selectedSection.title,
|
|
+ filePath: item.file.path,
|
|
+ lines: fileLineRows,
|
|
+ lineIndex: item.lineIndex,
|
|
+ })
|
|
+ }
|
|
+ />
|
|
+ </ReviewCodePanRow>
|
|
);
|
|
+ break;
|
|
}
|
|
}
|
|
+
|
|
+ return renderedItem;
|
|
},
|
|
[
|
|
activeCommentTarget,
|
|
@@ -1229,14 +1474,17 @@ export function ReviewSheet() {
|
|
handleRevealLargeDiff,
|
|
handleStartRangeSelection,
|
|
handleToggleExpandedFile,
|
|
- highlightedFilesById,
|
|
+ handleToggleViewedFile,
|
|
+ getReviewFileHorizontalOffset,
|
|
+ deferredHighlightedFilesById,
|
|
pendingCommentSelection,
|
|
- reviewFileById,
|
|
- reviewLineIndexByRowId,
|
|
+ reviewContentWidthByFileId,
|
|
+ reviewGutterWidthByFileId,
|
|
reviewLineRowsByFileId,
|
|
- reviewListContentWidth,
|
|
selectedSection,
|
|
selectedTheme,
|
|
+ viewedFileIdSet,
|
|
+ viewportWidth,
|
|
],
|
|
);
|
|
|
|
@@ -1374,27 +1622,20 @@ export function ReviewSheet() {
|
|
<View className="flex-1 bg-sheet">
|
|
{selectedSection && parsedDiff.kind === "files" ? (
|
|
<FlatList
|
|
- style={{ flex: 1 }}
|
|
+ style={{ flex: 1, width: viewportWidth }}
|
|
contentInsetAdjustmentBehavior="never"
|
|
- contentInset={{ top: topContentInset }}
|
|
- contentOffset={{ x: 0, y: -topContentInset }}
|
|
- scrollIndicatorInsets={{ top: topContentInset }}
|
|
data={reviewListItems}
|
|
renderItem={renderReviewListItem}
|
|
keyExtractor={(item) => item.id}
|
|
+ initialNumToRender={20}
|
|
+ maxToRenderPerBatch={20}
|
|
+ updateCellsBatchingPeriod={16}
|
|
+ windowSize={5}
|
|
+ removeClippedSubviews={false}
|
|
keyboardShouldPersistTaps="handled"
|
|
ListHeaderComponent={listHeader}
|
|
- stickyHeaderIndices={stickyHeaderIndices}
|
|
- removeClippedSubviews={false}
|
|
- initialNumToRender={24}
|
|
- maxToRenderPerBatch={16}
|
|
- updateCellsBatchingPeriod={16}
|
|
- windowSize={10}
|
|
- scrollEventThrottle={16}
|
|
- onViewableItemsChanged={onViewableItemsChangedRef.current}
|
|
- viewabilityConfig={viewabilityConfigRef.current}
|
|
contentContainerStyle={{
|
|
- paddingTop: REVIEW_HEADER_SPACING,
|
|
+ paddingTop: topContentInset + REVIEW_HEADER_SPACING,
|
|
paddingBottom: Math.max(insets.bottom, 18) + 18,
|
|
}}
|
|
/>
|
|
diff --git a/apps/mobile/src/features/review/reviewDiffRendering.tsx b/apps/mobile/src/features/review/reviewDiffRendering.tsx
|
|
index d61924a62..3f2ae0160 100644
|
|
--- a/apps/mobile/src/features/review/reviewDiffRendering.tsx
|
|
+++ b/apps/mobile/src/features/review/reviewDiffRendering.tsx
|
|
@@ -11,6 +11,9 @@ export const REVIEW_MONO_FONT_FAMILY = Platform.select({
|
|
default: "monospace",
|
|
});
|
|
|
|
+export const REVIEW_DIFF_LINE_HEIGHT = 26;
|
|
+const REVIEW_DELETE_STRIPE_COUNT = REVIEW_DIFF_LINE_HEIGHT / 2;
|
|
+
|
|
export function renderVisibleWhitespace(value: string): string {
|
|
const expandedTabs = value.replace(/\t/g, " ");
|
|
return expandedTabs.replace(/^( +)/, (leading) => leading.replaceAll(" ", "\u00A0"));
|
|
@@ -37,10 +40,13 @@ function diffHighlightColor(change: ReviewRenderableLineRow["change"]): string |
|
|
export function ReviewChangeBar(props: { readonly change: ReviewRenderableLineRow["change"] }) {
|
|
if (props.change === "delete") {
|
|
return (
|
|
- <View className="w-[5px] self-stretch overflow-hidden">
|
|
- <View className="flex-1 justify-between">
|
|
- {Array.from({ length: 6 }, (_, index) => (
|
|
- <View key={index} className="h-[2px] w-[5px] bg-rose-400" />
|
|
+ <View className="w-[5px] overflow-hidden" style={{ height: REVIEW_DIFF_LINE_HEIGHT }}>
|
|
+ <View>
|
|
+ {Array.from({ length: REVIEW_DELETE_STRIPE_COUNT }, (_, index) => (
|
|
+ <View key={index}>
|
|
+ <View className="w-[5px] bg-rose-400" style={{ height: 1 }} />
|
|
+ <View style={{ height: 1 }} />
|
|
+ </View>
|
|
))}
|
|
</View>
|
|
</View>
|
|
@@ -48,7 +54,7 @@ export function ReviewChangeBar(props: { readonly change: ReviewRenderableLineRo
|
|
}
|
|
|
|
return (
|
|
- <View className="w-[5px] self-stretch overflow-hidden">
|
|
+ <View className="w-[5px] overflow-hidden" style={{ height: REVIEW_DIFF_LINE_HEIGHT }}>
|
|
<View className={cn("h-full w-[5px] flex-1", changeBarTone(props.change))} />
|
|
</View>
|
|
);
|
|
@@ -63,6 +69,7 @@ export function DiffTokenText(props: {
|
|
if (!props.tokens || props.tokens.length === 0) {
|
|
return (
|
|
<NativeText
|
|
+ numberOfLines={1}
|
|
selectable
|
|
className={cn("text-[13px] leading-[17px] font-medium text-foreground", props.className)}
|
|
style={{ fontFamily: REVIEW_MONO_FONT_FAMILY }}
|
|
@@ -74,6 +81,7 @@ export function DiffTokenText(props: {
|
|
|
|
return (
|
|
<NativeText
|
|
+ numberOfLines={1}
|
|
selectable
|
|
className={cn("text-[13px] leading-[17px] font-medium text-foreground", props.className)}
|
|
style={{ fontFamily: REVIEW_MONO_FONT_FAMILY }}
|
|
diff --git a/apps/mobile/src/features/review/reviewHighlighterEngine.test.ts b/apps/mobile/src/features/review/reviewHighlighterEngine.test.ts
|
|
index d63a7a67c..5449fc6bf 100644
|
|
--- a/apps/mobile/src/features/review/reviewHighlighterEngine.test.ts
|
|
+++ b/apps/mobile/src/features/review/reviewHighlighterEngine.test.ts
|
|
@@ -6,9 +6,9 @@ import {
|
|
} from "./reviewHighlighterEngine";
|
|
|
|
describe("resolveReviewHighlighterEnginePreference", () => {
|
|
- it("defaults invalid values to javascript", () => {
|
|
- expect(resolveReviewHighlighterEnginePreference(undefined)).toBe("javascript");
|
|
- expect(resolveReviewHighlighterEnginePreference("bogus")).toBe("javascript");
|
|
+ it("defaults invalid values to native", () => {
|
|
+ expect(resolveReviewHighlighterEnginePreference(undefined)).toBe("native");
|
|
+ expect(resolveReviewHighlighterEnginePreference("bogus")).toBe("native");
|
|
});
|
|
|
|
it("accepts supported values", () => {
|
|
diff --git a/apps/mobile/src/features/review/reviewHighlighterEngine.ts b/apps/mobile/src/features/review/reviewHighlighterEngine.ts
|
|
index 5ef9f055a..428768537 100644
|
|
--- a/apps/mobile/src/features/review/reviewHighlighterEngine.ts
|
|
+++ b/apps/mobile/src/features/review/reviewHighlighterEngine.ts
|
|
@@ -11,7 +11,7 @@ export function resolveReviewHighlighterEnginePreference(
|
|
case "native":
|
|
return "native";
|
|
default:
|
|
- return "javascript";
|
|
+ return "native";
|
|
}
|
|
}
|
|
|
|
diff --git a/apps/mobile/src/features/review/reviewModel.test.ts b/apps/mobile/src/features/review/reviewModel.test.ts
|
|
index a24a99ceb..69a6e7261 100644
|
|
--- a/apps/mobile/src/features/review/reviewModel.test.ts
|
|
+++ b/apps/mobile/src/features/review/reviewModel.test.ts
|
|
@@ -238,7 +238,7 @@ describe("buildReviewParsedDiff", () => {
|
|
});
|
|
});
|
|
|
|
- it("flattens expanded files into virtualizable review items", () => {
|
|
+ it("flattens expanded file rows into virtualized review items", () => {
|
|
const file = makeRenderableFile({
|
|
path: "apps/mobile/src/a.ts",
|
|
rows: [
|
|
@@ -270,8 +270,19 @@ describe("buildReviewParsedDiff", () => {
|
|
|
|
expect(items).toEqual([
|
|
expect.objectContaining({ kind: "file-header", fileId: file.id, expanded: true }),
|
|
- expect.objectContaining({ kind: "hunk", fileId: file.id, row: file.rows[0] }),
|
|
- expect.objectContaining({ kind: "line", fileId: file.id, row: file.rows[1] }),
|
|
+ expect.objectContaining({
|
|
+ kind: "hunk",
|
|
+ fileId: file.id,
|
|
+ file,
|
|
+ row: file.rows[0],
|
|
+ }),
|
|
+ expect.objectContaining({
|
|
+ kind: "line",
|
|
+ fileId: file.id,
|
|
+ file,
|
|
+ row: file.rows[1],
|
|
+ lineIndex: 0,
|
|
+ }),
|
|
]);
|
|
});
|
|
|
|
diff --git a/apps/mobile/src/features/review/reviewModel.ts b/apps/mobile/src/features/review/reviewModel.ts
|
|
index 27e6d7ae4..1cfbf358c 100644
|
|
--- a/apps/mobile/src/features/review/reviewModel.ts
|
|
+++ b/apps/mobile/src/features/review/reviewModel.ts
|
|
@@ -72,6 +72,7 @@ export interface ReviewHunkListItem {
|
|
readonly kind: "hunk";
|
|
readonly id: string;
|
|
readonly fileId: string;
|
|
+ readonly file: ReviewRenderableFile;
|
|
readonly row: ReviewRenderableHunkRow;
|
|
}
|
|
|
|
@@ -79,7 +80,9 @@ export interface ReviewLineListItem {
|
|
readonly kind: "line";
|
|
readonly id: string;
|
|
readonly fileId: string;
|
|
+ readonly file: ReviewRenderableFile;
|
|
readonly row: ReviewRenderableLineRow;
|
|
+ readonly lineIndex: number;
|
|
}
|
|
|
|
export type ReviewListItem =
|
|
@@ -308,7 +311,7 @@ export function getReviewFilePreviewState(file: ReviewRenderableFile): ReviewFil
|
|
}
|
|
|
|
// The flattened review list item model is inspired by pierre/diffs' iterator-first
|
|
-// virtualization architecture, adapted here for React Native and LegendList.
|
|
+// virtualization architecture, adapted here for React Native virtualization.
|
|
// Original project: https://github.com/pingdotgg/pierre/tree/main/packages/diffs
|
|
// Reference files:
|
|
// - src/utils/iterateOverDiff.ts
|
|
@@ -350,12 +353,14 @@ export function buildReviewListItems(input: {
|
|
}
|
|
}
|
|
|
|
- file.rows.forEach((row) => {
|
|
+ let lineIndex = 0;
|
|
+ file.rows.forEach((row, rowIndex) => {
|
|
if (row.kind === "hunk") {
|
|
items.push({
|
|
kind: "hunk",
|
|
- id: row.id,
|
|
+ id: `${file.id}:row:${rowIndex}:${row.id}`,
|
|
fileId: file.id,
|
|
+ file,
|
|
row,
|
|
});
|
|
return;
|
|
@@ -363,10 +368,13 @@ export function buildReviewListItems(input: {
|
|
|
|
items.push({
|
|
kind: "line",
|
|
- id: row.id,
|
|
+ id: `${file.id}:row:${rowIndex}:${row.id}`,
|
|
fileId: file.id,
|
|
+ file,
|
|
row,
|
|
+ lineIndex,
|
|
});
|
|
+ lineIndex += 1;
|
|
});
|
|
});
|
|
|
|
diff --git a/apps/mobile/src/features/review/reviewState.ts b/apps/mobile/src/features/review/reviewState.ts
|
|
index 06134db7d..c116f93fe 100644
|
|
--- a/apps/mobile/src/features/review/reviewState.ts
|
|
+++ b/apps/mobile/src/features/review/reviewState.ts
|
|
@@ -64,6 +64,13 @@ const reviewRevealedLargeFileIdsByThreadKeyAtom = Atom.family((threadKey: string
|
|
),
|
|
);
|
|
|
|
+const reviewViewedFileIdsByThreadKeyAtom = Atom.family((threadKey: string) =>
|
|
+ Atom.make(EMPTY_REVIEW_SECTION_FILE_IDS).pipe(
|
|
+ Atom.keepAlive,
|
|
+ Atom.withLabel(`mobile:review:viewed-file-ids:${threadKey}`),
|
|
+ ),
|
|
+);
|
|
+
|
|
const reviewParsedDiffBySectionCacheKeyAtom = Atom.family((cacheKey: string) =>
|
|
Atom.make<{ readonly diff: string | null; readonly parsed: ReviewParsedDiff } | null>(null).pipe(
|
|
Atom.keepAlive,
|
|
@@ -110,6 +117,9 @@ export function useReviewCacheForThread(input: {
|
|
? reviewRevealedLargeFileIdsByThreadKeyAtom(threadKey)
|
|
: EMPTY_REVIEW_SECTION_FILE_IDS_ATOM,
|
|
);
|
|
+ const viewedFileIdsBySection = useAtomValue(
|
|
+ threadKey ? reviewViewedFileIdsByThreadKeyAtom(threadKey) : EMPTY_REVIEW_SECTION_FILE_IDS_ATOM,
|
|
+ );
|
|
|
|
return {
|
|
threadKey,
|
|
@@ -118,6 +128,7 @@ export function useReviewCacheForThread(input: {
|
|
selectedSectionId,
|
|
expandedFileIdsBySection,
|
|
revealedLargeFileIdsBySection,
|
|
+ viewedFileIdsBySection,
|
|
};
|
|
}
|
|
|
|
@@ -169,6 +180,20 @@ export function updateReviewRevealedLargeFileIds(
|
|
});
|
|
}
|
|
|
|
+export function updateReviewViewedFileIds(
|
|
+ threadKey: string,
|
|
+ sectionId: string,
|
|
+ update: (current: ReadonlyArray<string> | undefined) => ReadonlyArray<string> | undefined,
|
|
+): void {
|
|
+ const atom = reviewViewedFileIdsByThreadKeyAtom(threadKey);
|
|
+ const current = appAtomRegistry.get(atom);
|
|
+ const nextValue = update(current[sectionId]);
|
|
+ appAtomRegistry.set(atom, {
|
|
+ ...current,
|
|
+ [sectionId]: nextValue,
|
|
+ });
|
|
+}
|
|
+
|
|
export function getCachedReviewParsedDiff(input: {
|
|
readonly threadKey: string | null;
|
|
readonly sectionId: string | null;
|
|
diff --git a/apps/mobile/src/features/review/shikiReviewHighlighter.test.ts b/apps/mobile/src/features/review/shikiReviewHighlighter.test.ts
|
|
index 05b5c9213..402d00668 100644
|
|
--- a/apps/mobile/src/features/review/shikiReviewHighlighter.test.ts
|
|
+++ b/apps/mobile/src/features/review/shikiReviewHighlighter.test.ts
|
|
@@ -24,7 +24,7 @@ function makeRenderableFile(
|
|
describe("highlightReviewFile", () => {
|
|
it("preserves one highlighted token row per diff line even without trailing newlines", async () => {
|
|
const file = makeRenderableFile({
|
|
- path: "apps/mobile/src/example.test.ts",
|
|
+ path: "apps/mobile/src/example.txt",
|
|
additionLines: [
|
|
'const items = ["a"];',
|
|
'expect(items).toEqual(["a"]);',
|
|
@@ -36,15 +36,23 @@ describe("highlightReviewFile", () => {
|
|
const highlighted = await highlightReviewFile(file, "light");
|
|
|
|
expect(highlighted.additionLines).toHaveLength(file.additionLines.length);
|
|
- expect(highlighted.additionLines[0]?.some((token) => token.content === "const")).toBe(true);
|
|
- expect(highlighted.additionLines[1]?.some((token) => token.content === "expect")).toBe(true);
|
|
- expect(highlighted.additionLines[2]?.some((token) => token.content === "const")).toBe(true);
|
|
- expect(highlighted.additionLines[3]?.some((token) => token.content === "expect")).toBe(true);
|
|
+ expect(highlighted.additionLines[0]?.map((token) => token.content).join("")).toBe(
|
|
+ file.additionLines[0],
|
|
+ );
|
|
+ expect(highlighted.additionLines[1]?.map((token) => token.content).join("")).toBe(
|
|
+ file.additionLines[1],
|
|
+ );
|
|
+ expect(highlighted.additionLines[2]?.map((token) => token.content).join("")).toBe(
|
|
+ file.additionLines[2],
|
|
+ );
|
|
+ expect(highlighted.additionLines[3]?.map((token) => token.content).join("")).toBe(
|
|
+ file.additionLines[3],
|
|
+ );
|
|
});
|
|
|
|
it("adds word-alt diff emphasis for paired deletion and addition lines", async () => {
|
|
const file = makeRenderableFile({
|
|
- path: "apps/mobile/src/example-inline-diff.test.ts",
|
|
+ path: "apps/mobile/src/example-inline-diff.txt",
|
|
additionLines: ["const after = 2;"],
|
|
deletionLines: ["const before = 1;"],
|
|
rows: [
|
|
@@ -82,7 +90,7 @@ describe("highlightReviewFile", () => {
|
|
it("falls back to plain tokens for very long lines", async () => {
|
|
const longLine = `const value = "${"a".repeat(1_100)}";`;
|
|
const file = makeRenderableFile({
|
|
- path: "apps/mobile/src/example-long-line.ts",
|
|
+ path: "apps/mobile/src/example-long-line.txt",
|
|
additionLines: [longLine],
|
|
rows: [
|
|
{
|
|
diff --git a/apps/mobile/src/features/review/shikiReviewHighlighter.ts b/apps/mobile/src/features/review/shikiReviewHighlighter.ts
|
|
index f7a5c4125..eb6bf6973 100644
|
|
--- a/apps/mobile/src/features/review/shikiReviewHighlighter.ts
|
|
+++ b/apps/mobile/src/features/review/shikiReviewHighlighter.ts
|
|
@@ -1,5 +1,14 @@
|
|
import { createHighlighterCore, type HighlighterCore } from "@shikijs/core";
|
|
import { createJavaScriptRegexEngine } from "@shikijs/engine-javascript";
|
|
+import bashLanguage from "@shikijs/langs/bash";
|
|
+import javascriptLanguage from "@shikijs/langs/javascript";
|
|
+import jsonLanguage from "@shikijs/langs/json";
|
|
+import jsxLanguage from "@shikijs/langs/jsx";
|
|
+import tsxLanguage from "@shikijs/langs/tsx";
|
|
+import typescriptLanguage from "@shikijs/langs/typescript";
|
|
+import yamlLanguage from "@shikijs/langs/yaml";
|
|
+import githubDarkDefault from "@shikijs/themes/github-dark-default";
|
|
+import githubLightDefault from "@shikijs/themes/github-light-default";
|
|
import { getFiletypeFromFileName } from "@pierre/diffs/utils";
|
|
|
|
import {
|
|
@@ -11,6 +20,7 @@ import type { ReviewRenderableFile, ReviewRenderableLineRow } from "./reviewMode
|
|
import { applyDiffRangesToTokens, computeWordAltDiffRanges } from "./reviewWordDiffs";
|
|
|
|
export type ReviewDiffTheme = "light" | "dark";
|
|
+export type { ReviewHighlighterEngine };
|
|
|
|
export interface ReviewHighlightedToken {
|
|
content: string;
|
|
@@ -24,12 +34,19 @@ export interface ReviewHighlightedFile {
|
|
readonly deletionLines: ReadonlyArray<ReadonlyArray<ReviewHighlightedToken>>;
|
|
}
|
|
|
|
+export interface ReviewHighlightFileProgress {
|
|
+ readonly highlightedFile: ReviewHighlightedFile;
|
|
+ readonly complete: boolean;
|
|
+ readonly highlightedLineCount: number;
|
|
+}
|
|
+
|
|
const SHIKI_THEME_NAME_BY_SCHEME = {
|
|
light: "github-light-default",
|
|
dark: "github-dark-default",
|
|
} as const;
|
|
const REVIEW_HIGHLIGHTER_ENGINE_ENV_VALUE =
|
|
- process.env.EXPO_PUBLIC_REVIEW_HIGHLIGHTER_ENGINE ?? "javascript";
|
|
+ process.env.EXPO_PUBLIC_REVIEW_HIGHLIGHTER_ENGINE ??
|
|
+ (process.env.NODE_ENV === "test" ? "javascript" : "native");
|
|
const REVIEW_HIGHLIGHTER_ENGINE_PREFERENCE = resolveReviewHighlighterEnginePreference(
|
|
REVIEW_HIGHLIGHTER_ENGINE_ENV_VALUE,
|
|
);
|
|
@@ -38,12 +55,30 @@ const REVIEW_HIGHLIGHTER_DISABLE_RESULT_CACHE = resolveReviewHighlighterBooleanF
|
|
false,
|
|
);
|
|
const REVIEW_HIGHLIGHT_RESULT_CACHE_LIMIT = 8;
|
|
-const REVIEW_HIGHLIGHT_CHUNK_LINE_THRESHOLD = 40;
|
|
-const REVIEW_HIGHLIGHT_CHUNK_SIZE = 20;
|
|
+const REVIEW_HIGHLIGHT_CHUNK_LINE_THRESHOLD = 8;
|
|
+const REVIEW_HIGHLIGHT_CHUNK_SIZE = 200;
|
|
const REVIEW_TOKENIZE_MAX_LINE_LENGTH = 1_000;
|
|
const highlightCache = new Map<string, Promise<ReviewHighlightedFile>>();
|
|
const resolvedHighlightCache = new Map<string, ReviewHighlightedFile>();
|
|
-const loadedLanguages = new Set<string>(["text"]);
|
|
+const REVIEW_INITIAL_LANGUAGE_MODULES = [
|
|
+ bashLanguage,
|
|
+ javascriptLanguage,
|
|
+ jsonLanguage,
|
|
+ jsxLanguage,
|
|
+ tsxLanguage,
|
|
+ typescriptLanguage,
|
|
+ yamlLanguage,
|
|
+] satisfies Parameters<typeof createHighlighterCore>[0]["langs"];
|
|
+const loadedLanguages = new Set<string>([
|
|
+ "text",
|
|
+ "bash",
|
|
+ "javascript",
|
|
+ "json",
|
|
+ "jsx",
|
|
+ "tsx",
|
|
+ "typescript",
|
|
+ "yaml",
|
|
+]);
|
|
const languageLoadingPromises = new Map<string, Promise<boolean>>();
|
|
const languageImports: Partial<Record<string, () => Promise<unknown>>> = {
|
|
javascript: () => import("@shikijs/langs/javascript"),
|
|
@@ -215,21 +250,13 @@ function joinPatchLines(lines: ReadonlyArray<string>): string {
|
|
|
|
function waitForNextFrame(): Promise<void> {
|
|
return new Promise((resolve) => {
|
|
- if (typeof requestAnimationFrame === "function") {
|
|
- requestAnimationFrame(() => resolve());
|
|
- return;
|
|
- }
|
|
-
|
|
setTimeout(resolve, 0);
|
|
});
|
|
}
|
|
|
|
async function getHighlighter(): Promise<HighlighterCore> {
|
|
if (!highlighterPromise) {
|
|
- const configuredHighlighterPromise = Promise.all([
|
|
- import("@shikijs/themes/github-light-default"),
|
|
- import("@shikijs/themes/github-dark-default"),
|
|
- ]).then(async ([lightThemeModule, darkThemeModule]) => {
|
|
+ const configuredHighlighterPromise = (async () => {
|
|
let nativeEngineAvailable = false;
|
|
|
|
logReviewHighlighterDiagnostic("initializing", {
|
|
@@ -238,12 +265,11 @@ async function getHighlighter(): Promise<HighlighterCore> {
|
|
resultCacheDisabled: REVIEW_HIGHLIGHTER_DISABLE_RESULT_CACHE,
|
|
});
|
|
|
|
- const themes = [lightThemeModule.default, darkThemeModule.default];
|
|
+ const themes = [githubLightDefault, githubDarkDefault];
|
|
|
|
if (REVIEW_HIGHLIGHTER_ENGINE_PREFERENCE !== "javascript") {
|
|
try {
|
|
const nativeEngineModule = await import("react-native-shiki-engine");
|
|
- logReviewHighlighterDiagnostic("imported react-native-shiki-engine");
|
|
nativeEngineAvailable = nativeEngineModule.isNativeEngineAvailable();
|
|
logReviewHighlighterDiagnostic("checked native engine availability", {
|
|
nativeEngineAvailable,
|
|
@@ -253,7 +279,7 @@ async function getHighlighter(): Promise<HighlighterCore> {
|
|
logReviewHighlighterDiagnostic("creating native regex engine");
|
|
const highlighter = await createHighlighterCore({
|
|
themes,
|
|
- langs: [],
|
|
+ langs: REVIEW_INITIAL_LANGUAGE_MODULES,
|
|
engine: nativeEngineModule.createNativeEngine(),
|
|
});
|
|
logReviewHighlighterDiagnostic("using native engine");
|
|
@@ -281,7 +307,7 @@ async function getHighlighter(): Promise<HighlighterCore> {
|
|
);
|
|
const highlighter = await createHighlighterCore({
|
|
themes,
|
|
- langs: [],
|
|
+ langs: REVIEW_INITIAL_LANGUAGE_MODULES,
|
|
engine: createJavaScriptRegexEngine(),
|
|
});
|
|
logReviewHighlighterDiagnostic("using javascript engine", {
|
|
@@ -291,7 +317,7 @@ async function getHighlighter(): Promise<HighlighterCore> {
|
|
highlighter,
|
|
engine,
|
|
};
|
|
- });
|
|
+ })();
|
|
|
|
highlighterPromise = configuredHighlighterPromise
|
|
.then((result) => result.highlighter)
|
|
@@ -316,11 +342,52 @@ export async function getActiveReviewHighlighterEngine(): Promise<ReviewHighligh
|
|
return activeHighlighterEnginePromise ?? Promise.resolve("javascript");
|
|
}
|
|
|
|
+export async function prepareReviewHighlighter(): Promise<void> {
|
|
+ await getHighlighter();
|
|
+}
|
|
+
|
|
+export async function prepareReviewHighlighterLanguages(
|
|
+ languages: ReadonlyArray<string>,
|
|
+): Promise<void> {
|
|
+ const highlighter = await getHighlighter();
|
|
+ await Promise.all(
|
|
+ languages.map(async (language) => {
|
|
+ const candidate = resolveLanguageAlias(language);
|
|
+ if (candidate === "text" || !(candidate in languageImports)) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ await loadSingleLanguage(highlighter, candidate);
|
|
+ }),
|
|
+ );
|
|
+}
|
|
+
|
|
function resolveLanguageAlias(language: string): string {
|
|
const normalized = language.toLowerCase();
|
|
return languageAliases[normalized] ?? normalized;
|
|
}
|
|
|
|
+function resolveLoadedLanguageFromPath(
|
|
+ path: string,
|
|
+ languageHint: string | null = null,
|
|
+): string | null {
|
|
+ const detectedLanguage = languageHint ?? getFiletypeFromFileName(path);
|
|
+ if (!detectedLanguage) {
|
|
+ return "text";
|
|
+ }
|
|
+
|
|
+ const candidate = resolveLanguageAlias(detectedLanguage);
|
|
+ if (candidate === "text" || candidate === "ansi") {
|
|
+ return "text";
|
|
+ }
|
|
+
|
|
+ if (!(candidate in languageImports)) {
|
|
+ return "text";
|
|
+ }
|
|
+
|
|
+ return loadedLanguages.has(candidate) ? candidate : null;
|
|
+}
|
|
+
|
|
async function loadSingleLanguage(
|
|
highlighter: HighlighterCore,
|
|
language: string,
|
|
@@ -360,6 +427,11 @@ async function resolveLanguageFromPath(
|
|
path: string,
|
|
languageHint: string | null = null,
|
|
): Promise<string> {
|
|
+ const loadedLanguage = resolveLoadedLanguageFromPath(path, languageHint);
|
|
+ if (loadedLanguage) {
|
|
+ return loadedLanguage;
|
|
+ }
|
|
+
|
|
const detectedLanguage = languageHint ?? getFiletypeFromFileName(path);
|
|
if (!detectedLanguage) {
|
|
return "text";
|
|
@@ -374,8 +446,12 @@ async function resolveLanguageFromPath(
|
|
return "text";
|
|
}
|
|
|
|
+ if (loadedLanguages.has(candidate)) {
|
|
+ return candidate;
|
|
+ }
|
|
+
|
|
const highlighter = await getHighlighter();
|
|
- const loaded = await loadSingleLanguage(highlighter, resolveLanguageAlias(candidate));
|
|
+ const loaded = await loadSingleLanguage(highlighter, candidate);
|
|
if (!loaded) {
|
|
return "text";
|
|
}
|
|
@@ -384,7 +460,10 @@ async function resolveLanguageFromPath(
|
|
}
|
|
|
|
async function resolveLanguage(file: ReviewRenderableFile): Promise<string> {
|
|
- return resolveLanguageFromPath(file.path, file.languageHint);
|
|
+ return (
|
|
+ resolveLoadedLanguageFromPath(file.path, file.languageHint) ??
|
|
+ (await resolveLanguageFromPath(file.path, file.languageHint))
|
|
+ );
|
|
}
|
|
|
|
function normalizeHighlightedLines(
|
|
@@ -399,6 +478,18 @@ function normalizeHighlightedLines(
|
|
);
|
|
}
|
|
|
|
+function makePlainHighlightedLines(
|
|
+ lines: ReadonlyArray<string>,
|
|
+): ReadonlyArray<ReadonlyArray<ReviewHighlightedToken>> {
|
|
+ return lines.map((line) => [
|
|
+ {
|
|
+ content: stripTrailingNewline(line),
|
|
+ color: null,
|
|
+ fontStyle: null,
|
|
+ },
|
|
+ ]);
|
|
+}
|
|
+
|
|
function applyWordAltDiffHighlightsToFile(
|
|
file: ReviewRenderableFile,
|
|
highlighted: ReviewHighlightedFile,
|
|
@@ -594,6 +685,67 @@ async function highlightLines(
|
|
return highlightedLines;
|
|
}
|
|
|
|
+async function highlightPatchLinesInChunks(input: {
|
|
+ readonly lines: ReadonlyArray<string>;
|
|
+ readonly language: string;
|
|
+ readonly theme: string;
|
|
+ readonly onChunk: (
|
|
+ startIndex: number,
|
|
+ tokens: ReadonlyArray<ReadonlyArray<ReviewHighlightedToken>>,
|
|
+ ) => void;
|
|
+}): Promise<ReadonlyArray<ReadonlyArray<ReviewHighlightedToken>>> {
|
|
+ if (input.lines.length === 0) {
|
|
+ return [];
|
|
+ }
|
|
+
|
|
+ const highlighter = await getHighlighter();
|
|
+ const highlightedLines: Array<ReadonlyArray<ReviewHighlightedToken>> = [];
|
|
+
|
|
+ for (
|
|
+ let startIndex = 0;
|
|
+ startIndex < input.lines.length;
|
|
+ startIndex += REVIEW_HIGHLIGHT_CHUNK_SIZE
|
|
+ ) {
|
|
+ const lineChunk = input.lines.slice(startIndex, startIndex + REVIEW_HIGHLIGHT_CHUNK_SIZE);
|
|
+ const chunkTokens: Array<ReadonlyArray<ReviewHighlightedToken>> = [];
|
|
+ const tokenizableLines: string[] = [];
|
|
+ const tokenizableIndexes: number[] = [];
|
|
+
|
|
+ lineChunk.forEach((line, index) => {
|
|
+ const strippedLine = stripTrailingNewline(line);
|
|
+ if (strippedLine.length > REVIEW_TOKENIZE_MAX_LINE_LENGTH) {
|
|
+ chunkTokens[index] = [{ content: strippedLine, color: null, fontStyle: null }];
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ tokenizableIndexes.push(index);
|
|
+ tokenizableLines.push(strippedLine);
|
|
+ });
|
|
+
|
|
+ if (tokenizableLines.length > 0) {
|
|
+ const tokenLines = highlighter.codeToTokensBase(tokenizableLines.join("\n"), {
|
|
+ lang: input.language,
|
|
+ theme: input.theme,
|
|
+ });
|
|
+ const normalizedTokenLines = normalizeHighlightedLines(tokenLines);
|
|
+
|
|
+ tokenizableIndexes.forEach((chunkIndex, tokenIndex) => {
|
|
+ chunkTokens[chunkIndex] = normalizedTokenLines[tokenIndex] ?? [];
|
|
+ });
|
|
+ }
|
|
+
|
|
+ const completedChunk = lineChunk.map((_, index) => chunkTokens[index] ?? []);
|
|
+ highlightedLines.push(...completedChunk);
|
|
+ input.onChunk(startIndex, completedChunk);
|
|
+
|
|
+ if (startIndex + REVIEW_HIGHLIGHT_CHUNK_SIZE < input.lines.length) {
|
|
+ await waitForNextFrame();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return highlightedLines;
|
|
+}
|
|
+
|
|
function getHighlightCacheKey(file: ReviewRenderableFile, theme: ReviewDiffTheme): string {
|
|
return `${SHIKI_THEME_NAME_BY_SCHEME[theme]}:${file.cacheKey}`;
|
|
}
|
|
@@ -667,7 +819,28 @@ export async function highlightReviewFile(
|
|
deletionLineCount: file.deletionLines.length,
|
|
rowCount: file.rows.length,
|
|
});
|
|
- const language = await resolveLanguage(file);
|
|
+ const loadedLanguage = resolveLoadedLanguageFromPath(file.path, file.languageHint);
|
|
+ const language = loadedLanguage ?? (await resolveLanguage(file));
|
|
+ if (language === "text") {
|
|
+ const highlighted = applyWordAltDiffHighlightsToFile(file, {
|
|
+ additionLines: makePlainHighlightedLines(file.additionLines),
|
|
+ deletionLines: makePlainHighlightedLines(file.deletionLines),
|
|
+ });
|
|
+ if (!REVIEW_HIGHLIGHTER_DISABLE_RESULT_CACHE) {
|
|
+ storeResolvedHighlightedFile(cacheKey, highlighted);
|
|
+ }
|
|
+ logReviewHighlighterDiagnostic("file highlight complete", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ theme,
|
|
+ language,
|
|
+ highlightedAdditionLineCount: highlighted.additionLines.length,
|
|
+ highlightedDeletionLineCount: highlighted.deletionLines.length,
|
|
+ durationMs: Date.now() - startedAt,
|
|
+ });
|
|
+ return highlighted;
|
|
+ }
|
|
+
|
|
const additionLines = await highlightLines(
|
|
joinPatchLines(file.additionLines),
|
|
language,
|
|
@@ -707,6 +880,113 @@ export async function highlightReviewFile(
|
|
});
|
|
}
|
|
|
|
+export async function streamHighlightReviewFile(
|
|
+ file: ReviewRenderableFile,
|
|
+ theme: ReviewDiffTheme,
|
|
+ onProgress: (progress: ReviewHighlightFileProgress) => void,
|
|
+): Promise<ReviewHighlightedFile> {
|
|
+ const shikiTheme = SHIKI_THEME_NAME_BY_SCHEME[theme];
|
|
+ const cacheKey = getHighlightCacheKey(file, theme);
|
|
+ if (!REVIEW_HIGHLIGHTER_DISABLE_RESULT_CACHE) {
|
|
+ const resolved = resolvedHighlightCache.get(cacheKey);
|
|
+ if (resolved) {
|
|
+ onProgress({
|
|
+ highlightedFile: resolved,
|
|
+ complete: true,
|
|
+ highlightedLineCount: resolved.additionLines.length + resolved.deletionLines.length,
|
|
+ });
|
|
+ return resolved;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ const startedAt = Date.now();
|
|
+ logReviewHighlighterDiagnostic("file stream highlight start", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ theme,
|
|
+ additionLineCount: file.additionLines.length,
|
|
+ deletionLineCount: file.deletionLines.length,
|
|
+ rowCount: file.rows.length,
|
|
+ });
|
|
+
|
|
+ const loadedLanguage = resolveLoadedLanguageFromPath(file.path, file.languageHint);
|
|
+ const language = loadedLanguage ?? (await resolveLanguage(file));
|
|
+ if (language === "text") {
|
|
+ const highlighted = applyWordAltDiffHighlightsToFile(file, {
|
|
+ additionLines: makePlainHighlightedLines(file.additionLines),
|
|
+ deletionLines: makePlainHighlightedLines(file.deletionLines),
|
|
+ });
|
|
+ if (!REVIEW_HIGHLIGHTER_DISABLE_RESULT_CACHE) {
|
|
+ storeResolvedHighlightedFile(cacheKey, highlighted);
|
|
+ }
|
|
+ onProgress({
|
|
+ highlightedFile: highlighted,
|
|
+ complete: true,
|
|
+ highlightedLineCount: highlighted.additionLines.length + highlighted.deletionLines.length,
|
|
+ });
|
|
+ logReviewHighlighterDiagnostic("file stream highlight complete", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ theme,
|
|
+ language,
|
|
+ highlightedAdditionLineCount: highlighted.additionLines.length,
|
|
+ highlightedDeletionLineCount: highlighted.deletionLines.length,
|
|
+ highlightedLineCount: highlighted.additionLines.length + highlighted.deletionLines.length,
|
|
+ durationMs: Date.now() - startedAt,
|
|
+ });
|
|
+ return highlighted;
|
|
+ }
|
|
+
|
|
+ const additionLines: Array<ReadonlyArray<ReviewHighlightedToken>> = [];
|
|
+ const deletionLines: Array<ReadonlyArray<ReviewHighlightedToken>> = [];
|
|
+ let highlightedLineCount = 0;
|
|
+
|
|
+ await highlightPatchLinesInChunks({
|
|
+ lines: file.additionLines,
|
|
+ language,
|
|
+ theme: shikiTheme,
|
|
+ onChunk: (startIndex, tokens) => {
|
|
+ tokens.forEach((lineTokens, index) => {
|
|
+ additionLines[startIndex + index] = lineTokens;
|
|
+ });
|
|
+ highlightedLineCount += tokens.length;
|
|
+ },
|
|
+ });
|
|
+ await waitForNextFrame();
|
|
+ await highlightPatchLinesInChunks({
|
|
+ lines: file.deletionLines,
|
|
+ language,
|
|
+ theme: shikiTheme,
|
|
+ onChunk: (startIndex, tokens) => {
|
|
+ tokens.forEach((lineTokens, index) => {
|
|
+ deletionLines[startIndex + index] = lineTokens;
|
|
+ });
|
|
+ highlightedLineCount += tokens.length;
|
|
+ },
|
|
+ });
|
|
+
|
|
+ const highlighted = applyWordAltDiffHighlightsToFile(file, { additionLines, deletionLines });
|
|
+ if (!REVIEW_HIGHLIGHTER_DISABLE_RESULT_CACHE) {
|
|
+ storeResolvedHighlightedFile(cacheKey, highlighted);
|
|
+ }
|
|
+ onProgress({
|
|
+ highlightedFile: highlighted,
|
|
+ complete: true,
|
|
+ highlightedLineCount,
|
|
+ });
|
|
+ logReviewHighlighterDiagnostic("file stream highlight complete", {
|
|
+ fileId: file.id,
|
|
+ filePath: file.path,
|
|
+ theme,
|
|
+ language,
|
|
+ highlightedAdditionLineCount: highlighted.additionLines.length,
|
|
+ highlightedDeletionLineCount: highlighted.deletionLines.length,
|
|
+ highlightedLineCount,
|
|
+ durationMs: Date.now() - startedAt,
|
|
+ });
|
|
+ return highlighted;
|
|
+}
|
|
+
|
|
export async function highlightReviewSelectedLines(input: {
|
|
readonly filePath: string;
|
|
readonly lines: ReadonlyArray<ReviewRenderableLineRow>;
|
|
@@ -717,7 +997,9 @@ export async function highlightReviewSelectedLines(input: {
|
|
return {};
|
|
}
|
|
|
|
- const language = await resolveLanguageFromPath(input.filePath, input.languageHint ?? null);
|
|
+ const loadedLanguage = resolveLoadedLanguageFromPath(input.filePath, input.languageHint ?? null);
|
|
+ const language =
|
|
+ loadedLanguage ?? (await resolveLanguageFromPath(input.filePath, input.languageHint ?? null));
|
|
const shikiTheme = SHIKI_THEME_NAME_BY_SCHEME[input.theme];
|
|
const additionLikeLines = input.lines
|
|
.filter((line) => line.change !== "delete")
|
|
diff --git a/apps/mobile/docs/review-profiling.md b/apps/mobile/docs/review-profiling.md
|
|
new file mode 100644
|
|
index 000000000..6977eaf6e
|
|
--- /dev/null
|
|
+++ b/apps/mobile/docs/review-profiling.md
|
|
@@ -0,0 +1,80 @@
|
|
+# Review Screen Profiling
|
|
+
|
|
+Use this when the mobile review screen is slow or crashes while opening large diffs.
|
|
+
|
|
+## Preferred Capture: React Native DevTools Performance
|
|
+
|
|
+This app is on Expo SDK 55 / React Native 0.83 with Hermes, so the best first trace is the React Native DevTools Performance recording. The review screen also emits `t3.review.*` user timing marks in development builds so the trace can show parse, list-building, row indexing, and syntax-highlighting work.
|
|
+
|
|
+1. Start the development client:
|
|
+
|
|
+ ```sh
|
|
+ cd apps/mobile
|
|
+ bun dev:client
|
|
+ ```
|
|
+
|
|
+2. Open the app in the iOS Simulator or on the device using the development client.
|
|
+
|
|
+3. In the terminal running Expo, press `j` to open React Native DevTools.
|
|
+
|
|
+4. In DevTools, open the `Performance` panel.
|
|
+
|
|
+5. Start recording.
|
|
+
|
|
+6. In the app, reproduce the slow path:
|
|
+ - Navigate to the thread.
|
|
+ - Open `Files Changed`.
|
|
+ - Select the largest review source.
|
|
+ - Expand a few large files or tap `Load diff`.
|
|
+ - Scroll until the app is clearly slow or until just before it crashes.
|
|
+
|
|
+7. Stop recording.
|
|
+
|
|
+8. Export or save the Performance recording as a JSON trace.
|
|
+
|
|
+Send that exported trace file here. Also include the device/simulator model and whether it was iOS or Android.
|
|
+
|
|
+## Android Fallback: Hermes Sampling Profile
|
|
+
|
|
+Use this if the app crashes before DevTools can export a trace, or if we need deeper JavaScript stack samples.
|
|
+
|
|
+1. Run Android dev client:
|
|
+
|
|
+ ```sh
|
|
+ cd apps/mobile
|
|
+ bun android:dev
|
|
+ bun dev:client
|
|
+ ```
|
|
+
|
|
+2. Open the developer menu from the Expo terminal with `d`.
|
|
+
|
|
+3. Select `Enable Sampling Profiler`.
|
|
+
|
|
+4. Reproduce the review-screen slowdown.
|
|
+
|
|
+5. Open the developer menu again with `d`.
|
|
+
|
|
+6. Select `Disable Sampling Profiler`.
|
|
+
|
|
+7. Pull and convert the Hermes profile:
|
|
+
|
|
+ ```sh
|
|
+ cd apps/mobile
|
|
+ mkdir -p profiles/review
|
|
+ bunx react-native profile-hermes profiles/review
|
|
+ ```
|
|
+
|
|
+8. Send the generated Chrome trace/profile file from `apps/mobile/profiles/review`.
|
|
+
|
|
+For the development app variant, the Android package is `com.t3tools.t3code.dev`.
|
|
+
|
|
+## What To Capture
|
|
+
|
|
+For the first trace, do not optimize the repro. We want the slowest realistic case:
|
|
+
|
|
+- A diff with many files and large line counts.
|
|
+- At least one `Load diff` action for a suppressed large diff.
|
|
+- One vertical scroll pass after the content appears.
|
|
+- One horizontal scroll of a long file, if that is part of the slowdown.
|
|
+
|
|
+If the app crashes, note the last visible action before the crash and attach device logs if available.
|
|
diff --git a/apps/mobile/src/app/debug/syntax-highlight.tsx b/apps/mobile/src/app/debug/syntax-highlight.tsx
|
|
new file mode 100644
|
|
index 000000000..c2a36d126
|
|
--- /dev/null
|
|
+++ b/apps/mobile/src/app/debug/syntax-highlight.tsx
|
|
@@ -0,0 +1,423 @@
|
|
+import { createHighlighterCore, type HighlighterCore } from "@shikijs/core";
|
|
+import { createJavaScriptRegexEngine } from "@shikijs/engine-javascript";
|
|
+import typescriptLanguage from "@shikijs/langs/typescript";
|
|
+import githubDarkDefault from "@shikijs/themes/github-dark-default";
|
|
+import githubLightDefault from "@shikijs/themes/github-light-default";
|
|
+import Stack from "expo-router/stack";
|
|
+import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
+import {
|
|
+ FlatList,
|
|
+ Pressable,
|
|
+ Text as NativeText,
|
|
+ type ListRenderItemInfo,
|
|
+ useColorScheme,
|
|
+ useWindowDimensions,
|
|
+ View,
|
|
+} from "react-native";
|
|
+import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
+
|
|
+import { AppText as Text } from "../../components/AppText";
|
|
+import { cn } from "../../lib/cn";
|
|
+import { useThemeColor } from "../../lib/useThemeColor";
|
|
+
|
|
+type DebugHighlightEngine = "native" | "javascript";
|
|
+
|
|
+type DebugToken = {
|
|
+ readonly content: string;
|
|
+ readonly color: string | null;
|
|
+ readonly fontStyle: number | null;
|
|
+};
|
|
+
|
|
+type DebugLine = {
|
|
+ readonly id: string;
|
|
+ readonly chunkIndex: number;
|
|
+ readonly indexInChunk: number;
|
|
+ readonly lineNumber: number;
|
|
+ readonly content: string;
|
|
+};
|
|
+
|
|
+type DebugHighlighterHandle = {
|
|
+ readonly engine: DebugHighlightEngine;
|
|
+ readonly tokenize: (
|
|
+ code: string,
|
|
+ options: { readonly lang: string; readonly theme: string },
|
|
+ ) => ReadonlyArray<ReadonlyArray<DebugToken>>;
|
|
+};
|
|
+
|
|
+const DEBUG_LINE_COUNT = 10_000;
|
|
+const DEBUG_CHUNK_SIZE = 500;
|
|
+const DEBUG_LINE_HEIGHT = 24;
|
|
+const DEBUG_GUTTER_WIDTH = 58;
|
|
+const DEBUG_CONTENT_WIDTH = 3_200;
|
|
+const DEBUG_MONO_FONT_FAMILY = "BerkeleyMono-Regular";
|
|
+const DEBUG_THEME_NAME_BY_SCHEME = {
|
|
+ dark: "github-dark-default",
|
|
+ light: "github-light-default",
|
|
+} as const;
|
|
+
|
|
+let nativeHighlighterPromise: Promise<DebugHighlighterHandle> | null = null;
|
|
+let javascriptHighlighterPromise: Promise<DebugHighlighterHandle> | null = null;
|
|
+
|
|
+function waitForNextFrame(): Promise<void> {
|
|
+ return new Promise((resolve) => setTimeout(resolve, 0));
|
|
+}
|
|
+
|
|
+function normalizeTokens(
|
|
+ tokenLines: ReadonlyArray<ReadonlyArray<{ content: string; color?: string; fontStyle?: number }>>,
|
|
+): ReadonlyArray<ReadonlyArray<DebugToken>> {
|
|
+ return tokenLines.map((line) =>
|
|
+ line.map((token) => ({
|
|
+ content: token.content,
|
|
+ color: token.color ?? null,
|
|
+ fontStyle: token.fontStyle ?? null,
|
|
+ })),
|
|
+ );
|
|
+}
|
|
+
|
|
+function makeDebugCodeLine(index: number): string {
|
|
+ const label = `generatedLine${String(index).padStart(5, "0")}`;
|
|
+ switch (index % 8) {
|
|
+ case 0:
|
|
+ return `export async function ${label}(input: { value: number; name: string }) {`;
|
|
+ case 1:
|
|
+ return ` const normalized = input.name.trim().toLowerCase();`;
|
|
+ case 2:
|
|
+ return ` const result = await Promise.resolve({ id: "${label}", score: input.value * ${index + 1} });`;
|
|
+ case 3:
|
|
+ return ` if (result.score > ${index * 17}) return normalized + ":" + result.id;`;
|
|
+ case 4:
|
|
+ return ` return [normalized, String(result.score), "${"x".repeat((index % 24) + 8)}"].join("/");`;
|
|
+ case 5:
|
|
+ return `}`;
|
|
+ case 6:
|
|
+ return `type ${label}Record = Readonly<{ id: string; createdAt: Date; tags: string[] }>;`;
|
|
+ default:
|
|
+ return `const ${label}: ${label}Record = { id: "${label}", createdAt: new Date(), tags: ["debug", "highlight"] };`;
|
|
+ }
|
|
+}
|
|
+
|
|
+function makeDebugLines(): ReadonlyArray<DebugLine> {
|
|
+ return Array.from({ length: DEBUG_LINE_COUNT }, (_, index) => ({
|
|
+ id: `line:${index + 1}`,
|
|
+ chunkIndex: Math.floor(index / DEBUG_CHUNK_SIZE),
|
|
+ indexInChunk: index % DEBUG_CHUNK_SIZE,
|
|
+ lineNumber: index + 1,
|
|
+ content: makeDebugCodeLine(index + 1),
|
|
+ }));
|
|
+}
|
|
+
|
|
+async function createNativeDebugHighlighter(): Promise<DebugHighlighterHandle> {
|
|
+ const nativeEngineModule = await import("react-native-shiki-engine");
|
|
+ if (!nativeEngineModule.isNativeEngineAvailable()) {
|
|
+ throw new Error("Native Shiki engine is not available in this build.");
|
|
+ }
|
|
+
|
|
+ const highlighter = await createHighlighterCore({
|
|
+ langs: [typescriptLanguage],
|
|
+ themes: [githubLightDefault, githubDarkDefault],
|
|
+ engine: nativeEngineModule.createNativeEngine(),
|
|
+ });
|
|
+
|
|
+ return {
|
|
+ engine: "native",
|
|
+ tokenize: (code, options) => normalizeTokens(highlighter.codeToTokensBase(code, options)),
|
|
+ };
|
|
+}
|
|
+
|
|
+async function createJavascriptDebugHighlighter(): Promise<DebugHighlighterHandle> {
|
|
+ const highlighter: HighlighterCore = await createHighlighterCore({
|
|
+ langs: [typescriptLanguage],
|
|
+ themes: [githubLightDefault, githubDarkDefault],
|
|
+ engine: createJavaScriptRegexEngine(),
|
|
+ });
|
|
+
|
|
+ return {
|
|
+ engine: "javascript",
|
|
+ tokenize: (code, options) => normalizeTokens(highlighter.codeToTokensBase(code, options)),
|
|
+ };
|
|
+}
|
|
+
|
|
+async function getDebugHighlighter(engine: DebugHighlightEngine): Promise<DebugHighlighterHandle> {
|
|
+ if (engine === "native") {
|
|
+ nativeHighlighterPromise ??= createNativeDebugHighlighter();
|
|
+ return nativeHighlighterPromise;
|
|
+ }
|
|
+
|
|
+ javascriptHighlighterPromise ??= createJavascriptDebugHighlighter();
|
|
+ return javascriptHighlighterPromise;
|
|
+}
|
|
+
|
|
+const TokenText = memo(function TokenText(props: {
|
|
+ readonly content: string;
|
|
+ readonly tokens: ReadonlyArray<DebugToken> | null;
|
|
+}) {
|
|
+ if (!props.tokens) {
|
|
+ return (
|
|
+ <NativeText
|
|
+ numberOfLines={1}
|
|
+ className="text-[13px] font-medium leading-[18px] text-foreground"
|
|
+ style={{ fontFamily: DEBUG_MONO_FONT_FAMILY }}
|
|
+ >
|
|
+ {props.content}
|
|
+ </NativeText>
|
|
+ );
|
|
+ }
|
|
+
|
|
+ let tokenOffset = 0;
|
|
+
|
|
+ return (
|
|
+ <NativeText
|
|
+ numberOfLines={1}
|
|
+ className="text-[13px] font-medium leading-[18px] text-foreground"
|
|
+ style={{ fontFamily: DEBUG_MONO_FONT_FAMILY }}
|
|
+ >
|
|
+ {props.tokens.map((token) => {
|
|
+ const tokenKey = `${tokenOffset}:${token.content.length}:${token.color ?? ""}:${token.fontStyle ?? ""}`;
|
|
+ tokenOffset += token.content.length;
|
|
+ const fontWeight =
|
|
+ token.fontStyle !== null && (token.fontStyle & 2) === 2
|
|
+ ? ("700" as const)
|
|
+ : ("500" as const);
|
|
+ const fontStyle =
|
|
+ token.fontStyle !== null && (token.fontStyle & 1) === 1
|
|
+ ? ("italic" as const)
|
|
+ : ("normal" as const);
|
|
+
|
|
+ return (
|
|
+ <NativeText
|
|
+ key={tokenKey}
|
|
+ style={{
|
|
+ color: token.color ?? undefined,
|
|
+ fontFamily: DEBUG_MONO_FONT_FAMILY,
|
|
+ fontStyle,
|
|
+ fontWeight,
|
|
+ }}
|
|
+ >
|
|
+ {token.content}
|
|
+ </NativeText>
|
|
+ );
|
|
+ })}
|
|
+ </NativeText>
|
|
+ );
|
|
+});
|
|
+
|
|
+const DebugCodeLineRow = memo(function DebugCodeLineRow(props: {
|
|
+ readonly item: DebugLine;
|
|
+ readonly tokens: ReadonlyArray<DebugToken> | null;
|
|
+ readonly width: number;
|
|
+}) {
|
|
+ return (
|
|
+ <View className="flex-row bg-card" style={{ height: DEBUG_LINE_HEIGHT, width: props.width }}>
|
|
+ <View className="items-end justify-center pr-2" style={{ width: DEBUG_GUTTER_WIDTH }}>
|
|
+ <Text className="font-mono text-[11px] text-foreground-muted">{props.item.lineNumber}</Text>
|
|
+ </View>
|
|
+ <View className="justify-center px-2" style={{ width: DEBUG_CONTENT_WIDTH }}>
|
|
+ <TokenText content={props.item.content} tokens={props.tokens} />
|
|
+ </View>
|
|
+ </View>
|
|
+ );
|
|
+});
|
|
+
|
|
+function EngineToggle(props: {
|
|
+ readonly engine: DebugHighlightEngine;
|
|
+ readonly onChangeEngine: (engine: DebugHighlightEngine) => void;
|
|
+}) {
|
|
+ return (
|
|
+ <View className="flex-row rounded-full bg-subtle p-1">
|
|
+ {(["native", "javascript"] as const).map((engine) => {
|
|
+ const selected = props.engine === engine;
|
|
+ return (
|
|
+ <Pressable
|
|
+ key={engine}
|
|
+ className={cn("rounded-full px-3 py-1.5", selected && "bg-card")}
|
|
+ onPress={() => props.onChangeEngine(engine)}
|
|
+ >
|
|
+ <Text
|
|
+ className={cn(
|
|
+ "text-[12px] font-t3-bold",
|
|
+ selected ? "text-foreground" : "text-foreground-muted",
|
|
+ )}
|
|
+ >
|
|
+ {engine === "javascript" ? "JS" : "Native"}
|
|
+ </Text>
|
|
+ </Pressable>
|
|
+ );
|
|
+ })}
|
|
+ </View>
|
|
+ );
|
|
+}
|
|
+
|
|
+export default function SyntaxHighlightDebugRoute() {
|
|
+ const insets = useSafeAreaInsets();
|
|
+ const { width } = useWindowDimensions();
|
|
+ const colorScheme = useColorScheme();
|
|
+ const headerIcon = String(useThemeColor("--color-icon"));
|
|
+ const themeName = DEBUG_THEME_NAME_BY_SCHEME[colorScheme === "dark" ? "dark" : "light"];
|
|
+ const [engine, setEngine] = useState<DebugHighlightEngine>("native");
|
|
+ const [tokensByChunkIndex, setTokensByChunkIndex] = useState<
|
|
+ Record<number, ReadonlyArray<ReadonlyArray<DebugToken>>>
|
|
+ >({});
|
|
+ const [status, setStatus] = useState("Idle");
|
|
+ const renderStartRef = useRef<number | null>(null);
|
|
+ const generationRef = useRef(0);
|
|
+ const lines = useMemo(() => makeDebugLines(), []);
|
|
+
|
|
+ useEffect(() => {
|
|
+ const generation = generationRef.current + 1;
|
|
+ generationRef.current = generation;
|
|
+ renderStartRef.current = performance.now();
|
|
+ setTokensByChunkIndex({});
|
|
+ setStatus("Initializing highlighter");
|
|
+
|
|
+ void (async () => {
|
|
+ try {
|
|
+ const highlighterStartedAt = performance.now();
|
|
+ const highlighter = await getDebugHighlighter(engine);
|
|
+ if (generation !== generationRef.current) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ console.log("[debug-syntax-scratch] initialize", {
|
|
+ durationMs: Math.round(performance.now() - highlighterStartedAt),
|
|
+ engine: highlighter.engine,
|
|
+ });
|
|
+
|
|
+ let firstChunkMs: number | null = null;
|
|
+ const totalStartedAt = performance.now();
|
|
+ setStatus(`Streaming ${DEBUG_LINE_COUNT.toLocaleString()} lines`);
|
|
+
|
|
+ for (let startIndex = 0; startIndex < lines.length; startIndex += DEBUG_CHUNK_SIZE) {
|
|
+ if (generation !== generationRef.current) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const chunkLines = lines.slice(startIndex, startIndex + DEBUG_CHUNK_SIZE);
|
|
+ const chunkCode = chunkLines.map((line) => line.content).join("\n");
|
|
+ const chunkStartedAt = performance.now();
|
|
+ const chunkTokens = highlighter.tokenize(chunkCode, {
|
|
+ lang: "typescript",
|
|
+ theme: themeName,
|
|
+ });
|
|
+ const chunkMs = performance.now() - chunkStartedAt;
|
|
+
|
|
+ if (firstChunkMs === null) {
|
|
+ firstChunkMs = performance.now() - totalStartedAt;
|
|
+ console.log("[debug-syntax-scratch] first chunk", {
|
|
+ chunkSize: DEBUG_CHUNK_SIZE,
|
|
+ durationMs: Math.round(firstChunkMs),
|
|
+ engine,
|
|
+ lineCount: chunkTokens.length,
|
|
+ });
|
|
+ }
|
|
+
|
|
+ setTokensByChunkIndex((current) => ({
|
|
+ ...current,
|
|
+ [startIndex / DEBUG_CHUNK_SIZE]: chunkTokens,
|
|
+ }));
|
|
+ setStatus(
|
|
+ `Streamed ${Math.min(startIndex + DEBUG_CHUNK_SIZE, lines.length).toLocaleString()} / ${lines.length.toLocaleString()} lines`,
|
|
+ );
|
|
+
|
|
+ console.log("[debug-syntax-scratch] chunk", {
|
|
+ chunkIndex: startIndex / DEBUG_CHUNK_SIZE,
|
|
+ chunkMs: Math.round(chunkMs),
|
|
+ engine,
|
|
+ lineCount: chunkTokens.length,
|
|
+ });
|
|
+
|
|
+ await waitForNextFrame();
|
|
+ }
|
|
+
|
|
+ console.log("[debug-syntax-scratch] complete", {
|
|
+ durationMs: Math.round(performance.now() - totalStartedAt),
|
|
+ engine,
|
|
+ lineCount: lines.length,
|
|
+ });
|
|
+ setStatus(`Complete with ${engine}`);
|
|
+ } catch (error) {
|
|
+ console.error("[debug-syntax-scratch] failed", {
|
|
+ engine,
|
|
+ message: error instanceof Error ? error.message : String(error),
|
|
+ });
|
|
+ setStatus(error instanceof Error ? error.message : "Highlight failed");
|
|
+ }
|
|
+ })();
|
|
+ }, [engine, lines, themeName]);
|
|
+
|
|
+ useEffect(() => {
|
|
+ if (renderStartRef.current === null) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const startedAt = renderStartRef.current;
|
|
+ renderStartRef.current = null;
|
|
+ const commitMs = performance.now() - startedAt;
|
|
+ requestAnimationFrame(() => {
|
|
+ console.log("[debug-syntax-scratch] render", {
|
|
+ commitMs: Math.round(commitMs),
|
|
+ paintMs: Math.round(performance.now() - startedAt),
|
|
+ });
|
|
+ });
|
|
+ });
|
|
+
|
|
+ const renderItem = useCallback(
|
|
+ ({ item }: ListRenderItemInfo<DebugLine>) => (
|
|
+ <DebugCodeLineRow
|
|
+ item={item}
|
|
+ tokens={tokensByChunkIndex[item.chunkIndex]?.[item.indexInChunk] ?? null}
|
|
+ width={width}
|
|
+ />
|
|
+ ),
|
|
+ [tokensByChunkIndex, width],
|
|
+ );
|
|
+
|
|
+ return (
|
|
+ <View className="flex-1 bg-sheet">
|
|
+ <Stack.Screen
|
|
+ options={{
|
|
+ headerShown: true,
|
|
+ headerTitle: "Syntax Scratch",
|
|
+ headerTintColor: headerIcon,
|
|
+ headerTransparent: true,
|
|
+ headerShadowVisible: false,
|
|
+ }}
|
|
+ />
|
|
+
|
|
+ <View
|
|
+ className="border-b border-border bg-sheet px-3 pb-3"
|
|
+ style={{ paddingTop: insets.top + 56 }}
|
|
+ >
|
|
+ <View className="flex-row items-center justify-between gap-3">
|
|
+ <View className="min-w-0 flex-1">
|
|
+ <Text className="text-[13px] font-t3-bold text-foreground">
|
|
+ Shiki streaming baseline
|
|
+ </Text>
|
|
+ <Text className="text-[11px] text-foreground-muted" numberOfLines={1}>
|
|
+ {status}
|
|
+ </Text>
|
|
+ </View>
|
|
+ <EngineToggle engine={engine} onChangeEngine={setEngine} />
|
|
+ </View>
|
|
+ </View>
|
|
+
|
|
+ <FlatList
|
|
+ style={{ flex: 1, width }}
|
|
+ data={lines}
|
|
+ renderItem={renderItem}
|
|
+ keyExtractor={(item) => item.id}
|
|
+ getItemLayout={(_, index) => ({
|
|
+ length: DEBUG_LINE_HEIGHT,
|
|
+ offset: DEBUG_LINE_HEIGHT * index,
|
|
+ index,
|
|
+ })}
|
|
+ initialNumToRender={40}
|
|
+ maxToRenderPerBatch={80}
|
|
+ updateCellsBatchingPeriod={16}
|
|
+ windowSize={9}
|
|
+ removeClippedSubviews
|
|
+ keyboardShouldPersistTaps="handled"
|
|
+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
|
|
+ />
|
|
+ </View>
|
|
+ );
|
|
+}
|
|
diff --git a/apps/mobile/src/features/review/ReviewHighlighterProvider.tsx b/apps/mobile/src/features/review/ReviewHighlighterProvider.tsx
|
|
new file mode 100644
|
|
index 000000000..095201929
|
|
--- /dev/null
|
|
+++ b/apps/mobile/src/features/review/ReviewHighlighterProvider.tsx
|
|
@@ -0,0 +1,110 @@
|
|
+import { createContext, type ReactNode, useContext, useEffect, useMemo, useState } from "react";
|
|
+
|
|
+import {
|
|
+ getActiveReviewHighlighterEngine,
|
|
+ prepareReviewHighlighter,
|
|
+ prepareReviewHighlighterLanguages,
|
|
+ type ReviewHighlighterEngine,
|
|
+} from "./shikiReviewHighlighter";
|
|
+
|
|
+type ReviewHighlighterStatus = "idle" | "initializing" | "ready" | "error";
|
|
+
|
|
+interface ReviewHighlighterContextValue {
|
|
+ readonly engine: ReviewHighlighterEngine | null;
|
|
+ readonly error: string | null;
|
|
+ readonly status: ReviewHighlighterStatus;
|
|
+}
|
|
+
|
|
+const ReviewHighlighterContext = createContext<ReviewHighlighterContextValue>({
|
|
+ engine: null,
|
|
+ error: null,
|
|
+ status: "idle",
|
|
+});
|
|
+
|
|
+const REVIEW_INITIAL_LANGUAGES = [
|
|
+ "typescript",
|
|
+ "tsx",
|
|
+ "javascript",
|
|
+ "jsx",
|
|
+ "json",
|
|
+ "yaml",
|
|
+ "bash",
|
|
+] as const;
|
|
+
|
|
+function isReviewHighlighterProviderDebugLoggingEnabled(): boolean {
|
|
+ return typeof __DEV__ !== "undefined" ? __DEV__ : false;
|
|
+}
|
|
+
|
|
+function logReviewHighlighterProviderDiagnostic(
|
|
+ message: string,
|
|
+ details?: Record<string, unknown>,
|
|
+): void {
|
|
+ if (!isReviewHighlighterProviderDebugLoggingEnabled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (details) {
|
|
+ console.log(`[review-highlighter-provider] ${message}`, details);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ console.log(`[review-highlighter-provider] ${message}`);
|
|
+}
|
|
+
|
|
+export function ReviewHighlighterProvider(props: { readonly children: ReactNode }) {
|
|
+ const [value, setValue] = useState<ReviewHighlighterContextValue>({
|
|
+ engine: null,
|
|
+ error: null,
|
|
+ status: "idle",
|
|
+ });
|
|
+
|
|
+ useEffect(() => {
|
|
+ let cancelled = false;
|
|
+
|
|
+ setValue({ engine: null, error: null, status: "initializing" });
|
|
+
|
|
+ void (async () => {
|
|
+ const startedAt = performance.now();
|
|
+ try {
|
|
+ await prepareReviewHighlighter();
|
|
+ await prepareReviewHighlighterLanguages(REVIEW_INITIAL_LANGUAGES);
|
|
+ const engine = await getActiveReviewHighlighterEngine();
|
|
+
|
|
+ if (cancelled) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const durationMs = Math.round(performance.now() - startedAt);
|
|
+ logReviewHighlighterProviderDiagnostic("initialized", {
|
|
+ durationMs,
|
|
+ engine,
|
|
+ });
|
|
+ setValue({ engine, error: null, status: "ready" });
|
|
+ } catch (error) {
|
|
+ if (cancelled) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const message = error instanceof Error ? error.message : String(error);
|
|
+ logReviewHighlighterProviderDiagnostic("initialization failed", { error: message });
|
|
+ setValue({ engine: null, error: message, status: "error" });
|
|
+ }
|
|
+ })();
|
|
+
|
|
+ return () => {
|
|
+ cancelled = true;
|
|
+ };
|
|
+ }, []);
|
|
+
|
|
+ const contextValue = useMemo(() => value, [value]);
|
|
+
|
|
+ return (
|
|
+ <ReviewHighlighterContext.Provider value={contextValue}>
|
|
+ {props.children}
|
|
+ </ReviewHighlighterContext.Provider>
|
|
+ );
|
|
+}
|
|
+
|
|
+export function useReviewHighlighterStatus(): ReviewHighlighterContextValue {
|
|
+ return useContext(ReviewHighlighterContext);
|
|
+}
|
|
diff --git a/apps/mobile/src/features/review/reviewPerf.ts b/apps/mobile/src/features/review/reviewPerf.ts
|
|
new file mode 100644
|
|
index 000000000..2ae1095b1
|
|
--- /dev/null
|
|
+++ b/apps/mobile/src/features/review/reviewPerf.ts
|
|
@@ -0,0 +1,83 @@
|
|
+interface ReviewPerformanceLike {
|
|
+ readonly now?: () => number;
|
|
+ readonly mark?: (name: string) => void;
|
|
+ readonly measure?: (name: string, startMark: string, endMark: string) => void;
|
|
+ readonly clearMarks?: (name?: string) => void;
|
|
+ readonly clearMeasures?: (name?: string) => void;
|
|
+}
|
|
+
|
|
+const REVIEW_PERF_PREFIX = "t3.review";
|
|
+let reviewPerfSequence = 0;
|
|
+
|
|
+function getPerformance(): ReviewPerformanceLike | null {
|
|
+ const candidate = (globalThis as { readonly performance?: ReviewPerformanceLike }).performance;
|
|
+ return candidate ?? null;
|
|
+}
|
|
+
|
|
+export function isReviewPerfEnabled(): boolean {
|
|
+ return typeof __DEV__ !== "undefined" ? __DEV__ : false;
|
|
+}
|
|
+
|
|
+export function measureReviewWork<T>(name: string, callback: () => T): T {
|
|
+ if (!isReviewPerfEnabled()) {
|
|
+ return callback();
|
|
+ }
|
|
+
|
|
+ const perf = getPerformance();
|
|
+ const marker = `${REVIEW_PERF_PREFIX}.${name}.${reviewPerfSequence++}`;
|
|
+ const startMark = `${marker}.start`;
|
|
+ const endMark = `${marker}.end`;
|
|
+ const startedAt = perf?.now?.() ?? Date.now();
|
|
+
|
|
+ perf?.mark?.(startMark);
|
|
+ try {
|
|
+ return callback();
|
|
+ } finally {
|
|
+ const durationMs = (perf?.now?.() ?? Date.now()) - startedAt;
|
|
+ perf?.mark?.(endMark);
|
|
+ perf?.measure?.(`${REVIEW_PERF_PREFIX}.${name}`, startMark, endMark);
|
|
+ perf?.clearMarks?.(startMark);
|
|
+ perf?.clearMarks?.(endMark);
|
|
+ console.log(`[review-perf] ${name}`, { durationMs: Number(durationMs.toFixed(2)) });
|
|
+ }
|
|
+}
|
|
+
|
|
+export async function measureReviewAsyncWork<T>(
|
|
+ name: string,
|
|
+ callback: () => Promise<T>,
|
|
+): Promise<T> {
|
|
+ if (!isReviewPerfEnabled()) {
|
|
+ return callback();
|
|
+ }
|
|
+
|
|
+ const perf = getPerformance();
|
|
+ const marker = `${REVIEW_PERF_PREFIX}.${name}.${reviewPerfSequence++}`;
|
|
+ const startMark = `${marker}.start`;
|
|
+ const endMark = `${marker}.end`;
|
|
+ const startedAt = perf?.now?.() ?? Date.now();
|
|
+
|
|
+ perf?.mark?.(startMark);
|
|
+ try {
|
|
+ return await callback();
|
|
+ } finally {
|
|
+ const durationMs = (perf?.now?.() ?? Date.now()) - startedAt;
|
|
+ perf?.mark?.(endMark);
|
|
+ perf?.measure?.(`${REVIEW_PERF_PREFIX}.${name}`, startMark, endMark);
|
|
+ perf?.clearMarks?.(startMark);
|
|
+ perf?.clearMarks?.(endMark);
|
|
+ console.log(`[review-perf] ${name}`, { durationMs: Number(durationMs.toFixed(2)) });
|
|
+ }
|
|
+}
|
|
+
|
|
+export function markReviewEvent(name: string, details?: Record<string, unknown>): void {
|
|
+ if (!isReviewPerfEnabled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ getPerformance()?.mark?.(`${REVIEW_PERF_PREFIX}.${name}`);
|
|
+ if (details) {
|
|
+ console.log(`[review-perf] ${name}`, details);
|
|
+ return;
|
|
+ }
|
|
+ console.log(`[review-perf] ${name}`);
|
|
+}
|