From 9bebd283a5f5bee85b5094a67ee414405a51fd29 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 15 Apr 2026 10:31:05 -0700 Subject: [PATCH] Enhance mobile review comments with diff previews - Add syntax-highlighted diff rendering and cached review state - Support pasted/attached images in review comments - Improve mobile review sheet handling for large or partial diffs Co-authored-by: codex --- .oxfmtrc.json | 2 +- apps/mobile/package.json | 1 + .../[environmentId]/[threadId]/_layout.tsx | 1 + .../components/ComposerAttachmentStrip.tsx | 17 +- .../review/ReviewCommentComposerSheet.tsx | 403 +++++--- .../features/threads/review/ReviewSheet.tsx | 956 ++++++++++-------- .../threads/review/reviewCommentSelection.ts | 4 + .../threads/review/reviewDiffRendering.tsx | 82 ++ .../review/reviewHighlighterEngine.test.ts | 43 + .../threads/review/reviewHighlighterEngine.ts | 36 + .../threads/review/reviewModel.test.ts | 60 ++ .../features/threads/review/reviewModel.ts | 99 ++ .../features/threads/review/reviewState.ts | 195 ++++ .../review/shikiReviewHighlighter.test.ts | 44 + .../threads/review/shikiReviewHighlighter.ts | 159 ++- .../threads/use-thread-composer-state.ts | 21 + bun.lock | 23 +- 17 files changed, 1569 insertions(+), 577 deletions(-) create mode 100644 apps/mobile/src/features/threads/review/reviewDiffRendering.tsx create mode 100644 apps/mobile/src/features/threads/review/reviewHighlighterEngine.test.ts create mode 100644 apps/mobile/src/features/threads/review/reviewHighlighterEngine.ts create mode 100644 apps/mobile/src/features/threads/review/reviewState.ts create mode 100644 apps/mobile/src/features/threads/review/shikiReviewHighlighter.test.ts diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 43aa362c43..71c4b1e7bf 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -11,7 +11,7 @@ "**/routeTree.gen.ts", "apps/web/public/mockServiceWorker.js", "apps/web/src/lib/vendor/qrcodegen.ts", - "apps/mobile/uniwind-types.d.ts" + "apps/mobile/uniwind-types.d.ts", "*.icon/**" ], "sortPackageJson": {} diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 6d4395f06c..5226868520 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -73,6 +73,7 @@ "react-native-reanimated": "4.2.1", "react-native-safe-area-context": "~5.6.2", "react-native-screens": "~4.23.0", + "react-native-shiki-engine": "^0.3.9", "react-native-svg": "15.15.3", "react-native-worklets": "0.7.2", "shiki": "^4.0.2", diff --git a/apps/mobile/src/app/threads/[environmentId]/[threadId]/_layout.tsx b/apps/mobile/src/app/threads/[environmentId]/[threadId]/_layout.tsx index 898bebae63..fc0b29c488 100644 --- a/apps/mobile/src/app/threads/[environmentId]/[threadId]/_layout.tsx +++ b/apps/mobile/src/app/threads/[environmentId]/[threadId]/_layout.tsx @@ -46,6 +46,7 @@ export default function ThreadLayout() { options={{ animation: "slide_from_right", contentStyle: sheetStyle, + headerBackButtonDisplayMode: "minimal", headerShown: true, headerTitle: "Files changed", headerBackTitle: "", diff --git a/apps/mobile/src/components/ComposerAttachmentStrip.tsx b/apps/mobile/src/components/ComposerAttachmentStrip.tsx index 239b03010b..5b4d3d626c 100644 --- a/apps/mobile/src/components/ComposerAttachmentStrip.tsx +++ b/apps/mobile/src/components/ComposerAttachmentStrip.tsx @@ -15,6 +15,8 @@ export interface ComposerAttachmentStripProps { readonly imageSize?: number; /** Border radius of each image thumbnail. Defaults to 16. */ readonly imageBorderRadius?: number; + /** Whether the remove button should sit in its own gutter instead of overlapping the image. */ + readonly removeButtonPlacement?: "overlay" | "gutter"; } /** @@ -25,6 +27,8 @@ export function ComposerAttachmentStrip(props: ComposerAttachmentStripProps) { const subtleBg = useThemeColor("--color-subtle"); const size = props.imageSize ?? 72; const radius = props.imageBorderRadius ?? 16; + const removeButtonPlacement = props.removeButtonPlacement ?? "overlay"; + const removeButtonGutter = removeButtonPlacement === "gutter" ? 10 : 0; if (props.attachments.length === 0) { return null; @@ -39,7 +43,14 @@ export function ComposerAttachmentStrip(props: ComposerAttachmentStripProps) { > {props.attachments.map((image) => ( - + props.onPressImage!(image.previewUri) : undefined} > @@ -57,8 +68,8 @@ export function ComposerAttachmentStrip(props: ComposerAttachmentStripProps) { leading.replaceAll(" ", "\u00A0")); -} - -function changeTone(change: "context" | "add" | "delete"): string { - if (change === "add") return "bg-emerald-500/12"; - if (change === "delete") return "bg-rose-500/12"; - return "bg-card"; -} +const REVIEW_COMMENT_PREVIEW_MAX_LINES = 5; +const REVIEW_COMMENT_LINE_HEIGHT = 26; export function ReviewCommentComposerSheet() { const router = useRouter(); const insets = useSafeAreaInsets(); + const { width } = useWindowDimensions(); + const colorScheme = useColorScheme(); const iconTint = String(useThemeColor("--color-icon")); const target = useReviewCommentTarget(); const { environmentId, threadId } = useLocalSearchParams<{ @@ -44,6 +54,11 @@ export function ReviewCommentComposerSheet() { threadId: string; }>(); const [commentText, setCommentText] = useState(""); + const [highlightedLinesById, setHighlightedLinesById] = useState< + Record> + >({}); + const [attachments, setAttachments] = useState>([]); + const [previewImageUri, setPreviewImageUri] = useState(null); const selectedLines = useMemo( () => (target ? getSelectedReviewCommentLines(target) : []), @@ -53,136 +68,252 @@ export function ReviewCommentComposerSheet() { const lastLine = selectedLines[selectedLines.length - 1] ?? null; const firstNumber = firstLine ? getReviewUnifiedLineNumber(firstLine) : null; const lastNumber = lastLine ? getReviewUnifiedLineNumber(lastLine) : null; + const selectedTheme = (colorScheme === "dark" ? "dark" : "light") satisfies ReviewDiffTheme; const canSubmit = commentText.trim().length > 0 && target !== null && !!environmentId && !!threadId; + const selectionLabel = + selectedLines.length === 1 + ? firstNumber !== null + ? `Line ${firstNumber}` + : "File comment" + : firstNumber !== null && lastNumber !== null + ? `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, + ); + const previewViewportWidth = Math.max(width - 40, 280); + const handleNativePaste = useNativePaste((uris) => { + void (async () => { + try { + const images = await convertPastedImagesToAttachments({ + uris, + existingCount: attachments.length, + }); + if (images.length > 0) { + setAttachments((current) => [...current, ...images]); + } + } catch (error) { + console.error("[review comment] error converting pasted images", error); + } + })(); + }); + + useEffect(() => { + if (!target || selectedLines.length === 0) { + setHighlightedLinesById({}); + return; + } + + let cancelled = false; + void highlightReviewSelectedLines({ + filePath: target.filePath, + lines: selectedLines, + theme: selectedTheme, + }) + .then((next) => { + if (!cancelled) { + setHighlightedLinesById(next); + } + }) + .catch(() => { + if (!cancelled) { + setHighlightedLinesById({}); + } + }); + + return () => { + cancelled = true; + }; + }, [selectedLines, selectedTheme, target]); + + async function handlePickImages(): Promise { + const result = await pickComposerImages({ existingCount: attachments.length }); + if (result.images.length > 0) { + setAttachments((current) => [...current, ...result.images]); + } + if (result.error) { + setPendingConnectionError(result.error); + } + } return ( - - - { - clearReviewCommentTarget(); - router.dismiss(); - }} - > - - - - Add Comment - - { - if (!target || !environmentId || !threadId || commentText.trim().length === 0) { - return; - } - - appendReviewCommentToDraft({ - environmentId, - threadId, - text: formatReviewCommentContext(target, commentText), - }); - clearReviewCommentTarget(); - router.dismiss(); - }} - style={{ opacity: canSubmit ? 1 : 0.55 }} - > - + + { + clearReviewCommentTarget(); + router.dismiss(); + }} > - Comment - - - + + - {!target ? ( - - No selection - - Select a diff line or range first. - + Add Comment + + - ) : ( - <> - - - {target.filePath} - - - {selectedLines.length === 1 - ? firstNumber !== null - ? `Line ${firstNumber}` - : "File comment" - : firstNumber !== null && lastNumber !== null - ? `Lines ${firstNumber}-${lastNumber}` - : `${selectedLines.length} lines selected`} + + {!target ? ( + + No selection + + Select a diff line or range first. + ) : ( + + + + {selectionLabel} + + + {target.filePath} + + - - {selectedLines.map((line) => { - const lineNumber = getReviewUnifiedLineNumber(line); - - return ( - + + REVIEW_COMMENT_PREVIEW_MAX_LINES} + nestedScrollEnabled + keyboardShouldPersistTaps="always" + showsVerticalScrollIndicator={ + selectedLines.length > REVIEW_COMMENT_PREVIEW_MAX_LINES + } + style={{ height: previewHeight }} > - - {lineNumber ?? ""} - - - {getReviewChangeMarker(line.change)} - - - {renderVisibleWhitespace(line.content || " ")} - - - ); - })} - + + {selectedLines.map((line) => { + const lineNumber = getReviewUnifiedLineNumber(line); - - Comment - + return ( + + + {lineNumber ?? ""} + + + {getReviewChangeMarker(line.change)} + + + + + + ); + })} + + + + + + + Comment + + + + + + + {attachments.length > 0 ? ( + + { + setAttachments((current) => + current.filter((image) => image.id !== imageId), + ); + }} + /> + + ) : null} + + + + + void handlePickImages()} /> + + { + if (!target || !environmentId || !threadId || commentText.trim().length === 0) { + return; + } + + appendReviewCommentToDraft({ + environmentId, + threadId, + text: formatReviewCommentContext(target, commentText), + attachments, + }); + setAttachments([]); + clearReviewCommentTarget(); + router.dismiss(); + }} + /> + - - )} - + )} + + setPreviewImageUri(null)} + swipeToCloseEnabled + doubleTapToZoomEnabled + /> + ); } diff --git a/apps/mobile/src/features/threads/review/ReviewSheet.tsx b/apps/mobile/src/features/threads/review/ReviewSheet.tsx index 5745669147..29af80c832 100644 --- a/apps/mobile/src/features/threads/review/ReviewSheet.tsx +++ b/apps/mobile/src/features/threads/review/ReviewSheet.tsx @@ -1,15 +1,11 @@ -import { - ThreadId, - type GitReviewDiffSection, - type OrchestrationCheckpointSummary, -} from "@t3tools/contracts"; +import { ThreadId, type OrchestrationCheckpointSummary } from "@t3tools/contracts"; +import { LegendList } from "@legendapp/list/react-native"; import { useLocalSearchParams, useRouter } from "expo-router"; import Stack from "expo-router/stack"; import { SymbolView } from "expo-symbols"; -import { type ReactElement, useCallback, useEffect, useMemo, useState } from "react"; +import { memo, type ReactElement, useCallback, useEffect, useMemo, useState } from "react"; import { ActivityIndicator, - Platform, Pressable, ScrollView, Text as NativeText, @@ -25,16 +21,28 @@ import { useThemeColor } from "../../../lib/useThemeColor"; import { getEnvironmentClient } from "../../../state/use-remote-environment-registry"; import { useSelectedThreadDetail } from "../../../state/use-thread-detail"; import { useThreadSelection } from "../../../state/use-thread-selection"; +import { useThreadDraftForThread } from "../use-thread-composer-state"; +import { + getCachedReviewParsedDiff, + setReviewGitSections, + setReviewSelectedSectionId, + setReviewTurnDiff, + updateReviewExpandedFileIds, + updateReviewRevealedLargeFileIds, + useReviewCacheForThread, +} from "./reviewState"; import { - buildReviewParsedDiff, getReadyReviewCheckpoints, buildReviewSectionItems, getDefaultReviewSectionId, + getReviewFilePreviewState, getReviewSectionIdForCheckpoint, + type ReviewParsedDiff, type ReviewRenderableFile, type ReviewRenderableLineRow, } from "./reviewModel"; import { + getCachedHighlightedReviewFile, highlightReviewFile, type ReviewDiffTheme, type ReviewHighlightedFile, @@ -43,6 +51,7 @@ import { import { buildReviewCommentTarget, clearReviewCommentTarget, + countReviewCommentContexts, formatReviewSelectedRangeLabel, getReviewChangeMarker, getReviewUnifiedLineNumber, @@ -51,6 +60,7 @@ import { type ReviewCommentTarget, useReviewCommentTarget, } from "./reviewCommentSelection"; +import { changeTone, DiffTokenText } from "./reviewDiffRendering"; interface PendingCommentSelection { readonly sectionTitle: string; @@ -59,20 +69,16 @@ interface PendingCommentSelection { readonly anchorIndex: number; } -const REVIEW_MONO_FONT_FAMILY = Platform.select({ - ios: "ui-monospace", - android: "monospace", - default: "monospace", -}); +interface ReviewLineActionInput { + readonly sectionTitle: string; + readonly filePath: string; + readonly lines: ReadonlyArray; + readonly lineIndex: number; +} + const IOS_NAV_BAR_HEIGHT = 44; const REVIEW_HEADER_SPACING = 32; -function changeTone(change: ReviewRenderableLineRow["change"]): string { - if (change === "add") return "bg-emerald-500/12"; - if (change === "delete") return "bg-rose-500/12"; - return "bg-card"; -} - function changeTypeLabel(type: ReviewRenderableFile["changeType"]): string { switch (type) { case "new": @@ -88,7 +94,7 @@ function changeTypeLabel(type: ReviewRenderableFile["changeType"]): string { } } -function formatHeaderDiffSummary(parsedDiff: ReturnType): { +function formatHeaderDiffSummary(parsedDiff: ReviewParsedDiff): { readonly additions: string | null; readonly deletions: string | null; } { @@ -102,84 +108,13 @@ function formatHeaderDiffSummary(parsedDiff: ReturnType, ): ReadonlyArray { - const autoExpanded = files.filter(shouldAutoExpandFile).map((file) => file.id); - if (autoExpanded.length > 0) { - return autoExpanded; - } - return files.length === 1 ? [files[0]!.id] : []; + return files.map((file) => file.id); } -function renderVisibleWhitespace(value: string): string { - const expandedTabs = value.replace(/\t/g, " "); - return expandedTabs.replace(/^( +)/, (leading) => leading.replaceAll(" ", "\u00A0")); -} - -function DiffTokenText(props: { - readonly tokens: ReadonlyArray | null; - readonly fallback: string; -}) { - if (!props.tokens || props.tokens.length === 0) { - return ( - - {renderVisibleWhitespace(props.fallback || " ")} - - ); - } - - return ( - - {(() => { - let offset = 0; - - return props.tokens.map((token) => { - const start = offset; - offset += token.content.length; - - const fontWeight = - token.fontStyle !== null && (token.fontStyle & 2) === 2 - ? ("700" as const) - : ("400" as const); - const fontStyle = - token.fontStyle !== null && (token.fontStyle & 1) === 1 - ? ("italic" as const) - : ("normal" as const); - - return ( - - {token.content.length > 0 ? renderVisibleWhitespace(token.content) : " "} - - ); - }); - })()} - - ); -} - -function ReviewLineRow(props: { +const ReviewLineRow = memo(function ReviewLineRow(props: { readonly line: ReviewRenderableLineRow; readonly tokens: ReadonlyArray | null; readonly viewportWidth: number; @@ -192,7 +127,7 @@ function ReviewLineRow(props: { return ( - + {lineNumber ?? ""} {getReviewChangeMarker(props.line.change)} - + ); -} +}); -function ReviewFileCard(props: { +const ReviewFileCard = memo(function ReviewFileCard(props: { readonly file: ReviewRenderableFile; + readonly fileId: string; readonly expanded: boolean; - readonly onToggle: () => void; + readonly onToggleFile: (fileId: string) => void; }) { return ( - + props.onToggleFile(props.fileId)} + > ); -} +}); -function ReviewFileBody(props: { +const ReviewFileBody = memo(function ReviewFileBody(props: { readonly file: ReviewRenderableFile; readonly sectionTitle: string; readonly highlightedFile: ReviewHighlightedFile | null; readonly viewportWidth: number; readonly pendingSelection: PendingCommentSelection | null; readonly selectedTarget: ReviewCommentTarget | null; - readonly onPressLine: ( - line: ReviewRenderableLineRow, - availableLines: ReadonlyArray, - lineIndex: number, - ) => void; - readonly onStartRangeSelection: ( - line: ReviewRenderableLineRow, - availableLines: ReadonlyArray, - lineIndex: number, - ) => void; + readonly onPressLine: (input: ReviewLineActionInput) => void; + readonly onStartRangeSelection: (input: ReviewLineActionInput) => void; }) { - const commentableLines = props.file.rows.filter( - (row): row is ReviewRenderableLineRow => row.kind === "line", + const commentableLines = useMemo( + () => props.file.rows.filter((row): row is ReviewRenderableLineRow => row.kind === "line"), + [props.file.rows], + ); + const lineIndexById = useMemo( + () => new Map(commentableLines.map((line, index) => [line.id, index])), + [commentableLines], + ); + const anchorLineId = useMemo( + () => + props.pendingSelection && + props.pendingSelection.sectionTitle === props.sectionTitle && + props.pendingSelection.filePath === props.file.path + ? (props.pendingSelection.lines[props.pendingSelection.anchorIndex]?.id ?? null) + : null, + [props.file.path, props.pendingSelection, props.sectionTitle], + ); + const selectedLineIds = useMemo( + () => + props.selectedTarget && + props.selectedTarget.sectionTitle === props.sectionTitle && + props.selectedTarget.filePath === props.file.path + ? new Set(getSelectedReviewCommentLines(props.selectedTarget).map((line) => line.id)) + : null, + [props.file.path, props.sectionTitle, props.selectedTarget], ); - const anchorLineId = - props.pendingSelection && - props.pendingSelection.sectionTitle === props.sectionTitle && - props.pendingSelection.filePath === props.file.path - ? (props.pendingSelection.lines[props.pendingSelection.anchorIndex]?.id ?? null) - : null; - const selectedLineIds = - props.selectedTarget && - props.selectedTarget.sectionTitle === props.sectionTitle && - props.selectedTarget.filePath === props.file.path - ? new Set(getSelectedReviewCommentLines(props.selectedTarget).map((line) => line.id)) - : null; return ( { - const lineIndex = commentableLines.findIndex( - (candidate) => candidate.id === row.id, - ); - props.onPressLine(row, commentableLines, lineIndex >= 0 ? lineIndex : 0); + props.onPressLine({ + sectionTitle: props.sectionTitle, + filePath: props.file.path, + lines: commentableLines, + lineIndex: lineIndexById.get(row.id) ?? 0, + }); }} onStartRangeSelection={() => { - const lineIndex = commentableLines.findIndex( - (candidate) => candidate.id === row.id, - ); - props.onStartRangeSelection(row, commentableLines, lineIndex >= 0 ? lineIndex : 0); + props.onStartRangeSelection({ + sectionTitle: props.sectionTitle, + filePath: props.file.path, + lines: commentableLines, + lineIndex: lineIndexById.get(row.id) ?? 0, + }); }} /> ); @@ -362,7 +308,129 @@ function ReviewFileBody(props: { ); -} +}); + +const ReviewFileSuppressedBody = memo(function ReviewFileSuppressedBody(props: { + readonly message: string; + readonly actionLabel?: string | null; + readonly fileId: string; + readonly onLoadDiffFile?: (fileId: string) => void; +}) { + return ( + + {props.message} + {props.actionLabel && props.onLoadDiffFile ? ( + props.onLoadDiffFile?.(props.fileId)} + > + {props.actionLabel} + + ) : null} + + ); +}); + +const ReviewFileItem = memo(function ReviewFileItem(props: { + readonly file: ReviewRenderableFile; + readonly expanded: boolean; + readonly sectionTitle: string; + readonly selectedTheme: ReviewDiffTheme; + readonly pendingSelection: PendingCommentSelection | null; + readonly selectedTarget: ReviewCommentTarget | null; + readonly viewportWidth: number; + readonly revealedLarge: boolean; + readonly onToggleFile: (fileId: string) => void; + readonly onLoadDiffFile: (fileId: string) => void; + readonly onPressLine: (input: ReviewLineActionInput) => void; + readonly onStartRangeSelection: (input: ReviewLineActionInput) => void; +}) { + const previewState = useMemo(() => getReviewFilePreviewState(props.file), [props.file]); + const shouldRenderBody = + previewState.kind === "render" || (previewState.reason === "large" && props.revealedLarge); + const highlightCacheKey = `${props.selectedTheme}:${props.file.cacheKey}`; + const [highlightedFile, setHighlightedFile] = useState(() => + getCachedHighlightedReviewFile(props.file, props.selectedTheme), + ); + + useEffect(() => { + setHighlightedFile(getCachedHighlightedReviewFile(props.file, props.selectedTheme)); + }, [highlightCacheKey, props.file, props.selectedTheme]); + + useEffect(() => { + if (!props.expanded || !shouldRenderBody) { + return; + } + + const cached = getCachedHighlightedReviewFile(props.file, props.selectedTheme); + if (cached) { + setHighlightedFile(cached); + return; + } + + let cancelled = false; + void highlightReviewFile(props.file, props.selectedTheme) + .then((result) => { + if (!cancelled) { + setHighlightedFile(result); + } + }) + .catch(() => { + if (cancelled) { + return; + } + }); + + return () => { + cancelled = true; + }; + }, [highlightCacheKey, props.expanded, props.file, props.selectedTheme, shouldRenderBody]); + + return ( + <> + + {props.expanded ? ( + shouldRenderBody ? ( + + ) : ( + + ) + ) : null} + + ); +}); + +const ReviewNotice = memo(function ReviewNotice(props: { readonly notice: string }) { + return ( + + + Partial diff + + + {props.notice} + + + ); +}); function ReviewSelectionActionBar(props: { readonly target: ReviewCommentTarget | null; @@ -419,20 +487,13 @@ export function ReviewSheet() { environmentId: string; threadId: string; }>(); + const { draftMessage } = useThreadDraftForThread({ environmentId, threadId }); + const reviewCache = useReviewCacheForThread({ environmentId, threadId }); const { selectedThreadProject } = useThreadSelection(); const selectedThread = useSelectedThreadDetail(); - const [gitSections, setGitSections] = useState>([]); - const [turnDiffById, setTurnDiffById] = useState>({}); const [loadingTurnIds, setLoadingTurnIds] = useState>({}); - const [selectedSectionId, setSelectedSectionId] = useState(null); const [loadingGitDiffs, setLoadingGitDiffs] = useState(false); const [error, setError] = useState(null); - const [expandedFileIdsBySection, setExpandedFileIdsBySection] = useState< - Record | undefined> - >({}); - const [highlightedFileByKey, setHighlightedFileByKey] = useState< - Record - >({}); const [pendingCommentSelection, setPendingCommentSelection] = useState(null); const activeCommentTarget = useReviewCommentTarget(); @@ -456,39 +517,49 @@ export function ReviewSheet() { () => buildReviewSectionItems({ checkpoints: readyCheckpoints, - gitSections, - turnDiffById, + gitSections: reviewCache.gitSections, + turnDiffById: reviewCache.turnDiffById, loadingTurnIds, }), - [gitSections, loadingTurnIds, readyCheckpoints, turnDiffById], + [loadingTurnIds, readyCheckpoints, reviewCache.gitSections, reviewCache.turnDiffById], ); const selectedSection = - reviewSections.find((section) => section.id === selectedSectionId) ?? reviewSections[0] ?? null; + reviewSections.find((section) => section.id === reviewCache.selectedSectionId) ?? + reviewSections[0] ?? + null; const topContentInset = insets.top + IOS_NAV_BAR_HEIGHT; const parsedDiff = useMemo( - () => buildReviewParsedDiff(selectedSection?.diff, selectedSection?.id ?? "mobile-review"), - [selectedSection?.diff, selectedSection?.id], + () => + getCachedReviewParsedDiff({ + threadKey: reviewCache.threadKey, + sectionId: selectedSection?.id ?? null, + diff: selectedSection?.diff, + }), + [reviewCache.threadKey, selectedSection?.diff, selectedSection?.id], ); const headerDiffSummary = useMemo(() => formatHeaderDiffSummary(parsedDiff), [parsedDiff]); + const pendingReviewCommentCount = useMemo( + () => countReviewCommentContexts(draftMessage), + [draftMessage], + ); const selectedTheme = (colorScheme === "dark" ? "dark" : "light") satisfies ReviewDiffTheme; const expandedFileIds = useMemo( () => selectedSection?.id && parsedDiff.kind === "files" - ? (expandedFileIdsBySection[selectedSection.id] ?? + ? (reviewCache.expandedFileIdsBySection[selectedSection.id] ?? getDefaultExpandedFileIds(parsedDiff.files)) : [], - [expandedFileIdsBySection, parsedDiff, selectedSection?.id], + [parsedDiff, reviewCache.expandedFileIdsBySection, selectedSection?.id], ); - const expandedFiles = useMemo( + const revealedLargeFileIds = useMemo( () => - parsedDiff.kind === "files" - ? parsedDiff.files.filter((file) => expandedFileIds.includes(file.id)) + selectedSection?.id + ? (reviewCache.revealedLargeFileIdsBySection[selectedSection.id] ?? []) : [], - [expandedFileIds, parsedDiff], + [reviewCache.revealedLargeFileIdsBySection, selectedSection?.id], ); - const loadGitDiffs = useCallback(async () => { if (!environmentId || !cwd) { return; @@ -504,13 +575,15 @@ export function ReviewSheet() { setError(null); try { const result = await client.git.getReviewDiffs({ cwd }); - setGitSections(result.sections); + if (reviewCache.threadKey) { + setReviewGitSections(reviewCache.threadKey, result.sections); + } } catch (cause) { setError(cause instanceof Error ? cause.message : "Failed to load review diffs."); } finally { setLoadingGitDiffs(false); } - }, [cwd, environmentId]); + }, [cwd, environmentId, reviewCache.threadKey]); const loadTurnDiff = useCallback( async (checkpoint: OrchestrationCheckpointSummary, force = false) => { @@ -519,9 +592,11 @@ export function ReviewSheet() { } const sectionId = getReviewSectionIdForCheckpoint(checkpoint); - setSelectedSectionId(sectionId); + if (reviewCache.threadKey) { + setReviewSelectedSectionId(reviewCache.threadKey, sectionId); + } - if (!force && turnDiffById[sectionId] !== undefined) { + if (!force && reviewCache.turnDiffById[sectionId] !== undefined) { return; } @@ -539,7 +614,9 @@ export function ReviewSheet() { fromTurnCount: Math.max(0, checkpoint.checkpointTurnCount - 1), toTurnCount: checkpoint.checkpointTurnCount, }); - setTurnDiffById((current) => ({ ...current, [sectionId]: result.diff })); + if (reviewCache.threadKey) { + setReviewTurnDiff(reviewCache.threadKey, sectionId, result.diff); + } } catch (cause) { setError(cause instanceof Error ? cause.message : "Failed to load turn diff."); } finally { @@ -550,7 +627,7 @@ export function ReviewSheet() { }); } }, - [environmentId, threadId, turnDiffById], + [environmentId, reviewCache.threadKey, reviewCache.turnDiffById, threadId], ); useEffect(() => { @@ -563,10 +640,14 @@ export function ReviewSheet() { } const fallbackId = getDefaultReviewSectionId(reviewSections); - if (!selectedSectionId || !reviewSections.some((section) => section.id === selectedSectionId)) { - setSelectedSectionId(fallbackId); + if ( + reviewCache.threadKey && + (!reviewCache.selectedSectionId || + !reviewSections.some((section) => section.id === reviewCache.selectedSectionId)) + ) { + setReviewSelectedSectionId(reviewCache.threadKey, fallbackId); } - }, [reviewSections, selectedSectionId]); + }, [reviewCache.selectedSectionId, reviewCache.threadKey, reviewSections]); useEffect(() => { const latest = readyCheckpoints[0]; @@ -575,12 +656,12 @@ export function ReviewSheet() { } const latestId = getReviewSectionIdForCheckpoint(latest); - if (turnDiffById[latestId] !== undefined || loadingTurnIds[latestId]) { + if (reviewCache.turnDiffById[latestId] !== undefined || loadingTurnIds[latestId]) { return; } void loadTurnDiff(latest); - }, [loadTurnDiff, loadingTurnIds, readyCheckpoints, turnDiffById]); + }, [loadTurnDiff, loadingTurnIds, readyCheckpoints, reviewCache.turnDiffById]); useEffect(() => { if (!selectedSection || selectedSection.kind !== "turn" || selectedSection.diff !== null) { @@ -594,68 +675,41 @@ export function ReviewSheet() { }, [checkpointBySectionId, loadTurnDiff, loadingTurnIds, selectedSection]); useEffect(() => { - if (!selectedSectionId || parsedDiff.kind !== "files") { + if (!reviewCache.threadKey || !selectedSection?.id || parsedDiff.kind !== "files") { return; } - setExpandedFileIdsBySection((current) => { - const existing = current[selectedSectionId]; + 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 current; + return existing; } - return { ...current, [selectedSectionId]: validIds }; + return validIds; } - return { - ...current, - [selectedSectionId]: getDefaultExpandedFileIds(parsedDiff.files), - }; + return getDefaultExpandedFileIds(parsedDiff.files); }); - }, [parsedDiff, selectedSectionId]); + }, [parsedDiff, reviewCache.threadKey, selectedSection?.id]); useEffect(() => { - if (!selectedSection || expandedFiles.length === 0) { + if (!reviewCache.threadKey || !selectedSection?.id || parsedDiff.kind !== "files") { return; } - const filesToHighlight = expandedFiles.filter((file) => { - const key = `${selectedSection.id}:${selectedTheme}:${file.cacheKey}`; - return highlightedFileByKey[key] === undefined; + updateReviewRevealedLargeFileIds(reviewCache.threadKey, selectedSection.id, (existing) => { + if (existing === undefined) { + return undefined; + } + + const validIds = existing.filter((id) => parsedDiff.files.some((file) => file.id === id)); + if (validIds.length === existing.length) { + return existing; + } + + return validIds; }); - if (filesToHighlight.length === 0) { - return; - } - - let cancelled = false; - void Promise.all( - filesToHighlight.map( - async (file) => - [ - `${selectedSection.id}:${selectedTheme}:${file.cacheKey}`, - await highlightReviewFile(file, selectedTheme), - ] as const, - ), - ) - .then((entries) => { - if (!cancelled) { - setHighlightedFileByKey((current) => ({ - ...current, - ...Object.fromEntries(entries), - })); - } - }) - .catch(() => { - if (cancelled) { - return; - } - }); - - return () => { - cancelled = true; - }; - }, [expandedFiles, highlightedFileByKey, selectedSection, selectedTheme]); + }, [parsedDiff, reviewCache.threadKey, selectedSection?.id]); const refreshSelectedSection = useCallback(async () => { if (!selectedSection) { @@ -673,9 +727,100 @@ export function ReviewSheet() { await loadGitDiffs(); }, [checkpointBySectionId, loadGitDiffs, loadTurnDiff, selectedSection]); - const reviewContent = useMemo(() => { + const handleToggleExpandedFile = useCallback( + (fileId: string) => { + if (!reviewCache.threadKey || !selectedSection?.id || parsedDiff.kind !== "files") { + return; + } + + updateReviewExpandedFileIds(reviewCache.threadKey, selectedSection.id, (existing) => { + const currentIds = existing ?? getDefaultExpandedFileIds(parsedDiff.files); + return currentIds.includes(fileId) + ? currentIds.filter((id) => id !== fileId) + : [...currentIds, fileId]; + }); + }, + [parsedDiff, reviewCache.threadKey, selectedSection?.id], + ); + + const handleRevealLargeDiff = useCallback( + (fileId: string) => { + if (!reviewCache.threadKey || !selectedSection?.id) { + return; + } + + updateReviewRevealedLargeFileIds(reviewCache.threadKey, selectedSection.id, (existing) => { + const currentIds = existing ?? []; + return currentIds.includes(fileId) ? currentIds : [...currentIds, fileId]; + }); + }, + [reviewCache.threadKey, selectedSection?.id], + ); + + const handlePressLine = useCallback( + (input: ReviewLineActionInput) => { + if (pendingCommentSelection) { + if ( + pendingCommentSelection.sectionTitle === input.sectionTitle && + pendingCommentSelection.filePath === input.filePath + ) { + setReviewCommentTarget( + buildReviewCommentTarget( + { + sectionTitle: pendingCommentSelection.sectionTitle, + filePath: pendingCommentSelection.filePath, + lines: pendingCommentSelection.lines, + }, + pendingCommentSelection.anchorIndex, + input.lineIndex, + ), + ); + setPendingCommentSelection(null); + return; + } + + clearReviewCommentTarget(); + setPendingCommentSelection({ + sectionTitle: input.sectionTitle, + filePath: input.filePath, + lines: input.lines, + anchorIndex: input.lineIndex, + }); + return; + } + + setReviewCommentTarget({ + sectionTitle: input.sectionTitle, + filePath: input.filePath, + lines: input.lines, + startIndex: input.lineIndex, + endIndex: input.lineIndex, + }); + if (environmentId && threadId) { + router.push({ + pathname: "/threads/[environmentId]/[threadId]/review-comment", + params: { environmentId, threadId }, + }); + } + }, + [environmentId, pendingCommentSelection, router, threadId], + ); + + const handleStartRangeSelection = useCallback((input: ReviewLineActionInput) => { + clearReviewCommentTarget(); + setPendingCommentSelection({ + sectionTitle: input.sectionTitle, + filePath: input.filePath, + lines: input.lines, + anchorIndex: input.lineIndex, + }); + }, []); + + const parsedDiffNotice = + parsedDiff.kind === "files" || parsedDiff.kind === "raw" ? parsedDiff.notice : null; + + const listHeader = useMemo(() => { const children: ReactElement[] = []; - const stickyHeaderIndices: number[] = []; if (error) { children.push( @@ -686,185 +831,85 @@ export function ReviewSheet() { ); } - if (parsedDiff.kind !== "empty" && parsedDiff.notice) { - children.push( - - - Partial diff - - - {parsedDiff.notice} - - , - ); + if (parsedDiffNotice) { + children.push(); } - if (!selectedSection) { - children.push( - - No review diffs - - This thread has no ready turn diffs and the worktree diff is empty. - - , - ); - return { children, stickyHeaderIndices }; + if (children.length === 0) { + return null; } - if (selectedSection.isLoading && selectedSection.diff === null) { - children.push( - - - Loading diff… - , - ); - return { children, stickyHeaderIndices }; - } + return <>{children}; + }, [error, parsedDiffNotice]); - if (parsedDiff.kind === "empty") { - children.push( - - No changes - - {selectedSection.subtitle ?? "This diff is empty."} - - , - ); - return { children, stickyHeaderIndices }; - } - - if (parsedDiff.kind === "raw") { - children.push( - - - {parsedDiff.reason} - - - - {parsedDiff.text} - - - , - ); - return { children, stickyHeaderIndices }; - } - - parsedDiff.files.forEach((file) => { - const isExpanded = expandedFileIds.includes(file.id); - const fileHighlightKey = `${selectedSection.id}:${selectedTheme}:${file.cacheKey}`; - const fileHighlights = highlightedFileByKey[fileHighlightKey] ?? null; - - stickyHeaderIndices.push(children.length); - children.push( - - setExpandedFileIdsBySection((current) => { - const existing = - current[selectedSection.id] ?? getDefaultExpandedFileIds(parsedDiff.files); - const next = existing.includes(file.id) - ? existing.filter((id) => id !== file.id) - : [...existing, file.id]; - return { - ...current, - [selectedSection.id]: next, - }; - }) - } - />, - ); - - if (isExpanded) { - children.push( - { - if (pendingCommentSelection) { - if ( - pendingCommentSelection.sectionTitle === selectedSection.title && - pendingCommentSelection.filePath === file.path - ) { - setReviewCommentTarget( - buildReviewCommentTarget( - { - sectionTitle: pendingCommentSelection.sectionTitle, - filePath: pendingCommentSelection.filePath, - lines: pendingCommentSelection.lines, - }, - pendingCommentSelection.anchorIndex, - lineIndex, - ), - ); - setPendingCommentSelection(null); - return; - } - - clearReviewCommentTarget(); - setPendingCommentSelection({ - sectionTitle: selectedSection.title, - filePath: file.path, - lines: availableLines, - anchorIndex: lineIndex, - }); - return; - } - - setReviewCommentTarget({ - sectionTitle: selectedSection.title, - filePath: file.path, - lines: availableLines, - startIndex: lineIndex, - endIndex: lineIndex, - }); - if (environmentId && threadId) { - router.push({ - pathname: "/threads/[environmentId]/[threadId]/review-comment", - params: { environmentId, threadId }, - }); - } - }} - onStartRangeSelection={(_line, availableLines, lineIndex) => { - clearReviewCommentTarget(); - setPendingCommentSelection({ - sectionTitle: selectedSection.title, - filePath: file.path, - lines: availableLines, - anchorIndex: lineIndex, - }); - }} - />, - ); + const renderFileItem = useCallback( + ({ item }: { item: ReviewRenderableFile; index: number }) => { + if (!selectedSection) { + return null; } - }); + const pendingSelectionForFile = + pendingCommentSelection && + pendingCommentSelection.sectionTitle === selectedSection.title && + pendingCommentSelection.filePath === item.path + ? pendingCommentSelection + : null; + const selectedTargetForFile = + activeCommentTarget && + activeCommentTarget.sectionTitle === selectedSection.title && + activeCommentTarget.filePath === item.path + ? activeCommentTarget + : null; - return { children, stickyHeaderIndices }; + return ( + + ); + }, + [ + activeCommentTarget, + expandedFileIds, + handlePressLine, + handleRevealLargeDiff, + handleStartRangeSelection, + handleToggleExpandedFile, + pendingCommentSelection, + revealedLargeFileIds, + selectedSection, + selectedTheme, + width, + ], + ); + + const visibleListExtraData = useMemo(() => { + return { + selectedSectionId: selectedSection?.id ?? null, + selectedTheme, + expandedFileIds, + revealedLargeFileIds, + pendingSelection: pendingCommentSelection, + selectedTarget: activeCommentTarget, + viewportWidth: Math.max(width, 280), + }; }, [ activeCommentTarget, - error, expandedFileIds, - highlightedFileByKey, pendingCommentSelection, - parsedDiff, - router, + revealedLargeFileIds, selectedSection, selectedTheme, - threadId, width, - environmentId, ]); return ( @@ -891,7 +936,15 @@ export function ReviewSheet() { > Files Changed - + {headerDiffSummary.additions && headerDiffSummary.deletions ? ( <> {headerDiffSummary.deletions} + {pendingReviewCommentCount > 0 ? ( + + {pendingReviewCommentCount} pending + + ) : null} ) : ( - - {selectedSection?.title ?? "Review changes"} - + + + {selectedSection?.title ?? "Review changes"} + + {pendingReviewCommentCount > 0 ? ( + + {pendingReviewCommentCount} pending + + ) : null} + )} @@ -940,7 +1019,11 @@ export function ReviewSheet() { setSelectedSectionId(section.id)} + onPress={() => { + if (reviewCache.threadKey) { + setReviewSelectedSectionId(reviewCache.threadKey, section.id); + } + }} subtitle={section.subtitle ?? undefined} > {section.title} @@ -961,22 +1044,73 @@ export function ReviewSheet() { - - {reviewContent.children} - + {selectedSection && parsedDiff.kind === "files" ? ( + file.id} + extraData={visibleListExtraData} + keyboardShouldPersistTaps="handled" + estimatedItemSize={220} + drawDistance={900} + recycleItems + ListHeaderComponent={listHeader} + contentContainerStyle={{ + paddingTop: REVIEW_HEADER_SPACING, + paddingBottom: Math.max(insets.bottom, 18) + 18, + }} + /> + ) : ( + + {listHeader} + {!selectedSection ? ( + + No review diffs + + This thread has no ready turn diffs and the worktree diff is empty. + + + ) : selectedSection.isLoading && selectedSection.diff === null ? ( + + + Loading diff… + + ) : parsedDiff.kind === "empty" ? ( + + No changes + + {selectedSection.subtitle ?? "This diff is empty."} + + + ) : parsedDiff.kind === "raw" ? ( + + + {parsedDiff.reason} + + + + {parsedDiff.text} + + + + ) : null} + + )} ", ].join("\n"); } + +export function countReviewCommentContexts(value: string): number { + return Array.from(value.matchAll(//g)).length; +} diff --git a/apps/mobile/src/features/threads/review/reviewDiffRendering.tsx b/apps/mobile/src/features/threads/review/reviewDiffRendering.tsx new file mode 100644 index 0000000000..6f63993e4f --- /dev/null +++ b/apps/mobile/src/features/threads/review/reviewDiffRendering.tsx @@ -0,0 +1,82 @@ +import { Platform, Text as NativeText } from "react-native"; + +import { cn } from "../../../lib/cn"; + +import type { ReviewRenderableLineRow } from "./reviewModel"; +import type { ReviewHighlightedToken } from "./shikiReviewHighlighter"; + +export const REVIEW_MONO_FONT_FAMILY = Platform.select({ + ios: "ui-monospace", + android: "monospace", + default: "monospace", +}); + +export function renderVisibleWhitespace(value: string): string { + const expandedTabs = value.replace(/\t/g, " "); + return expandedTabs.replace(/^( +)/, (leading) => leading.replaceAll(" ", "\u00A0")); +} + +export function changeTone(change: ReviewRenderableLineRow["change"]): string { + if (change === "add") return "bg-emerald-500/12"; + if (change === "delete") return "bg-rose-500/12"; + return "bg-card"; +} + +export function DiffTokenText(props: { + readonly tokens: ReadonlyArray | null; + readonly fallback: string; + readonly className?: string; +}) { + if (!props.tokens || props.tokens.length === 0) { + return ( + + {renderVisibleWhitespace(props.fallback || " ")} + + ); + } + + return ( + + {(() => { + let offset = 0; + + return props.tokens.map((token) => { + const start = offset; + offset += 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 ( + + {token.content.length > 0 ? renderVisibleWhitespace(token.content) : " "} + + ); + }); + })()} + + ); +} diff --git a/apps/mobile/src/features/threads/review/reviewHighlighterEngine.test.ts b/apps/mobile/src/features/threads/review/reviewHighlighterEngine.test.ts new file mode 100644 index 0000000000..1e881eef0e --- /dev/null +++ b/apps/mobile/src/features/threads/review/reviewHighlighterEngine.test.ts @@ -0,0 +1,43 @@ +import { describe, expect, it } from "vitest"; + +import { + hasTurboModuleProxy, + resolveReviewHighlighterEngine, + resolveReviewHighlighterEnginePreference, +} from "./reviewHighlighterEngine"; + +describe("resolveReviewHighlighterEnginePreference", () => { + it("defaults invalid values to auto", () => { + expect(resolveReviewHighlighterEnginePreference(undefined)).toBe("auto"); + expect(resolveReviewHighlighterEnginePreference("bogus")).toBe("auto"); + }); + + it("accepts supported values", () => { + expect(resolveReviewHighlighterEnginePreference("auto")).toBe("auto"); + expect(resolveReviewHighlighterEnginePreference("javascript")).toBe("javascript"); + expect(resolveReviewHighlighterEnginePreference("native")).toBe("native"); + }); +}); + +describe("resolveReviewHighlighterEngine", () => { + it("uses javascript when explicitly requested", () => { + expect(resolveReviewHighlighterEngine("javascript", true)).toBe("javascript"); + expect(resolveReviewHighlighterEngine("javascript", false)).toBe("javascript"); + }); + + it("uses native when available for auto or native preference", () => { + expect(resolveReviewHighlighterEngine("auto", true)).toBe("native"); + expect(resolveReviewHighlighterEngine("native", true)).toBe("native"); + }); + + it("falls back to javascript when native is unavailable", () => { + expect(resolveReviewHighlighterEngine("auto", false)).toBe("javascript"); + expect(resolveReviewHighlighterEngine("native", false)).toBe("javascript"); + }); +}); + +describe("hasTurboModuleProxy", () => { + it("returns false outside a native runtime", () => { + expect(hasTurboModuleProxy()).toBe(false); + }); +}); diff --git a/apps/mobile/src/features/threads/review/reviewHighlighterEngine.ts b/apps/mobile/src/features/threads/review/reviewHighlighterEngine.ts new file mode 100644 index 0000000000..b8e17ec7fd --- /dev/null +++ b/apps/mobile/src/features/threads/review/reviewHighlighterEngine.ts @@ -0,0 +1,36 @@ +export type ReviewHighlighterEnginePreference = "auto" | "javascript" | "native"; +export type ReviewHighlighterEngine = "javascript" | "native"; + +export function resolveReviewHighlighterEnginePreference( + value: string | undefined, +): ReviewHighlighterEnginePreference { + switch (value) { + case "javascript": + case "native": + case "auto": + return value; + default: + return "auto"; + } +} + +export function resolveReviewHighlighterEngine( + preference: ReviewHighlighterEnginePreference, + nativeAvailable: boolean, +): ReviewHighlighterEngine { + if (preference === "javascript") { + return "javascript"; + } + + if (nativeAvailable) { + return "native"; + } + + return "javascript"; +} + +export function hasTurboModuleProxy(): boolean { + const turboModuleProxy = (globalThis as { readonly __turboModuleProxy?: unknown }) + .__turboModuleProxy; + return typeof turboModuleProxy === "function"; +} diff --git a/apps/mobile/src/features/threads/review/reviewModel.test.ts b/apps/mobile/src/features/threads/review/reviewModel.test.ts index 295ba871a2..8a0331c8c5 100644 --- a/apps/mobile/src/features/threads/review/reviewModel.test.ts +++ b/apps/mobile/src/features/threads/review/reviewModel.test.ts @@ -11,7 +11,9 @@ import { buildReviewParsedDiff, buildReviewSectionItems, getDefaultReviewSectionId, + getReviewFilePreviewState, getReviewSectionIdForCheckpoint, + type ReviewRenderableFile, } from "./reviewModel"; function makeCheckpoint( @@ -27,6 +29,24 @@ function makeCheckpoint( }; } +function makeRenderableFile( + input: Partial & Pick, +): ReviewRenderableFile { + return { + id: input.path, + cacheKey: input.path, + previousPath: null, + changeType: "new", + additions: 0, + deletions: 0, + languageHint: null, + additionLines: [], + deletionLines: [], + rows: [], + ...input, + }; +} + describe("buildReviewSectionItems", () => { it("keeps one chip per checkpoint and appends git sources", () => { const checkpoints = [ @@ -171,4 +191,44 @@ describe("buildReviewParsedDiff", () => { header: "@@ -1,1 +1,2 @@", }); }); + + it("suppresses preview for non-text file formats", () => { + const preview = getReviewFilePreviewState( + makeRenderableFile({ + path: "apps/mobile/assets/icon.png", + }), + ); + + expect(preview).toMatchObject({ + kind: "suppressed", + reason: "non-text", + title: "Non-text file", + actionLabel: null, + }); + }); + + it("suppresses large diffs until explicitly requested", () => { + const preview = getReviewFilePreviewState( + makeRenderableFile({ + path: "apps/mobile/src/big.ts", + rows: Array.from({ length: 401 }, (_, index) => ({ + kind: "line" as const, + id: `line-${index}`, + change: "add" as const, + oldLineNumber: null, + newLineNumber: index + 1, + content: `const line${index} = ${index};`, + additionTokenIndex: index, + deletionTokenIndex: null, + })), + }), + ); + + expect(preview).toMatchObject({ + kind: "suppressed", + reason: "large", + title: "Large diff", + actionLabel: "Load diff", + }); + }); }); diff --git a/apps/mobile/src/features/threads/review/reviewModel.ts b/apps/mobile/src/features/threads/review/reviewModel.ts index 7b289fbc77..6762999748 100644 --- a/apps/mobile/src/features/threads/review/reviewModel.ts +++ b/apps/mobile/src/features/threads/review/reviewModel.ts @@ -48,6 +48,18 @@ export interface ReviewRenderableFile { readonly rows: ReadonlyArray; } +export type ReviewFilePreviewState = + | { + readonly kind: "render"; + } + | { + readonly kind: "suppressed"; + readonly reason: "non-text" | "large"; + readonly title: string; + readonly message: string; + readonly actionLabel: string | null; + }; + export type ReviewParsedDiff = | { readonly kind: "empty"; @@ -147,6 +159,50 @@ const FNV_OFFSET_BASIS_32 = 0x811c9dc5; const FNV_PRIME_32 = 0x01000193; const SECONDARY_HASH_SEED = 0x9e3779b9; const SECONDARY_HASH_MULTIPLIER = 0x85ebca6b; +const LARGE_DIFF_LINE_THRESHOLD = 400; +const LARGE_DIFF_CHARACTER_THRESHOLD = 24_000; +const NON_TEXT_FILE_EXTENSIONS = new Set([ + "png", + "jpg", + "jpeg", + "gif", + "webp", + "bmp", + "ico", + "icns", + "avif", + "heic", + "tif", + "tiff", + "mp3", + "wav", + "flac", + "ogg", + "m4a", + "aac", + "mp4", + "mov", + "avi", + "mkv", + "webm", + "pdf", + "zip", + "gz", + "tgz", + "bz2", + "7z", + "rar", + "woff", + "woff2", + "ttf", + "otf", + "eot", + "wasm", + "exe", + "dll", + "so", + "dylib", +]); function fnv1a32(input: string, seed: number, multiplier: number): number { let hash = seed >>> 0; @@ -168,6 +224,49 @@ function buildPatchCacheKey(patch: string, scope: string): string { return `${scope}:${normalizedPatch.length}:${primary}:${secondary}`; } +function getFileExtension(path: string): string | null { + const match = /\.([a-z0-9]+)$/i.exec(path); + return match?.[1]?.toLowerCase() ?? null; +} + +function countReviewRenderableLineRows(file: ReviewRenderableFile): number { + return file.rows.reduce((total, row) => total + (row.kind === "line" ? 1 : 0), 0); +} + +function countReviewRenderableCharacters(file: ReviewRenderableFile): number { + return file.rows.reduce( + (total, row) => total + (row.kind === "line" ? row.content.length : row.header.length), + 0, + ); +} + +export function getReviewFilePreviewState(file: ReviewRenderableFile): ReviewFilePreviewState { + const extension = getFileExtension(file.path); + if (extension && NON_TEXT_FILE_EXTENSIONS.has(extension)) { + return { + kind: "suppressed", + reason: "non-text", + title: "Non-text file", + message: "Diff preview is not available for this file format.", + actionLabel: null, + }; + } + + const lineCount = countReviewRenderableLineRows(file); + const characterCount = countReviewRenderableCharacters(file); + if (lineCount > LARGE_DIFF_LINE_THRESHOLD || characterCount > LARGE_DIFF_CHARACTER_THRESHOLD) { + return { + kind: "suppressed", + reason: "large", + title: "Large diff", + message: "Large diffs are not rendered by default.", + actionLabel: "Load diff", + }; + } + + return { kind: "render" }; +} + function fallbackHunkHeader(hunk: FileDiffMetadata["hunks"][number]): string { return `@@ -${hunk.deletionStart},${hunk.deletionCount} +${hunk.additionStart},${hunk.additionCount} @@`; } diff --git a/apps/mobile/src/features/threads/review/reviewState.ts b/apps/mobile/src/features/threads/review/reviewState.ts new file mode 100644 index 0000000000..1cf997e233 --- /dev/null +++ b/apps/mobile/src/features/threads/review/reviewState.ts @@ -0,0 +1,195 @@ +import { useAtomValue } from "@effect/atom-react"; + +import { EnvironmentId, ThreadId, type GitReviewDiffSection } from "@t3tools/contracts"; +import { Atom } from "effect/unstable/reactivity"; + +import { scopedThreadKey } from "../../../lib/scopedEntities"; +import { appAtomRegistry } from "../../../state/atom-registry"; +import { buildReviewParsedDiff, type ReviewParsedDiff } from "./reviewModel"; + +const EMPTY_GIT_REVIEW_SECTIONS = Object.freeze>([]); +const EMPTY_REVIEW_TURN_DIFFS = Object.freeze>>({}); +const EMPTY_REVIEW_SECTION_FILE_IDS = Object.freeze< + Readonly | undefined>> +>({}); +const EMPTY_REVIEW_GIT_SECTIONS_ATOM = Atom.make(EMPTY_GIT_REVIEW_SECTIONS).pipe( + Atom.keepAlive, + Atom.withLabel("mobile:review:git-sections:null"), +); +const EMPTY_REVIEW_TURN_DIFFS_ATOM = Atom.make(EMPTY_REVIEW_TURN_DIFFS).pipe( + Atom.keepAlive, + Atom.withLabel("mobile:review:turn-diffs:null"), +); +const EMPTY_REVIEW_SELECTED_SECTION_ID_ATOM = Atom.make(null).pipe( + Atom.keepAlive, + Atom.withLabel("mobile:review:selected-section-id:null"), +); +const EMPTY_REVIEW_SECTION_FILE_IDS_ATOM = Atom.make(EMPTY_REVIEW_SECTION_FILE_IDS).pipe( + Atom.keepAlive, + Atom.withLabel("mobile:review:section-file-ids:null"), +); + +const reviewGitSectionsByThreadKeyAtom = Atom.family((threadKey: string) => + Atom.make(EMPTY_GIT_REVIEW_SECTIONS).pipe( + Atom.keepAlive, + Atom.withLabel(`mobile:review:git-sections:${threadKey}`), + ), +); + +const reviewTurnDiffByThreadKeyAtom = Atom.family((threadKey: string) => + Atom.make(EMPTY_REVIEW_TURN_DIFFS).pipe( + Atom.keepAlive, + Atom.withLabel(`mobile:review:turn-diffs:${threadKey}`), + ), +); + +const reviewSelectedSectionIdByThreadKeyAtom = Atom.family((threadKey: string) => + Atom.make(null).pipe( + Atom.keepAlive, + Atom.withLabel(`mobile:review:selected-section-id:${threadKey}`), + ), +); + +const reviewExpandedFileIdsByThreadKeyAtom = Atom.family((threadKey: string) => + Atom.make(EMPTY_REVIEW_SECTION_FILE_IDS).pipe( + Atom.keepAlive, + Atom.withLabel(`mobile:review:expanded-file-ids:${threadKey}`), + ), +); + +const reviewRevealedLargeFileIdsByThreadKeyAtom = Atom.family((threadKey: string) => + Atom.make(EMPTY_REVIEW_SECTION_FILE_IDS).pipe( + Atom.keepAlive, + Atom.withLabel(`mobile:review:revealed-large-file-ids:${threadKey}`), + ), +); + +const reviewParsedDiffBySectionCacheKeyAtom = Atom.family((cacheKey: string) => + Atom.make<{ readonly diff: string | null; readonly parsed: ReviewParsedDiff } | null>(null).pipe( + Atom.keepAlive, + Atom.withLabel(`mobile:review:parsed-diffs:${cacheKey}`), + ), +); + +function buildThreadKey(input: { + readonly environmentId?: string; + readonly threadId?: string; +}): string | null { + return input.environmentId && input.threadId + ? scopedThreadKey(EnvironmentId.make(input.environmentId), ThreadId.make(input.threadId)) + : null; +} + +function buildSectionCacheKey(threadKey: string, sectionId: string): string { + return `${threadKey}:${sectionId}`; +} + +export function useReviewCacheForThread(input: { + readonly environmentId?: string; + readonly threadId?: string; +}) { + const threadKey = buildThreadKey(input); + const gitSections = useAtomValue( + threadKey ? reviewGitSectionsByThreadKeyAtom(threadKey) : EMPTY_REVIEW_GIT_SECTIONS_ATOM, + ); + const turnDiffById = useAtomValue( + threadKey ? reviewTurnDiffByThreadKeyAtom(threadKey) : EMPTY_REVIEW_TURN_DIFFS_ATOM, + ); + const selectedSectionId = useAtomValue( + threadKey + ? reviewSelectedSectionIdByThreadKeyAtom(threadKey) + : EMPTY_REVIEW_SELECTED_SECTION_ID_ATOM, + ); + const expandedFileIdsBySection = useAtomValue( + threadKey + ? reviewExpandedFileIdsByThreadKeyAtom(threadKey) + : EMPTY_REVIEW_SECTION_FILE_IDS_ATOM, + ); + const revealedLargeFileIdsBySection = useAtomValue( + threadKey + ? reviewRevealedLargeFileIdsByThreadKeyAtom(threadKey) + : EMPTY_REVIEW_SECTION_FILE_IDS_ATOM, + ); + + return { + threadKey, + gitSections, + turnDiffById, + selectedSectionId, + expandedFileIdsBySection, + revealedLargeFileIdsBySection, + }; +} + +export function setReviewGitSections( + threadKey: string, + sections: ReadonlyArray, +): void { + appAtomRegistry.set(reviewGitSectionsByThreadKeyAtom(threadKey), sections); +} + +export function setReviewTurnDiff(threadKey: string, sectionId: string, diff: string): void { + const atom = reviewTurnDiffByThreadKeyAtom(threadKey); + const current = appAtomRegistry.get(atom); + appAtomRegistry.set(atom, { + ...current, + [sectionId]: diff, + }); +} + +export function setReviewSelectedSectionId(threadKey: string, sectionId: string | null): void { + appAtomRegistry.set(reviewSelectedSectionIdByThreadKeyAtom(threadKey), sectionId); +} + +export function updateReviewExpandedFileIds( + threadKey: string, + sectionId: string, + update: (current: ReadonlyArray | undefined) => ReadonlyArray | undefined, +): void { + const atom = reviewExpandedFileIdsByThreadKeyAtom(threadKey); + const current = appAtomRegistry.get(atom); + const nextValue = update(current[sectionId]); + appAtomRegistry.set(atom, { + ...current, + [sectionId]: nextValue, + }); +} + +export function updateReviewRevealedLargeFileIds( + threadKey: string, + sectionId: string, + update: (current: ReadonlyArray | undefined) => ReadonlyArray | undefined, +): void { + const atom = reviewRevealedLargeFileIdsByThreadKeyAtom(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; + readonly diff: string | null | undefined; +}): ReviewParsedDiff { + if (!input.threadKey || !input.sectionId) { + return buildReviewParsedDiff(input.diff, input.sectionId ?? "mobile-review"); + } + + const cacheKey = buildSectionCacheKey(input.threadKey, input.sectionId); + const normalizedDiff = input.diff?.trim() ?? null; + const atom = reviewParsedDiffBySectionCacheKeyAtom(cacheKey); + const cached = appAtomRegistry.get(atom); + if (cached && cached.diff === normalizedDiff) { + return cached.parsed; + } + + const parsed = buildReviewParsedDiff(input.diff, input.sectionId); + appAtomRegistry.set(atom, { + diff: normalizedDiff, + parsed, + }); + return parsed; +} diff --git a/apps/mobile/src/features/threads/review/shikiReviewHighlighter.test.ts b/apps/mobile/src/features/threads/review/shikiReviewHighlighter.test.ts new file mode 100644 index 0000000000..35a4de32d5 --- /dev/null +++ b/apps/mobile/src/features/threads/review/shikiReviewHighlighter.test.ts @@ -0,0 +1,44 @@ +import { describe, expect, it } from "vitest"; + +import type { ReviewRenderableFile } from "./reviewModel"; +import { highlightReviewFile } from "./shikiReviewHighlighter"; + +function makeRenderableFile( + input: Partial & Pick, +): ReviewRenderableFile { + return { + id: input.path, + cacheKey: input.path, + previousPath: null, + changeType: "new", + additions: 0, + deletions: 0, + languageHint: null, + additionLines: [], + deletionLines: [], + rows: [], + ...input, + }; +} + +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", + additionLines: [ + 'const items = ["a"];', + 'expect(items).toEqual(["a"]);', + "const next = items.map((item) => item.toUpperCase());", + 'expect(next).toContain("A");', + ], + }); + + 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); + }); +}); diff --git a/apps/mobile/src/features/threads/review/shikiReviewHighlighter.ts b/apps/mobile/src/features/threads/review/shikiReviewHighlighter.ts index 722cb4ea7a..73289f3e36 100644 --- a/apps/mobile/src/features/threads/review/shikiReviewHighlighter.ts +++ b/apps/mobile/src/features/threads/review/shikiReviewHighlighter.ts @@ -1,6 +1,12 @@ import { getFiletypeFromFileName } from "@pierre/diffs/utils"; -import type { ReviewRenderableFile } from "./reviewModel"; +import { + hasTurboModuleProxy, + resolveReviewHighlighterEngine, + resolveReviewHighlighterEnginePreference, + type ReviewHighlighterEngine, +} from "./reviewHighlighterEngine"; +import type { ReviewRenderableFile, ReviewRenderableLineRow } from "./reviewModel"; export type ReviewDiffTheme = "light" | "dark"; @@ -19,8 +25,12 @@ const SHIKI_THEME_BY_SCHEME = { light: "github-light-default", dark: "github-dark-default", } as const; +const REVIEW_HIGHLIGHTER_ENGINE_PREFERENCE = resolveReviewHighlighterEnginePreference( + process.env.EXPO_PUBLIC_REVIEW_HIGHLIGHTER_ENGINE, +); const highlightCache = new Map>(); +const resolvedHighlightCache = new Map(); const loadedLanguages = new Set(["text"]); type ShikiHighlighter = { loadLanguage: (...langs: string[]) => Promise; @@ -30,38 +40,83 @@ type ShikiHighlighter = { ) => Promise>>; }; let highlighterPromise: Promise | null = null; +let activeHighlighterEnginePromise: Promise | null = null; -function cleanLastNewline(value: string): string { +function stripTrailingNewline(value: string): string { return value.endsWith("\n") ? value.slice(0, -1) : value; } function joinPatchLines(lines: ReadonlyArray): string { - if (lines.length === 0) { - return ""; - } - - return cleanLastNewline(lines.join("")); + return lines.map(stripTrailingNewline).join("\n"); } async function getHighlighter() { if (!highlighterPromise) { - highlighterPromise = import("shiki").then( - async ({ createHighlighter, createJavaScriptRegexEngine }) => { - const highlighter = await createHighlighter({ - themes: [SHIKI_THEME_BY_SCHEME.light, SHIKI_THEME_BY_SCHEME.dark], - langs: [], - engine: createJavaScriptRegexEngine(), - }); - return highlighter as unknown as ShikiHighlighter; - }, - ); + const configuredHighlighterPromise = import("shiki").then(async (shikiModule) => { + const nativeRuntimeAvailable = hasTurboModuleProxy(); + let nativeEngineAvailable = false; + + if (nativeRuntimeAvailable && REVIEW_HIGHLIGHTER_ENGINE_PREFERENCE !== "javascript") { + try { + const nativeEngineModule = await import("react-native-shiki-engine"); + nativeEngineAvailable = nativeEngineModule.isNativeEngineAvailable(); + if (nativeEngineAvailable) { + const createHighlighter = shikiModule.createBundledHighlighter({ + langs: shikiModule.bundledLanguages, + themes: shikiModule.bundledThemes, + engine: () => nativeEngineModule.createNativeEngine(), + }); + const highlighter = await createHighlighter({ + themes: [SHIKI_THEME_BY_SCHEME.light, SHIKI_THEME_BY_SCHEME.dark], + langs: [], + }); + return { + highlighter: highlighter as unknown as ShikiHighlighter, + engine: "native" as const, + }; + } + } catch { + nativeEngineAvailable = false; + } + } + + const engine = resolveReviewHighlighterEngine( + REVIEW_HIGHLIGHTER_ENGINE_PREFERENCE, + nativeEngineAvailable, + ); + const createHighlighter = shikiModule.createBundledHighlighter({ + langs: shikiModule.bundledLanguages, + themes: shikiModule.bundledThemes, + engine: () => shikiModule.createJavaScriptRegexEngine(), + }); + const highlighter = await createHighlighter({ + themes: [SHIKI_THEME_BY_SCHEME.light, SHIKI_THEME_BY_SCHEME.dark], + langs: [], + }); + return { + highlighter: highlighter as unknown as ShikiHighlighter, + engine, + }; + }); + + highlighterPromise = configuredHighlighterPromise.then((result) => result.highlighter); + activeHighlighterEnginePromise = configuredHighlighterPromise.then((result) => result.engine); } return highlighterPromise as Promise; } -async function resolveLanguage(file: ReviewRenderableFile): Promise { - const candidate = file.languageHint ?? getFiletypeFromFileName(file.path); +export async function getActiveReviewHighlighterEngine(): Promise { + await getHighlighter(); + return (activeHighlighterEnginePromise ?? + Promise.resolve("javascript")) as Promise; +} + +async function resolveLanguageFromPath( + path: string, + languageHint: string | null = null, +): Promise { + const candidate = languageHint ?? getFiletypeFromFileName(path); if (!candidate || candidate === "text" || candidate === "ansi") { return "text"; } @@ -79,6 +134,10 @@ async function resolveLanguage(file: ReviewRenderableFile): Promise { return candidate; } +async function resolveLanguage(file: ReviewRenderableFile): Promise { + return resolveLanguageFromPath(file.path, file.languageHint); +} + function normalizeHighlightedLines( tokenLines: ReadonlyArray>, ): ReadonlyArray> { @@ -105,12 +164,27 @@ async function highlightLines( return normalizeHighlightedLines(tokenLines); } +function getHighlightCacheKey(file: ReviewRenderableFile, theme: ReviewDiffTheme): string { + return `${SHIKI_THEME_BY_SCHEME[theme]}:${file.cacheKey}`; +} + +export function getCachedHighlightedReviewFile( + file: ReviewRenderableFile, + theme: ReviewDiffTheme, +): ReviewHighlightedFile | null { + return resolvedHighlightCache.get(getHighlightCacheKey(file, theme)) ?? null; +} + export async function highlightReviewFile( file: ReviewRenderableFile, theme: ReviewDiffTheme, ): Promise { const shikiTheme = SHIKI_THEME_BY_SCHEME[theme]; - const cacheKey = `${shikiTheme}:${file.cacheKey}`; + const cacheKey = getHighlightCacheKey(file, theme); + const resolved = resolvedHighlightCache.get(cacheKey); + if (resolved) { + return resolved; + } const cached = highlightCache.get(cacheKey); if (cached) { return cached; @@ -123,9 +197,52 @@ export async function highlightReviewFile( highlightLines(joinPatchLines(file.deletionLines), language, shikiTheme), ]); - return { additionLines, deletionLines }; + const highlighted = { additionLines, deletionLines }; + resolvedHighlightCache.set(cacheKey, highlighted); + return highlighted; })(); highlightCache.set(cacheKey, promise); return promise; } + +export async function highlightReviewSelectedLines(input: { + readonly filePath: string; + readonly lines: ReadonlyArray; + readonly theme: ReviewDiffTheme; + readonly languageHint?: string | null; +}): Promise>> { + if (input.lines.length === 0) { + return {}; + } + + const language = await resolveLanguageFromPath(input.filePath, input.languageHint ?? null); + const shikiTheme = SHIKI_THEME_BY_SCHEME[input.theme]; + const additionLikeLines = input.lines + .filter((line) => line.change !== "delete") + .map((line) => `${line.content}\n`); + const deletionLines = input.lines + .filter((line) => line.change === "delete") + .map((line) => `${line.content}\n`); + const [additionTokens, deletionTokens] = await Promise.all([ + highlightLines(joinPatchLines(additionLikeLines), language, shikiTheme), + highlightLines(joinPatchLines(deletionLines), language, shikiTheme), + ]); + + const tokenMap: Record> = {}; + let additionIndex = 0; + let deletionIndex = 0; + + input.lines.forEach((line) => { + if (line.change === "delete") { + tokenMap[line.id] = deletionTokens[deletionIndex] ?? []; + deletionIndex += 1; + return; + } + + tokenMap[line.id] = additionTokens[additionIndex] ?? []; + additionIndex += 1; + }); + + return tokenMap; +} diff --git a/apps/mobile/src/features/threads/use-thread-composer-state.ts b/apps/mobile/src/features/threads/use-thread-composer-state.ts index 66392c66bf..0dd3162845 100644 --- a/apps/mobile/src/features/threads/use-thread-composer-state.ts +++ b/apps/mobile/src/features/threads/use-thread-composer-state.ts @@ -93,6 +93,7 @@ export function appendReviewCommentToDraft(input: { readonly environmentId: string; readonly threadId: string; readonly text: string; + readonly attachments?: ReadonlyArray; }): void { const threadKey = scopedThreadKey( EnvironmentId.make(input.environmentId), @@ -105,6 +106,26 @@ export function appendReviewCommentToDraft(input: { ...current, [threadKey]: `${existing}${separator}${input.text}`, }); + if (input.attachments && input.attachments.length > 0) { + appendDraftAttachments(threadKey, input.attachments); + } +} + +export function useThreadDraftForThread(input: { + readonly environmentId?: string; + readonly threadId?: string; +}) { + const draftMessageByThreadKey = useAtomValue(draftMessageByThreadKeyAtom); + const draftAttachmentsByThreadKey = useAtomValue(draftAttachmentsByThreadKeyAtom); + const threadKey = + input.environmentId && input.threadId + ? scopedThreadKey(EnvironmentId.make(input.environmentId), ThreadId.make(input.threadId)) + : null; + + return { + draftMessage: threadKey ? (draftMessageByThreadKey[threadKey] ?? "") : "", + draftAttachments: threadKey ? (draftAttachmentsByThreadKey[threadKey] ?? []) : [], + }; } function clearDraft(threadKey: string): void { diff --git a/bun.lock b/bun.lock index bca3c502d8..3914826aa1 100644 --- a/bun.lock +++ b/bun.lock @@ -85,6 +85,7 @@ "react-native-reanimated": "4.2.1", "react-native-safe-area-context": "~5.6.2", "react-native-screens": "~4.23.0", + "react-native-shiki-engine": "^0.3.9", "react-native-svg": "15.15.3", "react-native-worklets": "0.7.2", "shiki": "^4.0.2", @@ -1071,7 +1072,7 @@ "@shikijs/transformers": ["@shikijs/transformers@3.23.0", "", { "dependencies": { "@shikijs/core": "3.23.0", "@shikijs/types": "3.23.0" } }, "sha512-F9msZVxdF+krQNSdQ4V+Ja5QemeAoTQ2jxt7nJCwhDsdF1JWS3KxIQXA3lQbyKwS3J61oHRUSv4jYWv3CkaKTQ=="], - "@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + "@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="], "@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.0.2", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="], @@ -2453,6 +2454,8 @@ "react-native-screens": ["react-native-screens@4.23.0", "", { "dependencies": { "react-freeze": "^1.0.0", "warn-once": "^0.1.0" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-XhO3aK0UeLpBn4kLecd+J+EDeRRJlI/Ro9Fze06vo1q163VeYtzfU9QS09/VyDFMWR1qxDC1iazCArTPSFFiPw=="], + "react-native-shiki-engine": ["react-native-shiki-engine@0.3.9", "", { "dependencies": { "@shikijs/types": "^3.19.0", "@shikijs/vscode-textmate": "^10.0.2" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-FoCzxk6ODGqbYFXRAgnrZ+ZTt5gbCfvwxxobuvGtvjIAK3GtjV6gOImldgI2hB/oelwqw1gksrFjpN3BqE7jKA=="], + "react-native-svg": ["react-native-svg@15.15.3", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-/k4KYwPBLGcx2f5d4FjE+vCScK7QOX14cl2lIASJ28u4slHHtIhL0SZKU7u9qmRBHxTCKPoPBtN6haT1NENJNA=="], "react-native-worklets": ["react-native-worklets@0.7.2", "", { "dependencies": { "@babel/plugin-transform-arrow-functions": "7.27.1", "@babel/plugin-transform-class-properties": "7.27.1", "@babel/plugin-transform-classes": "7.28.4", "@babel/plugin-transform-nullish-coalescing-operator": "7.27.1", "@babel/plugin-transform-optional-chaining": "7.27.1", "@babel/plugin-transform-shorthand-properties": "7.27.1", "@babel/plugin-transform-template-literals": "7.27.1", "@babel/plugin-transform-unicode-regex": "7.27.1", "@babel/preset-typescript": "7.27.1", "convert-source-map": "2.0.0", "semver": "7.7.3" }, "peerDependencies": { "@babel/core": "*", "react": "*", "react-native": "*" } }, "sha512-DuLu1kMV/Uyl9pQHp3hehAlThoLw7Yk2FwRTpzASOmI+cd4845FWn3m2bk9MnjUw8FBRIyhwLqYm2AJaXDXsog=="], @@ -3023,9 +3026,19 @@ "@rollup/pluginutils/estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="], - "@shikijs/transformers/@shikijs/core": ["@shikijs/core@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-NSWQz0riNb67xthdm5br6lAkvpDJRTgB36fxlo37ZzM2yq0PQFFzbd8psqC2XMPgCzo1fW6cVi18+ArJ44wqgA=="], + "@shikijs/core/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], - "@shikijs/transformers/@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="], + "@shikijs/engine-javascript/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + + "@shikijs/engine-oniguruma/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + + "@shikijs/langs/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + + "@shikijs/primitive/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + + "@shikijs/themes/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + + "@shikijs/transformers/@shikijs/core": ["@shikijs/core@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-NSWQz0riNb67xthdm5br6lAkvpDJRTgB36fxlo37ZzM2yq0PQFFzbd8psqC2XMPgCzo1fW6cVi18+ArJ44wqgA=="], "@tailwindcss/node/tailwindcss": ["tailwindcss@4.2.1", "", {}, "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw=="], @@ -3205,6 +3218,8 @@ "serialize-error/type-fest": ["type-fest@0.13.1", "", {}, "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg=="], + "shiki/@shikijs/types": ["@shikijs/types@4.0.2", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg=="], + "simple-plist/bplist-parser": ["bplist-parser@0.3.1", "", { "dependencies": { "big-integer": "1.6.x" } }, "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA=="], "source-map-support/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="], @@ -3275,8 +3290,6 @@ "@pierre/diffs/shiki/@shikijs/themes": ["@shikijs/themes@3.23.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-5qySYa1ZgAT18HR/ypENL9cUSGOeI2x+4IvYJu4JgVJdizn6kG4ia5Q1jDEOi7gTbN4RbuYtmHh0W3eccOrjMA=="], - "@pierre/diffs/shiki/@shikijs/types": ["@shikijs/types@3.23.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="], - "@react-native/babel-preset/babel-plugin-syntax-hermes-parser/hermes-parser": ["hermes-parser@0.32.0", "", { "dependencies": { "hermes-estree": "0.32.0" } }, "sha512-g4nBOWFpuiTqjR3LZdRxKUkij9iyveWeuks7INEsMX741f3r9xxrOe8TeQfUxtda0eXmiIFiMQzoeSQEno33Hw=="], "@react-native/codegen/glob/minimatch": ["minimatch@3.1.5", "", { "dependencies": { "brace-expansion": "^1.1.7" } }, "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w=="],