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

DiffPanel.tsx

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