Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: storyboard shot-grammar editor + inline pre-render continuity warnings (#1468)
Adam Eivyd16c82818564
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b19cb60594..9b060ac9db 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -12,6 +12,7 @@- **[issue-1408] LoRA training quality-of-life: vision-assisted reference-sheet slicing, caption with Claude/Codex CLI providers, and a richer training queue.** Three improvements to building character LoRAs (Create → LoRA Training). **(1) Smarter sheet slicing** — "Slice reference sheet" now offers *Auto-detect figures with a vision model*, which asks a vision model to draw a tight box around each figure on the turnaround and crops those instead of a rigid grid; it falls back to the columns×rows grid automatically when no vision model is installed or detection finds nothing, so you still get crops to prune either way. **(2) Caption with a CLI model** — the caption-model picker now also lists vision-capable CLI providers (Codex / Claude Code), so you can auto-caption a dataset with `codex` or `claude` (vision) rather than only a local LM Studio / Ollama vision model. **(3) Training queue at a glance** — the new Training queue on the LoRA Training page shows each run's loss curve (a sparkline over its checkpoints) and sample thumbnails right in the row, so you can watch a run learn — and spot a divergence — without opening it. (Part of #1227, #1408)- **[issue-1466] Editorial check flags storyboard eyeline-match breaks — the LLM-assisted sibling of the deterministic shot-continuity check.** A new **Storyboard eyeline match (gaze continuity)** LLM check (Create → Editorial Checks) reads a scene's per-issue storyboard shots and flags the eyeline mistakes a deterministic scan can't compute: two characters in conversation whose **gaze directions don't reciprocate** across the cut (both look the same way instead of toward each other), a **described eyeline that contradicts the shot's tagged screen direction** (the storyboard's own two signals disagree), and a **reverse-angle that doesn't flip the eyeline**. Where the deterministic **Storyboard shot continuity** check (#1315) reasons over the structured `shotType`/`screenDirection`/continuity-link fields for 180°-rule axis reversals and shot-type monotony, an eyeline match needs *semantic* reading of the free-text shot descriptions — so this one runs an LLM over a compact per-scene shot block (id, framing, direction, continuity link, description), built only from scenes that have two-or-more described shots to compare. Findings render as `Continuity` notes anchored to the offending shot pair + issue. Gaze is read from the free-text shot description (the `screen direction` field records where a subject *faces or moves*, which isn't always where they look), and the pass is bounded four ways (scene count, shots-per-scene, a hard total-character ceiling, and per-shot description length) with non-silent omission/truncation markers so a very large storyboard — wide, deep, or with one pathological scene — can't overflow the model context. The check skips the model call entirely when no scene qualifies. Ships a new stage prompt (`pipeline-editorial-eyeline-match`) that migrates for existing installs (117). (`server/lib/editorial/shotContinuity.js`, `server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-eyeline-match.md`, `scripts/migrations/117-editorial-eyeline-match-stage.js`, Part of #1283, #1466)- **[issue-1467] Editorial check flags storyboard appearance / prop continuity — the LLM diff the name-matching shot parser can't do.** A new **Storyboard appearance / prop continuity** LLM check (Create → Editorial Checks) reads a scene's per-issue storyboard shots and diffs the *descriptions* of the same entity across shots, catching the continuity errors a vocabulary scan can't: the same named character described with **conflicting wardrobe / hair / physical state** (a "red jacket" in shot 1, a "grey coat" in shot 3, with no costume change described), a **prop that appears, vanishes, or transforms** with no action removing it (a coffee cup that pops in and out; a "mug" that becomes a "glass"), and a **setting whose weather / time-of-day / layout contradicts** across shots with no transition. Where the deterministic **Storyboard shot continuity** check (#1315) reasons over structured framing/direction fields and its eyeline sibling (#1466) judges gaze reciprocity, this one needs *semantic* comparison of two free-text descriptions — the shot parser matches characters by name but never diffs what they look like — so it runs an LLM over the same compact per-scene shot block (shared `summarizeStoryboardShots`, built only from scenes with two-or-more described shots, bounded four ways with non-silent truncation markers). Findings render as `Continuity` notes anchored to the offending shot pair + issue; deliberate changes the description justifies, single-shot details, and pure framing differences are explicitly not flagged. The check skips the model call entirely when no scene qualifies. Ships a new stage prompt (`pipeline-editorial-appearance-continuity`) that migrates for existing installs (118). (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-appearance-continuity.md`, `scripts/migrations/118-editorial-appearance-continuity-stage.js`, Part of #1283, #1467)+- **[issue-1468] Storyboard shot-grammar editor + inline pre-render continuity warnings.** The two UI follow-ups to the shot-continuity data model (#1315). **(1) Shot-grammar editor** — each storyboard shot row now carries **framing** and **screen-direction** selects, so you can set/correct the `shotType` (extreme-wide → POV) and `screenDirection` (faces screen-left / -right / head-on) the deterministic `visual.shot-continuity` check reasons over — instead of the prior all-or-nothing behavior where hand-editing a shot's description silently cleared both to "not captured." The selects persist immediately (discrete picks, like the wardrobe picker) and an empty value clears the field back to "not captured" (skipped by the check); they explicitly bypass the description-edit reset so an intentional set sticks. **(2) Inline pre-render warnings** — the same 180°-rule axis-jump and shot-type-monotony hazards the editorial check surfaces in the manuscript review now appear inline in the Storyboards stage (per scene) and aggregated in the Episode Video stage's pre-render panel, so you see a known continuity error *before* spending render time on the clip — mirroring the inline comic-lettering warning pattern (#1313). The two deterministic detectors are a byte-for-byte client mirror of `server/lib/editorial/shotContinuity.js` (the server check stays authoritative); a new `sceneShotWarnings` composer renders them as concise per-scene warnings. (`client/src/lib/shotContinuity.js`, `client/src/lib/shotGrammar.js`, `client/src/components/pipeline/stages/{StoryboardsStage,EpisodeVideoStage}.jsx`, Part of #1283, #1468)- **[issue-1412] Editorial check classifies unmodeled proper nouns used as character names — the LLM-assisted half of roster economy.** A new **Unmodeled proper nouns used as character names** LLM check (Create → Editorial Checks) closes the gap the deterministic **roster economy** check (#1292) deliberately left open: that scan only sees canon names + aliases, so a proper noun used as an *apparent* character name that was never added to the story bible is invisible to it. This check surfaces those — and **classifies** each one, because a keyword scan can't tell a person from a place, organization, brand, or honorific. It reads the stitched manuscript plus your canon roster (names + aliases) as an exclusion list, flags capitalized proper nouns used as character names that are **absent from canon**, and calls out **throwaway one-appearance names** the reader is told to remember but who never recur — suggesting either adding them to canon or recasting them as an unnamed description. Unlike roster economy it runs even on an **empty bible** (then every named proper noun is a candidate). The LLM does only the judgment it alone can — surface a name and confirm it's a *person* — while a **deterministic pass counts each surfaced name's appearances across the whole manuscript and authors the verdict** (one-appearance throwaway vs recurring), so a long book reviewed in chunks never mislabels a name that appears in chapters 1 and 12 as a throwaway (and the same name surfaced from two chunks collapses to one finding). Findings render as `Casting` notes anchored to the issue + a verbatim quote. Ships a new stage prompt (`pipeline-editorial-unmodeled-names`) that migrates for existing installs (116). (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md`, `scripts/migrations/116-editorial-unmodeled-names-stage.js`, Part of #1283, #1412)- **The Local LLM Playground now shows which Ollama models are warm in memory (and which one is processing).** The models sidebar reads Ollama's `/api/ps` (the same loaded-model probe the Memory Management panel uses) and flags each resident model with a green **In memory** badge carrying its VRAM footprint, plus a relative **"frees in Nm"** countdown until Ollama auto-evicts it. While a run is in flight, the model(s) it's driving show a **Processing** badge with a live spinner — derived from the playground's own in-flight run since `/api/ps` reports residency but not which model is mid-generation. A header chip summarizes **"N in memory"** at a glance. The loaded list polls every 6s (2s while busy) and refreshes on the manual refresh button. (`client/src/pages/LocalLlmPlayground.jsx`)diff --git a/client/src/components/pipeline/stages/EpisodeVideoStage.jsx b/client/src/components/pipeline/stages/EpisodeVideoStage.jsxindex cde6e01724..c005b82b26 100644--- a/client/src/components/pipeline/stages/EpisodeVideoStage.jsx+++ b/client/src/components/pipeline/stages/EpisodeVideoStage.jsx@@ -10,6 +10,7 @@ import ScenePreview from '../../creative-director/ScenePreview';import ModelSelect from '../../ModelSelect';import { useAsyncAction } from '../../../hooks/useAsyncAction';import { useAutoRefetch } from '../../../hooks/useAutoRefetch';+import { sceneShotWarnings } from '../../../lib/shotContinuity';// Monotonic snapshot: a poll is logically equivalent when the project's id,// updatedAt, and status all match. Including `id` guards against the restart@@ -88,6 +89,20 @@ export default function EpisodeVideoStage({ issue, onStageUpdate }) {const storyboardScenes = issue.stages?.storyboards?.scenes || [];const usableScenes = storyboardScenes.filter((s) => (s?.description || '').trim().length > 0);+ // Pre-render continuity gate (#1468): the same deterministic shot-continuity+ // hazards (180°-rule axis jumps, shot-type monotony) the server+ // `visual.shot-continuity` editorial check surfaces, aggregated across every+ // scene's shot list so the user is warned before spending episode-render time.+ // Soft gate — the warning surfaces below the Generate button (which stays+ // enabled); the fix lives in the Storyboards stage's shot-grammar editor.+ const continuityWarnings = useMemo(+ () => storyboardScenes.flatMap((scene, i) => {+ const sceneName = (scene?.slugline || scene?.heading || `Scene ${i + 1}`).trim() || `Scene ${i + 1}`;+ return sceneShotWarnings(scene).map((w) => ({ ...w, scene: sceneName }));+ }),+ [storyboardScenes],+ );+const [confirmRestart, setConfirmRestart] = useState(false);// Initialize from the persisted stage values so a page reload (or a fresh// tab) doesn't lose the user's previous picks. Falls through to defaults@@ -291,6 +306,18 @@ export default function EpisodeVideoStage({ issue, onStageUpdate }) {Ready to render {usableScenes.length} scene{usableScenes.length === 1 ? '' : 's'}. Each one becomes a short video clip; the first is text-to-video and every subsequent scene chains from the prior scene's last frame for visual continuity. Audio is disabled and scenes are auto-accepted (no LLM evaluator round-trip).</p>)}+ {continuityWarnings.length > 0 ? (+ <ul className="rounded border border-port-warning/30 bg-port-warning/5 px-2.5 py-1.5 space-y-0.5">+ <li className="text-[11px] text-gray-400">+ Shot-continuity check flagged {continuityWarnings.length} issue{continuityWarnings.length === 1 ? '' : 's'} — fix in the Storyboards stage before rendering to avoid wasted render time:+ </li>+ {continuityWarnings.map((w, i) => (+ <li key={i} className="text-[11px] text-port-warning">+ ⚠ {w.scene}: {w.message}+ </li>+ ))}+ </ul>+ ) : null}</div>) : (<div className="p-4 bg-port-card border border-port-border rounded-lg space-y-3">diff --git a/client/src/components/pipeline/stages/StoryboardsStage.jsx b/client/src/components/pipeline/stages/StoryboardsStage.jsxindex 290e388263..cbfcc86cdc 100644--- a/client/src/components/pipeline/stages/StoryboardsStage.jsx+++ b/client/src/components/pipeline/stages/StoryboardsStage.jsx@@ -19,6 +19,8 @@import { useEffect, useMemo, useRef, useState } from 'react';import { Plus, Trash2, Sparkles, Loader2, Wand2, Film, WandSparkles, Shirt, Layers } from 'lucide-react';import toast from '../../ui/Toast';+import { SHOT_TYPES, SCREEN_DIRECTIONS, SHOT_TYPE_LABELS, SCREEN_DIRECTION_LABELS } from '../../../lib/shotGrammar';+import { sceneShotWarnings } from '../../../lib/shotContinuity';import {generatePipelineVisualImage,generatePipelineSceneVideo,@@ -145,11 +147,21 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actions// screenDirection (#1315) were inferred from the OLD text and are now stale —// clear them to null ("not captured") so the deterministic visual.shot-continuity// check skips this shot rather than reporting an axis reversal that contradicts- // the new description. (A dedicated editor for these fields is tracked separately.)+ // the new description. The user can re-set them explicitly via the shot-grammar+ // selects below (setShotGrammar), which bypass this reset.const grammarReset = 'description' in patch ? { shotType: null, screenDirection: null } : {};updateShots(sceneIdx, (shots) => shots.map((sh, j) => j === shotIdx ? { ...sh, ...patch, ...grammarReset } : sh));};+ // Shot-grammar selects (#1468) are discrete picks (no blur), so persist+ // immediately — mirrors the wardrobe picker. Explicit user intent, so this+ // path NEVER applies updateShot's description-driven grammar reset. An empty+ // select value clears the field to null ("not captured"), which the+ // visual.shot-continuity check reads as ABSENT (skips the shot).+ const setShotGrammar = (sceneIdx, shotIdx, patch) =>+ persist(updateShots(sceneIdx, (shots) =>+ shots.map((sh, j) => j === shotIdx ? { ...sh, ...patch } : sh)));+const handleRenderShot = async (sceneIdx, shotIdx) => {const shot = scenes[sceneIdx].shots[shotIdx];const fallbackDesc = (scenes[sceneIdx].description || '').trim();@@ -519,6 +531,7 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actionsonAddShot={() => addShot(i)}onRemoveShot={(j) => removeShot(i, j)}onUpdateShot={(j, patch) => updateShot(i, j, patch)}+ onSetShotGrammar={(j, patch) => setShotGrammar(i, j, patch)}onBlurShot={() => persist(scenes)}onRenderShot={(j) => handleRenderShot(i, j)}/>@@ -532,9 +545,16 @@ export default function StoryboardsStage({ issue, series, onStageUpdate, actionsfunction ShotList({sceneIdx, shots, renderingShots, actionsGated,- onAddShot, onRemoveShot, onUpdateShot, onBlurShot, onRenderShot,+ onAddShot, onRemoveShot, onUpdateShot, onSetShotGrammar, onBlurShot, onRenderShot,}) {const hasShots = shots.length > 0;+ // Inline pre-render continuity warnings (#1468): the same hazards the server+ // `visual.shot-continuity` editorial check surfaces, computed here from the+ // shots' shotType / screenDirection / continuityFromShotId so the user sees a+ // 180°-axis jump or shot-type monotony BEFORE spending render time — without a+ // round-trip through an editorial-checks run. Mirrors the inline lettering+ // warning pattern (#1313) in ComicScriptStage.+ const continuityWarnings = useMemo(() => sceneShotWarnings({ shots }), [shots]);return (<div className="mt-3 pt-3 border-t border-port-border/60"><div className="flex items-center justify-between mb-2">@@ -549,6 +569,15 @@ function ShotList({<Plus size={11} /> Add shot</button></div>+ {continuityWarnings.length > 0 ? (+ <ul className="mb-2 rounded border border-port-warning/30 bg-port-warning/5 px-2.5 py-1.5 space-y-0.5">+ {continuityWarnings.map((w, i) => (+ <li key={i} className="text-[11px] text-port-warning">+ ⚠ Continuity — {w.message}+ </li>+ ))}+ </ul>+ ) : null}{hasShots ? (<ul className="space-y-2">{shots.map((shot, j) => {@@ -556,15 +585,49 @@ function ShotList({return (<li key={shot.id || j} className="flex items-start gap-2 p-2 bg-port-bg/40 border border-port-border/60 rounded"><span className="text-[10px] text-gray-500 font-mono pt-1.5 w-6">{j + 1}</span>- <textarea- value={shot.description || ''}- onChange={(e) => onUpdateShot(j, { description: e.target.value })}- onBlur={onBlurShot}- placeholder="One camera setup. Subject + framing + motion + mood."- rows={2}- className="flex-1 px-2 py-1 bg-port-bg border border-port-border rounded text-white text-xs"- maxLength={4000}- />+ <div className="flex-1 flex flex-col gap-1">+ <textarea+ value={shot.description || ''}+ onChange={(e) => onUpdateShot(j, { description: e.target.value })}+ onBlur={onBlurShot}+ placeholder="One camera setup. Subject + framing + motion + mood."+ rows={2}+ className="px-2 py-1 bg-port-bg border border-port-border rounded text-white text-xs"+ maxLength={4000}+ />+ {/* Shot-grammar editor (#1468): set/correct the film-grammar+ fields the visual.shot-continuity check reads. Discrete+ picks persist immediately and skip the description-driven+ reset. '' = clear to "not captured" (skipped by the check). */}+ <div className="flex gap-1">+ <select+ value={shot.shotType || ''}+ onChange={(e) => onSetShotGrammar(j, { shotType: e.target.value || null })}+ disabled={actionsGated}+ aria-label={`Shot ${j + 1} framing`}+ title="Camera framing — feeds the shot-type variety check"+ className="flex-1 min-w-0 px-1.5 py-1 bg-port-bg border border-port-border rounded text-gray-300 text-[10px] disabled:opacity-50"+ >+ <option value="">— framing —</option>+ {SHOT_TYPES.map((t) => (+ <option key={t} value={t}>{SHOT_TYPE_LABELS[t] || t}</option>+ ))}+ </select>+ <select+ value={shot.screenDirection || ''}+ onChange={(e) => onSetShotGrammar(j, { screenDirection: e.target.value || null })}+ disabled={actionsGated}+ aria-label={`Shot ${j + 1} screen direction`}+ title="Which way the subject faces / moves — feeds the 180°-rule axis check"+ className="flex-1 min-w-0 px-1.5 py-1 bg-port-bg border border-port-border rounded text-gray-300 text-[10px] disabled:opacity-50"+ >+ <option value="">— direction —</option>+ {SCREEN_DIRECTIONS.map((d) => (+ <option key={d} value={d}>{SCREEN_DIRECTION_LABELS[d] || d}</option>+ ))}+ </select>+ </div>+ </div><div className="flex flex-col gap-1 w-24"><inputtype="number"diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 2c8313669b..36dcae57bb 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -30,6 +30,8 @@ grep -i "what you want to do" client/src/lib/README.md| `personaTraitBlend.js` | Mirror of `server/lib/personaTraitBlend.js`. Digital-twin persona trait-blending (M34 P7) — `describeTraitAdjustments` / `renderTraitBlendDirective` / `BIG_FIVE_LEAN` for the Personas UI preview. || `seasonStructure.js` | Mirror of `server/lib/seasonStructure.js`. || `sheetPointers.js` | Mirror of the character-sheet pointer helpers from `server/lib/storyBible.js`. `LEGACY_SHEET_VARIANT_ID` + `readSheetPointer` / `listSheetPointers` / `applySheetPointer` for traversing both the legacy `referenceSheetImageRef` field and the `referenceSheets` map. |+| `shotContinuity.js` | Client mirror of `server/lib/editorial/shotContinuity.js` (#1315). `findAxisReversals` / `findShotTypeMonotony` (kept byte-for-byte with the authoritative server check) plus the client-only `sceneShotWarnings(scene, opts)` composer — the storyboards / episode-video stages' inline pre-render warnings (#1468) for 180°-rule axis jumps and shot-type monotony, so the user sees them before spending render time. Pure/DOM-free. |+| `shotGrammar.js` | Client mirror of the controlled vocabularies in `server/lib/shotGrammar.js` (#1315): `SHOT_TYPES` / `SCREEN_DIRECTIONS` enums (in sync with the server so a hand-set value passes `storyboardShotSchema`) + `SHOT_TYPE_LABELS` / `SCREEN_DIRECTION_LABELS` for the storyboards shot-grammar editor selects (#1468). || `universeStylePreset.js` | Build the client-side style preset that `composeStyledPrompt` layers on top. || `universeRunTag.js` | `buildUniverseSectionRenderTag(universe, kindKey, entry)` — the durable `universeRun` job tag the canon-render call sites (UniverseCanonSection, NounsStage, Story Builder characters step) pass to `generateImage` so the server auto-files the render into the universe collection AND appends it to the entry's `imageRefs[]` (no client follow-up PATCH). || `beatColors.js` | `BEAT_KIND_COLORS` + `getBeatKindColor(kind)` — per-kind display colors for reader-map emotional beats (kinds defined server-side in `storyArc.js`). Keeps every beat visualization consistent. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex 2fe46c6bf9..a085baf152 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -10,6 +10,8 @@ export * from './personaTraitBlend.js';export * from './scenePrompt.js';export * from './seasonStructure.js';export * from './sheetPointers.js';+export * from './shotContinuity.js';+export * from './shotGrammar.js';export * from './universeRunTag.js';export * from './universeStylePreset.js';diff --git a/client/src/lib/shotContinuity.js b/client/src/lib/shotContinuity.jsnew file mode 100644index 0000000000..4fb30b6831--- /dev/null+++ b/client/src/lib/shotContinuity.js@@ -0,0 +1,134 @@+// Client mirror of the deterministic shot-continuity primitives in+// server/lib/editorial/shotContinuity.js (#1315). The two detectors+// (`findAxisReversals`, `findShotTypeMonotony`) are kept byte-for-byte in sync+// with the server — the server `visual.shot-continuity` editorial check is+// authoritative and tested in server/lib/editorial/shotContinuity.test.js.+//+// This copy powers the storyboards / episode-video stages' INLINE pre-render+// warnings (#1468) so a user sees a 180°-rule axis jump or shot-type monotony+// BEFORE spending render time — without a round-trip through an editorial-checks+// run. Mirrors the inline comic-lettering warning pattern (#1313) in+// client/src/lib/letteringDensity.js. The warning composer (`sceneShotWarnings`)+// below is client-only (the server emits findings in a different shape); port any+// change to the two shared detectors to BOTH sides verbatim.++// Two directions are an axis reversal only when both are decided AND opposite.+// `neutral` (head-on / ambiguous) has no axis to cross, so it never reverses.+function isAxisReversal(a, b) {+ if (a == null || b == null) return false;+ if (a === 'neutral' || b === 'neutral') return false;+ return a !== b; // one 'left', one 'right'+}++// Shots of a scene as a safe array (an older/peer-synced scene may carry a+// non-array `shots`). Each element is passed through untouched — the caller+// type-guards the fields it reads.+function sceneShots(scene) {+ return Array.isArray(scene?.shots) ? scene.shots : [];+}++/**+ * Detect 180-degree-rule axis reversals across continuity-linked shot pairs in+ * one scene. For every shot that chains from an earlier shot in the same scene,+ * compare their `screenDirection`; a decided-and-opposite pair is flagged.+ *+ * @param {object} scene a storyboard scene with `shots[]`+ * @returns {Array<{ fromId, toId, fromDirection, toDirection, fromDescription, toDescription }>}+ */+export function findAxisReversals(scene) {+ const shots = sceneShots(scene);+ if (shots.length < 2) return [];+ // Shot ids are unique on the extract path (sanitizeShot synthesizes them) but+ // the route doesn't enforce cross-shot uniqueness, so a hand-edited scene could+ // carry a duplicate id — last-wins here, matching how a continuity ref would+ // resolve anyway. Acceptable under the check's high-precision / under-flag design.+ const byId = new Map();+ for (const s of shots) {+ if (s && typeof s === 'object' && typeof s.id === 'string' && s.id) byId.set(s.id, s);+ }+ const out = [];+ for (const shot of shots) {+ if (!shot || typeof shot !== 'object') continue;+ const fromId = typeof shot.continuityFromShotId === 'string' ? shot.continuityFromShotId : null;+ if (!fromId) continue;+ const prior = byId.get(fromId);+ if (!prior || prior === shot) continue;+ const fromDir = typeof prior.screenDirection === 'string' ? prior.screenDirection : null;+ const toDir = typeof shot.screenDirection === 'string' ? shot.screenDirection : null;+ if (!isAxisReversal(fromDir, toDir)) continue;+ out.push({+ fromId,+ toId: typeof shot.id === 'string' ? shot.id : '',+ fromDirection: fromDir,+ toDirection: toDir,+ fromDescription: typeof prior.description === 'string' ? prior.description : '',+ toDescription: typeof shot.description === 'string' ? shot.description : '',+ });+ }+ return out;+}++/**+ * Detect shot-type monotony in one scene: enough classified shots that they ALL+ * share a single `shotType`. Returns the monotony descriptor or null.+ *+ * @param {object} scene+ * @param {{ minClassified?: number }} [opts] minClassified — floored at 2;+ * default 3 (mirrors the check's `minShotsForMonotony` default).+ * @returns {{ shotType: string, classifiedCount: number } | null}+ */+export function findShotTypeMonotony(scene, opts = {}) {+ const minClassified = Math.max(2, Number.isInteger(opts.minClassified) ? opts.minClassified : 3);+ const shots = sceneShots(scene);+ const types = [];+ for (const s of shots) {+ if (s && typeof s === 'object' && typeof s.shotType === 'string' && s.shotType) types.push(s.shotType);+ }+ if (types.length < minClassified) return null;+ const first = types[0];+ if (!types.every((t) => t === first)) return null;+ return { shotType: first, classifiedCount: types.length };+}++// Screen-direction → reader-facing label, mirroring the server check's+// DIRECTION_LABEL so the inline warning and the editorial-run finding read the same.+const DIRECTION_LABEL = { left: 'screen-left', right: 'screen-right', neutral: 'head-on' };++/**+ * Compose the inline, render-gating continuity warnings for ONE storyboard scene+ * (client-only). Runs the two deterministic detectors with the check's default+ * config and returns concise, scene-scoped warnings — the same hazards the server+ * `visual.shot-continuity` check surfaces in the manuscript review, shown here so+ * the user sees them before spending render time.+ *+ * @param {object} scene a storyboard scene with `shots[]`+ * @param {{ minClassified?: number, flagAxisReversal?: boolean }} [opts]+ * @returns {Array<{ kind: 'axis-reversal'|'monotony', severity: 'medium', message: string }>}+ */+export function sceneShotWarnings(scene, opts = {}) {+ const flagAxis = opts.flagAxisReversal !== false;+ const minClassified = Number.isInteger(opts.minClassified) ? opts.minClassified : 3;+ const warnings = [];+ if (flagAxis) {+ for (const r of findAxisReversals(scene)) {+ const fromLabel = DIRECTION_LABEL[r.fromDirection] || r.fromDirection;+ const toLabel = DIRECTION_LABEL[r.toDirection] || r.toDirection;+ warnings.push({+ kind: 'axis-reversal',+ severity: 'medium',+ message: `180° axis jump — shot "${r.toId}" continues from "${r.fromId}" but faces ${toLabel} where "${r.fromId}" faced ${fromLabel}; the subject appears to flip sides across the cut.`,+ });+ }+ }+ if (minClassified > 0) {+ const mono = findShotTypeMonotony(scene, { minClassified });+ if (mono) {+ warnings.push({+ kind: 'monotony',+ severity: 'medium',+ message: `Shot-type monotony — all ${mono.classifiedCount} classified shots are ${mono.shotType}; the scene reads as flat, slideshow coverage with no establishing wide or punch-in.`,+ });+ }+ }+ return warnings;+}diff --git a/client/src/lib/shotContinuity.test.js b/client/src/lib/shotContinuity.test.jsnew file mode 100644index 0000000000..bd929bfe7d--- /dev/null+++ b/client/src/lib/shotContinuity.test.js@@ -0,0 +1,104 @@+import { describe, it, expect } from 'vitest';+import { findAxisReversals, findShotTypeMonotony, sceneShotWarnings } from './shotContinuity.js';++// The two detectors are byte-for-byte mirrors of+// server/lib/editorial/shotContinuity.js (exhaustively tested there). These are+// parity smoke tests; the focus is the client-only sceneShotWarnings composer.+describe('findAxisReversals (client mirror)', () => {+ it('flags a continuity-linked left↔right pair', () => {+ const scene = {+ shots: [+ { id: 'a', screenDirection: 'left' },+ { id: 'b', screenDirection: 'right', continuityFromShotId: 'a' },+ ],+ };+ expect(findAxisReversals(scene)).toHaveLength(1);+ });++ it('treats neutral as no axis', () => {+ const scene = {+ shots: [+ { id: 'a', screenDirection: 'neutral' },+ { id: 'b', screenDirection: 'right', continuityFromShotId: 'a' },+ ],+ };+ expect(findAxisReversals(scene)).toEqual([]);+ });+});++describe('findShotTypeMonotony (client mirror)', () => {+ it('flags 3 classified shots all one framing', () => {+ const scene = { shots: [{ shotType: 'medium' }, { shotType: 'medium' }, { shotType: 'medium' }] };+ expect(findShotTypeMonotony(scene)).toMatchObject({ shotType: 'medium', classifiedCount: 3 });+ });++ it('does not flag when framings vary', () => {+ const scene = { shots: [{ shotType: 'wide' }, { shotType: 'medium' }, { shotType: 'close' }] };+ expect(findShotTypeMonotony(scene)).toBeNull();+ });+});++describe('sceneShotWarnings', () => {+ it('returns an axis-reversal warning for a flipped continuity pair', () => {+ const scene = {+ shots: [+ { id: 'a', screenDirection: 'left' },+ { id: 'b', screenDirection: 'right', continuityFromShotId: 'a' },+ ],+ };+ const w = sceneShotWarnings(scene);+ expect(w).toHaveLength(1);+ expect(w[0].kind).toBe('axis-reversal');+ expect(w[0].severity).toBe('medium');+ expect(w[0].message).toContain('180° axis jump');+ expect(w[0].message).toContain('screen-left');+ expect(w[0].message).toContain('screen-right');+ });++ it('returns a monotony warning for a single-framing scene', () => {+ const scene = { shots: [{ shotType: 'close' }, { shotType: 'close' }, { shotType: 'close' }] };+ const w = sceneShotWarnings(scene);+ expect(w).toHaveLength(1);+ expect(w[0].kind).toBe('monotony');+ expect(w[0].message).toContain('Shot-type monotony');+ expect(w[0].message).toContain('close');+ });++ it('returns both kinds when both hazards are present', () => {+ const scene = {+ shots: [+ { id: 'a', shotType: 'medium', screenDirection: 'left' },+ { id: 'b', shotType: 'medium', screenDirection: 'right', continuityFromShotId: 'a' },+ { id: 'c', shotType: 'medium' },+ ],+ };+ const kinds = sceneShotWarnings(scene).map((w) => w.kind).sort();+ expect(kinds).toEqual(['axis-reversal', 'monotony']);+ });++ it('returns no warnings for a clean scene', () => {+ const scene = {+ shots: [+ { id: 'a', shotType: 'wide', screenDirection: 'left' },+ { id: 'b', shotType: 'close', screenDirection: 'left', continuityFromShotId: 'a' },+ ],+ };+ expect(sceneShotWarnings(scene)).toEqual([]);+ });++ it('respects flagAxisReversal: false (suppresses the axis warning)', () => {+ const scene = {+ shots: [+ { id: 'a', screenDirection: 'left' },+ { id: 'b', screenDirection: 'right', continuityFromShotId: 'a' },+ ],+ };+ expect(sceneShotWarnings(scene, { flagAxisReversal: false })).toEqual([]);+ });++ it('handles a non-array shots field without throwing', () => {+ expect(sceneShotWarnings({ shots: null })).toEqual([]);+ expect(sceneShotWarnings({})).toEqual([]);+ expect(sceneShotWarnings(null)).toEqual([]);+ });+});diff --git a/client/src/lib/shotGrammar.js b/client/src/lib/shotGrammar.jsnew file mode 100644index 0000000000..6747ec0929--- /dev/null+++ b/client/src/lib/shotGrammar.js@@ -0,0 +1,41 @@+// Client mirror of server/lib/shotGrammar.js (#1315) — the canonical controlled+// vocabularies for a storyboard shot's camera framing (`shotType`) and on-screen+// direction (`screenDirection`). The server module is authoritative (it also+// carries the LLM/UI normalizers); this copy holds only the enums + reader-facing+// labels the storyboards shot-grammar editor (#1468) needs to populate its selects.+// Keep SHOT_TYPES / SCREEN_DIRECTIONS in sync with the server verbatim — the route+// validates against the server enum (storyboardShotSchema), so a drifted client+// value would 400 on save.++// Camera framing / size. Same membership + order as the server SHOT_TYPES.+export const SHOT_TYPES = Object.freeze([+ 'extreme-wide',+ 'wide',+ 'medium',+ 'close',+ 'extreme-close',+ 'over-the-shoulder',+ 'two-shot',+ 'pov',+]);++// On-screen direction the subject faces / moves.+export const SCREEN_DIRECTIONS = Object.freeze(['left', 'right', 'neutral']);++// Reader-facing labels for the editor selects. Keys are the canonical tokens.+export const SHOT_TYPE_LABELS = Object.freeze({+ 'extreme-wide': 'Extreme wide',+ wide: 'Wide / establishing',+ medium: 'Medium',+ close: 'Close',+ 'extreme-close': 'Extreme close / insert',+ 'over-the-shoulder': 'Over-the-shoulder',+ 'two-shot': 'Two-shot',+ pov: 'POV',+});++export const SCREEN_DIRECTION_LABELS = Object.freeze({+ left: 'Faces screen-left',+ right: 'Faces screen-right',+ neutral: 'Head-on / neutral',+});