commit 36e19b5bf146d15a992c6e9f658156b0b517c7a8
parent d8137dfef34d3506f2138319cfc4c1cd69d312e4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 18 Nov 2026 04:17:25 -0500
editor: a streamed section that throws fails in its own place
A streamed section's read can fail on its own. Without a boundary the
failure climbed to the route's error page and took the shell with it: on
/settings, the form. StreamErrorBoundary (one shared component) is around
every streamed section of the dashboard, /jobs, /settings, /storage and
/channels: the section's place says in a sentence that it could not be
loaded, with the error's message, and the rest of the page stands. No
retry: the next render of the page shows what that render produced.
/settings reads settings.json once and hands it to both sections.
The test server can make one section throw (the e2e-stream-fail cookie,
beside the delay cookie; inert without E2E_TEST_ROUTES=1).
Dashboard, in the same files: with no channel directory at all (one readdir, already made for the
skeleton) the first-run checklist is drawn with the heading, so it no
longer pushes the page down when the live half arrives. Under a site
scope the channels skeleton counts that site's members (a cookie and the
site's own file), not the whole pool.
The drive and cookie-refresh alerts stay with the live half: whether one
exists is the answer of reads that are not cheap (a mount probe that is
a subprocess when its memo is cold; a cookie store read).
The job-row constant is 59 px (the row the box test now seeds), and the
comments beside the skeleton sizes say which states are held exactly.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
8 files changed, 220 insertions(+), 96 deletions(-)
diff --git a/editor/app/channels/page.tsx b/editor/app/channels/page.tsx
@@ -65,6 +65,7 @@ import { RefreshAllReportsButton } from "./components/RefreshAllReportsButton";
import { readActiveSite } from "../lib/activeSiteServer";
import { SkeletonPanel, SkeletonRows, StreamFilled } from "../components/StreamSkeleton";
import { e2eStreamDelay } from "../lib/streamDelay";
+import { StreamErrorBoundary } from "../components/StreamErrorBoundary";
export const dynamic = "force-dynamic";
@@ -181,7 +182,7 @@ const loadChannelsView = cache(
locationParam: string | undefined,
sortParam: string | undefined,
): Promise<{ freshnessLine: React.ReactNode; body: React.ReactNode }> => {
- await e2eStreamDelay();
+ await e2eStreamDelay("channels-rack");
const paths = getPaths();
const settings = getSettings();
// The active site: a `?site=` link's for this request, else the cookie's.
@@ -503,21 +504,24 @@ export default async function ChannelsPage({
read from each channel's last report, so the line says how old the
oldest one is and how many have none (the rack's Report column names
them). */}
- <Suspense
- fallback={
- pending > 0 ? (
- <p
- className="text-xs text-muted-foreground"
- data-stream-skeleton="channels-freshness"
- aria-hidden="true"
- >
-
- </p>
- ) : null
- }
- >
- <Freshness view={view} />
- </Suspense>
+ {/* Quiet: the rack below reports the same read's failure. */}
+ <StreamErrorBoundary name="channels-freshness" what="The report freshness" quiet>
+ <Suspense
+ fallback={
+ pending > 0 ? (
+ <p
+ className="text-xs text-muted-foreground"
+ data-stream-skeleton="channels-freshness"
+ aria-hidden="true"
+ >
+
+ </p>
+ ) : null
+ }
+ >
+ <Freshness view={view} />
+ </Suspense>
+ </StreamErrorBoundary>
</div>
{/* FOUR DARK PILLS OF EQUAL WEIGHT was four things shouting. Three of
these sweep the WHOLE pool and are used rarely; one creates a
@@ -540,23 +544,25 @@ export default async function ChannelsPage({
</div>
</div>
</header>
- <Suspense
- fallback={
- pending === 0 ? (
- <SkeletonPanel name="channels-rack" height={RACK_EMPTY_PX} />
- ) : (
- <SkeletonRows
- name="channels-rack"
- rows={pending}
- rowHeight={RACK_ROW_PX}
- head={RACK_CHROME_PX}
- className="min-h-0 flex-1 rounded-md border border-border"
- />
- )
- }
- >
- <Rack view={view} />
- </Suspense>
+ <StreamErrorBoundary name="channels-rack" what="The channels">
+ <Suspense
+ fallback={
+ pending === 0 ? (
+ <SkeletonPanel name="channels-rack" height={RACK_EMPTY_PX} />
+ ) : (
+ <SkeletonRows
+ name="channels-rack"
+ rows={pending}
+ rowHeight={RACK_ROW_PX}
+ head={RACK_CHROME_PX}
+ className="min-h-0 flex-1 rounded-md border border-border"
+ />
+ )
+ }
+ >
+ <Rack view={view} />
+ </Suspense>
+ </StreamErrorBoundary>
</div>
);
}
diff --git a/editor/app/components/StreamErrorBoundary.tsx b/editor/app/components/StreamErrorBoundary.tsx
@@ -0,0 +1,68 @@
+"use client";
+
+import { Component, type ReactNode } from "react";
+
+// WHAT A STREAMED SECTION SHOWS WHEN ITS READ THROWS.
+//
+// A page that streams sends its shell first and each slow section when its
+// read is done (StreamSkeleton.tsx). A section's read can fail on its own — a
+// session file that cannot be parsed, a probe that throws — and without a
+// boundary of its own the failure climbs to the route's error page and takes
+// the shell with it: on /settings, the form. With one, the rest of the page
+// stays and the section's place says, in a sentence, that it could not be
+// loaded, and why.
+//
+// NO RETRY. Nothing here asks for the section again. The next render of the
+// page (a refresh, a navigation) hands this boundary new children, and it
+// shows whatever that render produced — the section, or the error again.
+//
+// The message is the error's own. In a production build React replaces a
+// server component's message with a generic one and a digest; the digest is
+// shown, because that is what the server's log names the real error by.
+
+type Props = {
+ // data-stream-error="<name>": the section's name, as its skeleton has it.
+ name: string;
+ // The sentence's subject: "The job list".
+ what: string;
+ // A section whose failure another boundary on the page already reports
+ // (two sections of one read): hold nothing, say nothing.
+ quiet?: boolean;
+ children: ReactNode;
+};
+
+type State = { error: (Error & { digest?: string }) | null };
+
+export class StreamErrorBoundary extends Component<Props, State> {
+ state: State = { error: null };
+
+ static getDerivedStateFromError(error: Error): State {
+ return { error };
+ }
+
+ componentDidUpdate(prev: Props) {
+ // A new render of the page: show what it produced.
+ if (this.state.error && prev.children !== this.props.children) {
+ this.setState({ error: null });
+ }
+ }
+
+ render() {
+ const { error } = this.state;
+ if (!error) return this.props.children;
+ if (this.props.quiet) return null;
+ return (
+ <p
+ role="alert"
+ data-stream-error={this.props.name}
+ className="rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm"
+ >
+ {this.props.what} could not be loaded.{" "}
+ <span className="text-muted-foreground">
+ {error.message}
+ {error.digest ? ` (${error.digest})` : ""}
+ </span>
+ </p>
+ );
+ }
+}
diff --git a/editor/app/components/dashboard/DashboardCockpit.tsx b/editor/app/components/dashboard/DashboardCockpit.tsx
@@ -7,6 +7,7 @@ import type { WidgetActionablePayload } from "yt-dlp-transcript-common/views/wid
import type { WidgetSyncPayload } from "yt-dlp-transcript-common/views/widgetSync";
import { usePolledPayload, useNow } from "../../lib/usePolledPayload";
import { SkeletonPanel, SkeletonRows, StreamFilled } from "../StreamSkeleton";
+import { StreamErrorBoundary } from "../StreamErrorBoundary";
import { PipelineBand } from "./PipelineBand";
import { NeedsWorkPanel } from "./NeedsWorkPanel";
import { QuickAddPanel } from "./QuickAddPanel";
@@ -57,6 +58,9 @@ type CockpitProps = {
// boundary, so the page's shell is sent before either is done.
jobs: Promise<ActiveJobsPayload>;
corpus: Promise<DashboardCorpus>;
+ // The first-run checklist, when the shell already knows there is no channel
+ // (app/page.tsx): drawn with the heading, not with the live half.
+ firstRun: FirstRunState | null;
// What the skeletons are sized by: counts known without the slow reads.
pending: { channels: number; jobs: number };
};
@@ -78,6 +82,8 @@ export function DashboardCockpit(props: CockpitProps) {
return (
<div className="flex flex-col gap-6">
<h1 className="sr-only">Dashboard</h1>
+ {props.firstRun && <FirstRunPanel state={props.firstRun} />}
+ <StreamErrorBoundary name="dashboard-pipeline" what="The pipeline and Needs work">
<Suspense
fallback={
<>
@@ -99,6 +105,8 @@ export function DashboardCockpit(props: CockpitProps) {
>
<CockpitLive {...props} />
</Suspense>
+ </StreamErrorBoundary>
+ <StreamErrorBoundary name="dashboard-channels" what="The channels table">
<Suspense
fallback={
props.pending.channels > 0 ? (
@@ -118,6 +126,7 @@ export function DashboardCockpit(props: CockpitProps) {
>
<CockpitChannels corpus={props.corpus} />
</Suspense>
+ </StreamErrorBoundary>
</div>
);
}
@@ -126,19 +135,23 @@ export function DashboardCockpit(props: CockpitProps) {
// band; what a live job list adds to it (its strip and header) and one job's
// row; the "Needs work" card with nothing in it; the channels table's header
// and row. e2e/streaming.spec.ts holds each skeleton's box to the box of what
-// replaces it, so a restyle that moves one of these fails there. What is known
-// before the reads is a COUNT, so a section whose height depends on more than
-// that (a job row with several tasks, a "Needs work" list) is held to its
-// usual size, not its exact one.
+// replaces it — idle, and with one live job seeded — so a restyle that moves
+// one of these fails there. What is known before the reads is a COUNT, so a
+// section whose height depends on more than that is held to its usual size,
+// not its exact one: a job row with a channel and tasks is a few px taller
+// than this one, a job that just finished is listed for half a minute though
+// it is no longer counted, and "Needs work" is sized for its empty state.
+// The alerts above the band (a drive, a cookie refresh) are not held at all:
+// whether one exists is the answer of the slow read itself.
const PIPELINE_IDLE_PX = 333;
const PIPELINE_JOBS_CHROME_PX = 182;
-const PIPELINE_JOB_ROW_PX = 62;
+const PIPELINE_JOB_ROW_PX = 59;
const NEEDS_WORK_EMPTY_PX = 74;
const CHANNEL_HEAD_PX = 38;
const CHANNEL_ROW_PX = 43;
// The live half: the alerts, the pipeline band and "Needs work".
-function CockpitLive({ workers: workersSeed, changelog, jobs: jobsPromise, corpus }: CockpitProps) {
+function CockpitLive({ workers: workersSeed, changelog, jobs: jobsPromise, corpus, firstRun }: CockpitProps) {
const seed = use(corpus);
const jobsSeed = use(jobsPromise);
const now = useNow();
@@ -190,7 +203,9 @@ function CockpitLive({ workers: workersSeed, changelog, jobs: jobsPromise, corpu
data={cookieAlerts ?? EMPTY_COOKIE_ALERTS}
onChange={() => void refetchCookieAlerts()}
/>
- {seed.firstRun && <FirstRunPanel state={seed.firstRun} />}
+ {/* Only when the shell did not already draw it: channel directories
+ exist, but none of them holds a channel. */}
+ {!firstRun && seed.firstRun && <FirstRunPanel state={seed.firstRun} />}
<StreamFilled name="dashboard-pipeline">
<PipelineBand
jobs={jobs}
diff --git a/editor/app/jobs/page.tsx b/editor/app/jobs/page.tsx
@@ -20,6 +20,7 @@ import { RetryAllFailedButton } from "./components/RetryAllFailedButton";
import { PauseLaneButton } from "../components/lanes/pauseControl";
import { SkeletonPanel, StreamFilled } from "../components/StreamSkeleton";
import { e2eStreamDelay } from "../lib/streamDelay";
+import { StreamErrorBoundary } from "../components/StreamErrorBoundary";
export const dynamic = "force-dynamic";
@@ -41,13 +42,14 @@ function parseLimit(raw: string | string[] | undefined): number {
return Math.min(Math.floor(n), MAX_JOBS_LIMIT);
}
-// What the skeleton is sized by, in px (e2e/streaming.spec.ts holds it to the
-// box of what replaces it): the list with no job in it, the chrome above a
-// table (the lane strip, the health line, the kind filters, the header row),
-// and one row.
+// What the skeleton is sized by, in px: the list with no job in it, the chrome
+// above a table (the lane strip, the health line, the kind filters, the header
+// row), and one row. e2e/streaming.spec.ts holds the skeleton to the box of
+// what replaces it with no job and with one live and one finished job seeded;
+// a row with a channel and tasks is a few px taller than this one.
const JOBS_EMPTY_PX = 326;
const JOBS_CHROME_PX = 412;
-const JOBS_ROW_PX = 62;
+const JOBS_ROW_PX = 59;
export default async function JobsPage({
searchParams,
@@ -80,25 +82,27 @@ export default async function JobsPage({
</div>
</div>
<RenderModeBanner />
- <Suspense
- fallback={
- <SkeletonPanel
- name="jobs-list"
- height={
- pending === 0 ? JOBS_EMPTY_PX : JOBS_CHROME_PX + pending * JOBS_ROW_PX
- }
- />
- }
- >
- <JobsList limit={limit} />
- </Suspense>
+ <StreamErrorBoundary name="jobs-list" what="The job list">
+ <Suspense
+ fallback={
+ <SkeletonPanel
+ name="jobs-list"
+ height={
+ pending === 0 ? JOBS_EMPTY_PX : JOBS_CHROME_PX + pending * JOBS_ROW_PX
+ }
+ />
+ }
+ >
+ <JobsList limit={limit} />
+ </Suspense>
+ </StreamErrorBoundary>
</div>
);
}
// The list: the live head and one page of the history tail.
async function JobsList({ limit }: { limit: number }) {
- await e2eStreamDelay();
+ await e2eStreamDelay("jobs-list");
const [{ rows, hasMore, total }, initial] = await Promise.all([
listJobRows(getPaths(), { limit }),
buildActiveJobsPayload(),
diff --git a/editor/app/lib/streamDelay.ts b/editor/app/lib/streamDelay.ts
@@ -12,12 +12,21 @@ import { cookies } from "next/headers";
//
// INERT OUTSIDE A TEST SERVER: without E2E_TEST_ROUTES=1 (the test server's
// identity, api/test/_guard.ts) the cookie is not even read.
+//
+// A SECOND COOKIE MAKES ONE SECTION FAIL: `e2e-stream-fail=<name>` throws in
+// the section of that name, so a spec can see that a section's failure stays
+// in its own place (StreamErrorBoundary) and the rest of the page stands.
export const STREAM_DELAY_COOKIE = "e2e-stream-delay";
+export const STREAM_FAIL_COOKIE = "e2e-stream-fail";
const MAX_DELAY_MS = 5_000;
-export async function e2eStreamDelay(): Promise<void> {
+// `name` is the section's (its skeleton's `data-stream-skeleton`).
+export async function e2eStreamDelay(name?: string): Promise<void> {
if (process.env.E2E_TEST_ROUTES !== "1") return;
- const raw = (await cookies()).get(STREAM_DELAY_COOKIE)?.value;
- const ms = Math.min(Number(raw) || 0, MAX_DELAY_MS);
+ const jar = await cookies();
+ const ms = Math.min(Number(jar.get(STREAM_DELAY_COOKIE)?.value) || 0, MAX_DELAY_MS);
if (ms > 0) await new Promise((resolve) => setTimeout(resolve, ms));
+ if (name && jar.get(STREAM_FAIL_COOKIE)?.value === name) {
+ throw new Error(`e2e: the ${name} section was told to fail`);
+ }
}
diff --git a/editor/app/page.tsx b/editor/app/page.tsx
@@ -92,7 +92,7 @@ function loadChangelogCard(): React.ReactNode {
// boundary (DashboardCockpit).
const loadCorpus = cache(
async (paths: Paths, siteParam: string | undefined): Promise<DashboardCorpus> => {
- await e2eStreamDelay();
+ await e2eStreamDelay("dashboard-channels");
// The active site: a `?site=` link's for this request, else the cookie's.
const active = await readActiveSite(siteParam, listSiteIds(paths));
const summary = await getActionableSummary(paths);
@@ -176,7 +176,7 @@ const loadCorpus = cache(
// off the disk (a walk of that channel's data/) holds back only the cockpit's
// live half, never the page.
async function loadJobs() {
- await e2eStreamDelay();
+ await e2eStreamDelay("dashboard-pipeline");
return buildActiveJobsPayload();
}
@@ -188,9 +188,16 @@ export default async function Dashboard({
const paths = getPaths();
const { site } = await searchParams;
// WHAT THE SKELETONS ARE SIZED BY, known without either slow read: how many
- // channels there are (one readdir) and how many jobs are live (memory).
- // Under a site scope the table is shorter than this; the count is the pool's.
+ // channels the table will list (one readdir, narrowed to the active site's
+ // members — a cookie and that site's own file) and how many jobs are live
+ // (memory).
const slugs = await listChannelSlugs(paths);
+ const active = await readActiveSite(site, listSiteIds(paths));
+ const scope =
+ active.isAll || !active.siteId
+ ? null
+ : siteChannelSlugs(getSite(active.siteId, paths));
+ const channelCount = scope ? slugs.filter((s) => scope.has(s)).length : slugs.length;
const liveJobs = getRegistry()
.list()
.filter((j) => j.status === "running" || j.status === "queued").length;
@@ -201,7 +208,12 @@ export default async function Dashboard({
changelog={loadChangelogCard()}
jobs={loadJobs()}
corpus={loadCorpus(paths, site)}
- pending={{ channels: slugs.length, jobs: liveJobs }}
+ // THE FIRST-RUN CHECKLIST IS THE SHELL'S: an archive with no channel
+ // directory is known from the readdir above, and the checklist's facts
+ // are a few stats. Sent with the heading, it does not push the page
+ // down when the live half arrives.
+ firstRun={slugs.length === 0 ? firstRunState(paths) : null}
+ pending={{ channels: channelCount, jobs: liveJobs }}
/>
);
}
diff --git a/editor/app/settings/page.tsx b/editor/app/settings/page.tsx
@@ -3,13 +3,14 @@ import { Suspense } from "react";
import Link from "next/link";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import { displayPath } from "yt-dlp-transcript-common/lib/privacy/privacy-server";
-import { getSettings } from "yt-dlp-transcript-common/lib/settings";
+import { getSettings, type SiteSettings } from "yt-dlp-transcript-common/lib/settings";
import { readXSessionStatus } from "yt-dlp-transcript-common/social/xSessionBroker";
import { resolveXCookieSourceFor } from "yt-dlp-transcript-common/social/xBrowserLogin";
import { xCookieSourceView } from "yt-dlp-transcript-common/social/xCookieSource";
import { xPostsVisibility } from "yt-dlp-transcript-common/lib/postsVisibility";
import { SettingsForm } from "./components/SettingsForm";
import { SkeletonPanel, StreamFilled } from "../components/StreamSkeleton";
+import { StreamErrorBoundary } from "../components/StreamErrorBoundary";
import { e2eStreamDelay } from "../lib/streamDelay";
import { xSourceForDisplay } from "../lib/xSourceDisplay";
import { XSessionSection } from "./components/XSessionSection";
@@ -107,18 +108,22 @@ export default async function SettingsPage() {
the disk (X's profile and cookie source; archive.today's), and the
form above must not wait for either. */}
<section className="flex flex-col gap-3 border-t border-border pt-6">
- <Suspense fallback={<SkeletonPanel name="settings-x" height={X_SECTION_PX} />}>
- <XSection />
- </Suspense>
+ <StreamErrorBoundary name="settings-x" what="The X session section">
+ <Suspense fallback={<SkeletonPanel name="settings-x" height={X_SECTION_PX} />}>
+ <XSection settings={settings} />
+ </Suspense>
+ </StreamErrorBoundary>
</section>
{/* Release 37 lane F: archive.today's host, pace and session. */}
<section className="flex flex-col gap-3 border-t border-border pt-6">
- <Suspense
- fallback={<SkeletonPanel name="settings-archives" height={ARCHIVE_SECTION_PX} />}
- >
- <ArchivesSection />
- </Suspense>
+ <StreamErrorBoundary name="settings-archives" what="The archive.today section">
+ <Suspense
+ fallback={<SkeletonPanel name="settings-archives" height={ARCHIVE_SECTION_PX} />}
+ >
+ <ArchivesSection settings={settings} />
+ </Suspense>
+ </StreamErrorBoundary>
</section>
<section className="flex flex-col gap-3 border-t border-border pt-6">
@@ -160,10 +165,11 @@ export default async function SettingsPage() {
const X_SECTION_PX = 507;
const ARCHIVE_SECTION_PX = 198;
-async function XSection() {
- await e2eStreamDelay();
+// `settings` is the page's one read of the file: the form and both sections
+// draw the same settings, not three reads at three instants.
+async function XSection({ settings }: { settings: SiteSettings }) {
+ await e2eStreamDelay("settings-x");
const paths = getPaths();
- const settings = getSettings();
// The X session broker's current state and the X login source in use (see
// xSessionActions.ts). The source is resolved here, not read: with no stored
// choice it depends on cookiesFromBrowser and the profile.
@@ -184,12 +190,12 @@ async function XSection() {
);
}
-async function ArchivesSection() {
- await e2eStreamDelay();
+async function ArchivesSection({ settings }: { settings: SiteSettings }) {
+ await e2eStreamDelay("settings-archives");
const session = await readArchiveSessionStatus(getPaths());
return (
<StreamFilled name="settings-archives" className="flex flex-col gap-3">
- <ArchiveSourcesSection initial={getSettings().archives} session={session} />
+ <ArchiveSourcesSection initial={settings.archives} session={session} />
</StreamFilled>
);
}
diff --git a/editor/app/storage/page.tsx b/editor/app/storage/page.tsx
@@ -7,6 +7,7 @@ import { StorageLocationsTable } from "./components/StorageLocationsTable";
import { HealthTimingForm } from "./components/HealthTimingForm";
import { SkeletonPanel, StreamFilled } from "../components/StreamSkeleton";
import { e2eStreamDelay } from "../lib/streamDelay";
+import { StreamErrorBoundary } from "../components/StreamErrorBoundary";
// FORCE-DYNAMIC, and not as a formality. Every number on this page comes from a
// probe of the machine taken when the page was asked for — whether a disk is
@@ -18,7 +19,8 @@ export const dynamic = "force-dynamic";
export const metadata: Metadata = { title: "Storage" };
// The skeleton's size in px (e2e/streaming.spec.ts holds it to the box of what
-// replaces it): the section with no location in it — the two cards (the saved
+// replaces it, with no location and with one seeded): the section with no
+// location in it — the two cards (the saved
// video store, the clip windows) and the add form's button — and one
// location's card.
const STORAGE_BASE_PX = 1034;
@@ -28,7 +30,7 @@ const STORAGE_LOCATION_PX = 284;
// of the machine (is each drive mounted, how much room is on it, how big is
// the store), so it streams in behind the heading rather than holding it.
async function StorageBody() {
- await e2eStreamDelay();
+ await e2eStreamDelay("storage-locations");
const payload = await buildStorage();
return (
<StreamFilled name="storage-locations">
@@ -50,19 +52,21 @@ export default function StoragePage() {
<Link href="/channels" className="underline">Storage panel</Link>.
</p>
- <Suspense
- fallback={
- <SkeletonPanel
- name="storage-locations"
- height={
- STORAGE_BASE_PX +
- settings.storage.locations.length * STORAGE_LOCATION_PX
- }
- />
- }
- >
- <StorageBody />
- </Suspense>
+ <StreamErrorBoundary name="storage-locations" what="The storage locations">
+ <Suspense
+ fallback={
+ <SkeletonPanel
+ name="storage-locations"
+ height={
+ STORAGE_BASE_PX +
+ settings.storage.locations.length * STORAGE_LOCATION_PX
+ }
+ />
+ }
+ >
+ <StorageBody />
+ </Suspense>
+ </StreamErrorBoundary>
{/* THE TIMINGS EVERY LOCATION IS JUDGED BY (settings.storage.health),
collapsed and last: a page-wide setting, not a fact about a row. */}