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

DiffPanel.tsx

623 lines23.9 KB

1import { parsePatchFiles } from "@pierre/diffs";
2import { FileDiff, type FileDiffMetadata, Virtualizer } from "@pierre/diffs/react";
3import { useQuery } from "@tanstack/react-query";
4import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
5import { ThreadId, type TurnId } from "@t3tools/contracts";
6import { ChevronLeftIcon, ChevronRightIcon, Columns2Icon, Rows3Icon } from "lucide-react";
7import { type WheelEvent as ReactWheelEvent, useCallback, useEffect, useMemo, useRef, useState } from "react";
8import { gitBranchesQueryOptions } from "~/lib/gitReactQuery";
9import { checkpointDiffQueryOptions } from "~/lib/providerReactQuery";
10import { cn } from "~/lib/utils";
11import { readNativeApi } from "../nativeApi";
12import { preferredTerminalEditor, resolvePathLinkTarget } from "../terminal-links";
13import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch";
14import { isElectron } from "../env";
15import { useTheme } from "../hooks/useTheme";
16import { buildPatchCacheKey } from "../lib/diffRendering";
17import { resolveDiffThemeName } from "../lib/diffRendering";
18import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries";
19import { useStore } from "../store";
20import { ToggleGroup, Toggle } from "./ui/toggle-group";
21​
22type DiffRenderMode = "stacked" | "split";
23type DiffThemeType = "light" | "dark";
24​
25const DIFF_PANEL_UNSAFE_CSS = `
26[data-diffs-header],
27[data-diff],
28[data-file],
29[data-error-wrapper],
30[data-virtualizer-buffer] {
31 --diffs-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
32 --diffs-light-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
33 --diffs-dark-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
34 --diffs-token-light-bg: transparent;
35 --diffs-token-dark-bg: transparent;
36​
37 --diffs-bg-context-override: color-mix(in srgb, var(--background) 97%, var(--foreground));
38 --diffs-bg-hover-override: color-mix(in srgb, var(--background) 94%, var(--foreground));
39 --diffs-bg-separator-override: color-mix(in srgb, var(--background) 95%, var(--foreground));
40 --diffs-bg-buffer-override: color-mix(in srgb, var(--background) 90%, var(--foreground));
41​
42 --diffs-bg-addition-override: color-mix(in srgb, var(--background) 92%, var(--success));
43 --diffs-bg-addition-number-override: color-mix(in srgb, var(--background) 88%, var(--success));
44 --diffs-bg-addition-hover-override: color-mix(in srgb, var(--background) 85%, var(--success));
45 --diffs-bg-addition-emphasis-override: color-mix(in srgb, var(--background) 80%, var(--success));
46​
47 --diffs-bg-deletion-override: color-mix(in srgb, var(--background) 92%, var(--destructive));
48 --diffs-bg-deletion-number-override: color-mix(in srgb, var(--background) 88%, var(--destructive));
49 --diffs-bg-deletion-hover-override: color-mix(in srgb, var(--background) 85%, var(--destructive));
50 --diffs-bg-deletion-emphasis-override: color-mix(
51 in srgb,
52 var(--background) 80%,
53 var(--destructive)
54 );
55​
56 background-color: var(--diffs-bg) !important;
58​
59[data-file-info] {
60 background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
61 border-block-color: var(--border) !important;
62 color: var(--foreground) !important;
64​
65[data-diffs-header] {
66 position: sticky !important;
67 top: 0;
68 z-index: 4;
69 background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
70 border-bottom: 1px solid var(--border) !important;
72​
73[data-title] {
74 cursor: pointer;
75 transition:
76 color 120ms ease,
77 text-decoration-color 120ms ease;
78 text-decoration: underline;
79 text-decoration-color: transparent;
80 text-underline-offset: 2px;
82​
83[data-title]:hover {
84 color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
85 text-decoration-color: currentColor;
87`;
88​
89type RenderablePatch =
90 | {
91 kind: "files";
92 files: FileDiffMetadata[];
93 }
94 | {
95 kind: "raw";
96 text: string;
97 reason: string;
98 };
99​
100function getRenderablePatch(
101 patch: string | undefined,
102 cacheScope = "diff-panel",
103): RenderablePatch | null {
104 if (!patch) return null;
105 const normalizedPatch = patch.trim();
106 if (normalizedPatch.length === 0) return null;
107​
108 try {
109 const parsedPatches = parsePatchFiles(
110 normalizedPatch,
111 buildPatchCacheKey(normalizedPatch, cacheScope),
112 );
113 const files = parsedPatches.flatMap((parsedPatch) => parsedPatch.files);
114 if (files.length > 0) {
115 return { kind: "files", files };
116 }
117​
118 return {
119 kind: "raw",
120 text: normalizedPatch,
121 reason: "Unsupported diff format. Showing raw patch.",
122 };
123 } catch {
124 return {
125 kind: "raw",
126 text: normalizedPatch,
127 reason: "Failed to parse patch. Showing raw patch.",
128 };
129 }
131​
132function resolveFileDiffPath(fileDiff: FileDiffMetadata): string {
133 const raw = fileDiff.name ?? fileDiff.prevName ?? "";
134 if (raw.startsWith("a/") || raw.startsWith("b/")) {
135 return raw.slice(2);
136 }
137 return raw;
139​
140function buildFileDiffRenderKey(fileDiff: FileDiffMetadata): string {
141 return fileDiff.cacheKey ?? `${fileDiff.prevName ?? "none"}:${fileDiff.name}`;
143​
144function formatTurnChipTimestamp(isoDate: string): string {
145 return new Intl.DateTimeFormat(undefined, {
146 hour: "numeric",
147 minute: "2-digit",
148 }).format(new Date(isoDate));
150​
151interface DiffPanelProps {
152 mode?: "inline" | "sheet" | "sidebar";
154​
155export { DiffWorkerPoolProvider } from "./DiffWorkerPoolProvider";
156​
157export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
158 const navigate = useNavigate();
159 const { resolvedTheme } = useTheme();
160 const [diffRenderMode, setDiffRenderMode] = useState<DiffRenderMode>("stacked");
161 const patchViewportRef = useRef<HTMLDivElement>(null);
162 const turnStripRef = useRef<HTMLDivElement>(null);
163 const [canScrollTurnStripLeft, setCanScrollTurnStripLeft] = useState(false);
164 const [canScrollTurnStripRight, setCanScrollTurnStripRight] = useState(false);
165 const routeThreadId = useParams({
166 strict: false,
167 select: (params) => (params.threadId ? ThreadId.makeUnsafe(params.threadId) : null),
168 });
169 const diffSearch = useSearch({ strict: false, select: (search) => parseDiffRouteSearch(search) });
170 const activeThreadId = routeThreadId;
171 const activeThread = useStore((store) =>
172 activeThreadId ? store.threads.find((thread) => thread.id === activeThreadId) : undefined,
173 );
174 const activeProjectId = activeThread?.projectId ?? null;
175 const activeProject = useStore((store) =>
176 activeProjectId ? store.projects.find((project) => project.id === activeProjectId) : undefined,
177 );
178 const activeCwd = activeThread?.worktreePath ?? activeProject?.cwd;
179 const gitBranchesQuery = useQuery(gitBranchesQueryOptions(activeCwd ?? null));
180 const isGitRepo = gitBranchesQuery.data?.isRepo ?? true;
181 const { turnDiffSummaries, inferredCheckpointTurnCountByTurnId } =
182 useTurnDiffSummaries(activeThread);
183 const orderedTurnDiffSummaries = useMemo(
184 () =>
185 [...turnDiffSummaries].toSorted((left, right) => {
186 const leftTurnCount =
187 left.checkpointTurnCount ?? inferredCheckpointTurnCountByTurnId[left.turnId] ?? 0;
188 const rightTurnCount =
189 right.checkpointTurnCount ?? inferredCheckpointTurnCountByTurnId[right.turnId] ?? 0;
190 if (leftTurnCount !== rightTurnCount) {
191 return rightTurnCount - leftTurnCount;
192 }
193 return right.completedAt.localeCompare(left.completedAt);
194 }),
195 [inferredCheckpointTurnCountByTurnId, turnDiffSummaries],
196 );
197​
198 const selectedTurnId = diffSearch.diffTurnId ?? null;
199 const selectedFilePath = selectedTurnId !== null ? (diffSearch.diffFilePath ?? null) : null;
200 const selectedTurn =
201 selectedTurnId === null
202 ? undefined
203 : (orderedTurnDiffSummaries.find((summary) => summary.turnId === selectedTurnId) ??
204 orderedTurnDiffSummaries[0]);
205 const selectedCheckpointTurnCount =
206 selectedTurn &&
207 (selectedTurn.checkpointTurnCount ?? inferredCheckpointTurnCountByTurnId[selectedTurn.turnId]);
208 const selectedCheckpointRange = useMemo(
209 () =>
210 typeof selectedCheckpointTurnCount === "number"
211 ? {
212 fromTurnCount: Math.max(0, selectedCheckpointTurnCount - 1),
213 toTurnCount: selectedCheckpointTurnCount,
214 }
215 : null,
216 [selectedCheckpointTurnCount],
217 );
218 const conversationCheckpointTurnCount = useMemo(() => {
219 const turnCounts = orderedTurnDiffSummaries
220 .map(
221 (summary) =>
222 summary.checkpointTurnCount ?? inferredCheckpointTurnCountByTurnId[summary.turnId],
223 )
224 .filter((value): value is number => typeof value === "number");
225 if (turnCounts.length === 0) {
226 return undefined;
227 }
228 const latest = Math.max(...turnCounts);
229 return latest > 0 ? latest : undefined;
230 }, [inferredCheckpointTurnCountByTurnId, orderedTurnDiffSummaries]);
231 const conversationCheckpointRange = useMemo(
232 () =>
233 !selectedTurn && typeof conversationCheckpointTurnCount === "number"
234 ? {
235 fromTurnCount: 0,
236 toTurnCount: conversationCheckpointTurnCount,
237 }
238 : null,
239 [conversationCheckpointTurnCount, selectedTurn],
240 );
241 const activeCheckpointRange = selectedTurn
242 ? selectedCheckpointRange
243 : conversationCheckpointRange;
244 const conversationCacheScope = useMemo(() => {
245 if (selectedTurn || orderedTurnDiffSummaries.length === 0) {
246 return null;
247 }
248 return `conversation:${orderedTurnDiffSummaries.map((summary) => summary.turnId).join(",")}`;
249 }, [orderedTurnDiffSummaries, selectedTurn]);
250 const activeCheckpointDiffQuery = useQuery(
251 checkpointDiffQueryOptions({
252 threadId: activeThreadId,
253 fromTurnCount: activeCheckpointRange?.fromTurnCount ?? null,
254 toTurnCount: activeCheckpointRange?.toTurnCount ?? null,
255 cacheScope: selectedTurn ? `turn:${selectedTurn.turnId}` : conversationCacheScope,
256 enabled: isGitRepo,
257 }),
258 );
259 const selectedTurnCheckpointDiff = selectedTurn
260 ? activeCheckpointDiffQuery.data?.diff
261 : undefined;
262 const conversationCheckpointDiff = selectedTurn
263 ? undefined
264 : activeCheckpointDiffQuery.data?.diff;
265 const isLoadingCheckpointDiff = activeCheckpointDiffQuery.isLoading;
266 const checkpointDiffError =
267 activeCheckpointDiffQuery.error instanceof Error
268 ? activeCheckpointDiffQuery.error.message
269 : activeCheckpointDiffQuery.error
270 ? "Failed to load checkpoint diff."
271 : null;
272​
273 const selectedPatch = selectedTurn ? selectedTurnCheckpointDiff : conversationCheckpointDiff;
274 const hasResolvedPatch = typeof selectedPatch === "string";
275 const hasNoNetChanges = hasResolvedPatch && selectedPatch.trim().length === 0;
276 const renderablePatch = useMemo(
277 () => getRenderablePatch(selectedPatch, `diff-panel:${resolvedTheme}`),
278 [resolvedTheme, selectedPatch],
279 );
280 const renderableFiles = useMemo(() => {
281 if (!renderablePatch || renderablePatch.kind !== "files") {
282 return [];
283 }
284 return renderablePatch.files.toSorted((left, right) =>
285 resolveFileDiffPath(left).localeCompare(resolveFileDiffPath(right), undefined, {
286 numeric: true,
287 sensitivity: "base",
288 }),
289 );
290 }, [renderablePatch]);
291​
292 useEffect(() => {
293 if (!selectedFilePath || !patchViewportRef.current) {
294 return;
295 }
296 const target = Array.from(
297 patchViewportRef.current.querySelectorAll<HTMLElement>("[data-diff-file-path]"),
298 ).find((element) => element.dataset.diffFilePath === selectedFilePath);
299 target?.scrollIntoView({ block: "nearest" });
300 }, [selectedFilePath, renderableFiles]);
301​
302 const openDiffFileInEditor = useCallback(
303 (filePath: string) => {
304 const api = readNativeApi();
305 if (!api) return;
306 const targetPath = activeCwd ? resolvePathLinkTarget(filePath, activeCwd) : filePath;
307 void api.shell.openInEditor(targetPath, preferredTerminalEditor()).catch((error) => {
308 console.warn("Failed to open diff file in editor.", error);
309 });
310 },
311 [activeCwd],
312 );
313​
314 const selectTurn = (turnId: TurnId) => {
315 if (!activeThread) return;
316 void navigate({
317 to: "/$threadId",
318 params: { threadId: activeThread.id },
319 search: (previous) => {
320 const rest = stripDiffSearchParams(previous);
321 return { ...rest, diff: "1", diffTurnId: turnId };
322 },
323 });
324 };
325 const selectWholeConversation = () => {
326 if (!activeThread) return;
327 void navigate({
328 to: "/$threadId",
329 params: { threadId: activeThread.id },
330 search: (previous) => {
331 const rest = stripDiffSearchParams(previous);
332 return { ...rest, diff: "1" };
333 },
334 });
335 };
336 const updateTurnStripScrollState = useCallback(() => {
337 const element = turnStripRef.current;
338 if (!element) {
339 setCanScrollTurnStripLeft(false);
340 setCanScrollTurnStripRight(false);
341 return;
342 }
343​
344 const maxScrollLeft = Math.max(0, element.scrollWidth - element.clientWidth);
345 setCanScrollTurnStripLeft(element.scrollLeft > 4);
346 setCanScrollTurnStripRight(element.scrollLeft < maxScrollLeft - 4);
347 }, []);
348 const scrollTurnStripBy = useCallback((offset: number) => {
349 const element = turnStripRef.current;
350 if (!element) return;
351 element.scrollBy({ left: offset, behavior: "smooth" });
352 }, []);
353 const onTurnStripWheel = useCallback((event: ReactWheelEvent<HTMLDivElement>) => {
354 const element = turnStripRef.current;
355 if (!element) return;
356 if (element.scrollWidth <= element.clientWidth + 1) return;
357 if (Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return;
358​
359 event.preventDefault();
360 element.scrollBy({ left: event.deltaY, behavior: "auto" });
361 }, []);
362​
363 useEffect(() => {
364 const element = turnStripRef.current;
365 if (!element) return;
366​
367 const frameId = window.requestAnimationFrame(() => updateTurnStripScrollState());
368 const onScroll = () => updateTurnStripScrollState();
369​
370 element.addEventListener("scroll", onScroll, { passive: true });
371​
372 const resizeObserver = new ResizeObserver(() => updateTurnStripScrollState());
373 resizeObserver.observe(element);
374​
375 return () => {
376 window.cancelAnimationFrame(frameId);
377 element.removeEventListener("scroll", onScroll);
378 resizeObserver.disconnect();
379 };
380 }, [updateTurnStripScrollState]);
381​
382 useEffect(() => {
383 const frameId = window.requestAnimationFrame(() => updateTurnStripScrollState());
384 return () => {
385 window.cancelAnimationFrame(frameId);
386 };
387 }, [orderedTurnDiffSummaries, selectedTurnId, updateTurnStripScrollState]);
388​
389 useEffect(() => {
390 const element = turnStripRef.current;
391 if (!element) return;
392​
393 const selectedChip = element.querySelector<HTMLElement>("[data-turn-chip-selected='true']");
394 selectedChip?.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
395 }, [selectedTurn?.turnId, selectedTurnId]);
396​
397 const shouldUseDragRegion = isElectron && mode !== "sheet";
398 const headerRow = (
399 <>
400 <div className="relative min-w-0 flex-1 [-webkit-app-region:no-drag]">
401 {canScrollTurnStripLeft && (
402 <div className="pointer-events-none absolute inset-y-0 left-8 z-10 w-7 bg-linear-to-r from-card to-transparent" />
403 )}
404 {canScrollTurnStripRight && (
405 <div className="pointer-events-none absolute inset-y-0 right-8 z-10 w-7 bg-linear-to-l from-card to-transparent" />
406 )}
407 <button
408 type="button"
409 className={cn(
410 "absolute left-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors",
411 canScrollTurnStripLeft
412 ? "border-border/70 hover:border-border hover:text-foreground"
413 : "cursor-not-allowed border-border/40 text-muted-foreground/40",
414 )}
415 onClick={() => scrollTurnStripBy(-180)}
416 disabled={!canScrollTurnStripLeft}
417 aria-label="Scroll turn list left"
418 >
419 <ChevronLeftIcon className="size-3.5" />
420 </button>
421 <button
422 type="button"
423 className={cn(
424 "absolute right-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors",
425 canScrollTurnStripRight
426 ? "border-border/70 hover:border-border hover:text-foreground"
427 : "cursor-not-allowed border-border/40 text-muted-foreground/40",
428 )}
429 onClick={() => scrollTurnStripBy(180)}
430 disabled={!canScrollTurnStripRight}
431 aria-label="Scroll turn list right"
432 >
433 <ChevronRightIcon className="size-3.5" />
434 </button>
435 <div
436 ref={turnStripRef}
437 className="turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5"
438 onWheel={onTurnStripWheel}
439 >
440 <button
441 type="button"
442 className="shrink-0 rounded-md"
443 onClick={selectWholeConversation}
444 data-turn-chip-selected={selectedTurnId === null}
445 >
446 <div
447 className={cn(
448 "rounded-md border px-2 py-1 text-left transition-colors",
449 selectedTurnId === null
450 ? "border-border bg-accent text-accent-foreground"
451 : "border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80",
452 )}
453 >
454 <div className="text-[10px] leading-tight font-medium">All turns</div>
455 </div>
456 </button>
457 {orderedTurnDiffSummaries.map((summary) => (
458 <button
459 key={summary.turnId}
460 type="button"
461 className="shrink-0 rounded-md"
462 onClick={() => selectTurn(summary.turnId)}
463 title={summary.turnId}
464 data-turn-chip-selected={summary.turnId === selectedTurn?.turnId}
465 >
466 <div
467 className={cn(
468 "rounded-md border px-2 py-1 text-left transition-colors",
469 summary.turnId === selectedTurn?.turnId
470 ? "border-border bg-accent text-accent-foreground"
471 : "border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80",
472 )}
473 >
474 <div className="flex items-center gap-1">
475 <span className="text-[10px] leading-tight font-medium">
476 Turn{" "}
477 {summary.checkpointTurnCount ??
478 inferredCheckpointTurnCountByTurnId[summary.turnId] ??
479 "?"}
480 </span>
481 <span className="text-[9px] leading-tight opacity-70">
482 {formatTurnChipTimestamp(summary.completedAt)}
483 </span>
484 </div>
485 </div>
486 </button>
487 ))}
488 </div>
489 </div>
490 <ToggleGroup
491 className="shrink-0 [-webkit-app-region:no-drag]"
492 variant="outline"
493 size="xs"
494 value={[diffRenderMode]}
495 onValueChange={(value) => {
496 const next = value[0];
497 if (next === "stacked" || next === "split") {
498 setDiffRenderMode(next);
499 }
500 }}
501 >
502 <Toggle aria-label="Stacked diff view" value="stacked">
503 <Rows3Icon className="size-3" />
504 </Toggle>
505 <Toggle aria-label="Split diff view" value="split">
506 <Columns2Icon className="size-3" />
507 </Toggle>
508 </ToggleGroup>
509 </>
510 );
511 const headerRowClassName = cn(
512 "flex items-center justify-between gap-2 px-4",
513 shouldUseDragRegion ? "drag-region h-[52px] border-b border-border" : "h-12",
514 );
515​
516 return (
517 <div
518 className={cn(
519 "flex h-full min-w-0 flex-col bg-background",
520 mode === "inline"
521 ? "w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border"
522 : "w-full",
523 )}
524 >
525 {shouldUseDragRegion ? (
526 <div className={headerRowClassName}>{headerRow}</div>
527 ) : (
528 <div className="border-b border-border">
529 <div className={headerRowClassName}>{headerRow}</div>
530 </div>
531 )}
532​
533 {!activeThread ? (
534 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
535 Select a thread to inspect turn diffs.
536 </div>
537 ) : !isGitRepo ? (
538 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
539 Turn diffs are unavailable because this project is not a git repository.
540 </div>
541 ) : orderedTurnDiffSummaries.length === 0 ? (
542 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
543 No completed turns yet.
544 </div>
545 ) : (
546 <>
547 <div
548 ref={patchViewportRef}
549 className="diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden"
550 >
551 {checkpointDiffError && !renderablePatch && (
552 <div className="px-3">
553 <p className="mb-2 text-[11px] text-red-500/80">{checkpointDiffError}</p>
554 </div>
555 )}
556 {!renderablePatch ? (
557 <div className="flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70">
558 <p>
559 {isLoadingCheckpointDiff
560 ? "Loading checkpoint diff..."
561 : hasNoNetChanges
562 ? "No net changes in this selection."
563 : "No patch available for this selection."}
564 </p>
565 </div>
566 ) : renderablePatch.kind === "files" ? (
567 <Virtualizer
568 className="diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2"
569 config={{
570 overscrollSize: 600,
571 intersectionObserverMargin: 1200,
572 }}
573 >
574 {renderableFiles.map((fileDiff) => {
575 const filePath = resolveFileDiffPath(fileDiff);
576 const fileKey = buildFileDiffRenderKey(fileDiff);
577 const themedFileKey = `${fileKey}:${resolvedTheme}`;
578 return (
579 <div
580 key={themedFileKey}
581 data-diff-file-path={filePath}
582 className="diff-render-file mb-2 rounded-md first:mt-2 last:mb-0"
583 onClickCapture={(event) => {
584 const nativeEvent = event.nativeEvent as MouseEvent;
585 const composedPath = nativeEvent.composedPath?.() ?? [];
586 const clickedHeader = composedPath.some((node) => {
587 if (!(node instanceof Element)) return false;
588 return node.hasAttribute("data-title");
589 });
590 if (!clickedHeader) return;
591 openDiffFileInEditor(filePath);
592 }}
593 >
594 <FileDiff
595 fileDiff={fileDiff}
596 options={{
597 diffStyle: diffRenderMode === "split" ? "split" : "unified",
598 lineDiffType: "none",
599 theme: resolveDiffThemeName(resolvedTheme),
600 themeType: resolvedTheme as DiffThemeType,
601 unsafeCSS: DIFF_PANEL_UNSAFE_CSS,
602 }}
603 />
604 </div>
605 );
606 })}
607 </Virtualizer>
608 ) : (
609 <div className="h-full overflow-auto p-2">
610 <div className="space-y-2">
611 <p className="text-[11px] text-muted-foreground/75">{renderablePatch.reason}</p>
612 <pre className="max-h-[72vh] overflow-auto rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90">
613 {renderablePatch.text}
614 </pre>
615 </div>
616 </div>
617 )}
618 </div>
619 </>
620 )}
621 </div>
622 );