Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 876638dada923c20d77121a4bbec1dccf9ddc3f5
parent 7474d0567ba9c5274122c08706cc207454b67dc2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 09:29:00 -0500

local media page: the Local library tab only on a channel that has a library

Review fix 8. The tab showed on every video channel, and the page offered a
form to add a library to any of them. A library is added two ways only: the
New channel form (Local Archive) and `pnpm ops local-media-configure`. The
tab shows only when the channel has a library; /channels/<slug>/local-media
stays reachable by URL and, for a channel without one, renders an empty state
naming the command with the channel's slug. The page's configure action is
gone. e2e: the tab on the Local Archive channel; no tab, the empty state and
the command, and no Save library button on a plain channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
Meditor/app/channels/[slug]/local-media/LocalMediaPanel.tsx | 32++++++++++----------------------
Meditor/app/channels/[slug]/local-media/actions.ts | 14--------------
Meditor/app/channels/[slug]/page.tsx | 2+-
Meditor/e2e/local-media.spec.ts | 21++++++++++++++++++++-
4 files changed, 31 insertions(+), 38 deletions(-)

diff --git a/editor/app/channels/[slug]/local-media/LocalMediaPanel.tsx b/editor/app/channels/[slug]/local-media/LocalMediaPanel.tsx @@ -7,13 +7,11 @@ import type { LocalMediaConfig } from "yt-dlp-transcript-common/lib/localMedia"; import type { LocalMediaPreview } from "yt-dlp-transcript-common/controller/localMediaImport"; import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog"; import { cancelJobAction, drainJobAction } from "../../../jobs/actions"; -import { configureLibraryAction, previewLibraryAction, importLibraryAction, linkExistingLibraryRecordingAction } from "./actions"; +import { previewLibraryAction, importLibraryAction, linkExistingLibraryRecordingAction } from "./actions"; const button = "rounded border border-border px-3 py-2 disabled:opacity-50"; export function LocalMediaPanel({ slug, initialConfig }: { slug: string; initialConfig: LocalMediaConfig | null }) { - const [config, setConfig] = useState(initialConfig); - const [sourceId, setSourceId] = useState("library-1"); - const [directory, setDirectory] = useState(""); + const config = initialConfig; const [preview, setPreview] = useState<LocalMediaPreview | null>(null); const [selected, setSelected] = useState<Set<string>>(new Set()); const [error, setError] = useState<string | null>(null); @@ -57,24 +55,14 @@ export function LocalMediaPanel({ slug, initialConfig }: { slug: string; initial } return <section className="[&_button:enabled]:cursor-pointer [&_button:enabled:hover]:brightness-125 [&_button:disabled]:cursor-not-allowed space-y-4 rounded border border-border p-4"> - {!config ? <form className="space-y-3" onSubmit={event => { - event.preventDefault(); setError(null); - start(async () => { - try { - const result = await configureLibraryAction(slug, {sourceId, directory}); - if (result.ok) setConfig(result.config); else setError(result.error); - } catch { setError("Could not contact the editor. Try again."); } - }); - }}> - <label className="block">Library ID - <input required pattern="[a-z0-9][a-z0-9_-]{0,63}" value={sourceId} onChange={e => setSourceId(e.target.value)} className="block rounded border p-2 bg-background" /> - </label> - <label className="block">Library directory - <input required value={directory} onChange={e => setDirectory(e.target.value)} placeholder="/mnt/library" className="block w-full rounded border p-2 bg-background" /> - </label> - <p className="text-sm text-muted-foreground">An absolute path the editor can read (in Docker, the path inside the container). It cannot be changed once saved.</p> - <button className={button} disabled={busy}>Save library</button> - </form> : <> + {/* A library is added through the New channel form (Local Archive) or + `pnpm ops local-media-configure` (review fix 8); this route stays + reachable by URL for a channel without one, and says how. */} + {!config ? <div role="status" className="space-y-2"> + <p>This channel has no local media library.</p> + <p className="text-sm text-muted-foreground">Add one with the New channel form (Local Archive) for a new channel, or for this one:</p> + <pre className="whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs">{`pnpm ops local-media-configure --json '{"slug":"${slug}","sourceId":"library-1","directory":"/absolute/path/to/recordings"}'`}</pre> + </div> : <> <p><strong>{config.sourceId}</strong> ยท <code className="break-all">{config.directory}</code></p> <p className="text-sm text-muted-foreground">Each .mp4 directly in this directory, with a same-named .info.json and .vtt (or .srt). Subdirectories are not scanned.</p> <button className={button} disabled={busy} onClick={() => { diff --git a/editor/app/channels/[slug]/local-media/actions.ts b/editor/app/channels/[slug]/local-media/actions.ts @@ -3,7 +3,6 @@ import { channelWriters } from "yt-dlp-transcript-common/controller/channelWrite import { adoptLocalMediaReference } from "yt-dlp-transcript-common/controller/adoptLocalMediaReference"; import { revalidatePath } from "next/cache"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; -import { configureLocalMedia } from "yt-dlp-transcript-common/controller/configureLocalMedia"; import { prepareLocalMediaRecording, type LocalRecordingPreparationRequest, previewLocalMedia } from "yt-dlp-transcript-common/controller/localMediaImport"; import { startLocalMediaImportJob, type LocalMediaJobRequest } from "yt-dlp-transcript-common/controller/localMediaImportJob"; @@ -11,19 +10,6 @@ import { startLocalMediaImportJob, type LocalMediaJobRequest } from "yt-dlp-tran // as the channel's existing actions. Do not expose them through the public export. // Client input is validated again by the controllers. No absolute source paths // are accepted for import; selections refer to the stored source and preview. -export async function configureLibraryAction(slug: string, input: unknown) { - try { - const config = await configureLocalMedia(getPaths(), slug, input); - revalidatePath(`/channels/${slug}/local-media`); - return { ok: true as const, config }; - } catch (e) { - // A misplaced library says where it is (controller/localMediaLocation.ts). - const message = (e as Error).message ?? ""; - if (message.startsWith("The library directory is inside")) return { ok: false as const, error: message }; - return { ok: false as const, error: "Could not configure the library. Check the server path, channel activity, and whether a library is already configured." }; - } -} - export async function previewLibraryAction(slug: string) { try { return { ok: true as const, preview: await previewLocalMedia(getPaths(), slug) }; } catch (e) { diff --git a/editor/app/channels/[slug]/page.tsx b/editor/app/channels/[slug]/page.tsx @@ -1004,7 +1004,7 @@ export default async function ChannelDetailPage({ stageOrder={stageOrder} stages={stages} selected={selectedStage} - showLocalLibrary={!isSocialChannel(config)} + showLocalLibrary={!isSocialChannel(config) && !!config.localMedia} /> {selectedStage ? ( <section diff --git a/editor/e2e/local-media.spec.ts b/editor/e2e/local-media.spec.ts @@ -10,7 +10,7 @@ import { test, expect } from "@playwright/test"; import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { resetData, testPaths } from "./helpers"; +import { resetData, testPaths, writeChannelConfig } from "./helpers"; const VTT = "WEBVTT\n\n00:00:01.000 --> 00:00:03.000\nA synthetic library cue\n"; @@ -73,9 +73,28 @@ test("a Local Archive channel imports a library recording and a prepared one, pl await expect(page.getByRole("link", { name: "Open local media library" })).toBeVisible(); await expect(page.getByText("Download audio")).toHaveCount(0); + // The channel page offers its Local library tab (it has a library). + await page.goto("/channels/local-spec-library"); + await expect(page.getByLabel("Local library stage tab")).toBeVisible(); + // Playback stayed off, and the library was never touched. const after = JSON.parse(await readFile(join(testPaths().transcriptsDir, "channels", "local-spec-library", "config.json"), "utf8")); expect(after.localMedia.playback).toBeUndefined(); expect((await readdir(library)).sort()).toEqual(before); await rm(library, { recursive: true, force: true }); }); + +// Review fix 8: the tab is only on a channel that has a library; a library is +// added through the New channel form or `pnpm ops local-media-configure`, and +// the route, reachable by URL, says so for a channel without one. +test("a channel without a library has no Local library tab, and its route names the command", async ({ page }) => { + await resetData("empty"); + await writeChannelConfig("plain-channel", { name: "Plain", url: "https://www.youtube.com/@plain" }); + await page.goto("/channels/plain-channel"); + await expect(page.getByLabel("Overview stage tab")).toBeVisible(); + await expect(page.getByLabel("Local library stage tab")).toHaveCount(0); + await page.goto("/channels/plain-channel/local-media"); + await expect(page.getByText("This channel has no local media library.")).toBeVisible(); + await expect(page.getByText(/pnpm ops local-media-configure --json '\{"slug":"plain-channel"/)).toBeVisible(); + await expect(page.getByRole("button", { name: "Save library" })).toHaveCount(0); +});