The code cited its plan instead of saying why: `E28 review J4`, `(R6 S3b)`, `S1 justified…`,
`deep-review round 5`. That plan lives in the private ops repo, so for every reader of this one the
citation was noise, and a sentence whose subject was the plan step ("round 2 showed…") hid its
lesson behind an id. Each one is gone and the "why" kept: a bare citation is deleted, a sentence
carrying a lesson is reworded around it ("a later attempt showed…").
Measured (`scripts/audit_metrics.py`, product code): 652 lines in 270 files carried an epic code by
the definition the next commit holds (507 / 241 by the old, two-digit-only one) -> 0. Across all
code, tests, scripts and configs: ~1100 epic-code lines plus ~320 sprint/round ids.
Behaviour unchanged, checked mechanically: every changed .py file has the same AST once docstrings
are blanked; css/sh/toml/yml/json files are identical once comments are stripped; the only
non-comment changes in TS/JS are test titles, one description string in a contract table, and five
ESLint messages, whose text is all the gates snapshot diff holds. Not touched: Markdown (docs and
the changelog keep their history), Alembic migrations, TV episode notation (`S2 · E5`), DESIGN.md
ids (`C1`, `B4`, `S3h`), tracker ids (`SEC-16`, `DX-17`).
One stale claim fixed on the way: test_hls_reaper's docstring said the player checkpoints "every
10 s whether or not it is playing", which plex/stream.py calls wrong; it now says what the code does.
48 lines
2.4 KiB
TypeScript
48 lines
2.4 KiB
TypeScript
// The channel manager's layout vocabulary. Named `ChannelLayout` — NOT `ChannelView` — on
|
|
// purpose: the manager already has a `ChannelsView` (the subscribed/discovery/blocked TAB), and a
|
|
// one-letter-apart type would be a footgun. This is the table-vs-card density switch, riding the
|
|
// same generic `ViewSwitcher` as the feed. Two layouts: the DataTable, and a virtualized card grid.
|
|
// (A `rows` variant existed briefly but was retired — it barely differed from the table.)
|
|
export type ChannelLayout = "table" | "cards";
|
|
|
|
export const CHANNEL_LAYOUTS: readonly ChannelLayout[] = ["table", "cards"] as const;
|
|
|
|
const CHANNEL_LAYOUT_DEFAULT: ChannelLayout = "table";
|
|
|
|
/** The `cards` layout's grid spec, consumed by VirtualGrid. `table` has no entry — it keeps the
|
|
* numbered-pager DataTable, not the virtualized grid. */
|
|
export interface ChannelLayoutSpec {
|
|
/** Narrowest grid column in px. */
|
|
minCol: number;
|
|
/** First-paint row-height estimate; real heights are measured per-row after. Measured in the
|
|
* browser (channel heading + About line + meta + tags + actions), not guessed. */
|
|
rowEst: number;
|
|
}
|
|
|
|
export const CHANNEL_LAYOUT_SPEC: Record<Exclude<ChannelLayout, "table">, ChannelLayoutSpec> = {
|
|
cards: { minCol: 320, rowEst: 232 },
|
|
};
|
|
|
|
/** Coerce a stored value to a layout; anything unknown (corrupt, a rolled-back future layout, or the
|
|
* retired "rows") falls back to the default rather than rendering nothing. */
|
|
export function parseChannelLayout(raw: unknown): ChannelLayout {
|
|
return (CHANNEL_LAYOUTS as readonly string[]).includes(raw as string)
|
|
? (raw as ChannelLayout)
|
|
: CHANNEL_LAYOUT_DEFAULT;
|
|
}
|
|
|
|
/** Cards-per-page choices for the card layout's pager (0 = "All"), shared by both manager tabs. */
|
|
export const CARD_PAGE_SIZES = [10, 25, 50, 100];
|
|
const CARD_SIZE_DEFAULT = 25;
|
|
|
|
/** Coerce a stored cards-per-page value to one the pager actually OFFERS (the sizes above, or 0 =
|
|
* "All"). Clamped against the allowed set — like `clampView`/`clampStatus` — not merely type-checked:
|
|
* a corrupt entry would make the page count NaN and slice the grid down to nothing, and an
|
|
* off-menu number (a hand-edited 7, or an option a future build dropped) would page by a value the
|
|
* `<select>` cannot show, so the control and the behaviour would silently disagree. */
|
|
export function parseCardSize(raw: unknown): number {
|
|
return typeof raw === "number" && (raw === 0 || CARD_PAGE_SIZES.includes(raw))
|
|
? raw
|
|
: CARD_SIZE_DEFAULT;
|
|
}
|