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

DiffPanel.tsx

1,195 lines47.7 KB

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