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