Share checked-file progress with the patch view

It had its own copy of the path a file diff goes by.
This commit is contained in:
Rūdolfs Ošiņš
2026-10-01 18:20:25 +02:00
parent 05b6e01dc8
commit 41f93a0921
3 changed files with 39 additions and 41 deletions
+14 -19
View File
@@ -15,7 +15,12 @@
stepIndex,
} from "@app/lib/commentNavigation";
import { diffOptions } from "@app/lib/diffOptions.svelte";
import { fileDiffPath, fileMetaOf, fullFileLoader } from "@app/lib/diffText";
import {
checkedPaths,
fileDiffPath,
fileMetaOf,
fullFileLoader,
} from "@app/lib/diffText";
import { draftReviewStorage } from "@app/lib/draftReviewStorage";
import {
cachedDiffStats,
@@ -207,28 +212,18 @@
const fileMeta = $derived(fileMetaOf(diffFiles));
const reviewedPaths = $derived.by(() => {
if (!draftReviewId) return undefined;
// eslint-disable-next-line svelte/prefer-svelte-reactivity -- rebuilt fresh each derivation
const paths = new Set<string>();
for (const file of diffFiles) {
const path = fileDiffPath(file);
if (draftReviewStorage.isFileChecked(draftReviewId, path)) {
paths.add(path);
}
}
return paths;
const id = draftReviewId;
if (!id) return undefined;
return checkedPaths(diffFiles, path =>
draftReviewStorage.isFileChecked(id, path),
);
});
// Lockfiles and generated manifests are noise in a review, and a file already
// marked reviewed has been dealt with, so both start collapsed.
const collapsedPaths = $derived.by(() => {
// eslint-disable-next-line svelte/prefer-svelte-reactivity -- rebuilt fresh each derivation
const paths = new Set(fileMeta.ignored);
for (const path of reviewedPaths ?? []) {
paths.add(path);
}
return paths;
});
const collapsedPaths = $derived(
new Set([...fileMeta.ignored, ...(reviewedPaths ?? [])]),
);
const commentCounts = $derived.by(() => {
const comments = diffCodeComments;