commit 1cbc1ee9fc3cddcc29d4f07d15b61dd11844384b
parent c4108062bba32985377a0db1511daaa3a8393856
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 10 Oct 2026 17:24:36 -0400
editor: /sites saves no longer wait on the page's refresh (release 24 H5)
sites-crud.spec's hub-form test flaked on "Saved." arriving ~6 s late. In
the production build a revalidating server action's state commits with the
router's refresh of the page, and about 1 save in 18 that refresh did not
settle until the next router update (the AutoRefresh tick); the response
body was complete in ~15 ms each time. Without revalidatePath, 0 in 30.
The hub form, the site form, delete and migrate now save without
revalidating: the forms hand back what was submitted and seed from it
(seedAfterSave), so React's reset after the action shows the saved values,
and refresh the page themselves once the state has landed
(useRefreshAfterSave; router.refresh() after delete/migrate). A
sites-crud test holds every /sites refresh for 6 s and still expects
"Saved." within 5 s, with the fields showing what was saved.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
10 files changed, 151 insertions(+), 44 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **"Saved." on /sites comes at once.** Saving the hub config or a site, deleting a site and migrating settings into a first site sometimes waited up to ~6 s for the page's refresh before saying anything, the button stuck on "Saving…". They now save without making the page refresh wait, show what was saved straight away, and then refresh the page.
- **A channel taken off a site, or moved to its cited scope, is withdrawn at the edge.** The next build of the site replaces every `transcripts/`, `subs/`, `posts/` and `digests/` path its last build served for that channel with an empty file of the same shape, served no-store (the way withheld X posts already are), and keeps doing so while the channel stays out. The channel's cited moments and clips still publish. A site's deploy now reads its withdrawn paths back in its live check, as the hub's does.
- **Persisting a Wayback or archive.org record no longer undoes its title and date.** A re-download that rewrites `metadata.info.json` keeps the title, upload date and other fields `archilyzer wayback refresh --titles`, `archive-org refresh` or the feed backfill set, when the source only has its placeholder for them; a value the source genuinely changed still lands. A record a persist already reverted gets them back on its next download.
- **A site's reports can cite a channel the site does not publish.** A channel row outside the site's pool on the site form now has a **Cited only** box (`citedChannels` in site.json — see SITE.md); `/sites` shows "· N cited" beside the channel count. A report on that site may cite the channel: its moment pages and their clips publish, but not its browse page, transcripts, search entry or corpus.json entry, and its moments link no corpus page. A channel in the pool is never cited-only: ticking **Include** clears the box. A citation of a channel in neither list is still refused at compose (`not-in-site`), and the refusal now names both keys. A build or deploy whose bundle holds a cited-only channel's transcripts, subs, posts, digests, stats or archives, or lists it in corpus.json or site.json, is refused; a change to its transcripts or posts makes the site stale. Renaming a channel renames it in `citedChannels` too, and `pnpm ops get sites` lists the key. A site padding its pool with a channel only to cite it can move the channel to **Cited only**. Needs a restart of the editor for the form; rebuild each site that uses it.
diff --git a/editor/app/lib/formState.test.ts b/editor/app/lib/formState.test.ts
@@ -7,6 +7,7 @@ import {
seedValue,
type FormErrorState,
type FormState,
+ seedAfterSave,
} from "./formState";
// Run with: pnpm --filter editor test
@@ -103,3 +104,16 @@ test("the channels flavour reads through the same helpers", () => {
// An error with no values (an action that returns none) seeds from initial.
assert.equal(seedValue({ error: "no" }, "name", "Stored"), "Stored");
});
+
+test("seedAfterSave: a success that carries values seeds like a failure; anything else is the state as is", () => {
+ const values = { title: "Saved title", downloads: "on" };
+ const seed = seedAfterSave({ ok: true, values });
+ assert.equal(seedValue(seed, "title", "Old"), "Saved title");
+ assert.equal(seedChecked(seed, "downloads", false), true);
+ assert.equal(seedChecked(seed, "archives", true), false, "absent from a saved submit is unticked");
+ const ok = { ok: true };
+ assert.equal(seedAfterSave(ok), ok);
+ const failed = { ok: false, error: "no", values };
+ assert.equal(seedAfterSave(failed), failed);
+ assert.equal(seedAfterSave(undefined), undefined);
+});
diff --git a/editor/app/lib/formState.ts b/editor/app/lib/formState.ts
@@ -89,3 +89,20 @@ export function seedChecked(
const values = failedValues(state);
return values ? Object.hasOwn(values, name) : initial;
}
+
+// A SAVE THAT DOES NOT REVALIDATE (release 24 H5). A server action that calls
+// revalidatePath makes the router refresh the page as the action lands, and
+// React commits the action's state WITH that refresh. Now and then the refresh
+// did not settle until the next router update (the AutoRefresh tick, ~5 s), so
+// "Saved." — and the form's reset — waited with it. The /sites forms therefore
+// save without revalidating, hand back what was submitted, and refresh the
+// page themselves once the state has landed (useRefreshAfterSave): the
+// confirmation never waits on a page render, and the page still follows.
+//
+// `seedAfterSave` is the seed for such a form: after a success that carries
+// `values`, the fields seed from what was saved — React's reset after the
+// action then shows it, before the refresh brings the stored copy — and
+// otherwise the state as it is (a failure's values, or nothing).
+export function seedAfterSave(state: SeedSource): SeedSource {
+ return state && state.ok === true && state.values ? { values: state.values } : state;
+}
diff --git a/editor/app/lib/useRefreshAfterSave.ts b/editor/app/lib/useRefreshAfterSave.ts
@@ -0,0 +1,15 @@
+"use client";
+
+import { useEffect } from "react";
+import { useRouter } from "next/navigation";
+
+// Refresh the page once a save's state has landed (lib/formState.ts
+// seedAfterSave, release 24 H5): the save does not revalidate, so its
+// confirmation commits on its own, and this brings the rest of the page —
+// a heading, a list, a Publish row — up to date in a transition of its own.
+export function useRefreshAfterSave(state: { ok?: boolean } | null | undefined): void {
+ const router = useRouter();
+ useEffect(() => {
+ if (state && state.ok === true) router.refresh();
+ }, [state, router]);
+}
diff --git a/editor/app/sites/actions.ts b/editor/app/sites/actions.ts
@@ -1,7 +1,6 @@
"use server";
import { PUBLISH_POLICIES, type PublishPolicy } from "yt-dlp-transcript-common/lib/settingsSchema";
-import { revalidatePath } from "next/cache";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import {
parseAccent,
@@ -31,13 +30,13 @@ import {
} from "yt-dlp-transcript-common/lib/channelGroups";
import { migrateToSites } from "yt-dlp-transcript-common/controller/migrateToSites";
import { socialLinksForSave } from "yt-dlp-transcript-common/lib/socialLinks";
-import { formValues, type FormState } from "../lib/formState";
+import { formValues, type FormState, type FormValues } from "../lib/formState";
import { reportSiteKeysFromForm } from "./lib/reportSiteKeys";
import { citedChannelsFromForm } from "./lib/citedChannelsFromForm";
// A failure carries what was submitted, so SiteForm keeps what was typed
// (lib/formState.ts).
-export type SaveResult = FormState<{ siteId: string }>;
+export type SaveResult = FormState<{ siteId: string; values: FormValues }>;
export async function saveSiteAction(
_prev: SaveResult | undefined,
@@ -301,11 +300,13 @@ export async function saveSiteAction(
values,
};
}
- revalidatePath("/sites");
- // "layout": the h1 above every tab reads siteTitle, and a literal path would
- // revalidate only the settings page (revalidatePath.md).
- revalidatePath("/sites/[siteId]", "layout");
- return { ok: true, siteId };
+ // NO revalidatePath (release 24 H5): React commits a revalidating action's
+ // state with the router's refresh of the page, which now and then did not
+ // settle until the next AutoRefresh tick, so "Saved." came up to ~6 s late.
+ // SiteForm seeds from `values` and refreshes the page itself once "Saved." is
+ // in (lib/formState.ts seedAfterSave, lib/useRefreshAfterSave.ts) — the h1
+ // above the tabs and /sites's list follow with that refresh.
+ return { ok: true, siteId, values };
}
export type DeleteResult = { ok: true } | { ok: false; error: string };
@@ -318,7 +319,8 @@ export async function deleteSiteAction(
} catch (err) {
return { ok: false, error: err instanceof Error ? err.message : String(err) };
}
- revalidatePath("/sites");
+ // No revalidatePath: the button refreshes the page itself (release 24 H5,
+ // lib/formState.ts seedAfterSave says why).
return { ok: true };
}
@@ -328,7 +330,7 @@ export async function migrateToSitesAction(): Promise<DeleteResult> {
} catch (err) {
return { ok: false, error: err instanceof Error ? err.message : String(err) };
}
- revalidatePath("/sites");
- revalidatePath("/settings");
+ // No revalidatePath: the button refreshes the page itself (release 24 H5).
+ // /settings is dynamic, rendered afresh on the next visit.
return { ok: true };
}
diff --git a/editor/app/sites/components/HomepageConfigForm.tsx b/editor/app/sites/components/HomepageConfigForm.tsx
@@ -4,7 +4,8 @@ import { useActionState } from "react";
import type { HomepageConfig } from "yt-dlp-transcript-common/lib/homepage";
import { saveHomepageConfigAction, type SaveResult } from "../lib/homepageActions";
import { SeededInput } from "../../components/forms/Field";
-import { seedChecked } from "../../lib/formState";
+import { seedAfterSave, seedChecked } from "../../lib/formState";
+import { useRefreshAfterSave } from "../../lib/useRefreshAfterSave";
const input =
"rounded-md border border-border bg-card px-3 py-1.5 text-sm";
@@ -15,13 +16,17 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
SaveResult | undefined,
FormData
>(saveHomepageConfigAction, undefined);
+ // The save does not revalidate /sites (lib/formState.ts seedAfterSave): the
+ // fields seed from what it saved, and the page refreshes once it has landed.
+ const seed = seedAfterSave(state);
+ useRefreshAfterSave(state);
return (
<form action={formAction} className="flex flex-col gap-3 max-w-xl">
<label className={label}>
Site title
<SeededInput
- state={state}
+ state={seed}
className={input}
name="siteTitle"
initial={config.siteTitle}
@@ -30,7 +35,7 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
<label className={label}>
Header title
<SeededInput
- state={state}
+ state={seed}
className={input}
name="headerTitle"
initial={config.headerTitle}
@@ -39,7 +44,7 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
<label className={label}>
Description
<SeededInput
- state={state}
+ state={seed}
className={input}
name="siteDescription"
initial={config.siteDescription}
@@ -48,7 +53,7 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
<label className={label}>
Home tagline
<SeededInput
- state={state}
+ state={seed}
className={input}
name="homeTagline"
initial={config.homeTagline}
@@ -57,7 +62,7 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
<label className={label}>
Public URL
<SeededInput
- state={state}
+ state={seed}
className={input}
name="siteUrl"
placeholder="https://archilyzer-hub.pages.dev"
@@ -67,7 +72,7 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
<label className={label}>
Cloudflare Pages project
<SeededInput
- state={state}
+ state={seed}
className={input}
name="cloudflareProject"
placeholder="archilyzer-hub"
@@ -79,7 +84,7 @@ export function HomepageConfigForm({ config }: { config: HomepageConfig }) {
type="checkbox"
name="transcriptDownloads"
defaultChecked={seedChecked(
- state,
+ seed,
"transcriptDownloads",
config.transcriptDownloads !== false,
)}
diff --git a/editor/app/sites/components/SiteForm.tsx b/editor/app/sites/components/SiteForm.tsx
@@ -22,7 +22,8 @@ import {
ControlledCheck,
ControlledSelect,
} from "../../components/forms/Controlled";
-import { seedChecked } from "../../lib/formState";
+import { seedAfterSave, seedChecked } from "../../lib/formState";
+import { useRefreshAfterSave } from "../../lib/useRefreshAfterSave";
export type ChannelOption = { slug: string; name: string };
export type SiteOption = { siteId: string; siteTitle: string };
@@ -63,6 +64,10 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
saveSiteAction,
undefined,
);
+ // The save does not revalidate (lib/formState.ts seedAfterSave): the fields
+ // seed from what it saved, and the page refreshes once it has landed.
+ const seed = seedAfterSave(state);
+ useRefreshAfterSave(state);
const [groups, setGroups] = useState<GroupRow[]>(() =>
initial.groups.map(toGroupRow),
);
@@ -235,7 +240,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
{isNew ? (
<Field
label="Site ID"
- state={state}
+ state={seed}
name="siteId"
defaultValue={initial.siteId}
required
@@ -252,34 +257,34 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
)}
<Field
label="Site title"
- state={state}
+ state={seed}
name="siteTitle"
defaultValue={initial.siteTitle}
required
/>
<Field
label="Header title"
- state={state}
+ state={seed}
name="headerTitle"
defaultValue={initial.headerTitle}
required
/>
<Field
label="Wordmark lead"
- state={state}
+ state={seed}
name="wordmarkLead"
defaultValue={initial.wordmarkLead ?? ""}
hint={'The heavy start of the wordmark — the subject\'s name, e.g. "Jer" for Jeralyzer; the rest is set light. It must be how the header text begins (same case) and shorter than it. Leave blank to set the whole name heavy.'}
/>
<Field
label="Site description"
- state={state}
+ state={seed}
name="siteDescription"
defaultValue={initial.siteDescription}
/>
<Field
label="Home tagline"
- state={state}
+ state={seed}
name="homeTagline"
defaultValue={initial.homeTagline}
/>
@@ -350,14 +355,14 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
</fieldset>
<Field
label="Cloudflare Pages project"
- state={state}
+ state={seed}
name="cloudflareProject"
defaultValue={initial.cloudflareProject ?? ""}
hint="Project name this site deploys to (wrangler --project-name). Leave blank to set later."
/>
<Field
label="Public URL"
- state={state}
+ state={seed}
name="siteUrl"
defaultValue={initial.siteUrl ?? ""}
hint="Absolute URL this site is served at (e.g. https://jeralyzer.com). Used so other sites can link to it in their footer. Leave blank to omit this site from cross-site lists."
@@ -365,7 +370,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
<label className="flex flex-col gap-1 text-sm">
<span className="font-medium">Audience</span>
<SeededSelect
- state={state}
+ state={seed}
name="audience"
aria-label="Audience"
initial={initial.audience === "private" ? "private" : "public"}
@@ -384,7 +389,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
<label className="flex flex-col gap-1 text-sm">
<span className="font-medium">Publish policy</span>
<SeededSelect
- state={state}
+ state={seed}
name="publishAuto"
aria-label="Publish policy"
initial={initial.publish?.auto ?? "off"}
@@ -405,7 +410,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
<input
type="checkbox"
name="search"
- defaultChecked={seedChecked(state, "search", initial.search !== false)}
+ defaultChecked={seedChecked(seed, "search", initial.search !== false)}
className="accent-brand"
/>
Search
@@ -447,7 +452,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
type="checkbox"
name="listed"
defaultChecked={seedChecked(
- state,
+ seed,
"listed",
initial.listed !== false,
)}
@@ -464,7 +469,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
</p>
<Field
label="Hub URL"
- state={state}
+ state={seed}
name="hubUrl"
defaultValue={initial.hubUrl ?? ""}
hint="The hub this site belongs under (e.g. https://archilyzer-hub.pages.dev), published in this site's /site.json and /corpus.json so the hub can tell it is a member; the header does not link to it. Leave blank to inherit the family default from Settings."
@@ -473,7 +478,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
<input
type="checkbox"
name="pwa"
- defaultChecked={seedChecked(state, "pwa", initial.pwa === true)}
+ defaultChecked={seedChecked(seed, "pwa", initial.pwa === true)}
className="accent-brand"
/>
Ship as an installable PWA
@@ -489,7 +494,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
type="checkbox"
name="archives"
defaultChecked={seedChecked(
- state,
+ seed,
"archives",
initial.archives !== false,
)}
@@ -504,7 +509,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
</p>
<Field
label="Archive size cap (MB)"
- state={state}
+ state={seed}
name="archiveMaxMB"
type="number"
min="0"
@@ -520,7 +525,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
type="checkbox"
name="transcriptDownloads"
defaultChecked={seedChecked(
- state,
+ seed,
"transcriptDownloads",
initial.transcriptDownloads !== false,
)}
@@ -540,7 +545,7 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) {
type="checkbox"
name="duplicates"
defaultChecked={seedChecked(
- state,
+ seed,
"duplicates",
initial.duplicates !== false,
)}
diff --git a/editor/app/sites/components/SiteListActions.tsx b/editor/app/sites/components/SiteListActions.tsx
@@ -1,9 +1,13 @@
"use client";
import { useState, useTransition } from "react";
+import { useRouter } from "next/navigation";
import { deleteSiteAction, migrateToSitesAction } from "../actions";
+// Both actions save without revalidating and refresh the page here (release 24
+// H5, lib/formState.ts seedAfterSave says why).
export function DeleteSiteButton({ siteId }: { siteId: string }) {
+ const router = useRouter();
const [pending, start] = useTransition();
const [error, setError] = useState<string | null>(null);
return (
@@ -16,6 +20,7 @@ export function DeleteSiteButton({ siteId }: { siteId: string }) {
start(async () => {
const res = await deleteSiteAction(siteId);
if (!res.ok) setError(res.error);
+ else router.refresh();
});
}}
className="px-2 py-1 rounded border border-destructive/30 text-xs text-destructive disabled:opacity-50"
@@ -28,6 +33,7 @@ export function DeleteSiteButton({ siteId }: { siteId: string }) {
}
export function MigrateButton() {
+ const router = useRouter();
const [pending, start] = useTransition();
const [error, setError] = useState<string | null>(null);
return (
@@ -39,6 +45,7 @@ export function MigrateButton() {
start(async () => {
const res = await migrateToSitesAction();
if (!res.ok) setError(res.error);
+ else router.refresh();
})
}
className="px-3 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:opacity-90 disabled:opacity-50"
diff --git a/editor/app/sites/lib/homepageActions.ts b/editor/app/sites/lib/homepageActions.ts
@@ -1,6 +1,5 @@
"use server";
-import { revalidatePath } from "next/cache";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import {
getHomepageConfig,
@@ -8,10 +7,12 @@ import {
parseHomepageUrl,
type HomepageConfig,
} from "yt-dlp-transcript-common/lib/homepage";
-import { formValues, type FormState } from "../../lib/formState";
+import { formValues, type FormState, type FormValues } from "../../lib/formState";
-// A failure carries what was submitted (lib/formState.ts).
-export type SaveResult = FormState;
+// A failure carries what was submitted (lib/formState.ts), and so does a
+// success: the save does not revalidate, and the form seeds from it
+// (seedAfterSave) and refreshes the page itself (release 24 H5).
+export type SaveResult = FormState<{ values: FormValues }>;
// Branding/config for the hub landing site. The hub is a single cross-site
// landing page (no authored Markdown pages), so this is the only homepage action.
@@ -62,6 +63,5 @@ export async function saveHomepageConfigAction(
values,
};
}
- revalidatePath("/sites");
- return { ok: true };
+ return { ok: true, values };
}
diff --git a/editor/e2e/sites-crud.spec.ts b/editor/e2e/sites-crud.spec.ts
@@ -528,6 +528,47 @@ test("the hub form's per-video transcript downloads opt-out round-trips to homep
await expect(downloads).toBeChecked();
});
+// Release 24 H5: the hub form's "Saved." never waits for a refresh of /sites.
+// Its save used to revalidate the page, and now and then the router's refresh
+// as the action landed did not settle until the next AutoRefresh tick, ~5 s
+// later — the flake above. Every non-prefetch read of /sites is held here for
+// 6 s: a save that waited on one would miss the default 5 s. After each save the
+// fields show what was saved (React resets the form when the action lands).
+test("the hub form's Saved. does not wait for /sites to refresh, and the fields keep what was saved", async ({
+ page,
+}) => {
+ await resetData("empty");
+ await page.route(/\/sites\?_rsc=/, async (route) => {
+ if (!route.request().headers()["next-router-prefetch"]) {
+ await new Promise((r) => setTimeout(r, 6_000));
+ }
+ await route.continue().catch(() => {});
+ });
+ const form = page
+ .locator("form")
+ .filter({ has: page.getByRole("button", { name: "Save config" }) });
+ const downloads = form.getByRole("checkbox", { name: /per-video transcript downloads/i });
+ const tagline = form.getByRole("textbox", { name: "Home tagline" });
+ for (const [checked, text] of [
+ [false, "First tagline"],
+ [true, "Second tagline"],
+ ] as const) {
+ await page.goto("/sites");
+ await downloads.setChecked(checked);
+ await tagline.fill(text);
+ await form.getByRole("button", { name: "Save config" }).click();
+ await expect(form.getByText("Saved.")).toBeVisible();
+ if (checked) await expect(downloads).toBeChecked();
+ else await expect(downloads).not.toBeChecked();
+ await expect(tagline).toHaveValue(text);
+ }
+ const hub = await readJson<{ homeTagline?: string; transcriptDownloads?: boolean }>(
+ "test-transcripts/sites/_homepage/homepage.json",
+ );
+ expect(hub.homeTagline).toBe("Second tagline");
+ expect("transcriptDownloads" in hub).toBe(false);
+});
+
test("first-run migrate button appears only when no sites exist", async ({
page,
}) => {