// Client-safe: the counted confirmation of a clean WITHOUT CHECKING (lane // clean-unverified), the one text every button that would run unchecked shows // — the channel page's Cleanup stage (the one-off button, and Clean audio when // the channel's key is on), the /cleanup card and the dashboard's inline // buttons. Its numbers are planAudioClean's (no network, no deletes). import { formatBytes } from "./format"; // The counts it states: the structural part of controller // cleanAudioFromTranscribed's AudioCleanPlan (lib may not import controller). // `protected` includes the sourceGone group. export type CleanPlanCounts = { files: number; bytes: number; videos: number; protected: number; awaitingDiarization: number; awaitingVoiceprint: number; sourceGone?: SourceGoneCounts; }; export type SourceGoneCounts = { videos: number; files: number; bytes: number; inferred: { videos: number; files: number; bytes: number }; }; const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`; // THE OPT-IN'S CHECKBOX (lane mark-provenance), off by default, with its count. export function sourceGoneOptInLabel(g: SourceGoneCounts): string { return ( `Also remove audio kept only because the source was gone (${plural(g.videos, "video")}, ` + `${plural(g.files, "file")}, ${formatBytes(g.bytes)})` ); } // `includeSourceGone`: the opt-in is ticked. The group then has its own line // (videos, files, bytes; the inferred part separately) and leaves the kept // count; the button counts both. export function cleanConfirmationText( plan: CleanPlanCounts, opts: { includeSourceGone?: boolean } = {}, ): { ask: string; sourceGone: string | null; kept: string; button: string; files: number } { const g = plan.sourceGone; const include = opts.includeSourceGone === true && !!g && g.videos > 0; const files = plan.files + (include ? g!.files : 0); const keptMarked = include ? plan.protected - g!.videos : plan.protected; return { ask: files === 0 ? "Nothing to remove: no transcribed video here holds audio a clean would take." : `Remove ${plural(plan.files, "audio file")} (${formatBytes(plan.bytes)}) from ${plural(plan.videos, "transcribed video")} without checking? ` + "The source is not asked, so the audio of videos no longer available anywhere is removed too.", sourceGone: include ? `Also removed, kept only because the source was gone: ${plural(g!.files, "audio file")} (${formatBytes(g!.bytes)}) ` + `from ${plural(g!.videos, "video")} the availability check marked do not clean. Their marks stay.` + (g!.inferred.videos > 0 ? ` Of these, ${plural(g!.inferred.videos, "video")} (${plural(g!.inferred.files, "file")}, ${formatBytes(g!.inferred.bytes)}) ` + "carry marks inferred from the records (marks-backfill), not written by the check itself." : "") : null, kept: `Kept: ${keptMarked} marked do not clean or in the keep-latest window` + (!include && g && g.videos > 0 ? ` (${g.videos} of them only because the source was gone)` : "") + `, ${plan.awaitingDiarization} awaiting diarization, ${plan.awaitingVoiceprint} awaiting voice fingerprint. ` + "Videos with no transcript are not touched, and no saved video is." + (include ? " A mark set by a person, an import or a live recording is never touched." : ""), button: `Remove ${plural(files, "file")} without checking`, files, }; } // The confirmation to turn the channel's key ON: what it changes, stated // before it changes it. export const TURN_ON_CONFIRMATION = "Turn on cleaning without checking for this channel? From now on every clean of its audio — Clean audio here and on /cleanup, " + "the dashboard's buttons, pnpm ops and clean after capture — deletes audio without asking the source whether the video is still there, " + "so the audio of a video removed upstream is deleted too. The buttons still show a count before they run; these do not: clean after capture, " + "pnpm ops cleanup without its unchecked flag, a Retry (or Retry all failed) of an earlier clean, and a clean a restart re-queues. " + "Videos already marked do not clean, the keep-latest window and the speaker holds stay kept.";