import { autoPauseReasonOf, autoPausedSlugs, type ChannelPriority, type StoredChannelTier, } from "../lib/channelPriority"; // THE /review PAYLOAD'S THIRD SECTION: what the MACHINE decided on its own. // // /review is "findings a human decides, not work a lane runs", and an // auto-pause is exactly that shape from the other direction: the storage watch // took a decision while nobody was looking, and it stands until either the // drive comes back or a person overrides it. Until now the only place that // decision surfaced was a chip beside one channel's tier on /channels — so an // operator whose platter went away found out by noticing that a channel had // quietly stopped doing anything. // // PURE, like everything in this directory: the model arrives as an argument. // // ONE WORDING. The sentence is `autoPauseReasonOf`'s, the same one the rack and // the channel page say, because three surfaces wording the same machine // decision three ways is how an operator ends up unsure whether they are three // different problems. export type AutoPausedRow = { slug: string; // Which machine decided. One value today; a union so a second reason has // somewhere to go and a row can say which rather than "automatic". reason: "storage"; // ISO, as stored. The renderer decides how much of it to show. since: string; // WHERE RESUME PUTS IT BACK. Carried because it is not derivable from // anything once the tier was overwritten with `paused` — that is the whole // content of the record — and because the Resume control has to post it. previousTier: StoredChannelTier; // The one sentence, already assembled. detail: string; }; export function autoPausedRows(model: ChannelPriority): AutoPausedRow[] { const rows: AutoPausedRow[] = []; // `autoPausedSlugs` sorts, so the list is stable across renders — a section // that reorders itself under an auto-refresh is one an operator cannot click. for (const slug of autoPausedSlugs(model)) { const auto = model.channels[slug]?.autoPaused; if (!auto) continue; rows.push({ slug, reason: auto.reason, since: auto.since, previousTier: auto.previousTier, // Never null here — the entry carries a record, which is exactly the // condition `autoPauseReasonOf` returns a sentence for. detail: autoPauseReasonOf(model, slug) ?? "", }); } return rows; }