Open History to see the last commit
1import { RefreshIcon } from "~/components/ui/refresh-icon";
2import { useAtomValue } from "@effect/atom-react";
3import type { FileDiffContentsLoader, FileDiffMetadata } from "@pierre/diffs";
4import {
5 isAtomCommandInterrupted,
6 squashAtomCommandFailure,
7} from "@t3tools/client-runtime/state/runtime";
8import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
9import type { ScopedThreadRef, RunId } from "@t3tools/contracts";
10import {
11 ArrowRightIcon,
12 CheckIcon,
13 ChevronDownIcon,
14 Columns2Icon,
15 FolderTreeIcon,
16 PilcrowIcon,
17 Rows3Icon,
18 TextWrapIcon,
19} from "lucide-react";
20import { ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown } from "lucide";
21import * as Schema from "effect/Schema";
22import * as DateTime from "effect/DateTime";
23import { useEffect, useRef, useState } from "react";
24import { useCodeViewFileReveal } from "./diffs/useCodeViewFileReveal";
25import { useFilesystemReadAccess } from "~/state/filesystem";
26import { useOpenInPreferredEditor } from "../editorPreferences";
27import { useFileContextMenuHandler } from "../fileContextMenu";
28import { type DraftId } from "../composerDraftStore";
29import { openDiffFilePrimaryAction } from "../diffFileActions";
30import { useCheckpointDiff } from "~/lib/checkpointDiffState";
31import { cn } from "~/lib/utils";
32import { selectThreadDiffPanelSelection, useDiffPanelStore } from "../diffPanelStore";
33import { useLocalStorage } from "../hooks/useLocalStorage";
34import { useTheme } from "../hooks/useTheme";
35import { useStableCallback } from "../hooks/useStableCallback";
36import {
37 buildFileDiffContentVersion,
38 buildFileDiffIdentityKey,
39 getDiffCollapseIconClassName,
40 getDiffLineStat,
41 getRenderablePatch,
42 resolveDiffThemeName,
43 resolveFileDiffPath,
44} from "../lib/diffRendering";
45import { PREFERRED_HIGHLIGHTER } from "../lib/syntaxHighlighting";
46import { areAllDiffFilesCollapsed, toggleAllDiffFiles } from "../lib/diffCollapse";
47import { useWorkspaceMutationRefresh } from "../hooks/useWorkspaceMutationRefresh";
48import { useProject, useThreadCheckpointSummaries, useQuietThreadShell } from "../state/entities";
49import { useClientSettings, updateClientSettings } from "../hooks/useSettings";
50import { formatShortTimestamp } from "../timestampFormat";
51import { DiffFilePathCopyButton } from "./DiffFilePathCopyButton";
52import { DiffPanelLoadingState, DiffPanelShell, type DiffPanelMode } from "./DiffPanelShell";
53import { DiffStatLabel } from "./chat/DiffStatLabel";
54import { AnnotatableCodeView, type AnnotatableCodeViewHandle } from "./diffs/AnnotatableCodeView";
55import { DiffFileTree } from "./diffs/DiffFileTree";
56import { diffFileTreeEntries } from "./diffs/diffFileTree.logic";
57import { Button } from "./ui/button";
58import { MorphIcon } from "~/components/MorphIcon";
59import { ToggleGroup, Toggle } from "./ui/toggle-group";
60import { Switch } from "./ui/switch";
61import {
62 Combobox,
63 ComboboxEmpty,
64 ComboboxSearchInput,
65 ComboboxItem,
66 ComboboxList,
67 ComboboxPopup,
68 ComboboxTrigger,
69} from "./ui/combobox";
70import {
71 DropdownMenu,
72 DropdownMenuContent,
73 DropdownMenuRadioGroup,
74 DropdownMenuRadioItem,
75 DropdownMenuSub,
76 DropdownMenuSubContent,
77 DropdownMenuSubTrigger,
78 DropdownMenuTrigger,
79} from "./ui/menu";
80import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
81import { useEnvironmentQuery } from "../state/query";
82import { useAtomCommand } from "../state/use-atom-command";
83import { serverEnvironment } from "../state/server";
84import { reviewEnvironment } from "../state/review";
85import { vcsEnvironment } from "../state/vcs";
86import { buildBaseRefChoices, filterBaseRefChoices } from "../lib/baseRefChoices";
87import { createGitDiffFileContentsLoader } from "../lib/diffFileContents";
88
89import { useReviewFilePatches } from "./diffs/useReviewFilePatches";
90import { DiffFileLoadingBoundary } from "./diffs/DiffFileLoadingBoundary";
91import { DiffFileStatus } from "./diffs/DiffFileStatus";
92import { useThreadRouteRef } from "../hooks/useThreadRouteTarget";
93
94type DiffThemeType = "light" | "dark";
95const AUTOMATIC_BASE_REF = "__automatic_base_ref__";
96const DIFF_FILE_TREE_STORAGE_KEY = "t3code.diffFileTreeOpen";
97const fileEntryCache = new WeakMap<
98 FileDiffMetadata,
99 { fileDiff: FileDiffMetadata; fileKey: string; fileVersion: number }
100>();
101
102function getCachedFileEntry(fileDiff: FileDiffMetadata) {
103 const cached = fileEntryCache.get(fileDiff);
104 if (cached) return cached;
105 const entry = {
106 fileDiff,
107 fileKey: buildFileDiffIdentityKey(fileDiff),
108 fileVersion: buildFileDiffContentVersion(fileDiff),
109 };
110 fileEntryCache.set(fileDiff, entry);
111 return entry;
112}
113
114interface CollapsedDiffFilesState {
115 readonly scopeKey: string | null;
116 readonly fileKeys: ReadonlySet<string>;
117}
118
119const EMPTY_COLLAPSED_DIFF_FILE_KEYS: ReadonlySet<string> = new Set();
120
121function DiffFileCollapseToggle({
122 filePath,
123 fileKey,
124 collapsed,
125 unavailable,
126 iconClassName,
127 onToggle,
128}: {
129 filePath: string;
130 fileKey: string;
131 collapsed: boolean;
132 unavailable: boolean;
133 iconClassName: string;
134 onToggle: (fileKey: string) => void;
135}) {
136 return (
137 <Tooltip>
138 <TooltipTrigger
139 render={
140 <Button
141 size="icon-micro"
142 variant="ghost"
143 className="-ms-0.5"
144 aria-label={collapsed ? `Expand ${filePath}` : `Collapse ${filePath}`}
145 aria-expanded={!collapsed}
146 disabled={unavailable}
147 onClick={(event) => {
148 event.stopPropagation();
149 onToggle(fileKey);
150 }}
151 />
152 }
153 >
154 <MorphIcon
155 className={cn("size-4", iconClassName)}
156 icon={collapsed ? ChevronRight : ChevronDown}
157 />
158 </TooltipTrigger>
159 <TooltipPopup side="top">{collapsed ? "Expand diff" : "Collapse diff"}</TooltipPopup>
160 </Tooltip>
161 );
162}
163
164function DiffFileHeaderSuffix({
165 filePath,
166 hasStat,
167 error,
168 truncated,
169 onRetry,
170}: {
171 filePath: string;
172 hasStat: boolean;
173 error: boolean;
174 truncated: boolean;
175 onRetry: (path: string) => void;
176}) {
177 return (
178 <>
179 <DiffFilePathCopyButton filePath={filePath} />
180 {hasStat ? (
181 <DiffFileStatus error={error} truncated={truncated} retry={() => onRetry(filePath)} />
182 ) : null}
183 </>
184 );
185}
186
187interface DiffPanelProps {
188 mode?: DiffPanelMode;
189 composerDraftTarget: ScopedThreadRef | DraftId;
190 workspaceMutationId: string | null;
191 visible: boolean;
192}
193
194export default function DiffPanel({
195 mode = "inline",
196 composerDraftTarget,
197 workspaceMutationId,
198 visible,
199}: DiffPanelProps) {
200 const { resolvedTheme } = useTheme();
201 const settings = useClientSettings((settings) => ({
202 diffFilesCollapsed: settings.diffFilesCollapsed,
203 diffIgnoreWhitespace: settings.diffIgnoreWhitespace,
204 diffLayout: settings.diffLayout,
205 timestampFormat: settings.timestampFormat,
206 wordWrap: settings.wordWrap,
207 }));
208 const diffLayout = settings.diffLayout;
209 const [wordWrap, setWordWrap] = useState(settings.wordWrap);
210 const [diffIgnoreWhitespace, setDiffIgnoreWhitespace] = useState(settings.diffIgnoreWhitespace);
211 const [fileTreeOpen, setFileTreeOpen] = useLocalStorage(
212 DIFF_FILE_TREE_STORAGE_KEY,
213 false,
214 Schema.Boolean,
215 );
216 const [baseRefQuery, setBaseRefQuery] = useState("");
217 const [collapsedDiffFiles, setCollapsedDiffFiles] = useState<CollapsedDiffFilesState>(() => ({
218 scopeKey: null,
219 fileKeys: EMPTY_COLLAPSED_DIFF_FILE_KEYS,
220 }));
221 const [codeViewRevision, setCodeViewRevision] = useState(0);
222 const [codeView, setCodeView] = useState<AnnotatableCodeViewHandle | null>(null);
223
224 const routeThreadRef = useThreadRouteRef();
225 const activeThreadId = routeThreadRef?.threadId ?? null;
226 const activeThread = useQuietThreadShell(routeThreadRef);
227 const fileAccess = useFilesystemReadAccess(activeThread?.environmentId ?? null);
228 const { canReadFiles } = fileAccess;
229 const activeProjectId = activeThread?.projectId ?? null;
230 const activeProject = useProject(
231 activeThread && activeProjectId
232 ? {
233 environmentId: activeThread.environmentId,
234 projectId: activeProjectId,
235 }
236 : null,
237 );
238 const activeCwd = activeThread?.worktreePath ?? activeProject?.workspaceRoot;
239 const activeRepositoryRoot = activeThread?.worktreePath
240 ? undefined
241 : activeProject?.repositoryIdentity?.rootPath;
242 const serverConfig = useAtomValue(
243 serverEnvironment.configValueAtom(activeThread?.environmentId ?? null),
244 );
245 const onFileContextMenu = useFileContextMenuHandler(activeThread?.environmentId ?? null);
246 const openInPreferredEditor = useOpenInPreferredEditor(
247 activeThread?.environmentId ?? null,
248 serverConfig?.availableEditors ?? [],
249 );
250 const getDiffFileContents = useAtomCommand(reviewEnvironment.diffFileContents);
251 const gitStatusQuery = useEnvironmentQuery(
252 activeThread !== null && activeThread !== undefined && activeCwd != null
253 ? vcsEnvironment.status({
254 environmentId: activeThread.environmentId,
255 input: { cwd: activeCwd },
256 })
257 : null,
258 );
259 const diffSelection = useDiffPanelStore((state) =>
260 selectThreadDiffPanelSelection(state.byThreadKey, routeThreadRef),
261 );
262 const isGitRepo = gitStatusQuery.data?.isRepo ?? true;
263 const turnDiffSummaries = useThreadCheckpointSummaries(routeThreadRef);
264 const orderedTurnDiffSummaries = turnDiffSummaries.toSorted((left, right) => {
265 if (left.checkpointTurnCount !== right.checkpointTurnCount) {
266 return right.checkpointTurnCount - left.checkpointTurnCount;
267 }
268 return right.completedAt.localeCompare(left.completedAt);
269 });
270
271 useEffect(() => {
272 if (!routeThreadRef || diffSelection.kind !== "turn") return;
273 useDiffPanelStore.getState().reconcileTurnSelection(
274 routeThreadRef,
275 orderedTurnDiffSummaries.map((summary) => summary.runId),
276 );
277 }, [diffSelection, orderedTurnDiffSummaries, routeThreadRef]);
278
279 const selectedRunId = diffSelection.kind === "turn" ? diffSelection.turnId : null;
280 const selectedGitScope = diffSelection.kind === "unstaged" ? "unstaged" : "branch";
281 const selectedBaseRef = diffSelection.kind === "branch" ? diffSelection.baseRef : null;
282 const selectedFilePath = diffSelection.kind === "turn" ? diffSelection.filePath : null;
283 const selectedFileRevealRequestId =
284 diffSelection.kind === "turn" ? diffSelection.revealRequestId : 0;
285 const selectedTurn =
286 selectedRunId === null
287 ? undefined
288 : (orderedTurnDiffSummaries.find((summary) => summary.runId === selectedRunId) ??
289 orderedTurnDiffSummaries[0]);
290 const selectedCheckpointTurnCount = selectedTurn?.checkpointTurnCount;
291 const latestTurn = orderedTurnDiffSummaries[0];
292 const selectedScopeLabel =
293 selectedRunId === null
294 ? selectedGitScope === "unstaged"
295 ? "Uncommitted"
296 : "Changes"
297 : selectedTurn?.runId === latestTurn?.runId
298 ? "Latest turn"
299 : `Turn ${selectedCheckpointTurnCount ?? "?"}`;
300 const reviewSectionId = selectedTurn ? `turn:${selectedTurn.runId}` : selectedGitScope;
301 const collapseScopeKey = routeThreadRef
302 ? `${routeThreadRef.environmentId}:${routeThreadRef.threadId}:${reviewSectionId}`
303 : null;
304 const codeViewMountKey = `${collapseScopeKey ?? reviewSectionId}:${codeViewRevision}`;
305 const reviewSectionTitle = selectedTurn
306 ? `Turn ${selectedCheckpointTurnCount ?? "?"}`
307 : selectedGitScope === "unstaged"
308 ? "Uncommitted"
309 : "Changes";
310 const selectedCheckpointRange =
311 typeof selectedCheckpointTurnCount === "number"
312 ? {
313 fromTurnCount: Math.max(0, selectedCheckpointTurnCount - 1),
314 toTurnCount: selectedCheckpointTurnCount,
315 }
316 : null;
317 const activeCheckpointDiff = useCheckpointDiff(
318 {
319 environmentId: activeThread?.environmentId ?? null,
320 threadId: activeThreadId,
321 fromTurnCount: selectedCheckpointRange?.fromTurnCount ?? null,
322 toTurnCount: selectedCheckpointRange?.toTurnCount ?? null,
323 ignoreWhitespace: diffIgnoreWhitespace,
324 cacheScope: selectedTurn ? `turn:${selectedTurn.runId}` : null,
325 },
326 { enabled: isGitRepo && selectedTurn !== undefined },
327 );
328 const branchDiffPreview = useEnvironmentQuery(
329 canReadFiles && selectedRunId === null && activeThread && activeCwd
330 ? reviewEnvironment.diffPreview({
331 environmentId: activeThread.environmentId,
332 input: {
333 cwd: activeCwd,
334 ...(selectedBaseRef ? { baseRef: selectedBaseRef } : {}),
335 ignoreWhitespace: diffIgnoreWhitespace,
336 },
337 })
338 : null,
339 );
340 const canRefreshGitDiff =
341 isGitRepo && selectedRunId === null && activeThread != null && activeCwd != null;
342 const activeThreadRefreshKey = routeThreadRef
343 ? `${routeThreadRef.environmentId}:${routeThreadRef.threadId}`
344 : null;
345
346 const selectedGitSource = branchDiffPreview.data?.sources.find(
347 (source) => source.kind === (selectedGitScope === "unstaged" ? "working-tree" : "branch-range"),
348 );
349 const refreshPreviewQuery = branchDiffPreview.refresh;
350 const refreshDiffFromUserAction = refreshPreviewQuery;
351
352 const preview = branchDiffPreview.data;
353 const gitDiff = selectedGitSource?.diff;
354
355 const selectedPatch = selectedTurn ? activeCheckpointDiff.data?.diff : gitDiff;
356 const isSelectedPatchTruncated = !selectedTurn && selectedGitSource?.truncated === true;
357 const selectedPatchQuery = selectedTurn ? activeCheckpointDiff : branchDiffPreview;
358 const isLoadingSelectedPatch = selectedPatchQuery.isPending && selectedPatchQuery.data === null;
359 const selectedPatchError = selectedTurn ? activeCheckpointDiff.error : branchDiffPreview.error;
360 const hasResolvedPatch = typeof selectedPatch === "string";
361 const hasNoNetChanges = hasResolvedPatch && selectedPatch.trim().length === 0;
362 const lazySource =
363 !selectedTurn && selectedGitSource?.truncated && selectedGitSource.files
364 ? selectedGitSource
365 : null;
366 const renderablePatch = getRenderablePatch(
367 lazySource ? undefined : selectedPatch,
368 `diff-panel:${resolvedTheme}`,
369 { compactPartialHunkOffsets: selectedRunId === null },
370 );
371 const fileStats = new Map(lazySource?.files?.map((file) => [file.path, file]));
372 const sourceLineStat =
373 !selectedTurn && selectedGitSource?.files
374 ? selectedGitSource.files.reduce(
375 (total, file) => ({
376 additions: total.additions + file.additions,
377 deletions: total.deletions + file.deletions,
378 }),
379 { additions: 0, deletions: 0 },
380 )
381 : null;
382 const currentLoadDiffFiles =
383 selectedRunId === null && activeThread && preview && selectedGitSource && canReadFiles
384 ? createGitDiffFileContentsLoader(getDiffFileContents, {
385 environmentId: activeThread.environmentId,
386 cwd: preview.cwd,
387 sourceKind: selectedGitSource.kind,
388 baseRef: selectedGitSource.baseRef,
389 headRef: selectedGitSource.headRef,
390 cacheKey: selectedGitSource.diffHash,
391 })
392 : undefined;
393 // The code view keeps one loader for its lifetime; a new identity would remount it.
394 const loadDiffFiles: FileDiffContentsLoader = useStableCallback(async (fileDiff) => {
395 if (!currentLoadDiffFiles) {
396 throw new Error("Diff file contents are unavailable for this selection.");
397 }
398 return currentLoadDiffFiles(fileDiff);
399 });
400 const localBranchRefs = useEnvironmentQuery(
401 selectedRunId === null &&
402 selectedGitScope === "branch" &&
403 activeThread &&
404 branchDiffPreview.data?.cwd
405 ? vcsEnvironment.listRefs({
406 environmentId: activeThread.environmentId,
407 input: {
408 cwd: branchDiffPreview.data.cwd,
409 includeMatchingRemoteRefs: true,
410 refKind: "local",
411 ...(baseRefQuery.trim().length > 0 ? { query: baseRefQuery.trim() } : {}),
412 limit: 100,
413 },
414 })
415 : null,
416 );
417 const remoteBranchRefs = useEnvironmentQuery(
418 selectedRunId === null &&
419 selectedGitScope === "branch" &&
420 activeThread &&
421 branchDiffPreview.data?.cwd
422 ? vcsEnvironment.listRefs({
423 environmentId: activeThread.environmentId,
424 input: {
425 cwd: branchDiffPreview.data.cwd,
426 includeMatchingRemoteRefs: true,
427 refKind: "remote",
428 ...(baseRefQuery.trim().length > 0 ? { query: baseRefQuery.trim() } : {}),
429 limit: 100,
430 },
431 })
432 : null,
433 );
434 const baseRefChoices = buildBaseRefChoices(
435 localBranchRefs.data?.refs.filter((ref) => ref.name !== selectedGitSource?.headRef) ?? [],
436 remoteBranchRefs.data?.refs ?? [],
437 );
438 const matchingBaseRefChoices = filterBaseRefChoices(baseRefChoices, baseRefQuery);
439 const valueForBaseRefChoice = (choice: (typeof baseRefChoices)[number]) =>
440 selectedBaseRef && selectedBaseRef === choice.remote?.name
441 ? selectedBaseRef
442 : (choice.local?.name ?? choice.remote?.name ?? choice.id);
443 const baseRefItems = [AUTOMATIC_BASE_REF, ...baseRefChoices.map(valueForBaseRefChoice)];
444 const filteredBaseRefItems = [
445 ...(baseRefQuery.trim().length === 0 ? [AUTOMATIC_BASE_REF] : []),
446 ...matchingBaseRefChoices.map(valueForBaseRefChoice),
447 ];
448 const {
449 scope: filePatchScope,
450 isPending: areFilePatchesPending,
451 fileStates,
452 retry,
453 requestFile,
454 readyFilePaths,
455 renderableFiles,
456 settledFileCount,
457 loadNextFiles,
458 } = useReviewFilePatches({
459 environmentId: activeThread?.environmentId,
460 cwd: branchDiffPreview.data?.cwd,
461 source: lazySource,
462 baseRef: lazySource?.baseRef ?? selectedBaseRef,
463 ignoreWhitespace: diffIgnoreWhitespace,
464 theme: resolvedTheme,
465 revision: branchDiffPreview.data
466 ? DateTime.formatIso(branchDiffPreview.data.generatedAt)
467 : undefined,
468 preview: renderablePatch,
469 });
470 const refreshBranchDiffPreview = refreshPreviewQuery;
471 const previewOpenHandledRef = useRef(false);
472 const refreshDiffForWorkspaceMutation = useStableCallback(() => {
473 previewOpenHandledRef.current = true;
474 refreshBranchDiffPreview();
475 });
476
477 // A mutation refresh also satisfies revalidation for the current opening.
478 useWorkspaceMutationRefresh({
479 enabled: canRefreshGitDiff,
480 mutationId: workspaceMutationId,
481 refresh: refreshDiffForWorkspaceMutation,
482 resourceKey: `diff:${activeThreadRefreshKey ?? ""}`,
483 });
484
485 useEffect(() => {
486 if (!visible || !canReadFiles || !canRefreshGitDiff) {
487 previewOpenHandledRef.current = false;
488 return;
489 }
490 if (previewOpenHandledRef.current) return;
491 previewOpenHandledRef.current = true;
492 if (branchDiffPreview.data !== null && !branchDiffPreview.isPending) {
493 refreshBranchDiffPreview();
494 }
495 }, [
496 branchDiffPreview.data,
497 branchDiffPreview.isPending,
498 canReadFiles,
499 canRefreshGitDiff,
500 refreshBranchDiffPreview,
501 visible,
502 ]);
503
504 useEffect(() => {
505 if (!canRefreshGitDiff) return;
506 const refreshOnFocus = () => refreshBranchDiffPreview();
507 window.addEventListener("focus", refreshOnFocus);
508 return () => window.removeEventListener("focus", refreshOnFocus);
509 }, [canRefreshGitDiff, refreshBranchDiffPreview]);
510
511 const isRefreshingDiff = branchDiffPreview.isPending || areFilePatchesPending;
512 const renderableFileEntries = renderableFiles.map(getCachedFileEntry);
513 const diffFileKeys = renderableFileEntries.map((file) => file.fileKey);
514 const defaultCollapsedDiffFileKeys = settings.diffFilesCollapsed
515 ? new Set(diffFileKeys)
516 : EMPTY_COLLAPSED_DIFF_FILE_KEYS;
517 const collapsedDiffFileKeys =
518 collapsedDiffFiles.scopeKey === collapseScopeKey
519 ? collapsedDiffFiles.fileKeys
520 : defaultCollapsedDiffFileKeys;
521 const renderLoadingBoundary = () =>
522 settledFileCount < renderableFiles.length ? (
523 <DiffFileLoadingBoundary
524 load={loadNextFiles}
525 count={renderableFiles.length - settledFileCount}
526 />
527 ) : null;
528 const codeViewFiles = renderableFileEntries
529 .filter(
530 ({ fileDiff }) =>
531 !lazySource || !readyFilePaths || readyFilePaths.has(resolveFileDiffPath(fileDiff)),
532 )
533 .map(({ fileDiff, fileKey, fileVersion }) => ({
534 fileDiff,
535 filePath: resolveFileDiffPath(fileDiff),
536 fileKey,
537 fileVersion,
538 collapsed:
539 collapsedDiffFileKeys.has(fileKey) || fileDiff.cacheKey?.endsWith(":pending") === true,
540 }));
541 const codeViewFileKeys = codeViewFiles.map((file) => file.fileKey);
542 const allDiffFilesCollapsed = areAllDiffFilesCollapsed(diffFileKeys, collapsedDiffFileKeys);
543 const diffLineStat = sourceLineStat ?? getDiffLineStat(renderableFiles);
544 const fileTreeEntries = diffFileTreeEntries(renderableFiles);
545 const treeRevealScope = { collapseScopeKey, diffSelection };
546 const requestTreeReveal = useCodeViewFileReveal(codeView, treeRevealScope, codeViewFileKeys);
547 const revealDiffFile = (filePath: string) => {
548 const index = renderableFileEntries.findIndex(
549 (candidate) => resolveFileDiffPath(candidate.fileDiff) === filePath,
550 );
551 const file = renderableFileEntries[index];
552 if (!file) return false;
553 setCollapsedDiffFiles((current) => {
554 const next = new Set(
555 current.scopeKey === collapseScopeKey ? current.fileKeys : defaultCollapsedDiffFileKeys,
556 );
557 next.delete(file.fileKey);
558 return { scopeKey: collapseScopeKey, fileKeys: next };
559 });
560 if (lazySource && index >= settledFileCount) {
561 requestFile(index);
562 }
563 requestTreeReveal(file.fileKey);
564 return true;
565 };
566
567 const externalRevealRef = useRef<string | null>(null);
568 useEffect(() => {
569 if (!selectedFilePath) {
570 externalRevealRef.current = null;
571 return;
572 }
573 const key = JSON.stringify([collapseScopeKey, selectedFilePath, selectedFileRevealRequestId]);
574 if (externalRevealRef.current === key) return;
575 if (revealDiffFile(selectedFilePath)) {
576 externalRevealRef.current = key;
577 }
578 }, [collapseScopeKey, selectedFilePath, selectedFileRevealRequestId, revealDiffFile]);
579
580 const openDiffFile = (filePath: string) => {
581 openDiffFilePrimaryAction({
582 threadRef: routeThreadRef,
583 filePath,
584 activeCwd,
585 repositoryRoot: activeRepositoryRoot,
586 openInEditor: (targetPath) => {
587 void (async () => {
588 const result = await openInPreferredEditor(targetPath);
589 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
590 console.warn("Failed to open diff file in editor.", {
591 operation: "open-diff-file",
592 ...(routeThreadRef
593 ? {
594 environmentId: routeThreadRef.environmentId,
595 threadId: routeThreadRef.threadId,
596 }
597 : {}),
598 ...safeErrorLogAttributes(squashAtomCommandFailure(result)),
599 });
600 }
601 })();
602 },
603 });
604 };
605 // Every file header holds these; a new identity per collapse change would redraw them all.
606 const toggleDiffFileCollapsed = useStableCallback((fileKey: string) => {
607 setCollapsedDiffFiles((current) => {
608 const next = new Set(
609 current.scopeKey === collapseScopeKey ? current.fileKeys : defaultCollapsedDiffFileKeys,
610 );
611 if (next.has(fileKey)) {
612 next.delete(fileKey);
613 } else {
614 next.add(fileKey);
615 }
616 return { scopeKey: collapseScopeKey, fileKeys: next };
617 });
618 });
619 // Find can ask again before the unfolded file reaches the viewer, so this must never fold.
620 const unfoldDiffFile = useStableCallback((fileKey: string) => {
621 setCollapsedDiffFiles((current) => {
622 const fileKeys =
623 current.scopeKey === collapseScopeKey ? current.fileKeys : defaultCollapsedDiffFileKeys;
624 if (!fileKeys.has(fileKey)) return current;
625 const next = new Set(fileKeys);
626 next.delete(fileKey);
627 return { scopeKey: collapseScopeKey, fileKeys: next };
628 });
629 });
630
631 const toggleDiffFileCollapse = () => {
632 setCodeViewRevision((current) => current + 1);
633 setCollapsedDiffFiles((current) => {
634 const currentKeys =
635 current.scopeKey === collapseScopeKey ? current.fileKeys : defaultCollapsedDiffFileKeys;
636
637 return {
638 scopeKey: collapseScopeKey,
639 fileKeys: toggleAllDiffFiles(diffFileKeys, currentKeys),
640 };
641 });
642 };
643
644 const selectTurn = (runId: RunId) => {
645 if (!routeThreadRef) return;
646 useDiffPanelStore.getState().selectTurn(routeThreadRef, runId);
647 };
648 const selectGitScope = (scope: "branch" | "unstaged") => {
649 if (!routeThreadRef) return;
650 useDiffPanelStore.getState().selectGitScope(routeThreadRef, scope);
651 };
652 const selectBranchBaseRef = (baseRef: string | null) => {
653 if (!routeThreadRef) return;
654 useDiffPanelStore.getState().selectBranchBaseRef(routeThreadRef, baseRef);
655 };
656 const selectedTurnValue = selectedTurn ? `turn:${selectedTurn.runId}` : "";
657 const selectedScopeValue =
658 selectedRunId === null
659 ? selectedGitScope
660 : selectedTurn?.runId === latestTurn?.runId
661 ? "latest"
662 : selectedTurnValue;
663 const selectScopeValue = (value: string) => {
664 if (value === "unstaged" || value === "branch") {
665 selectGitScope(value);
666 } else if (value === "latest") {
667 if (latestTurn) selectTurn(latestTurn.runId);
668 } else {
669 const turn = orderedTurnDiffSummaries.find((summary) => `turn:${summary.runId}` === value);
670 if (turn) selectTurn(turn.runId);
671 }
672 };
673
674 const headerRow = (
675 <>
676 <div className="flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]">
677 <DropdownMenu>
678 <DropdownMenuTrigger
679 render={<Button size="xs" variant="secondary" />}
680 className="max-w-full"
681 aria-label={`Diff scope: ${selectedScopeLabel}`}
682 >
683 <span className="truncate">{selectedScopeLabel}</span>
684 <ChevronDownIcon className="size-3.5 shrink-0 opacity-70" />
685 </DropdownMenuTrigger>
686 <DropdownMenuContent align="start">
687 <DropdownMenuRadioGroup value={selectedScopeValue} onValueChange={selectScopeValue}>
688 <DropdownMenuRadioItem value="branch" closeOnClick>
689 <span>Changes</span>
690 </DropdownMenuRadioItem>
691 <DropdownMenuRadioItem value="unstaged" closeOnClick>
692 <span>Uncommitted</span>
693 </DropdownMenuRadioItem>
694 <DropdownMenuRadioItem value="latest" closeOnClick>
695 <span>Latest turn</span>
696 </DropdownMenuRadioItem>
697 </DropdownMenuRadioGroup>
698 <DropdownMenuSub>
699 <DropdownMenuSubTrigger>Turn</DropdownMenuSubTrigger>
700 <DropdownMenuSubContent>
701 <DropdownMenuRadioGroup value={selectedTurnValue} onValueChange={selectScopeValue}>
702 {orderedTurnDiffSummaries.map((summary) => {
703 const turnCount = summary.checkpointTurnCount;
704 return (
705 <DropdownMenuRadioItem
706 key={summary.runId}
707 value={`turn:${summary.runId}`}
708 closeOnClick
709 >
710 <span className="flex items-center gap-2">
711 <span>Turn {turnCount}</span>
712 <span className="ml-auto text-xs tabular-nums text-muted-foreground">
713 {formatShortTimestamp(summary.completedAt, settings.timestampFormat)}
714 </span>
715 </span>
716 </DropdownMenuRadioItem>
717 );
718 })}
719 </DropdownMenuRadioGroup>
720 </DropdownMenuSubContent>
721 </DropdownMenuSub>
722 </DropdownMenuContent>
723 </DropdownMenu>
724 {selectedRunId === null && selectedGitScope === "branch" && selectedGitSource?.baseRef && (
725 <div
726 className="flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground"
727 aria-label={`Comparing ${selectedGitSource.headRef ?? "HEAD"} against ${selectedGitSource.baseRef}`}
728 >
729 {/* The head ref keeps 3rem while the row has room; below that the
730 base-ref button keeps 2.25rem so its menu stays reachable. */}
731 <Tooltip>
732 <TooltipTrigger
733 render={
734 <span className="flex min-w-[min(3rem,calc(100%-2.75rem))] items-center gap-2 overflow-hidden" />
735 }
736 >
737 <span className="min-w-0 max-w-48 truncate">
738 {selectedGitSource.headRef ?? "HEAD"}
739 </span>
740 <ArrowRightIcon className="size-3.5 shrink-0 opacity-70" />
741 </TooltipTrigger>
742 <TooltipPopup side="top">
743 {`${selectedGitSource.headRef ?? "HEAD"} → ${selectedGitSource.baseRef}`}
744 </TooltipPopup>
745 </Tooltip>
746 <Combobox
747 items={baseRefItems}
748 filteredItems={filteredBaseRefItems}
749 value={selectedBaseRef ?? AUTOMATIC_BASE_REF}
750 onOpenChange={(open) => {
751 if (!open) setBaseRefQuery("");
752 }}
753 onValueChange={(value) => {
754 if (!value) return;
755 selectBranchBaseRef(value === AUTOMATIC_BASE_REF ? null : value);
756 }}
757 >
758 <ComboboxTrigger
759 render={<Button variant="ghost-muted" size="xs" />}
760 className="min-w-9 max-w-48 shrink"
761 aria-label={`Change comparison target. Currently ${selectedGitSource.baseRef}`}
762 >
763 <span className="min-w-0 truncate">{selectedGitSource.baseRef}</span>
764 <ChevronDownIcon className="size-3.5 shrink-0 opacity-70" />
765 </ComboboxTrigger>
766 <ComboboxPopup
767 align="start"
768 className="w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden"
769 >
770 <ComboboxSearchInput
771 placeholder="Search refs..."
772 value={baseRefQuery}
773 onChange={(event) => setBaseRefQuery(event.target.value)}
774 />
775 <div className="grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-3xs text-muted-foreground uppercase tracking-wide">
776 <span aria-hidden="true" />
777 <div className="grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center">
778 <span>Branch</span>
779 <span className="text-right">Remote</span>
780 </div>
781 </div>
782 <ComboboxEmpty>No matching refs.</ComboboxEmpty>
783 <ComboboxList className="max-h-64 min-w-0 overflow-x-hidden">
784 <ComboboxItem
785 className="w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)]"
786 value={AUTOMATIC_BASE_REF}
787 >
788 <span className="block min-w-0 truncate">Automatic</span>
789 </ComboboxItem>
790 {baseRefChoices.map((choice) => {
791 const item = valueForBaseRefChoice(choice);
792 const hasBoth = choice.local !== null && choice.remote !== null;
793 const useRemote = choice.remote?.name === item;
794 return (
795 <ComboboxItem
796 key={choice.id}
797 className="w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)]"
798 value={item}
799 >
800 <div className="grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden">
801 <span className="block min-w-0 truncate pe-2">{choice.label}</span>
802 {hasBoth ? (
803 <div
804 className="flex justify-end"
805 onClick={(event) => event.stopPropagation()}
806 onPointerDown={(event) => event.stopPropagation()}
807 >
808 <Switch
809 aria-label={`Use remote version of ${choice.label}`}
810 checked={useRemote}
811 className="[--thumb-size:--spacing(3)]"
812 onCheckedChange={(checked) => {
813 const nextRef = checked
814 ? choice.remote?.name
815 : choice.local?.name;
816 if (nextRef) selectBranchBaseRef(nextRef);
817 }}
818 />
819 </div>
820 ) : choice.remote ? (
821 <Tooltip>
822 <TooltipTrigger
823 render={
824 <span className="flex justify-end text-muted-foreground">
825 <CheckIcon
826 role="img"
827 aria-label="Remote only"
828 className="size-3"
829 />
830 </span>
831 }
832 />
833 <TooltipPopup side="top">Remote only</TooltipPopup>
834 </Tooltip>
835 ) : null}
836 </div>
837 </ComboboxItem>
838 );
839 })}
840 </ComboboxList>
841 </ComboboxPopup>
842 </Combobox>
843 </div>
844 )}
845 </div>
846 <div className="flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]">
847 {codeViewFiles.length > 0 || (!selectedTurn && selectedGitSource?.files?.length) ? (
848 <DiffStatLabel
849 additions={diffLineStat.additions}
850 deletions={diffLineStat.deletions}
851 className="mr-1 text-2xs"
852 layout="inline"
853 />
854 ) : null}
855 {canRefreshGitDiff && (
856 <Tooltip>
857 <TooltipTrigger
858 render={
859 <Button
860 type="button"
861 size="icon-sm"
862 variant="ghost"
863 aria-label={isRefreshingDiff ? "Refreshing diff" : "Refresh diff"}
864 onClick={refreshDiffFromUserAction}
865 />
866 }
867 >
868 <RefreshIcon size="sm" refreshing={isRefreshingDiff} />
869 </TooltipTrigger>
870 <TooltipPopup side="top">
871 {isRefreshingDiff ? "Refreshing diff…" : "Refresh diff"}
872 </TooltipPopup>
873 </Tooltip>
874 )}
875 {diffFileKeys.length > 0 && (
876 <Tooltip>
877 <TooltipTrigger
878 render={
879 <Button
880 type="button"
881 size="icon-sm"
882 variant="ghost"
883 aria-label={allDiffFilesCollapsed ? "Expand all files" : "Collapse all files"}
884 onClick={toggleDiffFileCollapse}
885 />
886 }
887 >
888 <MorphIcon
889 className="size-3.5"
890 icon={allDiffFilesCollapsed ? ChevronsUpDown : ChevronsDownUp}
891 />
892 </TooltipTrigger>
893 <TooltipPopup side="top">
894 {allDiffFilesCollapsed ? "Expand all files" : "Collapse all files"}
895 </TooltipPopup>
896 </Tooltip>
897 )}
898 <ToggleGroup
899 aria-label="Diff layout"
900 className="shrink-0"
901 variant="segmented"
902 value={[diffLayout]}
903 onValueChange={(value) => {
904 const next = value[0];
905 if (next === "stacked" || next === "split") {
906 updateClientSettings({ diffLayout: next });
907 }
908 }}
909 >
910 <Toggle aria-label="Stacked diff view" value="stacked">
911 <Rows3Icon className="size-3.5" />
912 </Toggle>
913 <Toggle aria-label="Split diff view" value="split">
914 <Columns2Icon className="size-3.5" />
915 </Toggle>
916 </ToggleGroup>
917 <Tooltip>
918 <TooltipTrigger
919 render={
920 <Toggle
921 aria-label={wordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}
922 variant="ghost"
923 size="sm"
924 pressed={wordWrap}
925 onPressedChange={(pressed) => {
926 setWordWrap(Boolean(pressed));
927 }}
928 />
929 }
930 >
931 <TextWrapIcon className="size-3.5" />
932 </TooltipTrigger>
933 <TooltipPopup side="top">
934 {wordWrap ? "Disable line wrapping" : "Enable line wrapping"}
935 </TooltipPopup>
936 </Tooltip>
937 <Tooltip>
938 <TooltipTrigger
939 render={
940 <Toggle
941 aria-label={
942 diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"
943 }
944 variant="ghost"
945 size="sm"
946 pressed={diffIgnoreWhitespace}
947 onPressedChange={(pressed) => {
948 setDiffIgnoreWhitespace(Boolean(pressed));
949 }}
950 />
951 }
952 >
953 <PilcrowIcon className="size-3.5" />
954 </TooltipTrigger>
955 <TooltipPopup side="top">
956 {diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
957 </TooltipPopup>
958 </Tooltip>
959 {diffFileKeys.length > 0 && (
960 <Tooltip>
961 <TooltipTrigger
962 render={
963 <Toggle
964 aria-label={fileTreeOpen ? "Hide file tree" : "Show file tree"}
965 variant="ghost"
966 size="sm"
967 pressed={fileTreeOpen}
968 onPressedChange={(pressed) => setFileTreeOpen(Boolean(pressed))}
969 />
970 }
971 >
972 <FolderTreeIcon className="size-3.5" />
973 </TooltipTrigger>
974 <TooltipPopup side="top">
975 {fileTreeOpen ? "Hide file tree" : "Show file tree"}
976 </TooltipPopup>
977 </Tooltip>
978 )}
979 </div>
980 </>
981 );
982
983 return (
984 <DiffPanelShell mode={mode} header={headerRow}>
985 {!activeThread ? (
986 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
987 Select a thread to inspect turn diffs.
988 </div>
989 ) : !isGitRepo ? (
990 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
991 Turn diffs are unavailable because this project is not a git repository.
992 </div>
993 ) : selectedRunId !== null && orderedTurnDiffSummaries.length === 0 ? (
994 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
995 No completed turns yet.
996 </div>
997 ) : selectedRunId === null && !canReadFiles ? (
998 fileAccess.isPending ? (
999 <DiffPanelLoadingState label="Checking file access..." />
1000 ) : (
1001 <div className="flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70">
1002 {fileAccess.error ?? "This connection cannot read local diffs."}
1003 </div>
1004 )
1005 ) : (
1006 <>
1007 <div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background">
1008 {isSelectedPatchTruncated && !lazySource && (
1009 <p className="shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-2xs text-muted-foreground">
1010 This preview exceeds the size limit. Changes shown are incomplete.
1011 {selectedGitSource?.files ? " Totals include all changes." : ""}
1012 </p>
1013 )}
1014 {selectedPatchError && !renderablePatch && (
1015 <div className="px-3">
1016 <p className="mb-2 text-2xs text-error/80">{selectedPatchError}</p>
1017 </div>
1018 )}
1019 {!renderablePatch && !lazySource ? (
1020 isLoadingSelectedPatch ? (
1021 <DiffPanelLoadingState
1022 label={
1023 selectedTurn
1024 ? "Loading checkpoint diff..."
1025 : selectedGitScope === "unstaged"
1026 ? "Loading uncommitted changes..."
1027 : "Loading changes..."
1028 }
1029 />
1030 ) : (
1031 <div className="flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70">
1032 <p>
1033 {hasNoNetChanges
1034 ? "No net changes in this selection."
1035 : "No patch available for this selection."}
1036 </p>
1037 </div>
1038 )
1039 ) : lazySource || renderablePatch?.kind === "files" ? (
1040 <div className="flex min-h-0 flex-1 overflow-hidden">
1041 <div
1042 className="min-h-0 min-w-0 flex-1"
1043 onClickCapture={(event) => {
1044 const composedPath = event.nativeEvent.composedPath?.() ?? [];
1045 for (const node of composedPath) {
1046 if (!(node instanceof HTMLElement)) continue;
1047 // Header controls keep their own actions. In particular, the chevron must
1048 // not also trigger the row handler or the two toggles cancel each other.
1049 if (node instanceof HTMLButtonElement || node instanceof HTMLAnchorElement) {
1050 return;
1051 }
1052 }
1053 const title = composedPath.find(
1054 (node): node is HTMLElement =>
1055 node instanceof HTMLElement && node.hasAttribute("data-title"),
1056 );
1057 const filePath = title?.textContent;
1058 if (filePath) {
1059 openDiffFile(filePath);
1060 return;
1061 }
1062 const header = composedPath.find(
1063 (node): node is HTMLElement =>
1064 node instanceof HTMLElement && node.hasAttribute("data-diffs-header"),
1065 );
1066 const headerFilePath = header?.querySelector("[data-title]")?.textContent;
1067 if (!headerFilePath) return;
1068 const file = codeViewFiles.find(
1069 (candidate) => candidate.filePath === headerFilePath,
1070 );
1071 if (file) toggleDiffFileCollapsed(file.fileKey);
1072 }}
1073 onContextMenuCapture={(event) => {
1074 const composedPath = event.nativeEvent.composedPath?.() ?? [];
1075 const title = composedPath.find(
1076 (node): node is HTMLElement =>
1077 node instanceof HTMLElement && node.hasAttribute("data-title"),
1078 );
1079 const filePath = title?.textContent?.trim();
1080 if (!filePath) return;
1081 event.preventDefault();
1082 onFileContextMenu(
1083 {
1084 environmentId: activeThread?.environmentId ?? null,
1085 filePath,
1086 workspaceRoot: activeCwd,
1087 repositoryRoot: activeRepositoryRoot,
1088 },
1089 event,
1090 );
1091 }}
1092 >
1093 <AnnotatableCodeView
1094 key={collapseScopeKey ?? reviewSectionId}
1095 viewerRef={setCodeView}
1096 codeViewKey={`${codeViewMountKey}:${lazySource ? filePatchScope : "preview"}`}
1097 className="h-full min-h-0 overflow-auto"
1098 files={codeViewFiles}
1099 renderCodeViewFooter={renderLoadingBoundary}
1100 sectionId={reviewSectionId}
1101 sectionTitle={reviewSectionTitle}
1102 composerDraftTarget={composerDraftTarget}
1103 renderHeaderFilenameSuffix={(fileDiff) => {
1104 const path = resolveFileDiffPath(fileDiff);
1105 const state = fileStates.get(path);
1106 return (
1107 <DiffFileHeaderSuffix
1108 filePath={path}
1109 hasStat={fileStats.has(path)}
1110 error={state?.error ?? false}
1111 truncated={state?.truncated ?? false}
1112 onRetry={retry}
1113 />
1114 );
1115 }}
1116 {...(lazySource
1117 ? {
1118 unsafeCSSExtra:
1119 "[data-additions-count], [data-deletions-count] { display: none; }",
1120 renderHeaderMetadata: (fileDiff: FileDiffMetadata) => {
1121 const stat = fileStats.get(resolveFileDiffPath(fileDiff));
1122 return stat ? (
1123 <DiffStatLabel
1124 additions={stat.additions}
1125 deletions={stat.deletions}
1126 />
1127 ) : null;
1128 },
1129 }
1130 : {})}
1131 onRevealSearchMatch={unfoldDiffFile}
1132 renderHeaderPrefix={(fileDiff, fileKey) => {
1133 const unavailable = fileDiff.cacheKey?.endsWith(":pending") === true;
1134 return (
1135 <DiffFileCollapseToggle
1136 filePath={resolveFileDiffPath(fileDiff)}
1137 fileKey={fileKey}
1138 collapsed={unavailable || collapsedDiffFileKeys.has(fileKey)}
1139 unavailable={unavailable}
1140 iconClassName={getDiffCollapseIconClassName(fileDiff)}
1141 onToggle={toggleDiffFileCollapsed}
1142 />
1143 );
1144 }}
1145 options={{
1146 diffStyle: diffLayout === "split" ? "split" : "unified",
1147 lineDiffType: "none",
1148 overflow: wordWrap ? "wrap" : "scroll",
1149 theme: resolveDiffThemeName(resolvedTheme),
1150 preferredHighlighter: PREFERRED_HIGHLIGHTER,
1151 themeType: resolvedTheme as DiffThemeType,
1152 stickyHeaders: true,
1153 ...(currentLoadDiffFiles ? { loadDiffFiles } : {}),
1154 }}
1155 />
1156 </div>
1157 {fileTreeOpen ? (
1158 <aside className="flex w-[min(16rem,40%)] min-w-40 shrink-0 border-l border-border/60">
1159 <DiffFileTree
1160 ariaLabel={`${reviewSectionTitle} files`}
1161 entries={fileTreeEntries}
1162 selectedPath={selectedFilePath}
1163 revealRequestId={selectedFileRevealRequestId}
1164 onSelectFile={revealDiffFile}
1165 />
1166 </aside>
1167 ) : null}
1168 </div>
1169 ) : (
1170 <div className="min-h-0 flex-1 overflow-auto p-2">
1171 <div className="space-y-2">
1172 <p className="text-2xs text-muted-foreground/75">
1173 {renderablePatch?.kind === "raw" ? renderablePatch.reason : null}
1174 </p>
1175 <pre
1176 className={cn(
1177 "max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-2xs leading-relaxed text-muted-foreground/90",
1178 wordWrap
1179 ? "overflow-auto whitespace-pre-wrap wrap-break-word"
1180 : "overflow-auto",
1181 )}
1182 >
1183 {renderablePatch?.kind === "raw" ? renderablePatch.text : null}
1184 </pre>
1185 </div>
1186 </div>
1187 )}
1188 </div>
1189 </>
1190 )}
1191 </DiffPanelShell>
1192 );
1193}