Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit b3e5722a01ab28abe52146593760a0bd0ec08b5f
parent cd2898b5f9acba890459fead66412abe15c2f466
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 24 Nov 2026 18:59:33 -0500

space-suggestions REVIEW-1 note 2: a disk's suggested total counts each file once

Of one channel's overlapping kinds (the clean sweeps, a move, live-chat
compression) the larger, never the sum; a move that does not fit left out.
The summary line and the page's heading use it.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/lib/spaceSuggestions.test.ts | 16++++++++++++++++
Mcommon/lib/spaceSuggestions.ts | 24+++++++++++++++++++++++-
Meditor/app/cleanup/space/page.tsx | 4++++
3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/common/lib/spaceSuggestions.test.ts b/common/lib/spaceSuggestions.test.ts @@ -6,6 +6,7 @@ import { capPerKind, compressSaving, diskNeedOrder, + diskSuggestedBytes, fullestDiskId, groupSuggestions, leadKindsFor, @@ -170,3 +171,18 @@ test("groups: a lead kind goes first whatever its subtotal (caption compression assert.deepEqual(leadKindsFor("corpus"), ["compress-captions"]); assert.deepEqual(leadKindsFor("platter"), []); }); + +test("a disk's suggested total counts each file once: one channel's overlapping kinds are the larger, a move that does not fit is left out", () => { + const list = [ + sug("clean-audio", "corpus", 10, { slug: "a" }), + sug("clean-extra-formats", "corpus", 4, { slug: "a" }), + sug("move-media", "corpus", 12, { slug: "a" }), + sug("compress-live-chat", "corpus", 3, { slug: "a" }), + sug("clean-audio", "corpus", 5, { slug: "b" }), + sug("move-media", "corpus", 50, { slug: "c", disabled: "does not fit" }), + sug("compress-captions", "corpus", 20, { slug: "a" }), + sug("evict-clips", "corpus", 1, { slug: "a" }), + ]; + // a: max(10, 4, 12, 3) = 12; b: 5; c's move left out; captions 20 and clips 1 add. + assert.equal(diskSuggestedBytes(list), (12 + 5 + 20 + 1) * GB); +}); diff --git a/common/lib/spaceSuggestions.ts b/common/lib/spaceSuggestions.ts @@ -352,6 +352,28 @@ export function alternateDisposition( return { offer: true }; } +// THE KINDS THAT COUNT THE SAME FILES: a channel's audio is what the clean +// sweeps remove and what a move carries; its raw live chat is what a move +// carries and what compression shrinks. +const OVERLAPPING: ReadonlySet<SpaceKind> = new Set(["clean-audio", "clean-extra-formats", "move-media", "compress-live-chat"]); + +// What a disk's list frees, each file once (review 1, not blocking 2): of one +// channel's overlapping kinds the larger, never the sum; a row that cannot +// run (a move that does not fit) left out; what frees nothing now counts 0. +export function diskSuggestedBytes(list: readonly SpaceSuggestion[]): number { + let total = 0; + const overlap = new Map<string, number>(); + for (const s of list) { + if (s.disabled || !s.frees) continue; + if (OVERLAPPING.has(s.kind) && s.slug) { + const k = `${s.slug}\u0000${s.frees.disk}`; + overlap.set(k, Math.max(overlap.get(k) ?? 0, s.frees.bytes)); + } else total += s.frees.bytes; + } + for (const v of overlap.values()) total += v; + return total; +} + // --- words ----------------------------------------------------------------------- export function usedPercent(d: Pick<SpaceDisk, "sizeBytes" | "freeBytes">, free = d.freeBytes): number | null { @@ -382,7 +404,7 @@ export function spaceSummaryLine( if (!d) return null; const free = live[d.id] ?? d.freeBytes; const pct = usedPercent(d, free ?? null); - const suggested = suggestionsForDisk(result, d.id).reduce((t, s) => t + freesNow(s), 0); + const suggested = diskSuggestedBytes(suggestionsForDisk(result, d.id)); return ( `${d.label}: ${free === null || free === undefined ? "free space unknown" : `${formatBytes(free)} free`}` + `${pct === null ? "" : ` (${pct} % used)`} ยท ~${formatBytes(suggested)} suggested there` diff --git a/editor/app/cleanup/space/page.tsx b/editor/app/cleanup/space/page.tsx @@ -4,6 +4,7 @@ import { formatBytes } from "yt-dlp-transcript-common/lib/format"; import { ageText, diskNeedOrder, + diskSuggestedBytes, fullestDiskId, groupSuggestions, leadKindsFor, @@ -82,6 +83,9 @@ export default async function SpacePage({ searchParams }: { searchParams: Promis <section aria-label="suggestions" className="flex flex-col gap-4"> <h2 className="text-lg font-semibold"> {selected ? `What frees space on ${diskLabel[selected] ?? selected}` : "No disk to free"} + {selected && list.length > 0 && ( + <span className="ml-2 font-mono text-sm font-normal text-muted-foreground">~{formatBytes(diskSuggestedBytes(list))}, each file once</span> + )} </h2> {groups.length === 0 && <p className="text-sm text-muted-foreground">Nothing the scan found frees space here.</p>} {groups.map((g) => (