explorer: Show files httpd did not diff as too large

httpd marks files it does not diff because of their size with
`"tooLarge": true` on their binary diff content. Show them as "Diff too
large" instead of "Binary file", which they usually are not.

When httpd leaves out files, say how many are not shown, and take the
number of changed files in the summary from the stats, which count
every file.
This commit is contained in:
Rūdolfs Ošiņš
2026-12-01 16:30:56 +01:00
parent 3d353ca8ad
commit 180b594749
3 changed files with 30 additions and 2 deletions
+2 -1
View File
@@ -133,7 +133,7 @@ const diffContentSchema = discriminatedUnion("type", [
literal("bothMissing"),
]),
}),
object({ type: literal("binary") }),
object({ type: literal("binary"), tooLarge: boolean().optional() }),
object({ type: literal("empty") }),
]);
const diffChangesetSchema = object({
@@ -225,6 +225,7 @@ const diffSchema = object({
insertions: number(),
deletions: number(),
}),
truncated: boolean().optional(),
});
type Commit = z.infer<typeof commitSchema>;
+24 -1
View File
@@ -6,6 +6,7 @@
import IconButton from "@app/components/IconButton.svelte";
import Icon from "@app/components/Icon.svelte";
import Observer, { intersection } from "@app/components/Observer.svelte";
import Placeholder from "@app/components/Placeholder.svelte";
export let diff: Diff | undefined = undefined;
export let files: Record<string, CommitBlob> | undefined = undefined;
@@ -15,6 +16,10 @@
let expanded = true;
$: filesLeftOut = diff?.truncated
? diff.stats.filesChanged - diff.files.length
: 0;
function pluralize(singular: string, count: number): string {
return count === 1 ? singular : `${singular}s`;
}
@@ -63,6 +68,9 @@
border-radius: var(--border-radius-md);
overflow: clip;
}
.files-left-out {
padding: 0.5rem 0 1rem 0;
}
.summary {
font: var(--txt-body-m-regular);
}
@@ -76,7 +84,14 @@
{#if diff}
<div class="header">
<div class="summary">
<span>{diffDescription(diff.files)}</span>
<span>
{#if filesLeftOut > 0}
{diff.stats.filesChanged}
{pluralize("file", diff.stats.filesChanged)} changed
{:else}
{diffDescription(diff.files)}
{/if}
</span>
with
<span class:additions={diff.stats.insertions > 0}>
{diff.stats.insertions}
@@ -135,5 +150,13 @@
</div>
{/each}
</Observer>
{#if filesLeftOut > 0}
<div class="files-left-out">
<Placeholder
iconName="document"
caption={`${filesLeftOut} more changed ${pluralize("file", filesLeftOut)} not shown, the diff is too large`}
inline />
</div>
{/if}
</div>
{/if}
@@ -549,6 +549,10 @@
title="The file may be too large for the seed node to serve, or it failed to load.">
<Placeholder caption="Preview not available" inline />
</div>
{:else if fileDiff.type === "binary" && fileDiff.tooLarge}
<div style:margin="1rem 0">
<Placeholder iconName="document" caption="Diff too large" inline />
</div>
{:else}
<div style:margin="1rem 0">
<Placeholder iconName="binary" caption="Binary file" inline />