commit b8064cfab42374879a3c0310128dc51605d4a99f
parent 3284696092f8e0ed78e1b5481ca1b6fc28f56f2b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 24 Nov 2026 16:40:43 -0500
space-suggestions: caption compression leads the corpus disk's list
leadKindsFor("corpus") puts compress-captions first whatever its subtotal
(orchestrator's default, 24 Nov); get space-suggestions answers the page's groups
in the same order.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
6 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/common/lib/spaceSuggestions.test.ts b/common/lib/spaceSuggestions.test.ts
@@ -8,6 +8,7 @@ import {
diskNeedOrder,
fullestDiskId,
groupSuggestions,
+ leadKindsFor,
moveFit,
refusalGroup,
spaceSummaryLine,
@@ -160,3 +161,12 @@ test("summary line: the fullest disk, its free space and what the scan suggests
assert.match(line!, /^Corpus disk: 25\.00 GB free \(98 % used\) · ~71\.00 GB suggested there/);
assert.equal(spaceSummaryLine(null, {}), null);
});
+
+test("groups: a lead kind goes first whatever its subtotal (caption compression on the corpus disk)", () => {
+ const list = [sug("unstored-container", "corpus", 30), sug("compress-captions", "corpus", 20), sug("evict-clips", "corpus", 25)];
+ assert.deepEqual(groupSuggestions(list).map((g) => g.kind), ["unstored-container", "evict-clips", "compress-captions"]);
+ assert.deepEqual(groupSuggestions(list, { lead: ["compress-captions"] }).map((g) => g.kind), ["compress-captions", "unstored-container", "evict-clips"]);
+ assert.deepEqual(groupSuggestions([sug("evict-clips", "corpus", 1)], { lead: ["compress-captions"] }).map((g) => g.kind), ["evict-clips"]);
+ assert.deepEqual(leadKindsFor("corpus"), ["compress-captions"]);
+ assert.deepEqual(leadKindsFor("platter"), []);
+});
diff --git a/common/lib/spaceSuggestions.ts b/common/lib/spaceSuggestions.ts
@@ -235,8 +235,17 @@ export function suggestionsForDisk(
export type SpaceGroup = { kind: SpaceKind; label: string; bytes: number; laterLow: number; laterHigh: number; rows: SpaceSuggestion[] };
-// By kind, each with what it frees in total; the group that frees most first.
-export function groupSuggestions(list: readonly SpaceSuggestion[]): SpaceGroup[] {
+// The kinds that lead a disk's list whatever their subtotal. On the corpus
+// disk: caption compression (orchestrator's default, 24 Nov) — lossless,
+// reversible, and there the biggest real win (77 GB of plain tracks measured
+// on 24 Nov, about 62 GB back at compress-text's ratio).
+export function leadKindsFor(diskId: string): SpaceKind[] {
+ return diskId === "corpus" ? ["compress-captions"] : [];
+}
+
+// By kind, each with what it frees in total; a `lead` kind first, then the
+// group that frees most.
+export function groupSuggestions(list: readonly SpaceSuggestion[], opts: { lead?: readonly SpaceKind[] } = {}): SpaceGroup[] {
const by = new Map<SpaceKind, SpaceGroup>();
for (const s of list) {
let g = by.get(s.kind);
@@ -251,7 +260,11 @@ export function groupSuggestions(list: readonly SpaceSuggestion[]): SpaceGroup[]
}
const groups = [...by.values()];
for (const g of groups) g.rows.sort((a, b) => freesNow(b) - freesNow(a) || (b.later?.low ?? 0) - (a.later?.low ?? 0));
- return groups.sort((a, b) => b.bytes - a.bytes || b.laterLow - a.laterLow);
+ const lead = (k: SpaceKind) => {
+ const i = opts.lead?.indexOf(k) ?? -1;
+ return i < 0 ? Number.POSITIVE_INFINITY : i;
+ };
+ return groups.sort((a, b) => lead(a.kind) - lead(b.kind) || b.bytes - a.bytes || b.laterLow - a.laterLow);
}
// --- bounds and rules ------------------------------------------------------------
diff --git a/editor/app/api/ops/space-suggestions/route.test.ts b/editor/app/api/ops/space-suggestions/route.test.ts
@@ -39,6 +39,8 @@ test("the fullest disk's suggestions by default, another disk's when named; the
assert.deepEqual((r.body.disks as { id: string }[]).map((d) => d.id), ["corpus", "platter"]);
assert.deepEqual((r.body.suggestions as { kind: string }[]).map((s) => s.kind), ["compress-captions", "evict-clips"]);
assert.equal("probes" in r.body, false);
+ // The page's groups: caption compression leads the corpus disk.
+ assert.deepEqual((r.body.groups as { kind: string }[]).map((g) => g.kind), ["compress-captions", "evict-clips"]);
const p = await callGet(GET, `${URL_BASE}?disk=platter`);
assert.deepEqual((p.body.suggestions as { kind: string }[]).map((s) => s.kind), ["drop-original"]);
assert.ok(typeof p.body.ageSeconds === "number");
diff --git a/editor/app/api/ops/space-suggestions/route.ts b/editor/app/api/ops/space-suggestions/route.ts
@@ -9,8 +9,10 @@ export const dynamic = "force-dynamic";
// GET [?disk=<id>]
// -> { ok, computedAt, ageSeconds, tookMs, jobId?, scan: {jobId, status} | null,
-// floorBytes, disks (most in need first), disk, suggestions (for `disk`,
-// default the fullest, biggest saving first), overflow, held, refused,
+// floorBytes, disks (most in need first), disk, groups (the page's
+// order: caption compression leads the corpus disk, then by subtotal),
+// suggestions (for `disk`, default the fullest, biggest saving first),
+// overflow, held, refused,
// unmanaged, notScanned, compactionAt }
//
// /cleanup/space's list (lane space-suggestions): what the last space scan
diff --git a/editor/app/cleanup/space/lib/loadSpace.ts b/editor/app/cleanup/space/lib/loadSpace.ts
@@ -7,6 +7,8 @@ import {
SPACE_SCAN_JOB_KIND,
diskNeedOrder,
fullestDiskId,
+ groupSuggestions,
+ leadKindsFor,
suggestionsForDisk,
type SpaceScanResult,
} from "yt-dlp-transcript-common/lib/spaceSuggestions";
@@ -58,10 +60,19 @@ export function spaceView(result: SpaceScanResult, disk: string | null) {
const { probes: _probes, ...rest } = result;
void _probes;
const id = disk ?? fullestDiskId(result.disks, result.floorBytes);
+ const suggestions = id ? suggestionsForDisk(result, id) : [];
return {
...rest,
disks: diskNeedOrder(result.disks, result.floorBytes),
disk: id,
- suggestions: id ? suggestionsForDisk(result, id) : [],
+ // The page's groups, in its order (a lead kind first, then by subtotal).
+ groups: groupSuggestions(suggestions, { lead: id ? leadKindsFor(id) : [] }).map((g) => ({
+ kind: g.kind,
+ label: g.label,
+ bytes: g.bytes,
+ count: g.rows.length,
+ ...(g.laterHigh ? { later: [g.laterLow, g.laterHigh] } : {}),
+ })),
+ suggestions,
};
}
diff --git a/editor/app/cleanup/space/page.tsx b/editor/app/cleanup/space/page.tsx
@@ -6,6 +6,7 @@ import {
diskNeedOrder,
fullestDiskId,
groupSuggestions,
+ leadKindsFor,
suggestionsForDisk,
usedPercent,
type SpaceArchiveShare,
@@ -44,7 +45,7 @@ export default async function SpacePage({ searchParams }: { searchParams: Promis
const selected = disks.find((d) => d.id === diskParam && d.status === "ok")?.id ?? fullest;
const diskLabel = Object.fromEntries(disks.map((d) => [d.id, d.label]));
const list = result && selected ? suggestionsForDisk(result, selected) : [];
- const groups = groupSuggestions(list);
+ const groups = groupSuggestions(list, { lead: selected ? leadKindsFor(selected) : [] });
const overflow = result?.overflow.filter((o) => o.disk === selected) ?? [];
return (