commit 3e2a8771a28de9f9002a91edfe2f5dc280711d34
parent 0019fff50ad7c36250367936195de6c6fabbc771
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 28 Oct 2026 23:27:59 -0400
editor: /changelog shows its forms first and pages its notes; Amend the latest release
/changelog rendered all of editor/CHANGELOG.md (757 KB of markdown: a 2.9 MB
response, 1.6 MB of it the RSC payload) with the Cut release form at the
bottom; the form took 4.5-9.7 s to appear in a browser. The Cut and Amend
forms are now the page's shell, and the notes stream in after them (Suspense)
one size-budgeted page at a time, ?page=N, with an index of every release.
Release headings carry a version id (#v0.9.0) beside the date id, and
ChangelogAnchorResolver sends a link to an anchor on another page there.
Amend the latest release: the form on /changelog (and, for the export
changelog, on /sites), POST /api/ops/amend-release (`pnpm ops amend-release`)
and `archilyzer release amend` — all over amendRelease. COMMANDS.md
regenerated. e2e: changelog-pages.spec.ts.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
18 files changed, 909 insertions(+), 13 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -95,6 +95,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi
| `archilyzer doctor` | `[--json]` | read-only report: node, the checkout, the corpus, settings, every tool, the port block; exit 1 on a failure |
| `archilyzer release show` | `[editor\|export]` | latest release, its date, how many bullets wait under \[Unreleased\] |
| `archilyzer release cut` | `<editor\|export\|all> <X.Y.Z\|next\|next-minor> [--commit] [--date YYYY-MM-DD]` | \[Unreleased\] -> a dated heading; all = both, one version, two commits |
+| `archilyzer release amend` | `<editor\|export> <release> [--to patch\|minor\|major\|X.Y.Z] [--date YYYY-MM-DD] [--fold] [--uncut] [--commit]` | amend the LATEST release: its bump (counted from the release before it), its date, \[Unreleased\] folded in; --uncut moves it back under \[Unreleased\]; an older release is refused |
## `pnpm ops`
@@ -149,6 +150,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `persist-videos` | persist-videos saves specific videos, across channels, to the saved-video store: {"items": \[{"slug", "id"}, ...\]}. "format": "original" \| "video\_720" (default: each channel's own). "replace": "above-height" also re-fetches a saved one whose height is unknown or above that quality (default "never"). "gapMs" pauses between downloads (default the batch gap), "minFreeMemMb" waits for that much free memory before each. "dryRun": true answers with the buckets (saved, wrongHeight, toFetch, noUrl, unknown) and starts nothing. One job per channel, on its download queue; a low disk or a rate limit stops it, and running the same body again resumes — saved videos are skipped. Over a copy already in the store (an import, an attach, a live recording or an earlier download) the download becomes the active one and the old copy is kept beside it, flagged for a check (`get saved-alternates`); nothing is deleted. | `pnpm ops persist-videos --file list.json --wait` |
| `fetch-windows` | fetch-windows fetches clip windows, one paced job per platform queue (YouTube and Rumble side by side): {"siteId"} fetches every window the site's published reports cite and the disk does not hold; {"items": \[{"slug", "id", "from", "to", "clipId"?, "reason"?, "pad"?, "webpageUrl"?, "force"?}, ...\], "requestedBy", "manifest"?} fetches a list. A window of a recording whose availability says deleted or private is refused (unresolved) unless the item names a "webpageUrl" (a copy: find-copy) or "force": true (a stale reading; or check its availability again on the channel page's Diagnostics). "maxHeight" caps the source height (default 720). "dryRun": true lists the windows per platform, the ones already on disk ("cached") and the ones no fetch can fill ("unfetchable": deleted, off the site) and starts nothing. A platform cooling down or held is refused for its group; a 429, or two 403s in a row, backs the platform off and stops its job. Running the same body again resumes — fetched windows are cached, and a window a queued or running job will already write is answered in "inFlight" with that job, whose id joins "jobIds" (so --wait follows it) and no second job is queued. Windows run on the platform's clip queue (clips:youtube), never behind its long downloads. "storedUrl": "fallback" \| "only" (default "never") cuts a window from the media URL its record's metadata.info.json stores — Odysee's CDN file (\*.odycdn.com), the only platform allowed — when the page lookup is rate-limited ("fallback": after a 429) or without asking the page at all ("only"). A held or cooling platform still runs its windows that have one; the rest are refused or left for a later run. Same queue, same gaps; the window's provenance says source "stored-media-url". "minGapSeconds" (items only, 30–3600) sets this run's pause between two fetches in place of the platform's floor (Rumble's 120 s); still jittered up to half again. Shorter than the default risks Rumble's IP-wide Cloudflare challenge; a Retry keeps it. A window on a whole-recording platform (settings.clips .wholeRecordingPlatforms, default Rumble) is not seeked: the video is saved whole once, as "Persist source video" saves it, on the platform's download queue, and its windows are cut from it — a remote Rumble seek put the picture 1-4 s off the sound. A failed whole download fails its windows with the download's message. "wholeRecording": false fetches every window of the run by a remote seek instead. A fetched window whose picture still runs off its sound is set aside (<from>-<to>.desynced.<ext>) and fails; a held one is set aside and fetched again (check-windows). | `pnpm ops fetch-windows --json '{"siteId":"demo-site","dryRun":true}'`<br>`pnpm ops fetch-windows --file windows.json --wait` |
| `cut-release` | cut-release turns a changelog's \[Unreleased\] into "## \[<version>\] - <date>": {"workspace": "editor" \| "export" \| "all", "version": "X.Y.Z" \| "next" \| "next-minor", "commit": boolean (default false), "date": "YYYY-MM-DD" (default today)}. "all" cuts both with ONE version and commits each ("Release <workspace> <version>") — or neither: every check runs before either file is written. Only an editor built from release 10 or later has the route (an older one answers 404); with no editor running, `archilyzer release cut` does the same locally. | `pnpm ops cut-release --json '{"workspace":"all","version":"next","commit":true}'` |
+| `amend-release` | amend-release rewrites the LATEST release of one changelog: {"workspace": "editor" \| "export", "release": "<its version, as you saw it>", "version": "patch" \| "minor" \| "major" (a bump of the release BEFORE it) \| "X.Y.Z", "date": "YYYY-MM-DD", "fold": true (the \[Unreleased\] bullets move into it), "commit": boolean (default false)} -- or {"uncut": true} to withdraw it, its bullets back under \[Unreleased\]. An older release is refused. A version change commits as that version's release ("Release editor 0.12.0") with the amend in the body; history is never rewritten. The same amend again changes nothing. With no editor running, `archilyzer release amend` does the same locally. | `pnpm ops amend-release --json '{"workspace":"editor","release":"0.11.1","version":"minor","commit":true}'` |
| `transcribe` | transcribe runs ONE local file through a local transcription worker, as a job: {"path": "/abs/file"} (audio or video), "start"/"end" (seconds) for a window, "workerId" (a settings worker id; default: the one auto-transcribe would get), "out" (an absolute path for the result JSON, never inside the corpus). The result is {path, window, worker: {id, appId, model, device}, cues: \[{start, end, text}\], text, ...}, cue times on the file's own clock. "words": true adds words: \[{w, start, end, conf?}\] on the same clock -- from parakeet, which keeps its word timestamps; \[\] from an engine that does not. "whilePaused": true runs it during a pause-all on a worker the pause alone switched off (never one drained, degraded or disabled by hand); the pause stays on. With --wait it is printed on stdout (the response and the log go to stderr), so `pnpm ops transcribe ... --wait \| jq -r .text` works. | `pnpm ops transcribe --json '{"path":"/abs/clip.mp4","start":120,"end":150}' --wait`<br>`pnpm ops transcribe --json '{"path":"/abs/a.wav","workerId":"parakeet-cpu","out":"/tmp/a.json"}' --wait` |
| `tts` | tts speaks a line with a local text-to-speech engine and a STOCK voice, as a job on the `tts` queue: {"text": "..."} or {"file": "/abs/script.txt"} (UTF-8, at most 20,000 characters), "engine" (kokoro \| orpheus \| espeak-ng), "voice" (one of the engine's stock voices; kokoro: af\_heart, bm\_george, ...; orpheus: leah, zac, ...), "speed" (0.5-2; orpheus has none) — defaults from settings.tts (kokoro, af\_heart, 1) — and "out" (an absolute .wav path the result is copied to, never inside the corpus). The expressive tags <laugh> <chuckle> <sigh> <cough> <sniffle> <groan> <yawn> <gasp> are performed by orpheus and stripped for the others; any other <...> is refused. Numbers, years, money and times are spoken (2024: "twenty twenty-four"). The result is {wav, seconds, engine, voice, cached, durationMs, waitedMs, sha, sampleRate, speed, disclosure}: wav is the 48 kHz mono WAV the editor wrote (out, or its cache), disclosure the line a narrated export carries. The same ask again is answered from the cache (cached: true, no engine run). Kokoro and orpheus need `archilyzer tts setup [--engine orpheus]` first; orpheus runs on the GPU (a local llama-server the editor starts and stops) and waits while a transcription holds it. With --wait the result is printed on stdout. | `pnpm ops tts --json '{"text":"In 2024 the archive spoke."}' --wait`<br>`pnpm ops tts --json '{"file":"/abs/script.txt","voice":"bm_george","out":"/abs/line.wav"}' --wait` |
| `settings` | settings patches settings.json through the editor's one writer: {"patch": {"<top-level key>": value, …}} (SETTINGS.md). A block's keys merge one level; an array, a scalar or an object nested in a block replaces. Refused before anything is written: an unknown key; a key another writer owns (channelPriority, autoQueue, workers, storage — the refusal names it); a value the schema would not keep as sent (clamped, dropped), named with what would be saved. Answers the saved values. | `pnpm ops settings --json '{"patch":{"minFreeDiskGB":20}}'` |
diff --git a/common/bin/_cli.test.ts b/common/bin/_cli.test.ts
@@ -19,6 +19,7 @@ import {
formatAllLine,
formatCutLines,
formatShowLine,
+ parseAmendArgs,
parseCutArgs,
parseShowArgs,
showMain,
@@ -196,6 +197,35 @@ test("parseCutArgs checks the changelog, the version and the date before anythin
assert.match((parseShowArgs(["hub"]) as { error: string }).error, /"hub" is not editor or export/);
});
+test("parseAmendArgs names the release, checks the version and date, and wants something to do", () => {
+ assert.deepEqual(parseAmendArgs(["editor", "0.11.1"], { to: "minor", commit: true }), {
+ workspace: "editor",
+ release: "0.11.1",
+ version: "minor",
+ fold: false,
+ uncut: false,
+ commit: true,
+ });
+ assert.deepEqual(parseAmendArgs(["export", "0.11.2"], { uncut: true }), {
+ workspace: "export",
+ release: "0.11.2",
+ fold: false,
+ uncut: true,
+ commit: false,
+ });
+ const error = (p: string[], f = {}) => {
+ const r = parseAmendArgs(p, f);
+ return "error" in r ? r.error : "";
+ };
+ assert.match(error([]), /which changelog\? editor or export/);
+ assert.match(error(["all", "0.11.1"], { to: "minor" }), /"all" is not editor or export/);
+ assert.match(error(["editor"], { to: "minor" }), /which release\?/);
+ assert.match(error(["editor", "0.11.1"], { to: "next" }), /"patch", "minor" or "major"/);
+ assert.match(error(["editor", "0.11.1"], { date: "2026-02-30" }), /not a calendar date/);
+ assert.match(error(["editor", "0.11.1"], { uncut: true, to: "minor" }), /--uncut takes no --to/);
+ assert.match(error(["editor", "0.11.1"]), /nothing to amend/);
+});
+
test("a refused release command exits 2 and prints why, touching nothing", async () => {
const errors: string[] = [];
const out = { log: () => {}, error: (s: string) => errors.push(s) };
diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts
@@ -1089,6 +1089,14 @@ export const COMMANDS: Command[] = [
maxPositionals: 2,
run: async (ctx) => (await import("./release")).cutMain(ctx),
},
+ {
+ path: ["release", "amend"],
+ usage:
+ "<editor|export> <release> [--to patch|minor|major|X.Y.Z] [--date YYYY-MM-DD] [--fold] [--uncut] [--commit] amend the LATEST release: its bump (counted from the release before it), its date, [Unreleased] folded in; --uncut moves it back under [Unreleased]; an older release is refused",
+ flags: { to: "string", date: "string", fold: "boolean", uncut: "boolean", commit: "boolean" },
+ maxPositionals: 2,
+ run: async (ctx) => (await import("./release")).amendMain(ctx),
+ },
];
// A string flag's value, or undefined.
diff --git a/common/bin/release.ts b/common/bin/release.ts
@@ -6,6 +6,8 @@
//
// archilyzer release show [editor|export]
// archilyzer release cut <editor|export|all> <X.Y.Z|next|next-minor> [--commit] [--date YYYY-MM-DD]
+// archilyzer release amend <editor|export> <release> [--to patch|minor|major|X.Y.Z]
+// [--date YYYY-MM-DD] [--fold] [--uncut] [--commit]
//
// It works on the checkout it is run from (the monorepo root above the cwd;
// EDITOR_CHANGELOG_FILE / EXPORT_CHANGELOG_FILE are honoured as everywhere).
@@ -14,7 +16,10 @@ import type { CommandContext } from "./_cli";
import type { FlagValue } from "./_parseFlags";
import { compareVersions, suggestNextMinorVersion, suggestNextVersion } from "../lib/changelog";
import {
+ amendRelease,
+ amendVersionProblem,
cutReleases,
+ describeAmend,
dateProblem,
describeRelease,
isReleaseTarget,
@@ -169,3 +174,69 @@ export async function showMain(ctx: CommandContext, out: Out = console): Promise
if (all) out.log(all);
return summaries.every((s) => s.ok) ? 0 : 1;
}
+
+export type AmendArgs = {
+ workspace: ReleaseWorkspace;
+ release: string;
+ version?: string;
+ date?: string;
+ fold: boolean;
+ uncut: boolean;
+ commit: boolean;
+};
+
+/** `release amend`'s arguments, checked before anything is read — or why not. */
+export function parseAmendArgs(
+ positionals: readonly string[],
+ flags: Record<string, FlagValue>,
+): AmendArgs | { error: string } {
+ const [workspace, release] = positionals;
+ if (workspace !== "editor" && workspace !== "export") {
+ return {
+ error: workspace
+ ? `release amend: "${workspace}" is not editor or export`
+ : "release amend: which changelog? editor or export",
+ };
+ }
+ if (!release || !release.trim()) {
+ return { error: "release amend: which release? Its version (only the latest can be amended)" };
+ }
+ const version = typeof flags.to === "string" ? flags.to.trim() : undefined;
+ if (version !== undefined) {
+ const problem = amendVersionProblem(version);
+ if (problem) return { error: `release amend: ${problem}` };
+ }
+ const date = typeof flags.date === "string" ? flags.date.trim() : undefined;
+ if (date !== undefined) {
+ const problem = dateProblem(date);
+ if (problem) return { error: `release amend: ${problem}` };
+ }
+ const fold = flags.fold === true;
+ const uncut = flags.uncut === true;
+ if (uncut && (version !== undefined || date !== undefined || fold)) {
+ return { error: "release amend: --uncut takes no --to, --date or --fold" };
+ }
+ if (!uncut && version === undefined && date === undefined && !fold) {
+ return { error: "release amend: nothing to amend — give --to, --date, --fold or --uncut" };
+ }
+ return {
+ workspace,
+ release: release.trim(),
+ ...(version !== undefined ? { version } : {}),
+ ...(date !== undefined ? { date } : {}),
+ fold,
+ uncut,
+ commit: flags.commit === true,
+ };
+}
+
+export async function amendMain(ctx: CommandContext, out: Out = console): Promise<number> {
+ const args = parseAmendArgs(ctx.positionals, ctx.flags);
+ if ("error" in args) {
+ out.error(args.error);
+ return 2;
+ }
+ const result = await amendRelease(args);
+ (result.ok ? out.log : out.error)(`${args.workspace}: ${describeAmend(result)}`);
+ return result.ok ? 0 : 1;
+}
diff --git a/common/components/Changelog.tsx b/common/components/Changelog.tsx
@@ -1,7 +1,12 @@
import type { ReactNode } from "react";
import { Children } from "react";
import Markdown from "markdown-to-jsx";
-import { changelogAnchor, sliceTopEntries } from "../lib/changelog";
+import {
+ changelogAnchor,
+ headingVersion,
+ releaseAnchor,
+ sliceTopEntries,
+} from "../lib/changelog";
import { CopyLinkButton } from "./CopyLinkButton";
function flattenText(children: ReactNode): string {
@@ -23,13 +28,18 @@ function flattenText(children: ReactNode): string {
function H2({ children }: { children?: ReactNode }) {
const text = flattenText(children).trim();
const anchor = text ? changelogAnchor(text) : null;
+ // A release heading carries its version's id too (`v0.11.1`), which no
+ // other heading shares; the date id stays for links copied before it.
+ const version = text ? headingVersion(text) : null;
+ const own = version ? releaseAnchor(version) : null;
return (
<h2
id={anchor ?? undefined}
className="scroll-mt-20 mt-8 mb-3 text-base font-semibold text-foreground first:mt-0 flex items-baseline"
>
+ {own && <span id={own} className="scroll-mt-20" aria-hidden="true" />}
<span>{children}</span>
- {anchor && <CopyLinkButton anchor={anchor} />}
+ {anchor && <CopyLinkButton anchor={own ?? anchor} />}
</h2>
);
}
diff --git a/common/lib/changelog.test.ts b/common/lib/changelog.test.ts
@@ -4,6 +4,7 @@ import {
amendLatestRelease,
bumpVersion,
changelogAnchor,
+ changelogAnchorPages,
changelogPageOf,
clampChangelogPage,
compareVersions,
@@ -131,11 +132,11 @@ const RELEASED = [
test("parseChangelogSections reads each heading's version, date, anchor and span", () => {
const sections = parseChangelogSections(SOURCE);
assert.deepEqual(
- sections.map((s) => [s.title, s.anchor, s.unreleased, s.version, s.date]),
+ sections.map((s) => [s.title, s.anchor, s.versionAnchor, s.unreleased, s.version, s.date]),
[
- ["[Unreleased]", "unreleased", true, null, null],
- ["[0.9.0] - 2026-09-26", "2026-09-26", false, "0.9.0", "2026-09-26"],
- ["[0.8.7] - 2026-08-12", "2026-08-12", false, "0.8.7", "2026-08-12"],
+ ["[Unreleased]", "unreleased", null, true, null, null],
+ ["[0.9.0] - 2026-09-26", "2026-09-26", "v0.9.0", false, "0.9.0", "2026-09-26"],
+ ["[0.8.7] - 2026-08-12", "2026-08-12", "v0.8.7", false, "0.8.7", "2026-08-12"],
],
);
// The spans tile the file from the first heading to the end.
@@ -184,6 +185,16 @@ test("paginateChangelog fills pages by size, keeps the head on page 1, never spl
assert.equal(changelogPageOf(sections, pages, "2026-02-02"), 2);
assert.equal(changelogPageOf(sections, pages, "2026-01-01"), 3);
assert.equal(changelogPageOf(sections, pages, "1999-01-01"), null);
+ assert.equal(changelogPageOf(sections, pages, "v1.0.1"), 2);
+ assert.deepEqual(changelogAnchorPages(sections, pages), {
+ unreleased: 1,
+ "2026-03-03": 1,
+ "v1.0.2": 1,
+ "2026-02-02": 2,
+ "v1.0.1": 2,
+ "2026-01-01": 3,
+ "v1.0.0": 3,
+ });
// A changelog with no headings is one empty page.
assert.deepEqual(paginateChangelog(parseChangelogSections("# Changelog\n")), [[]]);
});
diff --git a/common/lib/changelog.ts b/common/lib/changelog.ts
@@ -219,6 +219,9 @@ export type ChangelogSection = {
title: string;
// The id the page gives this heading's <h2> (`changelogAnchor`).
anchor: string;
+ // A release's own id beside it, `v0.11.1` (`releaseAnchor`): unique where
+ // the date is not (two releases cut on one day).
+ versionAnchor: string | null;
unreleased: boolean;
version: string | null;
date: string | null;
@@ -253,6 +256,17 @@ export function changelogAnchor(text: string): string {
return slug || "section";
}
+/** A release heading's own anchor: `v0.11.1`. */
+export function releaseAnchor(version: string): string {
+ return `v${version}`;
+}
+
+/** The version a rendered heading's text names (`[0.11.1] - …`), or null. */
+export function headingVersion(text: string): string | null {
+ const m = RELEASE_TITLE.exec(text.trim());
+ return m ? m[1] : null;
+}
+
/** Every `## ` heading of `source`, in order, with where its section runs. */
export function parseChangelogSections(source: string): ChangelogSection[] {
const sections: ChangelogSection[] = [];
@@ -266,6 +280,7 @@ export function parseChangelogSections(source: string): ChangelogSection[] {
sections.push({
title,
anchor: changelogAnchor(title),
+ versionAnchor: release ? releaseAnchor(release[1]) : null,
unreleased: UNRELEASED_TITLE.test(title),
version: release ? release[1] : null,
date: release ? (release[2] ?? null) : null,
@@ -312,18 +327,41 @@ export function paginateChangelog(
return pages;
}
-/** The 1-based page holding the first section with `anchor`, or null. */
+/**
+ * The 1-based page holding the first section with `anchor` (its date or slug
+ * id, or its `v<version>` id), or null.
+ */
export function changelogPageOf(
sections: readonly ChangelogSection[],
pages: readonly number[][],
anchor: string,
): number | null {
- const index = sections.findIndex((s) => s.anchor === anchor);
+ const index = sections.findIndex((s) => s.anchor === anchor || s.versionAnchor === anchor);
if (index === -1) return null;
const page = pages.findIndex((p) => p.includes(index));
return page === -1 ? null : page + 1;
}
+/**
+ * Every anchor of the file → the page that holds it (the first section with
+ * it, as the browser's `getElementById` picks the first): what lets a link
+ * copied from one page land on the page that now holds it.
+ */
+export function changelogAnchorPages(
+ sections: readonly ChangelogSection[],
+ pages: readonly number[][],
+): Record<string, number> {
+ const out: Record<string, number> = {};
+ pages.forEach((indexes, p) => {
+ for (const i of indexes) {
+ for (const a of [sections[i].anchor, sections[i].versionAnchor]) {
+ if (a && !Object.hasOwn(out, a)) out[a] = p + 1;
+ }
+ }
+ });
+ return out;
+}
+
/** `?page=` read leniently: anything not a page number is page 1. */
export function clampChangelogPage(raw: unknown, pageCount: number): number {
const v = Array.isArray(raw) ? raw[0] : raw;
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## [Unreleased]
+- **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 5-10 s to appear. The forms now come first 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.
+
## [0.11.1] - 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.
- **Use with AI is the homepage's.** A published site's header and slide-out menu no longer carry it (nor the hub's header); a site still reaches the homepage's AI and MCP doc from its footer and from Ask AI, and its corpus.json and llms.txt still name it. Rebuild a site to see it.
diff --git a/editor/app/api/ops/amend-release/route.ts b/editor/app/api/ops/amend-release/route.ts
@@ -0,0 +1,79 @@
+import { NextResponse } from "next/server";
+import {
+ amendRelease,
+ amendVersionProblem,
+ dateProblem,
+ describeAmend,
+ RELEASE_WORKSPACES,
+} from "yt-dlp-transcript-common/controller/cutRelease";
+import { revalidateAfterReleaseCut } from "../../../sites/lib/revalidateAfterReleaseCut";
+import {
+ OpsInputError,
+ oneOf,
+ ops,
+ opsFail,
+ optBool,
+ optString,
+ reqString,
+} from "../_lib";
+
+export const dynamic = "force-dynamic";
+
+// POST { workspace: "editor" | "export",
+// release: "X.Y.Z" (the LATEST release, as you saw it),
+// version?: "patch" | "minor" | "major" | "X.Y.Z" (default: kept),
+// date?: "YYYY-MM-DD" (default: kept),
+// fold?: boolean (fold [Unreleased] into it),
+// uncut?: boolean (withdraw it back to [Unreleased] instead),
+// commit?: boolean (default false) }
+//
+// SYNCHRONOUS, like cut-release: one heading rewrite and at most one
+// path-limited commit. The writer is the one the Amend form on /changelog and
+// /sites and `archilyzer release amend` call (common/controller/cutRelease.ts,
+// amendRelease); every refusal is its sentence. Only the newest release can
+// be amended — `release` naming an older one is a 400.
+//
+// 200 { ok: true, message, result } — `result.changed` false when the file
+// already said this (nothing written, nothing committed). A refusal is a 400
+// { ok: false, error, written }: `written` true means the changelog was
+// rewritten and only its commit failed.
+export async function POST(request: Request) {
+ return ops(
+ request,
+ ["workspace", "release", "version", "date", "fold", "uncut", "commit"],
+ async (body) => {
+ const workspace = oneOf(body, "workspace", RELEASE_WORKSPACES);
+ const release = reqString(body, "release");
+ const version = optString(body, "version");
+ if (version !== undefined) {
+ const problem = amendVersionProblem(version);
+ if (problem) throw new OpsInputError(problem);
+ }
+ const date = optString(body, "date");
+ const badDate = date === undefined ? null : dateProblem(date);
+ if (badDate) throw new OpsInputError(badDate);
+ const fold = optBool(body, "fold") ?? false;
+ const uncut = optBool(body, "uncut") ?? false;
+ if (uncut && (version !== undefined || date !== undefined || fold)) {
+ throw new OpsInputError("A withdrawal takes no version, date or fold.");
+ }
+ const commit = optBool(body, "commit") ?? false;
+
+ const result = await amendRelease({
+ workspace,
+ release,
+ version,
+ date,
+ fold,
+ uncut,
+ commit,
+ });
+ if (result.ok) {
+ if (result.changed) revalidateAfterReleaseCut();
+ return NextResponse.json({ ok: true, message: describeAmend(result), result });
+ }
+ if (result.written) revalidateAfterReleaseCut();
+ return opsFail(result.error, 400, { written: result.written === true });
+ },
+ );
+}
diff --git a/editor/app/changelog/ChangelogAnchorResolver.tsx b/editor/app/changelog/ChangelogAnchorResolver.tsx
@@ -0,0 +1,39 @@
+"use client";
+
+import { useEffect } from "react";
+
+// A LINK TO A RELEASE ON ANOTHER PAGE. /changelog is paged (?page=N), and a
+// copied link is `/changelog#<anchor>` with no page — so a link to an older
+// release would open page 1 and find nothing. This looks the anchor up in the
+// map the server sent (every anchor → its page) and, when another page holds
+// it, goes there. It sits in the page's shell, outside the streamed notes, so
+// it acts as soon as the shell hydrates rather than after page 1's notes load.
+export function ChangelogAnchorResolver({
+ anchors,
+ page,
+}: {
+ anchors: Record<string, number>;
+ page: number;
+}) {
+ useEffect(() => {
+ const resolve = () => {
+ let id: string;
+ try {
+ id = decodeURIComponent(window.location.hash.slice(1));
+ } catch {
+ return;
+ }
+ if (!id || !Object.hasOwn(anchors, id)) return;
+ const target = anchors[id];
+ if (target === page) return;
+ const query = target === 1 ? "" : `?page=${target}`;
+ window.location.replace(
+ `${window.location.pathname}${query}#${encodeURIComponent(id)}`,
+ );
+ };
+ resolve();
+ window.addEventListener("hashchange", resolve);
+ return () => window.removeEventListener("hashchange", resolve);
+ }, [anchors, page]);
+ return null;
+}
diff --git a/editor/app/changelog/ChangelogNotes.tsx b/editor/app/changelog/ChangelogNotes.tsx
@@ -0,0 +1,95 @@
+import { readFile } from "node:fs/promises";
+import Link from "next/link";
+import { getPaths } from "yt-dlp-transcript-common/lib/paths";
+import { Changelog } from "yt-dlp-transcript-common/components/Changelog";
+import {
+ clampChangelogPage,
+ paginateChangelog,
+ parseChangelogSections,
+} from "yt-dlp-transcript-common/lib/changelog";
+
+// THE NOTES of /changelog, one page of them, streamed after the page's shell
+// (the Cut and Amend forms). Async on purpose: its read is the await that lets
+// the shell flush before the markdown of a page is rendered.
+//
+// A page is whole sections up to a size budget (common/lib/changelog.ts,
+// paginateChangelog); page 1 opens with [Unreleased].
+
+export function pageHref(page: number, anchor?: string): string {
+ const base = page <= 1 ? "/changelog" : `/changelog?page=${page}`;
+ return anchor ? `${base}#${anchor}` : base;
+}
+
+export async function ChangelogNotes({
+ searchParams,
+}: {
+ searchParams: Promise<Record<string, string | string[] | undefined>>;
+}) {
+ const [params, source] = await Promise.all([
+ searchParams,
+ readFile(getPaths().editorChangelogFile, "utf8"),
+ ]);
+ const sections = parseChangelogSections(source);
+ const pages = paginateChangelog(sections);
+ const page = clampChangelogPage(params.page, pages.length);
+ const indexes = pages[page - 1];
+ const slice =
+ indexes.length > 0
+ ? source.slice(sections[indexes[0]].start, sections[indexes[indexes.length - 1]].end)
+ : "";
+ const pageOfSection = new Map<number, number>();
+ pages.forEach((p, n) => p.forEach((i) => pageOfSection.set(i, n + 1)));
+
+ const nav = pages.length > 1 && (
+ <nav
+ aria-label="Changelog pages"
+ className="flex flex-wrap items-center gap-3 text-sm text-muted-foreground"
+ >
+ {page > 1 ? (
+ <Link href={pageHref(page - 1)} className="underline hover:text-foreground">
+ ← Newer
+ </Link>
+ ) : (
+ <span className="opacity-40">← Newer</span>
+ )}
+ <span>
+ Page {page} of {pages.length}
+ </span>
+ {page < pages.length ? (
+ <Link href={pageHref(page + 1)} className="underline hover:text-foreground">
+ Older →
+ </Link>
+ ) : (
+ <span className="opacity-40">Older →</span>
+ )}
+ </nav>
+ );
+
+ return (
+ <section className="flex flex-col gap-4" aria-label="Release notes">
+ {sections.length > 1 && (
+ <details className="text-sm">
+ <summary className="cursor-pointer text-muted-foreground">
+ All releases ({sections.filter((s) => s.version).length})
+ </summary>
+ <ul className="mt-2 flex flex-wrap gap-x-4 gap-y-1">
+ {sections.map((s, i) => (
+ <li key={`${s.start}`}>
+ <a
+ href={pageHref(pageOfSection.get(i) ?? 1, s.versionAnchor ?? s.anchor)}
+ className="font-mono underline decoration-muted-foreground hover:decoration-foreground"
+ >
+ {s.version ?? (s.unreleased ? "Unreleased" : s.title)}
+ </a>
+ {s.date && <span className="text-muted-foreground"> {s.date}</span>}
+ </li>
+ ))}
+ </ul>
+ </details>
+ )}
+ {nav}
+ <Changelog source={slice} />
+ {nav}
+ </section>
+ );
+}
diff --git a/editor/app/changelog/page.tsx b/editor/app/changelog/page.tsx
@@ -1,15 +1,23 @@
import { readFileSync } from "node:fs";
+import { Suspense } from "react";
import type { Metadata } from "next";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
-import { Changelog } from "yt-dlp-transcript-common/components/Changelog";
import {
+ changelogAnchorPages,
+ clampChangelogPage,
+ describeAmendTarget,
extractUnreleasedSection,
getLatestChangelogDate,
getLatestReleasedVersion,
+ paginateChangelog,
+ parseChangelogSections,
suggestNextVersion,
} from "yt-dlp-transcript-common/lib/changelog";
import { MarkChangelogSeen } from "../components/MarkChangelogSeen";
import { CutReleaseForm } from "../sites/components/CutReleaseForm";
+import { AmendReleaseForm } from "../sites/components/AmendReleaseForm";
+import { ChangelogAnchorResolver } from "./ChangelogAnchorResolver";
+import { ChangelogNotes } from "./ChangelogNotes";
export const dynamic = "force-dynamic";
export const metadata: Metadata = { title: "Changelog" };
@@ -20,20 +28,34 @@ function loadChangelog(): string {
return readFileSync(getPaths().editorChangelogFile, "utf8");
}
-export default function ChangelogPage() {
+// THE SHELL FIRST. The page used to render all of editor/CHANGELOG.md (~760
+// KB of markdown: a 2.9 MB response the browser took 5-10 s to show) with the
+// Cut release form at the bottom. Now the forms come first, from a few regex
+// reads of the file, and the notes stream in after them one page at a time
+// (ChangelogNotes, ?page=N).
+export default async function ChangelogPage({
+ searchParams,
+}: {
+ searchParams: Promise<Record<string, string | string[] | undefined>>;
+}) {
const source = loadChangelog();
const latestDate = getLatestChangelogDate(source);
const lastVersion = getLatestReleasedVersion(source);
const suggestedVersion = suggestNextVersion(lastVersion);
const unreleased = extractUnreleasedSection(source);
const hasUnreleased = unreleased.length > 0;
+ const amendTarget = describeAmendTarget(source);
+ const sections = parseChangelogSections(source);
+ const pages = paginateChangelog(sections);
+ const page = clampChangelogPage((await searchParams).page, pages.length);
return (
<div className="flex flex-col gap-6 max-w-3xl">
<h1 className="text-2xl font-semibold">Changelog</h1>
- <Changelog source={source} />
- <section className="flex flex-col gap-3 border-t border-border pt-6">
+ <section className="flex flex-col gap-3" aria-labelledby="cut-release-heading">
<div>
- <h2 className="text-lg font-semibold">Cut release</h2>
+ <h2 id="cut-release-heading" className="text-lg font-semibold">
+ Cut release
+ </h2>
<p className="text-sm text-muted-foreground">
Turns the current <code>## [Unreleased]</code> heading into a
dated semver heading.
@@ -46,6 +68,34 @@ export default function ChangelogPage() {
hasUnreleased={hasUnreleased}
/>
</section>
+ <section
+ className="flex flex-col gap-3 border-t border-border pt-6"
+ aria-labelledby="amend-release-heading"
+ >
+ <div>
+ <h2 id="amend-release-heading" className="text-lg font-semibold">
+ Amend the latest release
+ </h2>
+ <p className="text-sm text-muted-foreground">
+ Re-pick its bump or date, fold in what is under{" "}
+ <code>[Unreleased]</code>, or move it back there. Only the newest
+ release; a version change commits as that version's release.
+ </p>
+ </div>
+ <AmendReleaseForm workspace="editor" target={amendTarget} />
+ </section>
+ <div className="border-t border-border pt-6">
+ <Suspense
+ fallback={
+ <p className="text-sm text-muted-foreground" role="status">
+ Loading release notes…
+ </p>
+ }
+ >
+ <ChangelogNotes searchParams={searchParams} />
+ </Suspense>
+ </div>
+ <ChangelogAnchorResolver anchors={changelogAnchorPages(sections, pages)} page={page} />
<MarkChangelogSeen latestDate={latestDate} />
</div>
);
diff --git a/editor/app/sites/components/AmendReleaseForm.tsx b/editor/app/sites/components/AmendReleaseForm.tsx
@@ -0,0 +1,144 @@
+"use client";
+
+import { useActionState } from "react";
+import type { AmendTarget } from "yt-dlp-transcript-common/lib/changelog";
+import {
+ amendReleaseAction,
+ type AmendReleaseState,
+} from "../lib/amendReleaseAction";
+import { SeededInput, SeededSelect } from "../../components/forms/Field";
+import { seedChecked } from "../../lib/formState";
+
+// AMEND THE LATEST RELEASE: re-pick its bump (counted from the release before
+// it, so a patch cut can become the minor it should have been), its date, fold
+// in what has gathered under [Unreleased] since — or move it back under
+// [Unreleased] altogether. The writer is common/controller/cutRelease.ts's
+// amendRelease; only the newest release can be amended, and the form names
+// it, so a stale form is refused rather than amending another.
+export function AmendReleaseForm({
+ workspace,
+ target,
+}: {
+ workspace: "editor" | "export";
+ target: AmendTarget | null;
+}) {
+ const [state, formAction, pending] = useActionState<
+ AmendReleaseState | undefined,
+ FormData
+ >(amendReleaseAction, undefined);
+
+ if (!target) {
+ return (
+ <p className="text-sm text-muted-foreground">No release to amend yet.</p>
+ );
+ }
+ const { latest, previous, bumps } = target;
+ const id = (name: string) => `amend-${name}-${workspace}`;
+ // The select's default: the bump the latest release already is, if any.
+ const current =
+ (["patch", "minor", "major"] as const).find((k) => bumps[k] === latest.version) ?? "";
+ return (
+ <form
+ action={formAction}
+ className="flex flex-col gap-2"
+ aria-label={`Amend release ${latest.version}`}
+ >
+ <input type="hidden" name="workspace" value={workspace} />
+ <input type="hidden" name="release" value={latest.version} />
+ <div className="text-sm text-muted-foreground">
+ Latest release: <span className="font-mono">{latest.version}</span>
+ {latest.date ? ` (${latest.date})` : ""}
+ {previous
+ ? `; a bump counts from ${previous.version}.`
+ : "; it is the first release."}
+ </div>
+ <div className="flex flex-wrap items-end gap-2">
+ <label className="flex flex-col gap-1 text-xs text-muted-foreground" htmlFor={id("version")}>
+ Version
+ <SeededSelect
+ state={state}
+ id={id("version")}
+ name="version"
+ initial={current}
+ disabled={pending}
+ className="px-3 py-2 rounded-md border border-border bg-card text-sm font-mono"
+ >
+ {current === "" && <option value="">Keep {latest.version}</option>}
+ <option value="patch">patch: {bumps.patch}</option>
+ <option value="minor">minor: {bumps.minor}</option>
+ <option value="major">major: {bumps.major}</option>
+ </SeededSelect>
+ </label>
+ <label className="flex flex-col gap-1 text-xs text-muted-foreground" htmlFor={id("date")}>
+ Date
+ <SeededInput
+ state={state}
+ id={id("date")}
+ name="date"
+ type="date"
+ initial={latest.date ?? ""}
+ disabled={pending}
+ className="px-3 py-2 rounded-md border border-border bg-card text-sm font-mono"
+ />
+ </label>
+ <button
+ type="submit"
+ name="intent"
+ value="amend"
+ disabled={pending}
+ className="px-3 py-2 rounded-md text-sm bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed"
+ >
+ {pending ? "Working…" : "Amend release"}
+ </button>
+ <button
+ type="submit"
+ name="intent"
+ value="uncut"
+ disabled={pending}
+ className="px-3 py-2 rounded-md text-sm border border-border hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed"
+ >
+ Move back to [Unreleased]
+ </button>
+ </div>
+ <div className="flex flex-wrap items-center gap-4">
+ <label className="flex items-center gap-1 text-sm text-muted-foreground">
+ <input
+ type="checkbox"
+ name="fold"
+ value="true"
+ defaultChecked={seedChecked(state, "fold", false)}
+ disabled={pending || target.pending === 0}
+ />
+ <span>
+ {target.pending === 0
+ ? "Nothing under [Unreleased] to fold in"
+ : `Fold the ${target.pending} note${target.pending === 1 ? "" : "s"} under [Unreleased] into it`}
+ </span>
+ </label>
+ <label className="flex items-center gap-1 text-sm text-muted-foreground">
+ <input
+ type="checkbox"
+ name="commit"
+ value="true"
+ defaultChecked={seedChecked(state, "commit", true)}
+ disabled={pending}
+ />
+ <span>Commit the amend</span>
+ </label>
+ </div>
+ {state && !state.ok && (
+ <div
+ role="alert"
+ className="text-sm text-destructive bg-destructive-soft border border-destructive/30 rounded-md px-3 py-2"
+ >
+ {state.error}
+ </div>
+ )}
+ {state && state.ok && (
+ <div role="status" className="text-sm text-success">
+ {state.message}
+ </div>
+ )}
+ </form>
+ );
+}
diff --git a/editor/app/sites/lib/amendReleaseAction.ts b/editor/app/sites/lib/amendReleaseAction.ts
@@ -0,0 +1,61 @@
+"use server";
+
+import {
+ amendRelease,
+ describeAmend,
+} from "yt-dlp-transcript-common/controller/cutRelease";
+import { revalidateAfterReleaseCut } from "./revalidateAfterReleaseCut";
+import { formValues, type FormState } from "../../lib/formState";
+
+// The "Amend release" form's server action: a FormData adapter over the one
+// writer, `amendRelease` (common/controller/cutRelease.ts), which
+// `archilyzer release amend` and POST /api/ops/amend-release call too. Every
+// refusal is that module's sentence.
+//
+// Fields: workspace, release (the latest version the form was rendered
+// against — the guard), version ("" keeps it; patch | minor | major), date
+// (YYYY-MM-DD; "" keeps it), fold, commit, and the submit button's `intent`:
+// "amend" or "uncut" (withdraw: version, date and fold are ignored).
+
+export type AmendReleaseState = FormState<{ message: string; changed: boolean }>;
+
+const str = (formData: FormData, key: string): string => {
+ const v = formData.get(key);
+ return typeof v === "string" ? v.trim() : "";
+};
+const checked = (formData: FormData, key: string): boolean => {
+ const v = formData.get(key);
+ return v === "true" || v === "on";
+};
+
+export async function amendReleaseAction(
+ _prev: AmendReleaseState | undefined,
+ formData: FormData,
+): Promise<AmendReleaseState> {
+ const values = formValues(formData);
+ const workspaceRaw = str(formData, "workspace");
+ const workspace =
+ workspaceRaw === "editor" || workspaceRaw === "export" ? workspaceRaw : null;
+ if (!workspace) return { ok: false, error: "Invalid workspace.", values };
+ const uncut = str(formData, "intent") === "uncut";
+ const version = str(formData, "version");
+ const date = str(formData, "date");
+ const result = await amendRelease({
+ workspace,
+ release: str(formData, "release"),
+ ...(uncut
+ ? { uncut: true }
+ : {
+ ...(version ? { version } : {}),
+ ...(date ? { date } : {}),
+ fold: checked(formData, "fold"),
+ }),
+ commit: checked(formData, "commit"),
+ });
+ if (!result.ok) {
+ if (result.written) revalidateAfterReleaseCut();
+ return { ok: false, error: result.error, values };
+ }
+ if (result.changed) revalidateAfterReleaseCut();
+ return { ok: true, message: describeAmend(result), changed: result.changed };
+}
diff --git a/editor/app/sites/page.tsx b/editor/app/sites/page.tsx
@@ -4,6 +4,7 @@ import Link from "next/link";
import { Changelog } from "yt-dlp-transcript-common/components/Changelog";
import {
extractUnreleasedSection,
+ describeAmendTarget,
getLatestReleasedVersion,
suggestNextVersion,
} from "yt-dlp-transcript-common/lib/changelog";
@@ -17,6 +18,7 @@ import { liveJobRows } from "../jobs/active/buildActiveJobs";
import { RunningJobsList } from "../jobs/components/RunningJobsList";
import { BuildButtons } from "./components/BuildButtons";
import { CutReleaseForm } from "./components/CutReleaseForm";
+import { AmendReleaseForm } from "./components/AmendReleaseForm";
import { HomepageConfigForm } from "./components/HomepageConfigForm";
import { PublishPanel, type PanelRow } from "./components/PublishPanel";
import { DeleteSiteButton, MigrateButton } from "./components/SiteListActions";
@@ -152,6 +154,17 @@ export default async function SitesPage() {
suggestedVersion={suggestedVersion}
hasUnreleased={hasUnreleased}
/>
+ <details className="text-sm">
+ <summary className="cursor-pointer text-muted-foreground">
+ Amend the latest release
+ </summary>
+ <div className="mt-2">
+ <AmendReleaseForm
+ workspace="export"
+ target={source ? describeAmendTarget(source) : null}
+ />
+ </div>
+ </details>
</section>
{/* Publish: every site, the hub and the homepage as stages (release
diff --git a/editor/e2e/changelog-pages.spec.ts b/editor/e2e/changelog-pages.spec.ts
@@ -0,0 +1,212 @@
+import { readFile, writeFile } from "node:fs/promises";
+import { test, expect, type Locator } from "@playwright/test";
+import { baseUrl } from "./baseUrl";
+import { resolvePath, testPaths } from "./helpers";
+
+// /changelog as a release tool: the Cut and Amend forms come first and the
+// notes stream in after them one PAGE at a time (?page=N, whole releases up to
+// a size budget — common/lib/changelog.ts paginateChangelog); a link to an
+// older release's anchor lands on the page that holds it; and the latest
+// release can be amended (a patch cut made a minor) or moved back under
+// [Unreleased], through the same writer as `pnpm ops amend-release`.
+//
+// The changelog is the test server's disposable EDITOR_CHANGELOG_FILE, as in
+// cut-release.spec.ts; "commit" is off everywhere (the commit path is the
+// controller's unit tests', each in a git repo of its own).
+
+const CHANGELOG = resolvePath(testPaths().editorChangelog);
+const AUTH = { authorization: "Bearer test-worker-token" };
+
+// What cut-release.spec.ts and ops-cut-release.spec.ts leave behind.
+const RESTING = "# Changelog\n\n## [9.9.9] - 2024-01-01\n- old released bullet\n";
+
+test.afterEach(async () => {
+ await writeFile(CHANGELOG, RESTING);
+});
+
+// A release of ~60 KB: two of them never share a page (the budget is ~96 KB),
+// so the pages are [Unreleased] + 9.9.12 | 9.9.11 | 9.9.10 + 9.9.9.
+function bigRelease(version: string, date: string, word: string): string {
+ const bullet = `- **${word} change.** ${`${word} `.repeat(120)}`;
+ return [`## [${version}] - ${date}`, ...Array.from({ length: 70 }, () => bullet), ""].join("\n");
+}
+
+const PAGED = [
+ "# Changelog",
+ "",
+ "## [Unreleased]",
+ "- **A pending note.**",
+ "",
+ bigRelease("9.9.12", "2024-04-01", "twelve"),
+ bigRelease("9.9.11", "2024-03-01", "eleven"),
+ bigRelease("9.9.10", "2024-02-01", "tenths"),
+ "## [9.9.9] - 2024-01-01",
+ "- **The oldest note.**",
+ "",
+].join("\n");
+
+const MISCUT = [
+ "# Changelog",
+ "",
+ "## [9.9.10] - 2024-02-01",
+ "- **A minor's worth of features.**",
+ "",
+ "## [9.9.9] - 2024-01-01",
+ "- old released bullet",
+ "",
+].join("\n");
+
+// A click before React hydrates submits nothing a client action sees.
+async function hydrated(form: Locator): Promise<void> {
+ await expect(async () => {
+ const ok = await form.evaluate((el) =>
+ Object.keys(el).some((k) => k.startsWith("__reactProps")),
+ );
+ expect(ok).toBe(true);
+ }).toPass({ timeout: 15_000 });
+}
+
+test("the forms come first and the notes are paged, older pages by link", async ({ page }) => {
+ await writeFile(CHANGELOG, PAGED);
+ await page.goto("/changelog");
+
+ // The shell: both forms, ahead of the notes.
+ const cut = page.getByRole("button", { name: /^cut release$/i });
+ await expect(cut).toBeEnabled();
+ await expect(page.getByRole("button", { name: /^amend release$/i })).toBeVisible();
+ const notes = page.getByRole("region", { name: "Release notes" });
+ await expect(notes).toBeVisible();
+ const cutBox = await cut.boundingBox();
+ const notesBox = await notes.boundingBox();
+ expect(cutBox!.y).toBeLessThan(notesBox!.y);
+
+ // Page 1: [Unreleased] and the newest release, nothing older.
+ const nav = notes.getByRole("navigation", { name: "Changelog pages" }).first();
+ await expect(nav).toContainText("Page 1 of 3");
+ await expect(notes.getByText("A pending note.")).toBeVisible();
+ await expect(notes.locator("#v9\\.9\\.12")).toHaveCount(1);
+ await expect(notes.locator("#v9\\.9\\.11")).toHaveCount(0);
+
+ await nav.getByRole("link", { name: "Older →" }).click();
+ await expect(page).toHaveURL(/\/changelog\?page=2$/);
+ await expect(nav).toContainText("Page 2 of 3");
+ await expect(notes.locator("#v9\\.9\\.11")).toHaveCount(1);
+ await expect(notes.getByText("A pending note.")).toHaveCount(0);
+
+ await nav.getByRole("link", { name: "← Newer" }).click();
+ await expect(page).toHaveURL(/\/changelog$/);
+ await expect(nav).toContainText("Page 1 of 3");
+
+ // A page past the end is the last page.
+ await page.goto("/changelog?page=99");
+ await expect(nav).toContainText("Page 3 of 3");
+ await expect(notes.getByText("The oldest note.")).toBeVisible();
+});
+
+test("a link to an older release's anchor lands on the page that holds it", async ({ page }) => {
+ await writeFile(CHANGELOG, PAGED);
+
+ // By the release's own id…
+ await page.goto("/changelog#v9.9.10");
+ await expect(page).toHaveURL(/\/changelog\?page=3#v9\.9\.10$/);
+ await expect(page.locator("#v9\\.9\\.10")).toBeInViewport();
+
+ // …and by the date id a link copied before this page had pages carries.
+ await page.goto("/changelog#2024-01-01");
+ await expect(page).toHaveURL(/\/changelog\?page=3#2024-01-01$/);
+ await expect(page.locator("#2024-01-01")).toBeInViewport();
+
+ // An anchor on page 1 stays on page 1.
+ await page.goto("/changelog#unreleased");
+ await expect(page.locator("#unreleased")).toBeVisible();
+ await expect(page).toHaveURL(/\/changelog#unreleased$/);
+
+ // The index of every release links to each one's page.
+ const notes = page.getByRole("region", { name: "Release notes" });
+ await notes.getByText(/^All releases/).click();
+ await expect(notes.getByRole("link", { name: "9.9.11" })).toHaveAttribute(
+ "href",
+ "/changelog?page=2#v9.9.11",
+ );
+});
+
+test("amend round trip: a patch made a minor, then moved back and cut again", async ({ page }) => {
+ await writeFile(CHANGELOG, MISCUT);
+ await page.goto("/changelog");
+ const form = page.getByRole("form", { name: "Amend release 9.9.10" });
+ await hydrated(form);
+ await expect(form).toContainText("a bump counts from 9.9.9");
+
+ // patch → minor, counted from 9.9.9.
+ await form.getByLabel("Version").selectOption("minor");
+ await form.getByRole("checkbox", { name: "Commit the amend" }).uncheck();
+ await form.getByRole("button", { name: /^amend release$/i }).click();
+ await expect(
+ page.getByRole("status").filter({ hasText: "Amended 9.9.10 -> [9.10.0] - 2024-02-01 (not committed)." }),
+ ).toBeVisible();
+ expect(await readFile(CHANGELOG, "utf8")).toBe(MISCUT.replace("[9.9.10]", "[9.10.0]"));
+
+ // The page now offers 9.10.0 as the latest release.
+ const amended = page.getByRole("form", { name: "Amend release 9.10.0" });
+ await expect(amended).toBeVisible();
+ await expect(page.getByText("Last released: 9.10.0")).toBeVisible();
+
+ // Moved back under [Unreleased]: the cut form has something to cut again.
+ await hydrated(amended);
+ await amended.getByRole("checkbox", { name: "Commit the amend" }).uncheck();
+ await amended.getByRole("button", { name: "Move back to [Unreleased]" }).click();
+ await expect(
+ page.getByRole("status").filter({ hasText: "Withdrew 9.10.0: 1 note back under [Unreleased]" }),
+ ).toBeVisible();
+ expect(await readFile(CHANGELOG, "utf8")).toBe(MISCUT.replace("[9.9.10] - 2024-02-01", "[Unreleased]"));
+ await expect(page.locator("#version-editor")).toBeEnabled();
+});
+
+test("only the latest release can be amended: a stale form is refused, nothing written", async ({ page }) => {
+ await writeFile(CHANGELOG, MISCUT);
+ await page.goto("/changelog");
+ const form = page.getByRole("form", { name: "Amend release 9.9.10" });
+ await hydrated(form);
+
+ // Someone cuts 9.9.11 while the form is open.
+ const moved = MISCUT.replace("# Changelog\n\n", "# Changelog\n\n## [9.9.11] - 2024-03-01\n- newer\n\n");
+ await writeFile(CHANGELOG, moved);
+ await form.getByLabel("Version").selectOption("major");
+ await form.getByRole("checkbox", { name: "Commit the amend" }).uncheck();
+ await form.getByRole("button", { name: /^amend release$/i }).click();
+ await expect(
+ page.getByRole("alert").filter({
+ hasText: "Only the latest release can be amended: 9.9.10 is older than 9.9.11.",
+ }),
+ ).toBeVisible();
+ expect(await readFile(CHANGELOG, "utf8")).toBe(moved);
+});
+
+test("POST /api/ops/amend-release: the same writer over HTTP", async ({ request }) => {
+ await writeFile(CHANGELOG, MISCUT);
+ const post = (data: Record<string, unknown>) =>
+ request.post(`${baseUrl}/api/ops/amend-release`, { headers: AUTH, data });
+
+ const older = await post({ workspace: "editor", release: "9.9.9", version: "minor" });
+ expect(older.status()).toBe(400);
+ expect(await older.json()).toEqual({
+ ok: false,
+ error: "Only the latest release can be amended: 9.9.9 is older than 9.9.10.",
+ written: false,
+ });
+ const bad = await post({ workspace: "editor", release: "9.9.10", version: "next" });
+ expect(bad.status()).toBe(400);
+ expect((await bad.json()).error).toMatch(/"patch", "minor" or "major"/);
+ expect(await readFile(CHANGELOG, "utf8")).toBe(MISCUT);
+
+ const ok = await post({ workspace: "editor", release: "9.9.10", version: "minor" });
+ expect(ok.status()).toBe(200);
+ const body = await ok.json();
+ expect(body.message).toBe("Amended 9.9.10 -> [9.10.0] - 2024-02-01 (not committed).");
+ expect(body.result).toMatchObject({ changed: true, to: { version: "9.10.0" } });
+ // Again: idempotent.
+ const again = await post({ workspace: "editor", release: "9.9.10", version: "minor" });
+ expect(again.status()).toBe(200);
+ expect((await again.json()).result.changed).toBe(false);
+ expect(await readFile(CHANGELOG, "utf8")).toBe(MISCUT.replace("[9.9.10]", "[9.10.0]"));
+});
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -114,6 +114,7 @@
// pnpm ops get x-session
// pnpm ops recheck-service --json '{"service":"rumble"}'
// pnpm ops cut-release --json '{"workspace":"all","version":"next","commit":true}'
+// pnpm ops amend-release --json '{"workspace":"editor","release":"0.11.1","version":"minor","commit":true}'
// pnpm ops transcribe --json '{"path":"/abs/clip.mp4","start":120,"end":150}' --wait
// pnpm ops transcribe --json '{"path":"/abs/a.wav","workerId":"parakeet-cpu","out":"/tmp/a.json"}' --wait
// pnpm ops tts --json '{"text":"In 2024 the archive spoke."}' --wait
@@ -466,6 +467,11 @@ const ACTIONS = [
// needs no editor at all — this route exists only on an editor built from
// release 10 or later.
"cut-release",
+ // Amend the LATEST release of a changelog: its bump (patch/minor/major of the
+ // release before it), its date, [Unreleased] folded in — or withdraw it
+ // ({workspace, release, version?, date?, fold?, uncut?, commit?}).
+ // Synchronous; the same writer as `archilyzer release amend`.
+ "amend-release",
// ONE local file, or a window of it, through a local transcription worker
// ({path, start?, end?, workerId?, out?}) — the corpus's own engine and
// model, as a job. With --wait the result JSON is what stdout carries.
@@ -1600,6 +1606,17 @@ export function usage() {
" (an older one answers 404); with no editor running, `archilyzer release",
" cut` does the same locally.",
"",
+ 'amend-release rewrites the LATEST release of one changelog: {"workspace":',
+ ' "editor" | "export", "release": "<its version, as you saw it>",',
+ ' "version": "patch" | "minor" | "major" (a bump of the release BEFORE it)',
+ ' | "X.Y.Z", "date": "YYYY-MM-DD", "fold": true (the [Unreleased] bullets',
+ ' move into it), "commit": boolean (default false)} -- or {"uncut": true}',
+ " to withdraw it, its bullets back under [Unreleased]. An older release is",
+ " refused. A version change commits as that version's release (\"Release",
+ ' editor 0.12.0") with the amend in the body; history is never rewritten.',
+ " The same amend again changes nothing. With no editor running,",
+ " `archilyzer release amend` does the same locally.",
+ "",
'transcribe runs ONE local file through a local transcription worker, as a',
' job: {"path": "/abs/file"} (audio or video), "start"/"end" (seconds) for a',
' window, "workerId" (a settings worker id; default: the one auto-transcribe',
diff --git a/scripts/archilyzer-ops.test.mjs b/scripts/archilyzer-ops.test.mjs
@@ -70,6 +70,19 @@ test("cut-release posts its body to /api/ops/cut-release and is a known action",
assert.match(usage(), /release 10 or later/);
});
+test("amend-release posts its body to /api/ops/amend-release and is a known action", () => {
+ const p = parseArgs([
+ "amend-release",
+ "--json",
+ '{"workspace":"editor","release":"0.11.1","version":"minor","commit":true}',
+ ]);
+ assert.equal(p.method, "POST");
+ assert.equal(p.path, "/api/ops/amend-release");
+ assert.deepEqual(p.body, { workspace: "editor", release: "0.11.1", version: "minor", commit: true });
+ assert.match(usage(), /amend-release rewrites the LATEST release of one changelog/);
+ assert.match(usage(), /An older release is/);
+});
+
test("malformed --json is refused before any request", () => {
assert.match(parseArgs(["sync", "--json", "{"]).error, /not valid JSON/);
assert.match(parseArgs(["sync", "--json", "[1]"]).error, /must be a JSON object/);