commit 45d252dc75b4ed49fefff098b991719d324d3bdf
parent 348a42175a7c36eebb2a624ea79af1ed076a7eeb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 29 Oct 2026 13:44:54 -0400
Merge lane/drop-alternate: drop one saved-video alternate (ops drop-saved-alternate, the video page's Drop this alternate)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
13 files changed, 618 insertions(+), 6 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -164,6 +164,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `transcribe-one` | transcribe-one transcribes one video: {"slug", "id", "file"?}. With "file" (an audio file in its dir) that file; without, the video page's Transcribe — the audio on disk, or downloaded first through the channel's managed path. Only a download waits on the platform's queue: the transcription runs as a transcribe-one job on the video's own queue (transcribe-one:<slug>:<id>), at once when nothing is downloaded, else handed off by the whisper-video once the audio is down. A job; --wait follows it through the hand-off to the end of the transcription. "queueKey" names another queue. A youtube-handling video with no audio whose metadata lists English captions has those fetched instead ({"instead": "captions", "message"}, the job the caption download), one with an English caption track on disk is refused; "asr": true transcribes it anyway (no "file"). "salvage": true decodes a damaged file with error tolerance and transcribes what decodes, on the recording's clock, its gaps recorded (the transcript is listed as salvaged); a corrupt-full-source video is salvaged unless "salvage": false — once its full audio was tried: when its record stores an Odysee media URL, that URL is downloaded first, up to 2 times (20 min apart), and the salvage follows only if neither download is clean. "storedUrl": "only" \| "fallback" \| "never" downloads missing audio from the media URL the record stores (Odysee's CDN), read in ranges as its player reads it — no page request with "only", the page first with "fallback" — through the audio check; one new file per platform per 20 min. Absent = the channel's storedUrlDownloads. "whilePaused": true runs this one transcription during a pause-all on a worker the pause alone switched off; the pause stays on (the video page's "Transcribe now (workers paused)"). | |
| `delete-file` | delete-file deletes one file of one video, as its Files list does: {"slug", "id", "file"}. A tiered media file goes with its bytes on the media drive (never a bare link); refused while that drive is not answering. No undo. | |
| `do-not-clean` | do-not-clean sets one video's "Do not clean" marker: {"slug", "id", "keep"?: true}; "keep": false removes it. (keep-videos is the bulk form.) | |
+| `drop-saved-alternate` | drop-saved-alternate deletes one saved alternate of one video, as its "Drop this alternate" button does: {"slug", "id", "file", "dryRun"?}. "file" is a name `get saved-alternates` lists under "alternates"; the active copy, an unlisted name and any path are refused, and so is a store being moved. The file goes from the store and its entry from saved-video.json (the rest of the pointer is untouched); one already gone is cleaned from the pointer ("existed": false). "dryRun": true answers the same and changes nothing. No undo. | |
| `cleanup` | cleanup runs one of a channel's cleanup sweeps as a job: {"slug", "sweep": "transcribed" (audio of transcribed videos — the /cleanup total) \| "extra-formats" \| "wrong-format" \| "failed-transcriptions" (clears the list; deletes nothing)}. Do-not-clean videos are skipped; `get cleanup <slug>` says what each would reclaim. | `pnpm ops cleanup --json '{"slug":"x","sweep":"transcribed"}' --wait` |
| `web-search` | web-search searches the web (DuckDuckGo's HTML page) and answers the results: {"query", "n"?: 6 (at most 20)} -> {results: \[{title, url, snippet}\]}. Read only, through the editor's one web queue: one request at a time, 3 s apart, backing off on a 429 or 503. For context; a web page is never cited as what someone said. | `pnpm ops web-search --json '{"query":"second shop opening","n":5}'` |
| `web-fetch` | web-fetch reads one web page as plain text: {"url", "maxChars"?: 12000 (at most 60000)} -> {page: {url, finalUrl, status, contentType, title?, text, truncated}}. http and https only; a private or loopback host (by name, by address, or by what its name resolves to, every redirect checked) is refused before any request, and so is a page that is not text (a PDF, an image). Read only, on the same web queue as web-search. | `pnpm ops web-fetch --json '{"url":"https://example.com/news/item","maxChars":4000}'` |
@@ -260,6 +261,7 @@ get saved-alternates [<slug>] lists every saved video holding two copies:
the download is longer — and the other stays beside it as
source-media.alt-<h>p-<stamp>.<ext>, flagged for a check. Each video:
its line, the active copy, the alternates (height, seconds, origin).
+ Once one is checked, `drop-saved-alternate` deletes it.
get sites lists every site: id, title, siteUrl, Pages project, audience,
listed, search, publish policy, channels, citedChannels. (`get publish`
is the status.)
diff --git a/common/lib/savedVideo-server.ts b/common/lib/savedVideo-server.ts
@@ -1,4 +1,9 @@
-import { copyFileAtomic, writeJsonAtomic } from "./jsonFile-server";
+import {
+ copyFileAtomic,
+ readJsonFile,
+ withJsonFileLock,
+ writeJsonAtomic,
+} from "./jsonFile-server";
import path from "node:path";
import {
mkdir,
@@ -14,6 +19,7 @@ import {
savedVideoPath,
type SavedVideoFormat,
type SavedVideoKeepReason,
+ type SavedVideoAlternate,
type SavedVideoOrigin,
type SavedVideoPointer,
} from "./savedVideo";
@@ -240,3 +246,109 @@ export async function dropSavedVideo(videoDir: string): Promise<number> {
await pruneEmptyStoreDirs(pointer.dir);
return savedVideoBytes(pointer);
}
+
+// DROP ONE ALTERNATE (operator, 2026-10-29: a copy kept beside a newer download
+// — ytdlp/savedAlternates.ts — is checked, found corrupt or redundant, and has
+// to go without taking the active copy or the video with it). `dropSavedVideo`
+// above removes everything; this removes one named alternate and nothing else.
+//
+// Refused (SavedAlternateRefusal, nothing touched) unless `file` is a bare name
+// listed in the pointer's `alternates` — never the active copy, never a path.
+// The file is removed from the store dir with a plain `rm`, as every store
+// deleter here does: the store is not a video dir, so nothing in it is a tier
+// link (removeMediaFile's rule is for `data/<id>/`). The pointer is rewritten
+// from its RAW JSON with that one entry filtered out — every other key, value
+// and order stays as it was, and `alternates` goes when it empties. IDEMPOTENT:
+// an alternate already gone from disk but still listed is cleaned from the
+// pointer (`existed: false`). `dryRun` answers the same and changes nothing.
+//
+// The read-modify-write holds the pointer's file lock (jsonFile-server), and
+// with `paths` the store's relocation marker refuses it like any store write.
+export class SavedAlternateRefusal extends Error {
+ constructor(message: string) {
+ super(message);
+ this.name = "SavedAlternateRefusal";
+ }
+}
+
+export type DropSavedAlternateResult = {
+ dryRun: boolean;
+ // The pointer's entry for the dropped copy, as it was.
+ alternate: SavedVideoAlternate;
+ // Absolute path of the copy in the store.
+ path: string;
+ // Whether the file was on disk (false: only the pointer entry was left).
+ existed: boolean;
+ // Bytes freed (or that would be): the file's size on disk, else 0.
+ bytes: number;
+ // Alternates the pointer lists after the drop.
+ remaining: number;
+};
+
+export function isBareStoreName(file: string): boolean {
+ return (
+ file !== "" &&
+ file !== "." &&
+ file !== ".." &&
+ !/[/\\\0]/.test(file) &&
+ path.basename(file) === file
+ );
+}
+
+export async function dropSavedAlternate(
+ videoDir: string,
+ file: string,
+ opts: {
+ dryRun?: boolean;
+ paths?: Pick<Paths, "transcriptsDir" | "savedVideosDir">;
+ } = {},
+): Promise<DropSavedAlternateResult> {
+ if (!isBareStoreName(file)) {
+ throw new SavedAlternateRefusal(`"${file}" is not a file name in the store (one path segment)`);
+ }
+ const pointerFile = savedVideoPointerPath(videoDir);
+ return withJsonFileLock(pointerFile, async () => {
+ const read = await readJsonFile(pointerFile);
+ const pointer = read.ok ? parseSavedVideoPointer(read.value) : null;
+ if (!read.ok || !pointer) {
+ throw new SavedAlternateRefusal("This video has no saved-video pointer.");
+ }
+ if (file === pointer.file) {
+ throw new SavedAlternateRefusal(
+ `${file} is the active copy, not an alternate — it is never dropped this way.`,
+ );
+ }
+ const alternate = pointer.alternates?.find((a) => a.file === file);
+ if (!alternate) {
+ const listed = (pointer.alternates ?? []).map((a) => a.file);
+ throw new SavedAlternateRefusal(
+ `${file} is not one of this video's listed alternates` +
+ (listed.length ? ` (${listed.join(", ")})` : " (it lists none)") +
+ ".",
+ );
+ }
+ if (opts.paths) await assertSavedVideosStoreWritable(opts.paths, pointer.dir);
+ const target = path.join(pointer.dir, file);
+ const st = await stat(target).catch(() => null);
+ const existed = st !== null;
+ const remaining = (pointer.alternates ?? []).length - 1;
+ const result: DropSavedAlternateResult = {
+ dryRun: opts.dryRun === true,
+ alternate,
+ path: target,
+ existed,
+ bytes: st?.size ?? 0,
+ remaining,
+ };
+ if (opts.dryRun) return result;
+ if (existed) await rm(target, { force: true });
+ const raw = { ...(read.value as Record<string, unknown>) };
+ const kept = (Array.isArray(raw.alternates) ? raw.alternates : []).filter(
+ (a) => !(a && typeof a === "object" && (a as { file?: unknown }).file === file),
+ );
+ if (kept.length) raw.alternates = kept;
+ else delete raw.alternates;
+ await writeJsonAtomic(pointerFile, raw);
+ return result;
+ });
+}
diff --git a/common/lib/savedVideo.ts b/common/lib/savedVideo.ts
@@ -66,7 +66,8 @@ export type SavedVideoPointer = {
// stays the ACTIVE copy, the one every reader uses; each other copy sits in
// the same `dir` under a name no reader takes for a source
// (`source-media.alt-<h>p-<stamp>.<ext>`), listed here so a later check can
- // decide between them. Absent on every pointer with one copy.
+ // decide between them; `dropSavedAlternate` removes one once checked.
+ // Absent on every pointer with one copy.
alternates?: SavedVideoAlternate[];
// The active copy's own measured length and height, written when an
// alternate was recorded beside it (a landed container has no `format`).
diff --git a/common/lib/savedVideoDropAlternate.test.ts b/common/lib/savedVideoDropAlternate.test.ts
@@ -0,0 +1,167 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import type { Paths } from "./paths";
+import {
+ dropSavedAlternate,
+ loadSavedVideo,
+ SavedAlternateRefusal,
+ savedVideoPointerPath,
+} from "./savedVideo-server";
+import { SAVED_VIDEOS_MARKER_FILENAME, SavedVideosStoreInTransitionError } from "./savedVideoStore";
+
+// Run with:
+// pnpm --filter yt-dlp-transcript-common exec tsx --test lib/savedVideoDropAlternate.test.ts
+//
+// dropSavedAlternate: one listed alternate out of the store and out of the
+// pointer, nothing else — refused for the active copy, an unlisted name and a
+// path; dryRun changes nothing; a file already gone is cleaned from the
+// pointer; every other byte of the pointer is what it was.
+
+const ACTIVE = "source-media.mp4";
+const ALT = "source-media.alt-1080p-20261029142639.mp4";
+const ALT2 = "source-media.alt-360p-20261023172312.mp4";
+
+type Fixture = { paths: Paths; videoDir: string; storeDir: string; pointer: Record<string, unknown> };
+
+async function withVideo(alts: string[], fn: (f: Fixture) => Promise<void>): Promise<void> {
+ const root = await mkdtemp(path.join(tmpdir(), "drop-alternate-"));
+ const paths = {
+ transcriptsDir: root,
+ channelsDir: path.join(root, "channels"),
+ savedVideosDir: path.join(root, "saved-videos"),
+ } as Paths;
+ const videoDir = path.join(paths.channelsDir, "synth", "data", "v1");
+ const storeDir = path.join(paths.savedVideosDir, "synth", "v1");
+ await mkdir(videoDir, { recursive: true });
+ await mkdir(storeDir, { recursive: true });
+ await writeFile(path.join(storeDir, ACTIVE), "active-bytes");
+ for (const a of alts) await writeFile(path.join(storeDir, a), `bytes of ${a}`);
+ // Key order and an unknown key on purpose: the rewrite must keep both.
+ const pointer: Record<string, unknown> = {
+ storedAt: "2026-10-29T14:26:39.000Z",
+ dir: storeDir,
+ file: ACTIVE,
+ bytes: 12,
+ keepReason: "pin",
+ origin: { requestedBy: "persist-videos" },
+ format: { preset: "original", height: 720, vcodec: "avc1" },
+ futureKey: { kept: [1, 2, 3] },
+ alternates: alts.map((a, i) => ({
+ file: a,
+ bytes: 10 + i,
+ storedAt: "2026-10-23T17:23:12.000Z",
+ setAsideAt: "2026-10-29T14:26:39.000Z",
+ height: 1080,
+ someLaterField: "kept",
+ })),
+ probed: { seconds: 4696.5, height: 720 },
+ };
+ await writeFile(savedVideoPointerPath(videoDir), JSON.stringify(pointer, null, 2) + "\n");
+ try {
+ await fn({ paths, videoDir, storeDir, pointer });
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+}
+
+const pointerText = (videoDir: string) => readFile(savedVideoPointerPath(videoDir), "utf8");
+
+test("drops a listed alternate: the file goes, its entry goes, every other byte of the pointer stays", async () => {
+ await withVideo([ALT, ALT2], async ({ paths, videoDir, storeDir, pointer }) => {
+ const r = await dropSavedAlternate(videoDir, ALT, { paths });
+ assert.equal(r.dryRun, false);
+ assert.equal(r.existed, true);
+ assert.equal(r.bytes, `bytes of ${ALT}`.length);
+ assert.equal(r.remaining, 1);
+ assert.equal(r.path, path.join(storeDir, ALT));
+ assert.equal(r.alternate.file, ALT);
+ assert.deepEqual((await readdir(storeDir)).sort(), [ALT2, ACTIVE].sort());
+ const expected = {
+ ...pointer,
+ alternates: (pointer.alternates as { file: string }[]).filter((a) => a.file !== ALT),
+ };
+ assert.equal(await pointerText(videoDir), JSON.stringify(expected, null, 2) + "\n");
+ });
+});
+
+test("the last alternate dropped removes the `alternates` key and nothing else", async () => {
+ await withVideo([ALT], async ({ paths, videoDir, storeDir, pointer }) => {
+ const r = await dropSavedAlternate(videoDir, ALT, { paths });
+ assert.equal(r.remaining, 0);
+ assert.deepEqual(await readdir(storeDir), [ACTIVE]);
+ const { alternates: _gone, ...rest } = pointer;
+ assert.equal(await pointerText(videoDir), JSON.stringify(rest, null, 2) + "\n");
+ const loaded = await loadSavedVideo(videoDir);
+ assert.equal(loaded?.file, ACTIVE);
+ assert.equal(loaded?.alternates, undefined);
+ });
+});
+
+test("refuses the active copy, an unlisted name and any path; nothing is touched", async () => {
+ await withVideo([ALT], async ({ paths, videoDir, storeDir }) => {
+ const before = await pointerText(videoDir);
+ await assert.rejects(dropSavedAlternate(videoDir, ACTIVE, { paths }), (e: Error) => {
+ assert.ok(e instanceof SavedAlternateRefusal);
+ assert.match(e.message, /is the active copy/);
+ return true;
+ });
+ await assert.rejects(dropSavedAlternate(videoDir, "source-media.alt-9p-1.mp4", { paths }), (e: Error) => {
+ assert.ok(e instanceof SavedAlternateRefusal);
+ assert.match(e.message, /is not one of this video's listed alternates \(source-media\.alt-1080p/);
+ return true;
+ });
+ for (const bad of [`../v1/${ALT}`, `x/${ALT}`, path.join(storeDir, ALT), "..", ".", "", "a\\b"]) {
+ await assert.rejects(dropSavedAlternate(videoDir, bad, { paths }), SavedAlternateRefusal, bad);
+ }
+ assert.equal(await pointerText(videoDir), before);
+ assert.deepEqual((await readdir(storeDir)).sort(), [ALT, ACTIVE].sort());
+ });
+});
+
+test("no pointer is a refusal", async () => {
+ await withVideo([ALT], async ({ paths, videoDir }) => {
+ await rm(savedVideoPointerPath(videoDir));
+ await assert.rejects(dropSavedAlternate(videoDir, ALT, { paths }), /no saved-video pointer/);
+ });
+});
+
+test("dryRun answers the same and changes nothing", async () => {
+ await withVideo([ALT], async ({ paths, videoDir, storeDir }) => {
+ const before = await pointerText(videoDir);
+ const r = await dropSavedAlternate(videoDir, ALT, { dryRun: true, paths });
+ assert.equal(r.dryRun, true);
+ assert.equal(r.existed, true);
+ assert.equal(r.remaining, 0);
+ assert.equal(await pointerText(videoDir), before);
+ assert.deepEqual((await readdir(storeDir)).sort(), [ALT, ACTIVE].sort());
+ });
+});
+
+test("idempotent: a listed alternate already gone from disk is cleaned from the pointer; a second drop is refused", async () => {
+ await withVideo([ALT], async ({ paths, videoDir, storeDir }) => {
+ await rm(path.join(storeDir, ALT));
+ const r = await dropSavedAlternate(videoDir, ALT, { paths });
+ assert.equal(r.existed, false);
+ assert.equal(r.bytes, 0);
+ assert.equal((await loadSavedVideo(videoDir))?.alternates, undefined);
+ assert.deepEqual(await readdir(storeDir), [ACTIVE]);
+ await assert.rejects(dropSavedAlternate(videoDir, ALT, { paths }), /not one of this video's listed alternates \(it lists none\)/);
+ });
+});
+
+test("the store's relocation marker holds a drop; a dry run is held too", async () => {
+ await withVideo([ALT], async ({ paths, videoDir, storeDir }) => {
+ await writeFile(
+ path.join(paths.transcriptsDir, SAVED_VIDEOS_MARKER_FILENAME),
+ JSON.stringify({ target: "/mnt/x/saved-videos", direction: "out", startedAt: "", phase: "copy" }),
+ );
+ const before = await pointerText(videoDir);
+ await assert.rejects(dropSavedAlternate(videoDir, ALT, { paths }), SavedVideosStoreInTransitionError);
+ await assert.rejects(dropSavedAlternate(videoDir, ALT, { dryRun: true, paths }), SavedVideosStoreInTransitionError);
+ assert.equal(await pointerText(videoDir), before);
+ assert.deepEqual((await readdir(storeDir)).sort(), [ALT, ACTIVE].sort());
+ });
+});
diff --git a/common/ytdlp/savedAlternates.ts b/common/ytdlp/savedAlternates.ts
@@ -27,6 +27,12 @@
// download's requester, else the old one's — never a
// landed copy's, which now describes the alternate.
//
+// DROPPING ONE after the check (2026-10-29): `dropSavedAlternate`
+// (lib/savedVideo-server.ts) — `pnpm ops drop-saved-alternate`, or the video
+// page's "Drop this alternate" — deletes one listed alternate and its pointer
+// entry, never the active copy. Nothing else deletes one but `dropSavedVideo`
+// (the whole video) and `unpersistSavedVideo` (which brings them back).
+//
// Audio is not part of this: the landed guard's audio half still keeps the
// longer audio.<fmt> (a transcript was made from it), as before.
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -9,6 +9,7 @@
- **Report-video takes no longer keep their build work forever.** On 2026-10-27 /home reached 100 % (5.4 GB free of 1.5 TB), and 131 GB of it was takes' build work: each full take's chrome frames (about 12 GB for the 34-minute Huck cut, kept with `--keep-frames` so a `--from` twin can reuse them), its crossfade batches and its clip segments, swept by hand. `umtool prune <project>` (or `--all`) now lists each take's work files — segments, chrome frames, crossfade batches, encode chunks, raw clip copies, `work-from-*` — and what freeing them gives back, or why the take keeps them: a build running in it or from it (never freed), the picked take, the take the project's manifest is, a pin in `takes/prune.json`, the newest 2 of its group, anything modified in the last 3 days, and the `--from` bases of those. It is a dry run unless `--yes`. Files hard-linked between takes are counted once, and freed only when every take holding them lets them go, so the numbers are what the disk gets back, not a sum of `du`s. The renders, previews, take.json and manifests are never touched, and nothing is followed out of a take through a link. The Takes page says each take's work and why it is kept, with **Free work files** per take and for the project (the plan first, then **Free them**). A take that finishes building now prunes its project by the same rules and says what it freed in its log, and a render that starts with under 30 GB free does the same across every project, and refuses to start under 10 GB with a sentence saying so. `--keep`, `--older-than`, `takes/prune.json` and `UMTOOL_PRUNE_*` / `UMTOOL_DISK_GUARD*` change the rules or turn them off. A dry run over ~/reports on 2026-10-27, after the hand sweep: 27 GiB of work in 32 projects' takes, 4.0 GiB of it free to go (2.4 GiB in the Huck project, whose last three days of takes are all kept). Needs a restart of umtool for the Takes page and for takes made from it; the CLI has it at once.
- **The changelog page opens with its Cut and Amend forms, and pages its notes; the latest release can be amended.** `/changelog` rendered the whole of `editor/CHANGELOG.md` (760 KB of markdown, a 2.9 MB response) before the Cut release form at its bottom, so the form took 1 s to appear on an idle machine and 5-10 s on a busy one. The forms now come first (the Cut release button shows in about 0.35 s where it took 1 s) and the notes stream in after them a page at a time (`?page=N`: whole releases up to about 96 KB a page, `[Unreleased]` always on page 1, an index of every release under **All releases**); a link to an older release's anchor (`/changelog#2026-09-26`, or the new per-release `#v0.9.0`) goes to the page that holds it. **Amend the latest release** re-picks its bump (patch, minor or major, counted from the release before it), its date, folds the notes now under `[Unreleased]` into it, or moves it back under `[Unreleased]`; only the newest release, and a version change commits as that version's release (`Release editor 0.12.0`, the amend in the body). The same writer is `pnpm ops amend-release` and `archilyzer release amend`; `/sites` has the form for the export changelog.
- **Bad clip windows of one video can be evicted, and nothing else.** `evict-clips` only evicted by age, a channel at most, so the four windows cut from a corrupt saved video could not be removed without emptying the channel's cache. `pnpm ops evict-clips --json '{"slug": "<slug>", "id": "<video>"}'` now evicts every cached window of that one video; `"windows": ["<from>-<to>", …]` (the cache's own names) narrows it to those, and `"covering": [{"from": s, "to": s}, …]` to every window that overlaps a span, a wider window holding it included. A set-aside `.desynced` window of a targeted span goes with it, `"dryRun": true` only lists, and `"olderThanDays"` is optional here (still required for the by-age form). A video that does not exist is said in the run's summary, as is a named window that is not cached; an unknown shape is refused by name. umtool asks for it: `umtool fetch <project> --refetch <clipId>[,<clipId>…]` evicts the windows overlapping those clips' fetch spans, waits for that, then fetches as usual (`--refetch-video <slug>/<id>` for every window the project asks of a video; `--dry-run` evicts nothing), and records what went in `fetch-runs.json`. Needs a restart of the editor.
+- **A saved alternate can be dropped once it has been checked.** A download over a copy already in the saved-video store keeps both and flags the other copy (`source-media.alt-<h>p-<stamp>.<ext>`, listed by `pnpm ops get saved-alternates`), but nothing could remove one alternate after the check: the only deleter took the whole video. `pnpm ops drop-saved-alternate --json '{"slug": "<slug>", "id": "<video>", "file": "<alternate>"}'` now deletes that one copy from the store and its entry from `saved-video.json`, leaving the rest of the pointer as it was (`alternates` goes when it empties); `"dryRun": true` says what it would free and changes nothing. The active copy, a name the pointer does not list and any path are refused, and so is a store being moved; an alternate already gone from disk is cleaned from the pointer. The video page's Source video card now lists a saved video's alternates, each with **Drop this alternate** (and a confirm). No undo. Needs a restart of the editor.
## [0.12.0] - 2026-10-28
- **An X post's screenshot is of the post, not of a page in the middle of laying itself out.** On 2026-10-27 a forced capture of TheQuartering's post 2114859155022389342 came out shifted about 100 px: its left edge cut off, X's menu laid over its words and the gap beside the column showing; another post once came out as a strip of the post above it. The shot was a full-page capture, which resizes the page for the moment of the capture — in the X session profile the page saw its window go to 1×1 — and X laid itself out again for that size while it was being captured, so the shot was cut from a different layout than the one measured. A post is now shot from the window as it stands: scrolled into it, the window made taller first when the post is taller than it, so nothing is resized under the shot; and the post is measured again after the shot and shot again if it moved. An X Article's shot is taken the same way. Posts taller than the tallest window (16,384 px) are still shot from a full-page capture. Needs a restart of the editor.
diff --git a/editor/app/api/ops/_writes.test.ts b/editor/app/api/ops/_writes.test.ts
@@ -1,6 +1,6 @@
import test from "node:test";
import assert from "node:assert/strict";
-import { mkdtemp, readFile, rm } from "node:fs/promises";
+import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { callPost, setupOpsCorpus } from "./_testCorpus";
@@ -153,6 +153,60 @@ test("transcribe-one, delete-file and do-not-clean refuse before anything is tou
assert.deepEqual(await corpus.listJobIds(), []);
});
+test("drop-saved-alternate refuses the active copy, an unlisted name and a path; dryRun answers and changes nothing", async () => {
+ const drop = await route("drop-saved-alternate");
+ const storeDir = path.join(corpus.transcripts, "saved-videos", SLUG, VIDEO);
+ const alt = "source-media.alt-1080p-20261029142639.mp4";
+ await mkdir(storeDir, { recursive: true });
+ await writeFile(path.join(storeDir, "source-media.mp4"), "active");
+ await writeFile(path.join(storeDir, alt), "alternate");
+ const pointerFile = path.join(corpus.transcripts, "channels", SLUG, "data", VIDEO, "saved-video.json");
+ const pointer =
+ JSON.stringify(
+ {
+ storedAt: "2026-10-29T14:26:39.000Z",
+ dir: storeDir,
+ file: "source-media.mp4",
+ bytes: 6,
+ alternates: [{ file: alt, bytes: 9, storedAt: "", setAsideAt: "", height: 1080 }],
+ },
+ null,
+ 2,
+ ) + "\n";
+ await writeFile(pointerFile, pointer);
+ try {
+ const active = await callPost(drop, { slug: SLUG, id: VIDEO, file: "source-media.mp4" });
+ assert.equal(active.status, 400);
+ assert.match(String(active.body.error), /is the active copy/);
+ const unlisted = await callPost(drop, { slug: SLUG, id: VIDEO, file: "source-media.alt-1p-1.mp4" });
+ assert.equal(unlisted.status, 400);
+ assert.match(String(unlisted.body.error), /not one of this video's listed alternates/);
+ const traversing = await callPost(drop, { slug: SLUG, id: VIDEO, file: `../${VIDEO}/${alt}` });
+ assert.equal(traversing.status, 400);
+ assert.match(String(traversing.body.error), /not a file name in the store/);
+ const badDry = await callPost(drop, { slug: SLUG, id: VIDEO, file: alt, dryRun: "yes" });
+ assert.equal(badDry.status, 400);
+ assert.match(String(badDry.body.error), /"dryRun" must be a boolean/);
+ const noChannel = await callPost(drop, { slug: "no-such", id: VIDEO, file: alt });
+ assert.equal(noChannel.status, 400);
+ assert.match(String(noChannel.body.error), /No such channel: no-such/);
+
+ const dry = await callPost(drop, { slug: SLUG, id: VIDEO, file: alt, dryRun: true });
+ assert.equal(dry.status, 200, JSON.stringify(dry.body));
+ assert.equal(dry.body.dryRun, true);
+ assert.equal(dry.body.file, alt);
+ assert.equal(dry.body.existed, true);
+ assert.equal(dry.body.bytes, "alternate".length);
+ assert.equal(dry.body.remaining, 0);
+ assert.equal(dry.body.path, path.join(storeDir, alt));
+ assert.equal(await readFile(pointerFile, "utf8"), pointer);
+ assert.deepEqual((await readdir(storeDir)).sort(), [alt, "source-media.mp4"].sort());
+ } finally {
+ await rm(pointerFile, { force: true });
+ await rm(path.join(corpus.transcripts, "saved-videos"), { recursive: true, force: true });
+ }
+});
+
test("cleanup refuses an unknown sweep and a traversing slug, before any job", async () => {
const cleanup = await route("cleanup");
const sweep = await callPost(cleanup, { slug: SLUG, sweep: "everything" });
diff --git a/editor/app/api/ops/drop-saved-alternate/route.ts b/editor/app/api/ops/drop-saved-alternate/route.ts
@@ -0,0 +1,41 @@
+import { NextResponse } from "next/server";
+import { dropSavedAlternateAction } from "../../../channels/[slug]/videos/[id]/videoActions";
+import { ops, opsFail, optBool, reqSlug, reqString, reqVideoId } from "../_lib";
+
+export const dynamic = "force-dynamic";
+
+// POST { slug, id, file, dryRun? }
+// -> { ok, dryRun, file, path, existed, bytes, remaining, alternate }
+//
+// Drop ONE saved alternate of one video — a copy kept beside a newer download
+// (ytdlp/savedAlternates.ts), listed by `get saved-alternates` — after it has
+// been checked. The video page's "Drop this alternate" button. It is
+// dropSavedAlternate (lib/savedVideo-server.ts): refused unless `file` is a
+// bare name the pointer lists as an alternate (never the active copy, never a
+// path), and while the saved-video store is being moved. The file is deleted
+// from the store and its entry from the pointer; everything else in the pointer
+// is left as it was. A file already gone but still listed is cleaned from the
+// pointer (`existed: false`). "dryRun": true answers the same and changes
+// nothing. No undo.
+export async function POST(request: Request) {
+ return ops(request, ["slug", "id", "file", "dryRun"], async (body) => {
+ const res = await dropSavedAlternateAction(
+ reqSlug(body, "slug"),
+ reqVideoId(body, "id"),
+ reqString(body, "file"),
+ { dryRun: optBool(body, "dryRun") ?? false },
+ );
+ if (!res.ok) return opsFail(res.error);
+ const r = res.result;
+ return NextResponse.json({
+ ok: true,
+ dryRun: r.dryRun,
+ file: r.alternate.file,
+ path: r.path,
+ existed: r.existed,
+ bytes: r.bytes,
+ remaining: r.remaining,
+ alternate: r.alternate,
+ });
+ });
+}
diff --git a/editor/app/channels/[slug]/videos/[id]/components/cards/SourceVideoSection.tsx b/editor/app/channels/[slug]/videos/[id]/components/cards/SourceVideoSection.tsx
@@ -3,7 +3,10 @@
import { useState, useTransition } from "react";
import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog";
import type { ChannelHandling } from "yt-dlp-transcript-common/lib/channelConfig";
-import type { SavedVideoPointer } from "yt-dlp-transcript-common/lib/savedVideo";
+import type {
+ SavedVideoAlternate,
+ SavedVideoPointer,
+} from "yt-dlp-transcript-common/lib/savedVideo";
import { formatBytes } from "yt-dlp-transcript-common/lib/format";
import {
DEFAULT_SOURCE_VIDEO_QUALITY,
@@ -14,6 +17,7 @@ import {
import { QueueControl } from "../../../../../../components/QueueControl";
import { cancelJobAction } from "../../../../../../jobs/actions";
import {
+ dropSavedAlternateAction,
redownloadToArchiveAction,
unpersistVideoAction,
} from "../../videoActions";
@@ -210,6 +214,28 @@ function PersistedSourceVideo({
<dt className="text-muted-foreground">Location</dt>
<dd className="font-mono text-xs break-all">{savedVideo.dir}</dd>
</dl>
+ {(savedVideo.alternates?.length ?? 0) > 0 && (
+ <section
+ aria-label="saved alternates"
+ className="flex flex-col gap-2 text-sm"
+ >
+ <p className="text-muted-foreground">
+ Other copies kept beside the active one (a download over a copy
+ already in the store keeps both), flagged for a check. Drop one
+ once it has been checked; the active copy is not touched.
+ </p>
+ <ul className="flex flex-col gap-2">
+ {savedVideo.alternates!.map((a) => (
+ <SavedAlternateRow
+ key={a.file}
+ slug={slug}
+ videoId={videoId}
+ alternate={a}
+ />
+ ))}
+ </ul>
+ </section>
+ )}
<p className="text-xs text-muted-foreground">
Unpersist moves the container back into this video's data dir
(where it appears under Files and plays inline) and removes the
@@ -241,3 +267,93 @@ function PersistedSourceVideo({
</>
);
}
+
+// One alternate with its drop control. The confirm is a second, in-page step
+// (never window.confirm): the first click arms it, "Drop it" deletes.
+function SavedAlternateRow({
+ slug,
+ videoId,
+ alternate,
+}: {
+ slug: string;
+ videoId: string;
+ alternate: SavedVideoAlternate;
+}) {
+ const [pending, startTransition] = useTransition();
+ const [armed, setArmed] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const facts = [
+ alternate.height ? `${alternate.height}p` : "height unknown",
+ alternate.seconds !== undefined
+ ? `${alternate.seconds.toFixed(1)} s`
+ : "length unknown",
+ alternate.vcodec,
+ formatBytes(alternate.bytes),
+ alternate.origin?.requestedBy ?? "download",
+ ]
+ .filter(Boolean)
+ .join(", ");
+ return (
+ <li
+ aria-label={`saved alternate ${alternate.file}`}
+ className="flex flex-col gap-1"
+ >
+ <span>
+ <span className="font-mono break-all">{alternate.file}</span>{" "}
+ <span className="text-muted-foreground">({facts})</span>
+ </span>
+ <span className="flex flex-wrap items-center gap-2">
+ {armed ? (
+ <>
+ <span>Delete this copy from the store? No undo.</span>
+ <button
+ type="button"
+ disabled={pending}
+ aria-label={`confirm drop ${alternate.file}`}
+ onClick={() => {
+ setError(null);
+ startTransition(async () => {
+ const res = await dropSavedAlternateAction(
+ slug,
+ videoId,
+ alternate.file,
+ );
+ if (!res.ok) setError(res.error);
+ setArmed(false);
+ });
+ }}
+ className="px-3 py-1 rounded-md border border-destructive text-destructive text-sm font-medium hover:bg-muted disabled:opacity-50"
+ >
+ {pending ? "Dropping…" : "Drop it"}
+ </button>
+ <button
+ type="button"
+ disabled={pending}
+ onClick={() => setArmed(false)}
+ className="px-3 py-1 rounded-md border border-border text-sm hover:bg-muted disabled:opacity-50"
+ >
+ Cancel
+ </button>
+ </>
+ ) : (
+ <button
+ type="button"
+ aria-label={`drop saved alternate ${alternate.file}`}
+ onClick={() => {
+ setError(null);
+ setArmed(true);
+ }}
+ className="px-3 py-1 rounded-md border border-border text-sm hover:bg-muted"
+ >
+ Drop this alternate
+ </button>
+ )}
+ {error && (
+ <span className="text-destructive" aria-label="drop alternate error">
+ {error}
+ </span>
+ )}
+ </span>
+ </li>
+ );
+}
diff --git a/editor/app/channels/[slug]/videos/[id]/videoActions.ts b/editor/app/channels/[slug]/videos/[id]/videoActions.ts
@@ -75,9 +75,13 @@ import { findVideoSourceUrl } from "yt-dlp-transcript-common/controller/undownlo
import { fullAudioFirst } from "yt-dlp-transcript-common/controller/fullAudioFirst";
import { fullAudioGate } from "yt-dlp-transcript-common/lib/fullAudioFirst-server";
import {
+ dropSavedAlternate,
loadSavedVideo,
+ SavedAlternateRefusal,
unpersistSavedVideo,
+ type DropSavedAlternateResult,
} from "yt-dlp-transcript-common/lib/savedVideo-server";
+import { SavedVideosStoreInTransitionError } from "yt-dlp-transcript-common/lib/savedVideoStore";
import {
savedVideoPath,
type SavedVideoOrigin,
@@ -1410,6 +1414,43 @@ export async function unpersistVideoAction(
return { ok: true };
}
+// DROP ONE SAVED ALTERNATE: the copy kept beside a newer download
+// (ytdlp/savedAlternates.ts), once it has been checked. The video page's
+// "Drop this alternate" button and `pnpm ops drop-saved-alternate` both call
+// this; it is dropSavedAlternate, which refuses the active copy, a name the
+// pointer does not list and any path, and holds while the store is being moved.
+// `dryRun` answers the same and changes nothing. No undo.
+export async function dropSavedAlternateAction(
+ slug: string,
+ videoId: string,
+ file: string,
+ opts: { dryRun?: boolean } = {},
+): Promise<{ ok: true; result: DropSavedAlternateResult } | { ok: false; error: string }> {
+ const paths = getPaths();
+ const config = await readChannelConfig(paths, slug);
+ if (!config) return { ok: false, error: `No such channel: ${slug}` };
+ if (channelTextStall(config)) {
+ return { ok: false, error: `${file} not dropped: this channel's drive is not answering.` };
+ }
+ let result: DropSavedAlternateResult;
+ try {
+ result = await dropSavedAlternate(videoDirOf(slug, videoId), file, {
+ dryRun: opts.dryRun,
+ paths,
+ });
+ } catch (e) {
+ if (e instanceof SavedAlternateRefusal || e instanceof SavedVideosStoreInTransitionError) {
+ return { ok: false, error: e.message };
+ }
+ throw e;
+ }
+ if (!result.dryRun) {
+ revalidatePath(`/channels/${slug}/videos/${videoId}`);
+ revalidatePath("/saved-videos");
+ }
+ return { ok: true, result };
+}
+
// ---------------------------------------------------------------------------
// Sourcing media FOR ANOTHER TOOL, through this app's managed download path.
//
diff --git a/editor/e2e/saved-videos.spec.ts b/editor/e2e/saved-videos.spec.ts
@@ -1,4 +1,4 @@
-import { mkdir, writeFile } from "node:fs/promises";
+import { mkdir, readdir, writeFile } from "node:fs/promises";
import { test, expect } from "@playwright/test";
import {
channelStage,
@@ -116,6 +116,64 @@ test("video page shows persisted source status and an unpersist control", async
).toBeVisible();
});
+// A saved alternate (ytdlp/savedAlternates.ts) is listed under the persisted
+// view and dropped there, through an in-page confirm: the copy leaves the store
+// and the pointer, the active copy stays.
+test("video page drops a saved alternate after an in-page confirm", async ({
+ page,
+}) => {
+ await resetData("one-transcribe-channel-with-audio");
+ const alt = "source-media.alt-1080p-20261029142639.mp4";
+ const storeDir = resolvePath(
+ `${testPaths().transcriptsDir}/saved-videos/${SLUG}/vidA`,
+ );
+ await mkdir(storeDir, { recursive: true });
+ await writeFile(`${storeDir}/source-media.mp4`, "x".repeat(64));
+ await writeFile(`${storeDir}/${alt}`, "y".repeat(32));
+ const pointerFile = resolvePath(
+ `${testPaths().transcriptsDir}/channels/${SLUG}/data/vidA/saved-video.json`,
+ );
+ await writeFile(
+ pointerFile,
+ JSON.stringify(
+ {
+ storedAt: "2026-10-29T14:26:39.000Z",
+ dir: storeDir,
+ file: "source-media.mp4",
+ bytes: 64,
+ keepReason: "pin",
+ alternates: [
+ {
+ file: alt,
+ bytes: 32,
+ storedAt: "2026-10-23T17:23:12.000Z",
+ setAsideAt: "2026-10-29T14:26:39.000Z",
+ height: 1080,
+ seconds: 12.5,
+ },
+ ],
+ },
+ null,
+ 2,
+ ) + "\n",
+ );
+ await fetch(`${baseUrl}/api/test/invalidate-cache`).catch(() => {});
+
+ await page.goto(`/channels/${SLUG}/videos/vidA`);
+ const row = page.getByLabel(`saved alternate ${alt}`, { exact: true });
+ await expect(row).toContainText("1080p, 12.5 s");
+ await row.getByLabel(`drop saved alternate ${alt}`).click();
+ // Armed, not done: nothing is deleted until the confirm.
+ expect((await readdir(storeDir)).sort()).toEqual([alt, "source-media.mp4"].sort());
+ await row.getByLabel(`confirm drop ${alt}`).click();
+ await expect(page.getByLabel("saved alternates", { exact: true })).toHaveCount(0);
+ await expect(page.getByLabel("unpersist source video vidA")).toBeVisible();
+ expect(await readdir(storeDir)).toEqual(["source-media.mp4"]);
+ const pointer = await readJson<{ file: string; alternates?: unknown }>(pointerFile);
+ expect(pointer.file).toBe("source-media.mp4");
+ expect(pointer.alternates).toBeUndefined();
+});
+
// The persist run writes saved-video.json and StreamActionLog then calls
// router.refresh() ITSELF, which re-renders this section with the pointer now on
// disk. The section used to early-return the persisted view at that point,
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -497,7 +497,8 @@ const ACTIONS = [
// writer ({patch}); a platform's rate-limit hold cleared ({platform});
// workers switched on, off or drained ({op, ids}); one video transcribed
// ({slug, id, file?}), one of its files deleted ({slug, id, file}), its
- // do-not-clean marker set ({slug, id, keep?}); a channel's cleanup sweep
+ // do-not-clean marker set ({slug, id, keep?}), one of its saved alternates
+ // dropped ({slug, id, file, dryRun?}); a channel's cleanup sweep
// ({slug, sweep}).
"settings",
"clear-platform-hold",
@@ -511,6 +512,7 @@ const ACTIONS = [
"transcribe-one",
"delete-file",
"do-not-clean",
+ "drop-saved-alternate",
"cleanup",
// WEB READS (release 27 S3): a DuckDuckGo search ({query, n?}) and one
// page as text ({url, maxChars?}), read only, through the editor's one
@@ -1040,6 +1042,7 @@ export function usage() {
" the download is longer — and the other stays beside it as",
" source-media.alt-<h>p-<stamp>.<ext>, flagged for a check. Each video:",
" its line, the active copy, the alternates (height, seconds, origin).",
+ " Once one is checked, `drop-saved-alternate` deletes it.",
"get sites lists every site: id, title, siteUrl, Pages project, audience,",
" listed, search, publish policy, channels, citedChannels. (`get publish`",
" is the status.)",
@@ -1192,6 +1195,15 @@ export function usage() {
'do-not-clean sets one video\'s "Do not clean" marker: {"slug", "id",',
' "keep"?: true}; "keep": false removes it. (keep-videos is the bulk form.)',
"",
+ 'drop-saved-alternate deletes one saved alternate of one video, as its',
+ ' "Drop this alternate" button does: {"slug", "id", "file", "dryRun"?}.',
+ ' "file" is a name `get saved-alternates` lists under "alternates"; the',
+ ' active copy, an unlisted name and any path are refused, and so is a',
+ ' store being moved. The file goes from the store and its entry from',
+ ' saved-video.json (the rest of the pointer is untouched); one already',
+ ' gone is cleaned from the pointer ("existed": false). "dryRun": true',
+ ' answers the same and changes nothing. No undo.',
+ "",
'cleanup runs one of a channel\'s cleanup sweeps as a job: {"slug", "sweep":',
' "transcribed" (audio of transcribed videos — the /cleanup total) |',
' "extra-formats" | "wrong-format" | "failed-transcriptions" (clears the',
diff --git a/scripts/archilyzer-ops.test.mjs b/scripts/archilyzer-ops.test.mjs
@@ -867,6 +867,7 @@ test("the archival writes are POSTs to their routes, each named in the usage", (
"transcribe-one",
"delete-file",
"do-not-clean",
+ "drop-saved-alternate",
"cleanup",
]) {
const p = parseArgs([action, "--json", "{}"]);