Archilyzer · Source

archilyzer

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

commit 36ed1882f470412f64e82f3b5e930088d6b0b585
parent 2f1bbb67226075a08065129e0a28f60aef0f4991
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  2 Nov 2026 02:09:30 -0500

editor: Sync on a social channel runs fetch-posts, never the yt-dlp listing (UI notes #17)

- syncAction: a social channel (X, Bluesky, a forum thread, Wayback pages) dispatches fetchPostsAction -- the channel page's Fetch posts job: the platform's queue, paced, and for X a fresh cookie jar and no raised alert, refused in its own sentence otherwise. Every Sync goes through it: the /channels rack's and the dashboard's buttons, a group's Sync, Sync all, `pnpm ops sync`, a sync job's Retry. The scheduler already dispatched this way.
- a full sweep is the video listing's: `sync` with "full" on a social channel is refused, naming Fetch posts -> Re-fetch full history
- ChannelSyncButton: `social` (ChannelRowView.social) changes only the words -- the title says fetch-posts, "posts fetched (job …)"; data-sync-runs; a refusal shows beside it, as before
- tests: app/api/ops/sync/route.test.ts (the X guard's sentence, the Wayback pages refusal only fetch-posts gives, the full-sweep refusal), channelRow.test.ts; e2e social-channel.spec.ts: the rack's Sync on an X channel runs a fetch-posts job (the fake gallery-dl's three posts), and a refusal's sentence
- the ops `sync` help says so; COMMANDS.md regenerated

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
MCOMMANDS.md | 2+-
Mcommon/views/channelRow.test.ts | 6++++++
Mcommon/views/channelRow.ts | 6+++++-
Aeditor/app/api/ops/sync/route.test.ts | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Meditor/app/api/ops/sync/route.ts | 4+++-
Meditor/app/channels/[slug]/pipelineActions.ts | 20++++++++++++++++++++
Meditor/app/channels/components/ChannelSyncButton.tsx | 17+++++++++++++++--
Meditor/app/channels/components/channelColumns.tsx | 2+-
Meditor/app/components/dashboard/DashboardCockpit.tsx | 2+-
Meditor/e2e/social-channel.spec.ts | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscripts/archilyzer-ops.mjs | 5++++-
11 files changed, 204 insertions(+), 8 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -128,7 +128,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `build-cues` | build-cues writes each video's transcript.cues.json from its raw transcript (the caption-track rule for VTTs), as the digest card's Normalize button does: {"slug"}, "ids": \[...\] for those videos only (every one held), "force": true to rewrite a fresh one. A job on the channel's queue. The file every reader without an index build wants. | `pnpm ops build-cues --json '{"slug":"demo-yt","ids":["<videoId>"]}' --wait` | | `feed-metadata` | feed-metadata completes a podcast channel's records from its RSS feed: one fetch of the channel's url, then title, date, description and duration into each record that lacks them: {"slug"}. "dryRun": true counts matched, unmatched and already complete, and writes nothing. | `pnpm ops feed-metadata --json '{"slug":"demo-podcast","dryRun":true}' --wait` | | `refresh-report` | refresh-report regenerates a channel's report (the buckets and counts its page shows) on the one serial report queue: {"slug"} answers the job queued, or the one already waiting ("started": false); {"all": true} queues every channel and answers {queued, jobIds, skipped}. | `pnpm ops refresh-report --json '{"all":true}'` | -| `sync` | sync lists a channel and downloads what is new, as its Sync button does: {"slug"}. "full": true runs the periodic whole-listing sweep now (else the configured cadence decides); "queueKey" picks another queue. On the channel's platform queue, paced like its downloads. | `pnpm ops sync --json '{"slug":"the-quartering"}' --wait` | +| `sync` | sync lists a channel and downloads what is new, as its Sync button does: {"slug"}. "full": true runs the periodic whole-listing sweep now (else the configured cadence decides); "queueKey" picks another queue. On the channel's platform queue, paced like its downloads. A social channel's sync is its post fetch (fetch-posts' new posts, its guards and refusals: for X a fresh cookie jar), never the video listing; "full" is refused there (fetch-posts "full": true re-walks the timeline). | `pnpm ops sync --json '{"slug":"the-quartering"}' --wait` | | `download-missing` | download-missing downloads every listed video the channel does not hold: {"slug"}. "ignoreArchive": true drops the download archive so listed videos it names are fetched again (recovery from a stale archive); "abortOnError": false carries on past a failure (default: stop at the first that is not one video's own). Paced on the platform's queue. "storedUrl": "fallback" \| "only" reads each video from the media URL its record stores when the page is rate-limited (or always), one file per 20 min; with one, a held platform's run goes ahead as "only". | | | `retry-bucket` | retry-bucket runs one bucket of a channel's report as one job, past any lane hold: {"slug", "bucket"}. "ids": \[...\] runs only those videos, and every one must be in the bucket (a stray id is refused, named); a job run with ids is not replayable, as a checkbox selection in the UI is not. "corruptFullSource" downloads again: the kept file is set aside, and comes back if the download fails; malformed again, the longer decode stays. A record that stores an Odysee media URL is read from that URL (as "only") until 2 such downloads are on record, then from the page. "storedUrl": "fallback" \| "only" reads each from the media URL its record stores, as on download-missing (a held platform's retry runs as "only"). "corruptHeldAudio" (held audio the audio audit found damaged) is refetched the same way, with the audio check on; the new file is audited again. | `pnpm ops retry-bucket --json '{"slug":"demo-odysee","bucket":"corruptHeldAudio"}' --wait` | | `transcribe-bucket` | transcribe-bucket transcribes a channel's "downloaded, not transcribed" bucket on the transcription queue, as the channel page's Transcribe button does: {"slug"}. "ids": \[...\] narrows it the same way as on retry-bucket. | | diff --git a/common/views/channelRow.test.ts b/common/views/channelRow.test.ts @@ -114,6 +114,12 @@ test("the view carries no config, only the fields a cell draws", () => { assert.equal(bare.lastSyncedAt, null); }); +test("social: a posts channel's row says so, so its Sync button runs fetch-posts (UI notes #17)", () => { + assert.equal(buildChannelRowView(input()).social, false); + const x = buildChannelRowView(input({ config: { handling: "youtube", url: "https://x.com/someone", sourceKind: "social" } as ChannelConfig })); + assert.equal(x.social, true); +}); + test("media: in-place is dropped; the label is the volume's unless overridden", () => { const inPlace = buildChannelRowView( input({ media: { status: "in-place", target: "/x", detail: "" } }), diff --git a/common/views/channelRow.ts b/common/views/channelRow.ts @@ -1,5 +1,5 @@ import { channelDownloadsAreManual } from "../lib/manualDownloads"; -import type { ChannelConfig } from "../lib/channelConfig"; +import { isSocialChannel, type ChannelConfig } from "../lib/channelConfig"; import type { ChannelSnapshot } from "../controller/channelSnapshot"; import type { ChannelMediaLocation } from "../lib/channelMedia"; import { mediaHoldText } from "../lib/channelMediaHold"; @@ -82,6 +82,9 @@ export type ChannelRowView = { handling: ChannelConfig["handling"]; // Whether the channel has a URL — Sync and Download need one. hasUrl: boolean; + // A social (posts) channel: its Sync runs fetch-posts, never the yt-dlp + // listing (UI notes 2026-10-30, #17), and the button says so. + social: boolean; excludeFromBuild: boolean; lastSyncedAt: string | null; // The playlist file's line count; null when there is no playlist file. @@ -195,6 +198,7 @@ export function buildChannelRowView(i: ChannelRowInput): ChannelRowView { name: i.config.name ?? "", handling: i.config.handling, hasUrl: Boolean(i.config.url), + social: isSocialChannel(i.config), excludeFromBuild: i.config.excludeFromBuild === true, lastSyncedAt: i.config.lastSyncedAt ?? null, playlistCount: i.playlistCount, diff --git a/editor/app/api/ops/sync/route.test.ts b/editor/app/api/ops/sync/route.test.ts @@ -0,0 +1,76 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; + +// Run with: +// pnpm -C editor exec tsx --test "app/api/ops/sync/route.test.ts" +// +// A SOCIAL CHANNEL'S SYNC IS ITS POST FETCH (UI notes 2026-10-30, #17): Sync on +// an X channel ran yt-dlp against the profile and failed. Every case here is a +// refusal answered before any job, from a temp corpus: the X channel has no +// cookie jar, so fetch-posts' own guard refuses it in its own sentence — which +// is how this knows the sync went to fetch-posts and not the video listing — +// and nothing reaches X. + +const ROOT = await mkdtemp(path.join(os.tmpdir(), "sync-route-")); +// Set before the route (and getPaths, which caches) is first imported. +process.env.WORKER_TOKEN = "test-token"; +process.env.TRANSCRIPTS_DIR = ROOT; +process.env.SETTINGS_FILE = path.join(ROOT, "settings.json"); +const channel = async (slug: string, config: Record<string, unknown>) => { + await mkdir(path.join(ROOT, "channels", slug), { recursive: true }); + await writeFile(path.join(ROOT, "channels", slug, "config.json"), JSON.stringify(config)); +}; +await channel("demo-x", { + handling: "transcribe", + sourceKind: "social", + platform: "twitter", + postFetcher: "x-gallery-dl", + socialHandle: "example_user", + name: "Example (X)", + url: "https://x.com/example_user", +}); +await channel("demo-pages", { + handling: "transcribe", + sourceKind: "social", + platform: "webpage", + name: "Example pages", + url: "https://web.archive.org/web/2020/https://example.test/", +}); +const { POST } = await import("./route"); +const { WAYBACK_PAGES_NOT_FETCHED } = await import("yt-dlp-transcript-common/controller/fetchPosts"); +test.after(() => rm(ROOT, { recursive: true, force: true })); + +async function post(body: Record<string, unknown>): Promise<{ status: number; error: string }> { + const res = await POST( + new Request("http://localhost/api/ops/sync", { + method: "POST", + headers: { authorization: "Bearer test-token", "content-type": "application/json" }, + body: JSON.stringify(body), + }), + ); + return { status: res.status, error: ((await res.json()) as { error?: string }).error ?? "" }; +} + +const jobs = () => readdir(path.join(ROOT, ".jobs")).catch(() => []); + +test("an X channel's sync is fetch-posts: refused on no cookie jar, in the post fetch's own words, before any job", async () => { + const res = await post({ slug: "demo-x" }); + assert.notEqual(res.status, 200); + assert.match(res.error, /^No X cookie jar has been exported: press Connect X account on \/settings, then fetch again\.$/); + assert.deepEqual(await jobs(), []); +}); + +test("a Wayback pages channel's sync is its post fetch too, which says such a channel is never fetched", async () => { + const res = await post({ slug: "demo-pages" }); + assert.equal(res.error, WAYBACK_PAGES_NOT_FETCHED); + assert.deepEqual(await jobs(), []); +}); + +test("a full sweep is the video listing's: a social channel's sync says where its whole re-walk is", async () => { + const res = await post({ slug: "demo-x", full: true }); + assert.match(res.error, /^A social channel's Sync fetches its new posts; a full re-walk of its timeline is Fetch posts → Re-fetch full history/); + assert.deepEqual(await jobs(), []); +}); diff --git a/editor/app/api/ops/sync/route.ts b/editor/app/api/ops/sync/route.ts @@ -6,7 +6,9 @@ export const dynamic = "force-dynamic"; // POST { slug: string, full?: boolean, queueKey?: string } -> { ok: true, jobId } // // `full` forces the periodic whole-listing sweep now; without it the job -// decides for itself from the configured cadence. +// decides for itself from the configured cadence. A social channel's sync is +// its post fetch (syncAction → fetch-posts, UI notes #17), and `full` is +// refused there. export async function POST(request: Request) { return ops(request, ["slug", "full", "queueKey"], async (body) => jobResponse( diff --git a/editor/app/channels/[slug]/pipelineActions.ts b/editor/app/channels/[slug]/pipelineActions.ts @@ -1,6 +1,8 @@ "use server"; import { manualDownloadsRefusal } from "yt-dlp-transcript-common/lib/manualDownloads"; +import { isSocialChannel } from "yt-dlp-transcript-common/lib/channelConfig"; +import { fetchPostsAction } from "./socialActions"; import path from "node:path"; import { safeRevalidate } from "../../lib/safeRevalidate"; import { @@ -394,11 +396,29 @@ export async function downloadMissingAction( // the periodic full sweep (see common/jobs/deepSync.ts). Pass fullSweep to force // one now — the sweep is still a single `sync` job: one row, one log, one // Cancel, and the same per-platform serialization. +// +// A SOCIAL CHANNEL'S SYNC IS ITS POST FETCH (UI notes 2026-10-30, #17). An X, +// Bluesky, forum-thread or Wayback-pages channel holds posts, not a video +// listing: Sync on one ran yt-dlp against the profile URL and failed. Every +// Sync — the channel rows', the dashboard's, a group's, Sync all, `pnpm ops +// sync`, a Retry of a sync job — now runs fetch-posts (socialActions.ts +// fetchPostsAction, the same job the channel page's Fetch posts runs: the +// platform's queue, paced, and for X a fresh cookie jar and no raised alert, +// refused in its own sentence otherwise), never the yt-dlp listing. A full +// sweep is the video listing's; a social channel's whole re-walk is +// fetch-posts' `full`, asked for by name, so a Sync never starts one. +const SOCIAL_FULL_SWEEP_REFUSAL = + "A social channel's Sync fetches its new posts; a full re-walk of its timeline is Fetch posts → Re-fetch full history (fetch-posts \"full\": true)."; + export async function syncAction( slug: string, queueKey?: string, fullSweep?: boolean, ): Promise<StreamActionResult> { + if (isSocialChannel(await readChannelConfig(getPaths(), slug))) { + if (fullSweep) return { ok: false, info: true, error: SOCIAL_FULL_SWEEP_REFUSAL }; + return fetchPostsAction(slug, queueKey); + } return runPipelineAction(slug, "sync", "sync", queueKey, { forceFullSweep: fullSweep, spec: { kind: "sync", slug, params: { queueKey, fullSweep } }, diff --git a/editor/app/channels/components/ChannelSyncButton.tsx b/editor/app/channels/components/ChannelSyncButton.tsx @@ -9,12 +9,19 @@ type Status = | { kind: "done"; jobId: string } | { kind: "error"; message: string }; +// A SOCIAL channel's Sync is its post fetch (UI notes 2026-10-30, #17): +// syncAction runs fetch-posts for it — the channel page's Fetch posts job, +// paced on the platform's queue, and for X refused on a stale cookie jar in +// its own sentence, which shows here — never the yt-dlp listing. `social` +// only changes the words. export function ChannelSyncButton({ slug, disabled, + social = false, }: { slug: string; disabled?: boolean; + social?: boolean; }) { const [status, setStatus] = useState<Status>({ kind: "idle" }); @@ -48,6 +55,12 @@ export function ChannelSyncButton({ onClick={handleClick} disabled={running || disabled} aria-label={`sync ${slug}`} + data-sync-runs={social ? "fetch-posts" : "sync"} + title={ + social + ? "Fetches this account's new posts (fetch-posts, on its platform's queue) — a social channel has no video listing" + : "Lists the channel and downloads what is new" + } className="px-2 py-1 rounded-md bg-primary text-primary-foreground text-xs font-medium hover:opacity-90 disabled:opacity-50" > {running ? "Syncing…" : "Sync"} @@ -66,7 +79,7 @@ export function ChannelSyncButton({ aria-label={`sync ${slug} job`} className="text-xs text-muted-foreground font-mono" > - job {status.jobId} + {social ? "fetching posts · " : ""}job {status.jobId} </span> )} {status.kind === "done" && ( @@ -74,7 +87,7 @@ export function ChannelSyncButton({ aria-label={`sync ${slug} done`} className="text-xs text-muted-foreground" > - done (job {status.jobId}) + {social ? "posts fetched" : "done"} (job {status.jobId}) </span> )} </div> diff --git a/editor/app/channels/components/channelColumns.tsx b/editor/app/channels/components/channelColumns.tsx @@ -342,7 +342,7 @@ export const CHANNEL_COLUMNS: Record< className: "whitespace-nowrap", content: ctx.extras?.actions ?? ( <div className="flex items-center gap-2"> - <ChannelSyncButton slug={c.slug} disabled={!c.hasUrl} /> + <ChannelSyncButton slug={c.slug} disabled={!c.hasUrl} social={c.social} /> <ChannelAvailabilityButton slug={c.slug} disabled={!c.hasUrl} /> <InlineActionButton variant={{ kind: "refreshReport", slug: c.slug }} /> </div> diff --git a/editor/app/components/dashboard/DashboardCockpit.tsx b/editor/app/components/dashboard/DashboardCockpit.tsx @@ -132,7 +132,7 @@ function DashboardChannels({ <div className="flex flex-wrap items-center gap-1.5"> {c.hasUrl ? ( <> - <ChannelSyncButton slug={c.slug} /> + <ChannelSyncButton slug={c.slug} social={c.social} /> {c.work.undownloaded > 0 && ( <InlineActionButton variant={{ kind: "downloadMissing", slug: c.slug }} diff --git a/editor/e2e/social-channel.spec.ts b/editor/e2e/social-channel.spec.ts @@ -264,3 +264,75 @@ test("a forum thread URL makes a forum-thread channel, and saved pages import in ) .toEqual(["xenforo 21", "xenforo 22", "xenforo 23"]); }); + +// A SOCIAL CHANNEL'S SYNC IS ITS POST FETCH (UI notes 2026-10-30, #17): the +// Sync button on the /channels rack ran yt-dlp's listing against an X profile +// and failed. It runs fetch-posts now (the fake gallery-dl here), and a +// refusal is the post fetch's own sentence beside the button. +const UI_OPS_SHOTS = process.env.UI_OPS_SHOTS ?? ""; +const shot = async (page: import("@playwright/test").Page, name: string) => { + if (!UI_OPS_SHOTS) return; + await mkdir(UI_OPS_SHOTS, { recursive: true }); + await page.screenshot({ path: path.join(UI_OPS_SHOTS, `${name}.png`), fullPage: false }); +}; + +test("Sync on a social channel runs fetch-posts, never the video listing", async ({ page }) => { + await resetData("empty"); + await generateReport(page, "new"); + await page.goto("/channels/new"); + await page.locator('input[name="url"]').fill(X_URL); + await page.locator('input[name="name"]').fill("Fake Tester"); + await page.locator('input[name="slug"]').fill("faketester"); + await page.locator('input[name="fetchPostsNow"]').uncheck(); + await page.getByRole("button", { name: /create|add channel|save/i }).first().click(); + const config = `${testPaths().transcriptsDir}/channels/faketester/config.json`; + await expect.poll(() => pathExists(config), { timeout: 15_000 }).toBe(true); + await generateReport(page, "faketester"); + + await page.goto("/channels"); + const sync = page.getByRole("button", { name: "sync faketester" }); + await expect(sync).toHaveAttribute("data-sync-runs", "fetch-posts"); + await expect(sync).toHaveAttribute("title", /fetch-posts/); + await sync.click(); + // The fake gallery-dl's three tweets: the post fetch ran, not yt-dlp. + const archive = `${testPaths().transcriptsDir}/channels/faketester/posts-archive`; + await expect + .poll(async () => ((await pathExists(archive)) ? (await readFile(resolvePath(archive), "utf8")).split("\n").filter(Boolean).length : 0), { + timeout: 30_000, + }) + .toBe(3); + await expect(page.getByLabel("sync faketester done")).toContainText(/posts fetched \(job /, { timeout: 30_000 }); + await sync.scrollIntoViewIfNeeded(); + await shot(page, "17-social-sync-fetch-posts"); + // The job it ran is a fetch-posts job (its record beside its log). + const jobId = ((await page.getByLabel("sync faketester done").textContent()) ?? "").match(/job ([^)\s]+)/)?.[1] ?? ""; + expect(jobId).not.toBe(""); + const meta = await readJson<{ kind: string; channelSlug?: string }>(`${testPaths().transcriptsDir}/.jobs/${jobId}.meta.json`); + expect(meta.kind).toBe("fetch-posts"); + expect(meta.channelSlug).toBe("faketester"); +}); + +test("a social channel whose post fetch refuses: the Sync button shows the refusal's sentence", async ({ page }) => { + await resetData("empty"); + const dir = resolvePath(`${testPaths().transcriptsDir}/channels/waypages`); + await mkdir(dir, { recursive: true }); + await writeFile( + path.join(dir, "config.json"), + JSON.stringify({ + handling: "transcribe", + sourceKind: "social", + platform: "webpage", + name: "Wayback pages", + url: "https://web.archive.org/web/2020/https://example.test/", + }), + ); + await generateReport(page, "waypages"); + await page.goto("/channels"); + const sync = page.getByRole("button", { name: "sync waypages" }); + await expect(sync).toHaveAttribute("data-sync-runs", "fetch-posts"); + await sync.click(); + await expect(page.getByLabel("sync waypages error")).toHaveText( + "A Wayback pages channel is not fetched: import its captures (import-page, the channel page's Import a capture).", + ); + await shot(page, "17-social-sync-refusal"); +}); diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -1264,7 +1264,10 @@ export function usage() { 'sync lists a channel and downloads what is new, as its Sync button does:', ' {"slug"}. "full": true runs the periodic whole-listing sweep now (else', ' the configured cadence decides); "queueKey" picks another queue. On the', - " channel's platform queue, paced like its downloads.", + " channel's platform queue, paced like its downloads. A social channel's", + " sync is its post fetch (fetch-posts' new posts, its guards and refusals:", + ' for X a fresh cookie jar), never the video listing; "full" is refused', + ' there (fetch-posts "full": true re-walks the timeline).', "", 'download-missing downloads every listed video the channel does not hold:', ' {"slug"}. "ignoreArchive": true drops the download archive so listed',