"use server"; // READ A TRENDING PAGE INTO AN X TRENDING LIBRARY (lane x-trending, slice 1): // the channel page's "Read a trending page" and `pnpm ops read-x-trending`, // one body (common/controller/readXTrending.ts). // // Refused HERE, before a job exists, with the controller's sentences: no such // channel, not a library, a URL that is not a trending page, a cap out of // range, no connected X profile, a saved read that is not there — and a // Connect or Refresh of X in flight, which holds the profile's browser // (lib/cookieRefreshGuard.ts). runManagedFunction then asks the network guard // (the fresh-jar rule, the X alert) at enqueue and at the job's start, and X's // queue spaces it from every other X job. // // A read is a `read-x-trending` job on X's queue; `reparse` (a saved capture // parsed again, nothing asked of X) a `reparse-x-trending` job on the same // queue, so neither writes the library's posts beside the other. The log ends // with `@@read-x-trending {…}`. import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getRegistry } from "yt-dlp-transcript-common/jobs/registry"; import { runManagedFunction, type StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; import { planReadXTrending, READ_X_TRENDING_KIND, READ_X_TRENDING_RESULT_MARKER, REPARSE_X_TRENDING_KIND, reparseXTrendingRead, runXTrendingRead, X_TRENDING_QUEUE, xTrendingTabsAsked, type ReadXTrendingAsk, type ReadXTrendingResult, } from "yt-dlp-transcript-common/controller/readXTrending"; import { noteXTrendingWatchRead, refuseWatchJob, runXTrendingWatchScan, xTrendingWatchFollowUp, type WatchScanResult, } from "yt-dlp-transcript-common/controller/xTrendingWatch"; import { describeXTrendingWatch, setXTrendingWatch, type XTrendingWatch, } from "yt-dlp-transcript-common/lib/xTrending/watch"; import { X_TRENDING_MAX_VIDEO_MB, X_TRENDING_WATCH_MAX_HOURS, X_TRENDING_WATCH_MAX_INTERVAL_MINUTES, X_TRENDING_WATCH_MAX_TOPICS, X_TRENDING_WATCH_MIN_INTERVAL_MINUTES, xTrendingWatchMaxTopics, xTrendingWatchTerms, type XTrendingConfig, } from "yt-dlp-transcript-common/lib/xTrending/config"; import { fakeXProfileChromium } from "yt-dlp-transcript-common/social/fakeXProfileBrowser"; import path from "node:path"; import { isValidChannelSlug, patchChannelConfig, readChannelConfig } from "yt-dlp-transcript-common/controller/channels"; import { isXTrendingChannel, NOT_AN_X_TRENDING_LIBRARY } from "yt-dlp-transcript-common/lib/xTrending/config"; import { judgeXTrending, xTrendingJudgeProblem, type XTrendingJudgeItem, type XTrendingJudgeResult, } from "yt-dlp-transcript-common/lib/xTrending/judgements"; import { isIdleBoot } from "yt-dlp-transcript-common/lib/idleBoot"; import { purgeXTrendingDropped, type XTrendingPurgeResult } from "yt-dlp-transcript-common/lib/xTrending/purge"; import { readXTrendingTopics } from "yt-dlp-transcript-common/lib/xTrending/store"; import slugify from "@sindresorhus/slugify"; import { mergeXTrendingTopics, moveXTrendingPosts, renameXTrendingTopic, type XTrendingMergeResult, type XTrendingMoveResult, type XTrendingRenameResult, } from "yt-dlp-transcript-common/lib/xTrending/organise"; import { publishXTrendingTopic, type PublishXTrendingResult } from "yt-dlp-transcript-common/controller/publishXTrending"; import { safeRevalidate } from "../../lib/safeRevalidate"; import { capturePostsAction } from "./socialActions"; import { xJobCounts } from "yt-dlp-transcript-common/lib/xJobRule"; import { recompileChannelPriorityAction } from "../actions"; import { xPressInFlight } from "../../lib/cookieRefreshGuard"; export async function readXTrendingAction(ask: ReadXTrendingAsk): Promise { const paths = getPaths(); // A read of this library queued or running: a reparse of a record still // marked "started" is then refused (the read has not ended). const readInFlight = async () => getRegistry() .list() .some((j) => j.kind === READ_X_TRENDING_KIND && j.channelSlug === ask.slug && (j.status === "queued" || j.status === "running")); const planned = await planReadXTrending(paths, ask, { readInFlight }); if (!planned.ok) return { ok: false, error: planned.error }; const plan = planned.plan; const done = (onLog: (line: string) => void, result: { ok: boolean; error?: string }) => { onLog(`${READ_X_TRENDING_RESULT_MARKER}${JSON.stringify(result)}`); safeRevalidate([`/channels/${plan.slug}`]); if (!result.ok) throw new Error(result.error ?? "The trending page was not read"); }; if (plan.mode === "reparse") { return runManagedFunction({ kind: REPARSE_X_TRENDING_KIND, queueKey: X_TRENDING_QUEUE, paths, channelSlug: plan.slug, // Asked again inside the job: the read may have started since the plan. fn: async (onLog) => done(onLog, await reparseXTrendingRead({ plan, onLog, readInFlight })), }); } const busy = xPressInFlight(); if (busy) return { ok: false, error: busy }; // Under the e2e test server only, the fake browser (fakeXProfileBrowser.ts // says how it is gated) and its short waits; everywhere else the real // profile and X's request gap. const chromium = fakeXProfileChromium(paths.transcriptsDir); return runManagedFunction({ kind: READ_X_TRENDING_KIND, queueKey: X_TRENDING_QUEUE, paths, channelSlug: plan.slug, fn: async (onLog, signal) => { const result = await runXTrendingRead({ paths, plan, onLog, signal, deps: { profileBusy: () => xPressInFlight(), // A watch's tick asks the watch's own jar rule again, now, at its // start (review 2 N1): it may have waited its turn for a long time. ...(plan.watch ? { watchRefusal: () => refuseWatchJob(paths, plan.slug) } : {}), ...(chromium ? { chromium, pauseMs: () => 50 } : {}), }, }); // A tick the watch's rule refused was not a read: the watch is paused // (refuseWatchJob), and it is no strike against it. if (!result.watchRefused) { await afterXTrendingRead(plan.slug, plan.channelRoot, result, onLog).catch((err) => onLog(`The watch could not be told of this read: ${(err as Error).message}`), ); } done(onLog, result); }, }); } // THE END OF A READ, FOR THE WATCH (controller/xTrendingWatch.ts): a page X // retired is not read again, and ends its topic's watch when it was the last; // and a read into a WATCHED topic queues ONE capture for its new posts — // their media at once, from the CDN (no page is opened), and a screenshot // too when the topic says so — and for what an earlier capture left owed. async function afterXTrendingRead( slug: string, channelRoot: string, result: ReadXTrendingResult, onLog: (line: string) => void, ): Promise { const told = await noteXTrendingWatchRead(channelRoot, { trendId: result.trendId, outcome: result.outcome, sentence: result.sentence }); if (told) onLog(told); if (result.outcome !== "read" || !result.topic) return; const follow = await xTrendingWatchFollowUp(channelRoot, { topic: result.topic.id, newIds: result.newIds ?? [] }); if (!follow) return; const what = `${follow.fresh} new post${follow.fresh === 1 ? "" : "s"}` + (follow.owed ? ` and ${follow.owed} owed from an earlier capture` : "") + (follow.uncaptured ? ` and ${follow.uncaptured} never captured` : "") + ` of the watched topic "${result.topic.title}"`; // THE CAPTURE IS THE WATCH'S JOB TOO (review 2 N1): the watch's jar rule is // asked before it is queued, and again inside the job when it starts // (`watch: true`) — with "screenshot everything new" it opens pages on X. // Media only (no shots) asks x.com nothing and does not count against X's // job cap (lib/xJobRule.ts xJobCounts, ruling R-a): the cap does not hold it. const plan = { shots: follow.shots, media: true, articles: false, ...(follow.shots ? {} : { avatars: false, context: false }) }; const counts = xJobCounts({ kind: "capture-posts", params: plan, channel: { library: true } }); const refusal = await refuseWatchJob(getPaths(), slug, undefined, { counts }); if (refusal) { onLog(`The media of ${what} was not queued, and the watch is paused: ${refusal.sentence}`); return; } const started = await capturePostsAction(slug, follow.ids, undefined, follow.shots, true, false, false, { // Media only: no page is opened for the avatars or the context either. ...(follow.shots ? {} : { avatars: false, context: false }), watch: true, }); if (started.ok) { void started.stream.cancel(); onLog(`Queued capture ${started.jobId} for ${what}: their media${follow.shots ? " and a screenshot of each" : ""}.`); } else { onLog(`The media of ${what} was not queued: ${started.error}`); } } // A library's root on disk, or the refusal's sentence. async function libraryRoot(slug: string): Promise<{ ok: true; channelRoot: string } | { ok: false; error: string }> { if (!isValidChannelSlug(slug)) return { ok: false, error: `"${String(slug)}" is not a valid channel slug` }; const paths = getPaths(); const config = await readChannelConfig(paths, slug); if (!config) return { ok: false, error: `No such channel: ${slug}` }; if (!isXTrendingChannel(config)) return { ok: false, error: NOT_AN_X_TRENDING_LIBRARY(slug) }; return { ok: true, channelRoot: path.join(paths.channelsDir, slug) }; } export type JudgeXTrendingAsk = { slug: string; // Who decided: the channel page's buttons say "operator"; `pnpm ops // judge-trending` says "agent" unless told otherwise. by: unknown; set: unknown; // false: mark only; the posts that became keep are not archived now. archive?: boolean; }; // What became of archiving the posts that became keep: the capture job, or // why none was started (the judgements are written all the same). export type JudgeArchive = { jobId: string; ids: string[] } | { error: string; ids: string[] }; export type JudgeXTrendingActionResult = | ({ ok: true; slug: string; archive?: JudgeArchive } & XTrendingJudgeResult) | { ok: false; error: string }; // JUDGE POSTS OF A LIBRARY (lane x-trending-2): keep / drop / later, or // undecided (the judgement removed), per post or per thread — the channel // page's buttons and `pnpm ops judge-trending`, one writer // (lib/xTrending/judgements.ts). An agent's write over the operator's // judgement is skipped for that id and reported. export async function judgeXTrendingAction(ask: JudgeXTrendingAsk): Promise { const lib = await libraryRoot(ask.slug); if (!lib.ok) return lib; const problem = xTrendingJudgeProblem(ask); if (problem) return { ok: false, error: problem }; const result = await judgeXTrending(lib.channelRoot, { by: ask.by as "agent" | "operator", set: ask.set as XTrendingJudgeItem[], }); safeRevalidate([`/channels/${ask.slug}`]); // A KEEP ARCHIVES: the posts that became keep go into ONE capture-posts job // on X's queue — a screenshot, the context, a reply's thread shot, and the // media (from the CDN, no cap, the logged-in download as the fallback). A // refusal (a stale jar, the X alert, X cooling down) leaves the judgements // written and says why nothing was started. let archive: JudgeArchive | undefined; if (result.kept.length > 0 && ask.archive !== false) { const started = await capturePostsAction(ask.slug, result.kept, undefined, true, true, false, true, { thread: true, keptMedia: true, }); if (started.ok) { void started.stream.cancel(); archive = { jobId: started.jobId, ids: result.kept }; } else { archive = { error: started.error, ids: result.kept }; } } return { ok: true, slug: ask.slug, ...result, ...(archive ? { archive } : {}) }; } // ── the watch ────────────────────────────────────────────────────────────── export type WatchSettingsAsk = { maxVideoMb?: unknown; intervalMinutes?: unknown; hours?: unknown; maxTopics?: unknown }; export type WatchXTrendingAsk = { slug: string; // One scan now (what the timer does every minute). tick?: boolean; // The library's defaults, changed. settings?: WatchSettingsAsk; // The switch of one topic. topic?: string; on?: boolean; intervalMinutes?: unknown; hours?: unknown; shots?: boolean; tabs?: unknown; by?: unknown; }; export type WatchXTrendingResult = | { ok: true; slug: string; topic?: string; watch?: XTrendingWatch; sentence: string; scan?: WatchScanResult; settings?: XTrendingConfig } | { ok: false; error: string }; const WATCH_ONE_OF = `Give "topic" with "on" (the switch of one topic), "settings" (the library's defaults) or "tick": true (one scan now), one of them.`; function settingsPatch(ask: WatchSettingsAsk): { ok: true; patch: Partial } | { ok: false; error: string } { const patch: Partial = {}; const int = (v: unknown, min: number, max: number, what: string): number | string => typeof v === "number" && Number.isInteger(v) && v >= min && v <= max ? v : `"${what}" is a whole number, ${min}–${max}`; const unknown = Object.keys(ask).filter((k) => !["maxVideoMb", "intervalMinutes", "hours", "maxTopics"].includes(k)); if (unknown.length) return { ok: false, error: `unknown setting(s): ${unknown.join(", ")} (maxVideoMb, intervalMinutes, hours, maxTopics)` }; for (const [key, to, min, max] of [ ["maxVideoMb", "maxVideoMb", 1, X_TRENDING_MAX_VIDEO_MB], ["intervalMinutes", "watchIntervalMinutes", X_TRENDING_WATCH_MIN_INTERVAL_MINUTES, X_TRENDING_WATCH_MAX_INTERVAL_MINUTES], ["hours", "watchHours", 1, X_TRENDING_WATCH_MAX_HOURS], ["maxTopics", "watchMaxTopics", 1, X_TRENDING_WATCH_MAX_TOPICS], ] as const) { const v = ask[key]; if (v === undefined) continue; const n = int(v, min, max, key); if (typeof n === "string") return { ok: false, error: n }; patch[to] = n; } if (Object.keys(patch).length === 0) return { ok: false, error: `"settings" names nothing to change (maxVideoMb, intervalMinutes, hours, maxTopics)` }; return { ok: true, patch }; } // WATCH A TOPIC (lane x-trending-2): the channel page's switch and `pnpm ops // watch-trending`. While a topic is watched its trending page is read again // every `intervalMinutes` until `hours` from now — each tick the same single // read-x-trending job, started by the scan (controller/xTrendingWatch.ts). // A WATCH RUNS ONLY WHILE X'S COOKIE JAR IS FRESH: it pauses when the jar // passes its limit and resumes at the first scan after Refresh cookies. export async function watchXTrendingAction(ask: WatchXTrendingAsk): Promise { const lib = await libraryRoot(ask.slug); if (!lib.ok) return lib; const paths = getPaths(); const asked = [ask.tick === true, ask.settings !== undefined, ask.topic !== undefined].filter(Boolean).length; if (asked !== 1) return { ok: false, error: WATCH_ONE_OF }; if (ask.tick) { // The armed scan when there is one (one scan at a time); else one of its own. // AN IDLE BOOT STARTS NO WORK (review 1 S6): the scan is not armed // there, and asking for one by hand is refused too. if (isIdleBoot()) { return { ok: false, error: "This editor booted idle (ARCHILYZER_IDLE_BOOT): it starts no work, so no watch scan runs. Restart it without the switch to watch topics." }; } // One scan at a time, the armed timer's included: two asks are one scan. const { xTrendingWatchDeps } = await import("../../api/ops/_xTrendingWatch"); const scan = await runXTrendingWatchScan(xTrendingWatchDeps); safeRevalidate([`/channels/${ask.slug}`, "/review"]); const sentence = scan.enqueued ? `Scanned: a tick of "${scan.enqueued.topic}" (${scan.enqueued.slug}) was started, job ${scan.enqueued.jobId}.` : scan.refused ? `Scanned: the tick of "${scan.refused.topic}" was refused: ${scan.refused.error}` : `Scanned: ${scan.live} live watch${scan.live === 1 ? "" : "es"}, no tick started` + (scan.paused.length ? ` (${scan.paused.length} paused)` : "") + "."; return { ok: true, slug: ask.slug, scan, sentence }; } if (ask.settings !== undefined) { if (!ask.settings || typeof ask.settings !== "object" || Array.isArray(ask.settings)) { return { ok: false, error: `"settings" is an object: {maxVideoMb?, intervalMinutes?, hours?, maxTopics?}` }; } const parsed = settingsPatch(ask.settings); if (!parsed.ok) return parsed; const next = await patchChannelConfig(paths, ask.slug, {}, { derive: (current) => ({ xTrending: { ...current.xTrending, ...parsed.patch } }) }); safeRevalidate([`/channels/${ask.slug}`]); const settings = next?.xTrending ?? {}; return { ok: true, slug: ask.slug, settings, sentence: `Saved: ${JSON.stringify(parsed.patch)}.` }; } if (typeof ask.on !== "boolean") return { ok: false, error: `"on" is true (watch the topic) or false (stop watching it)` }; if (ask.by !== undefined && ask.by !== "agent" && ask.by !== "operator") return { ok: false, error: `"by" is "agent" or "operator"` }; const config = (await readChannelConfig(paths, ask.slug))?.xTrending; const terms = xTrendingWatchTerms(config, ask.on ? { intervalMinutes: ask.intervalMinutes, hours: ask.hours } : {}); if (!terms.ok) return terms; // The tabs each tick reads: as a read's ("top", "latest" or both). const tabs = ask.tabs === undefined ? undefined : xTrendingTabsAsked(ask.tabs); if (tabs && !tabs.ok) return { ok: false, error: tabs.error }; const now = Date.now(); const set = await setXTrendingWatch(lib.channelRoot, { topics: await readXTrendingTopics(lib.channelRoot), topic: String(ask.topic), on: ask.on, intervalMinutes: terms.terms.intervalMinutes, hours: terms.terms.hours, ...(ask.shots !== undefined ? { shots: ask.shots } : {}), ...(tabs?.ok ? { tabs: tabs.tabs } : {}), by: ask.by === "operator" ? "operator" : "agent", maxTopics: xTrendingWatchMaxTopics(config), now, }); if (!set.ok) return set; safeRevalidate([`/channels/${ask.slug}`, "/review"]); return { ok: true, slug: ask.slug, topic: set.topic, watch: set.watch, sentence: describeXTrendingWatch(set.watch, now) }; } // ── the purge ────────────────────────────────────────────────────────────── export type PurgeXTrendingAsk = { slug: string; topic?: string; ids?: unknown; dryRun?: boolean; confirm?: string; by?: unknown; }; export type PurgeXTrendingActionResult = ({ ok: true; slug: string; topic?: string } & XTrendingPurgeResult) | { ok: false; error: string }; const PURGE_IS_THE_OPERATORS = `Removing dropped posts' captures is the operator's press: an agent may ask for the dry run ("dryRun": true), which counts what would go and removes nothing. The operator confirms it on umtool's Posts library page (or with "by": "operator" and the dry run's "confirm").`; // PURGE THE CAPTURES OF DROPPED POSTS (lane posts-library): umtool's Posts // library page and `pnpm ops purge-trending`, one body // (lib/xTrending/purge.ts). Two steps: the dry run counts and answers // `confirm`; the removal carries it, and is the OPERATOR's. export async function purgeXTrendingAction(ask: PurgeXTrendingAsk): Promise { const lib = await libraryRoot(ask.slug); if (!lib.ok) return lib; if (ask.by !== undefined && ask.by !== "agent" && ask.by !== "operator") return { ok: false, error: `"by" is "agent" or "operator"` }; const dryRun = ask.dryRun === true; if (!dryRun && ask.by !== "operator") return { ok: false, error: PURGE_IS_THE_OPERATORS }; if (!dryRun && (typeof ask.confirm !== "string" || !ask.confirm)) { return { ok: false, error: `Run it with "dryRun": true first: it says what would be removed and answers "confirm", which the removal must carry.` }; } if (ask.ids !== undefined && (!Array.isArray(ask.ids) || ask.ids.length === 0)) return { ok: false, error: `"ids" is a list of post ids` }; if (ask.topic !== undefined) { const topics = await readXTrendingTopics(lib.channelRoot); if (!topics.some((t) => t.id === ask.topic)) { return { ok: false, error: `${ask.slug} has no topic "${ask.topic}" (its topics: ${topics.map((t) => t.id).join(", ") || "none yet"})` }; } } const out = await purgeXTrendingDropped(lib.channelRoot, { slug: ask.slug, ...(ask.topic !== undefined ? { topic: ask.topic } : {}), ...(ask.ids !== undefined ? { ids: ask.ids as string[] } : {}), dryRun, ...(ask.confirm ? { confirm: ask.confirm } : {}), captureInFlight: () => getRegistry() .list() .some((j) => j.kind === "capture-posts" && j.channelSlug === ask.slug && (j.status === "queued" || j.status === "running")), }); if (!out.ok) return out; if (!dryRun) safeRevalidate([`/channels/${ask.slug}`]); return { ok: true, slug: ask.slug, ...(ask.topic !== undefined ? { topic: ask.topic } : {}), ...out.result }; } // ── organise: rename, merge, move (lane x-trending-publish) ──────────────── // A job of this library, of one of these kinds, queued or running. function libraryJobInFlight(slug: string, kinds: ReadonlyArray): boolean { return getRegistry() .list() .some((j) => kinds.includes(j.kind) && j.channelSlug === slug && (j.status === "queued" || j.status === "running")); } export type OrganiseXTrendingAsk = { slug: string; op: unknown; by?: unknown; // rename topic?: unknown; title?: unknown; // merge into?: unknown; from?: unknown; // move to?: unknown; ids?: unknown; thread?: unknown; create?: unknown; }; export type OrganiseXTrendingActionResult = | ({ slug: string } & Extract) | { ok: false; error: string }; // RENAME A TOPIC, MOVE POSTS BETWEEN TOPICS, MERGE TOPICS: umtool's Posts // library page, `pnpm ops organise-trending` and `umtool library`, one body // (lib/xTrending/organise.ts). Rename and move are an agent's or the // operator's and record who; a merge is the operator's, and waits for a read. export async function organiseXTrendingAction(ask: OrganiseXTrendingAsk): Promise { const lib = await libraryRoot(ask.slug); if (!lib.ok) return lib; if (ask.by !== "agent" && ask.by !== "operator") return { ok: false, error: `"by" is "agent" or "operator"` }; const by = ask.by; let out: XTrendingRenameResult | XTrendingMoveResult | XTrendingMergeResult; if (ask.op === "rename") { out = await renameXTrendingTopic(lib.channelRoot, { topic: ask.topic as string, title: ask.title as string, by, readInFlight: () => libraryJobInFlight(ask.slug, [READ_X_TRENDING_KIND, REPARSE_X_TRENDING_KIND]), }); } else if (ask.op === "move") { out = await moveXTrendingPosts(lib.channelRoot, { to: ask.to as string, ...(ask.ids !== undefined ? { ids: ask.ids as string[] } : {}), ...(ask.thread !== undefined ? { thread: ask.thread as string } : {}), ...(ask.create === true ? { create: true } : {}), by, }); } else if (ask.op === "merge") { out = await mergeXTrendingTopics(lib.channelRoot, { into: ask.into as string, from: ask.from as string[], by, readInFlight: () => libraryJobInFlight(ask.slug, [READ_X_TRENDING_KIND, REPARSE_X_TRENDING_KIND]), }); } else { return { ok: false, error: `"op" is "rename", "move" or "merge"` }; } if (!out.ok) return out; safeRevalidate([`/channels/${ask.slug}`]); return { slug: ask.slug, ...out }; } // ── publish a topic (lane x-trending-publish) ────────────────────────────── export type PublishXTrendingActionAsk = { slug: string; topic: string; channel?: string; dryRun?: boolean; confirm?: string; by?: unknown; }; export type PublishXTrendingActionResult = ({ ok: true; slug: string } & PublishXTrendingResult) | { ok: false; error: string }; // PUBLISH A TOPIC'S KEPT POSTS INTO AN ORDINARY CHANNEL: umtool's Posts // library page, `pnpm ops publish-trending` and `umtool library publish`, one // body (controller/publishXTrending.ts). The channel's slug, for a topic // never published, is the New channel form's own slug of the topic's title // unless the ask names one. On NO site: adding it to one is another act. export async function publishXTrendingAction(ask: PublishXTrendingActionAsk): Promise { const dryRun = ask.dryRun === true; const out = await publishXTrendingTopic(getPaths(), { slug: ask.slug, topic: ask.topic, ...(ask.channel !== undefined ? { channel: ask.channel } : {}), deriveSlug: (title) => slugify(title), dryRun, ...(ask.confirm ? { confirm: ask.confirm } : {}), ...(ask.by !== undefined ? { by: ask.by } : {}), busy: () => libraryJobInFlight(ask.slug, [READ_X_TRENDING_KIND, REPARSE_X_TRENDING_KIND, "capture-posts"]), }); if (!out.ok) return out; if (!dryRun) { try { // What creating a channel does everywhere (channels/actions.ts): the // priority document learns of it. if (out.result.creates) await recompileChannelPriorityAction(); } catch { /* best-effort — the channel was made regardless */ } safeRevalidate([`/channels/${ask.slug}`, `/channels/${out.result.channel}`, "/channels"]); } return { ok: true, slug: ask.slug, ...out.result }; }