Replaces the freeform "Endings shown" Input in Playthrough Notes
with a structured editor that knows about ending numbers, names,
multi-video splits, and timeline cross-validation. The output
description bullet renders comma-joined structured entries with
fallback to the legacy freeform for migrated drafts.
Key changes:
* New `EndingsEditor` component with three logical cases:
- 1 ending → Number + Name pair with live preview
- 2+ endings, 1 video → table row per ending + timeline gate
(warns when timeline lacks `ending` markers for each row)
- 2+ endings, 2+ videos → endings table + per-video range table
with auto-contiguous balanced split (extras spill into the
LAST video — climactic-final convention) and override support
+ inline overlap/gap/out-of-bounds warnings.
* Schema additions to `EditorData`:
- `endings: EndingEntry[]` ({number, name})
- `endingVideoCount: number`
- `endingVideoRanges: EndingVideoRange[]` (1-indexed inclusive)
- `endingsShown` kept on the type for migration round-trip but
no longer surfaces in the UI.
* Engine `endings-format.ts` — pure helpers used by description
builder + editor preview:
- `formatEndingEntry` (4 cases: both / number-only / name-only
/ neither → null drop signal)
- `sliceEndingsForVideo` (whole-array fallback when not multi-
video / index out of range; targeted slice otherwise)
- `clampRange`
* Timeline parser ending pattern now captures an optional ordinal
so `Ending 3: Best End` parses into `{keyword: "ending",
number: 3, rest: ": Best End"}`. Unblocks the case-B timeline
gate. Renderer collapses trailing whitespace so a bare `Boss`
no longer becomes `Boss `.
* Description builder reads structured `endings[]` first, falls
back to legacy `endingsShown` only when the array is empty.
Multi-row entries render comma-joined; sliced by
`endingVideoIndex` when supplied.
* Migration `migrateEditorState` v11 → v12:
- `liftLegacyEndingString` parses "Ending 3: Best End" /
"Ending 3" / localised "Kết thúc N" / "エンディングN" / etc.
into a single structured row. Unparseable strings fall
through to a name-only row.
- `computeContiguousRanges` builds the default video split.
- Clamps `endingVideoCount` to `[1, endings.length]`.
* 19 new locale keys × 6 locales under `editor.endings.*`
(705/705 keys, up from 686/686). Schema updated.
* 42 new tests (367 → 409): endings-format, editor-store
migration, description-builder structured render, timeline-
parser ending ordinal capture.
* Bundle: index 463.08 KB (+62 KB for new UI + engine). Under
the 500 KB cap.
Migration notes:
* Persisted v0.12–v0.15 drafts auto-lift their `endingsShown`
string into a single structured row on first rehydrate. The
rendered description bullet is byte-identical for the common
case ("True ending only" → "True ending only"). Numbered
legacy strings ("Ending 3: Best End") gain structure so future
edits via the new UI work seamlessly.
* Pre-v0.16 templates with `endings` missing still load — the
TemplateSnapshot type makes all three new fields optional.
* Case C (multi-video) currently renders the union of all
endings in the Output preview. Per-video output rendering is
wired into the engine via `endingVideoIndex` but the UI
selector for it lands in a follow-up patch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>