Skip to content

Commit 624a668

Browse files
fix(web): simplify orphaned diff draft recovery
1 parent de7c79b commit 624a668

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

‎apps/web/src/components/DiffPanel.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ export default function DiffPanel({
513513
collapsedDiffFileKeys.has(fileKey) || fileDiff.cacheKey?.endsWith(":pending") === true,
514514
}));
515515
const codeViewFileKeys = codeViewFiles.map((file) => file.fileKey);
516-
const pendingFiles = renderableFileEntries
517-
.filter(({ fileDiff }) => fileDiff.cacheKey?.endsWith(":pending"))
518-
.map(({ fileDiff }) => fileDiff);
516+
const pendingFiles = renderableFiles.filter((file) => file.cacheKey?.endsWith(":pending"));
519517
const allDiffFilesCollapsed = areAllDiffFilesCollapsed(diffFileKeys, collapsedDiffFileKeys);
520518
const diffLineStat = sourceLineStat ?? getDiffLineStat(renderableFiles);
521519
const fileTreeEntries = diffFileTreeEntries(renderableFiles);

apps/web/src/components/diffs/AnnotatableCodeView.test.tsx renamed to apps/web/src/components/diffs/AnnotatableCodeView.browser.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @vitest-environment jsdom
21
import type { CodeViewDiffItem, FileDiffMetadata, SelectedLineRange } from "@pierre/diffs";
32
import { parsePatchFiles } from "@pierre/diffs/utils/parsePatchFiles";
43
import { act, StrictMode, type ComponentProps } from "react";

‎apps/web/src/components/diffs/AnnotatableCodeView.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ interface AnnotatableCodeViewProps {
8080
fileVersion: number;
8181
collapsed: boolean;
8282
}>;
83-
/** Files with unavailable patches; placeholder change types are provisional. */
8483
pendingFiles: ReadonlyArray<FileDiffMetadata>;
8584
sectionId: string;
8685
sectionTitle: string;
@@ -142,6 +141,7 @@ export function AnnotatableCodeView({
142141
if (
143142
draft !== null &&
144143
!filesByKey.has(draft.fileKey) &&
144+
// Lazy placeholders have provisional change types, so match both paths instead.
145145
!pendingFiles.some(
146146
(file) =>
147147
resolveFileDiffPath(file) === draft.filePath &&
@@ -254,7 +254,6 @@ export function AnnotatableCodeView({
254254
});
255255
};
256256

257-
const hasOpenComment = draft !== null;
258257
return (
259258
<StyledDiffCodeView<DiffCommentAnnotationGroup>
260259
key={codeViewKey}
@@ -274,8 +273,8 @@ export function AnnotatableCodeView({
274273
onRevealSearchMatch={(item) => onRevealSearchMatch(item.id)}
275274
options={{
276275
...options,
277-
enableGutterUtility: !hasOpenComment,
278-
enableLineSelection: !hasOpenComment,
276+
enableGutterUtility: draft === null,
277+
enableLineSelection: draft === null,
279278
onGutterUtilityClick: beginComment,
280279
}}
281280
renderHeaderFilenameSuffix={(item) =>

0 commit comments

Comments
 (0)