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
refactor([issue-758]): extract subcomponents from StoryboardPanel
[._.]/ Adam Eivyd7c72d90616b
diff --git a/client/src/components/writers-room/StoryboardBibleTab.jsx b/client/src/components/writers-room/StoryboardBibleTab.jsxnew file mode 100644index 0000000000..bd00511b0e--- /dev/null+++ b/client/src/components/writers-room/StoryboardBibleTab.jsx@@ -0,0 +1,91 @@+import { Loader2, RefreshCcw } from 'lucide-react';+import CharactersBible from './CharactersBible';+import PlacesBible from './PlacesBible';+import ObjectsBible from './ObjectsBible';++const BIBLE_KINDS = {+ characters: {+ label: 'Character bible',+ sub: 'Persisted across runs · feeds image-gen prompts',+ refreshNoun: 'characters',+ Component: CharactersBible,+ propName: 'characters',+ changeProp: 'onCharactersChange',+ },+ world: {+ label: 'World / places bible',+ sub: 'Locations keyed by slugline · feeds image-gen prompts',+ refreshNoun: 'world',+ Component: PlacesBible,+ propName: 'places',+ changeProp: 'onPlacesChange',+ },+ objects: {+ label: 'Recurring objects',+ sub: 'Symbolic / recurring items the prose returns to',+ refreshNoun: 'objects',+ Component: ObjectsBible,+ propName: 'objects',+ changeProp: 'onObjectsChange',+ },+};++function RefreshHeader({ noun, label, sub, running, anyRunning, onRefresh, empty }) {+ return (+ <div className="flex items-start justify-between gap-2 pb-2 border-b border-port-border">+ <div className="min-w-0">+ <div className="text-[12px] font-semibold text-gray-200">{label}</div>+ <div className="text-[10px] text-gray-500">{sub}</div>+ </div>+ <button+ type="button"+ onClick={onRefresh}+ disabled={anyRunning || !onRefresh}+ className="shrink-0 flex items-center gap-1 px-2 py-1 text-[10px] rounded bg-port-bg border border-port-border text-gray-300 hover:bg-port-card hover:text-white disabled:opacity-50 disabled:cursor-not-allowed"+ title={empty ? `Extract ${noun} from prose` : `Re-extract ${noun} from prose (merges into existing)`}+ >+ {running+ ? <Loader2 size={10} className="animate-spin text-port-accent" />+ : <RefreshCcw size={10} />+ }+ {running ? 'Refreshing…' : empty ? 'Extract from prose' : 'Refresh from prose'}+ </button>+ </div>+ );+}++export default function StoryboardBibleTab({+ kind,+ workId,+ items,+ onItemsChange,+ onRefresh,+ running,+ anyRunning,+ readingTheme,+ hotRefId = null,+}) {+ const meta = BIBLE_KINDS[kind];+ const Bible = meta.Component;+ const bibleProps = {+ workId,+ [meta.propName]: items,+ [meta.changeProp]: onItemsChange,+ readingTheme,+ hotRefId,+ };+ return (+ <div className="px-3 py-3 space-y-3">+ <RefreshHeader+ noun={meta.refreshNoun}+ label={meta.label}+ sub={meta.sub}+ running={running}+ anyRunning={anyRunning}+ onRefresh={onRefresh}+ empty={items.length === 0}+ />+ <Bible {...bibleProps} />+ </div>+ );+}diff --git a/client/src/components/writers-room/StoryboardBoardsBanners.jsx b/client/src/components/writers-room/StoryboardBoardsBanners.jsxnew file mode 100644index 0000000000..5b0423a5b5--- /dev/null+++ b/client/src/components/writers-room/StoryboardBoardsBanners.jsx@@ -0,0 +1,237 @@+import {+ Clapperboard, Loader2, RefreshCcw, AlertTriangle, Check,+ Users, MapPin as MapPinIcon, ArrowRight, SlidersHorizontal,+} from 'lucide-react';++// 3-step setup that replaces the old single "Run Adapt" CTA. Recommended+// order is characters → settings → script so Adapt's prompt has the bibles+// to cite (otherwise the LLM re-improvises descriptions every scene). The+// user can skip any step (clicking later steps directly is allowed) or just+// click "Run all in order" to fire the sequential pipeline.+export function StoryboardSetup({+ charactersCount,+ placesCount,+ onRunCharacters,+ onRunPlaces,+ onRunAdapt,+ onRunFullPipeline,+ runningKind,+}) {+ const isRunning = !!runningKind;+ const charDone = charactersCount > 0;+ const setDone = placesCount > 0;++ const Step = ({ n, kind, done, label, sublabel, hint, onClick, primary = false }) => {+ const running = runningKind === kind;+ const Icon = done ? Check : kind === 'characters' ? Users : kind === 'places' ? MapPinIcon : Clapperboard;+ return (+ <div className={`flex items-start gap-2.5 p-2.5 border rounded ${+ done ? 'border-port-success/40 bg-port-success/5' :+ running ? 'border-port-accent/60 bg-port-accent/5' :+ 'border-port-border bg-port-card/30'+ }`}>+ <div className={`shrink-0 w-5 h-5 rounded-full border flex items-center justify-center text-[10px] font-semibold ${+ done ? 'border-port-success text-port-success' :+ running ? 'border-port-accent text-port-accent' :+ 'border-port-border text-gray-500'+ }`}>+ {done ? <Check size={10} /> : running ? <Loader2 size={10} className="animate-spin" /> : n}+ </div>+ <div className="flex-1 min-w-0">+ <div className="flex items-center gap-1.5">+ <Icon size={12} className={done ? 'text-port-success' : running ? 'text-port-accent' : 'text-gray-500'} />+ <span className="text-[11px] font-medium text-gray-200">{label}</span>+ {done && <span className="text-[10px] text-port-success">{sublabel}</span>}+ </div>+ {!done && (+ <div className="text-[10px] text-gray-500 mt-0.5">{hint}</div>+ )}+ <button+ type="button"+ onClick={onClick}+ disabled={isRunning || !onClick}+ className={`mt-1.5 inline-flex items-center gap-1 px-2 py-1 text-[10px] rounded disabled:opacity-50 ${+ primary+ ? 'bg-port-accent text-white hover:bg-port-accent/80'+ : 'border border-port-border text-gray-300 hover:bg-port-border/40'+ }`}+ >+ {running ? <Loader2 size={10} className="animate-spin" /> : null}+ {done ? 'Re-run' : running ? 'Running…' : `Run ${kind === 'script' ? 'Adapt' : kind}`}+ </button>+ </div>+ </div>+ );+ };++ return (+ <div className="px-1 py-1 space-y-3">+ <div className="text-center space-y-1">+ <Clapperboard size={24} className="mx-auto text-gray-600" />+ <div className="text-[12px] text-gray-300 font-medium">No storyboard yet</div>+ <div className="text-[11px] text-gray-500 max-w-[36ch] mx-auto">+ For best results, scan your prose for characters and settings first — Adapt will reference both bibles when generating scene descriptions, keeping people and places visually consistent.+ </div>+ </div>++ <div className="space-y-1.5">+ <Step+ n={1}+ kind="characters"+ done={charDone}+ label="Extract characters"+ sublabel={`${charactersCount} found`}+ hint="Names, image-gen-ready physical descriptions, personality, role"+ onClick={onRunCharacters}+ />+ <Step+ n={2}+ kind="places"+ done={setDone}+ label="Extract places / world"+ sublabel={`${placesCount} location${placesCount === 1 ? '' : 's'}`}+ hint="Locations keyed by slugline (description, palette, era, recurring details)"+ onClick={onRunPlaces}+ />+ <Step+ n={3}+ kind="script"+ done={false}+ label="Run Adapt"+ sublabel=""+ hint="Break prose into scene-by-scene storyboard. Cites the bibles above for consistency."+ onClick={onRunAdapt}+ primary+ />+ </div>++ <button+ type="button"+ onClick={onRunFullPipeline}+ disabled={isRunning || !onRunFullPipeline}+ className="w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-port-accent text-white text-[11px] rounded hover:bg-port-accent/80 disabled:opacity-50"+ title="Runs all three steps sequentially: characters → settings → Adapt. Skip if you want to run them individually."+ >+ {isRunning ? <Loader2 size={12} className="animate-spin" /> : <ArrowRight size={12} />}+ {isRunning ? `Running ${runningKind}…` : 'Run all in order →'}+ </button>++ {(charDone || setDone) && (+ <div className="text-[10px] text-gray-500 text-center">+ Tip: edit either bible in its tab above before running Adapt.+ </div>+ )}+ </div>+ );+}++export function FailedAdaptBanner({ failure, onRunAdapt, runningAdapt, onOpenConfig, hasPriorScript }) {+ const error = failure?.error || 'Adapt failed for an unknown reason';+ const isTimeout = /timed out/i.test(error);+ return (+ <div className="p-3 mb-2 border border-port-error/40 bg-port-error/5 rounded text-[11px] space-y-2">+ <div className="flex items-start gap-2">+ <AlertTriangle size={14} className="text-port-error mt-0.5 shrink-0" />+ <div className="flex-1 min-w-0">+ <div className="text-port-error font-medium">Adapt failed</div>+ <div className="text-gray-300 break-words">{error}</div>+ {isTimeout && (+ <div className="text-gray-500 mt-1">+ Long drafts are heavy for small/light models — try a faster model+ (e.g. an API provider) in the Config tab.+ </div>+ )}+ {!hasPriorScript && (+ <div className="text-gray-500 mt-1">+ No prior storyboard to fall back to — re-running will create the first one.+ </div>+ )}+ </div>+ </div>+ <div className="flex gap-2 justify-end">+ <button+ onClick={onOpenConfig}+ className="flex items-center gap-1 px-2 py-1 border border-port-border text-gray-300 rounded text-[10px] hover:bg-port-border/40"+ >+ <SlidersHorizontal size={10} /> Adjust LLM+ </button>+ <button+ onClick={onRunAdapt}+ disabled={runningAdapt || !onRunAdapt}+ className="flex items-center gap-1 px-2 py-1 bg-port-error/20 border border-port-error/40 text-port-error rounded text-[10px] hover:bg-port-error/30 disabled:opacity-50"+ >+ {runningAdapt ? <Loader2 size={10} className="animate-spin" /> : <RefreshCcw size={10} />}+ Re-run Adapt+ </button>+ </div>+ </div>+ );+}++// Surfaced when the storyboard exists but one or both bibles are empty —+// Adapt's visualPrompts won't be referencing canonical descriptions, so+// the user gets visual drift across scenes. Inline run buttons let them+// fix it without leaving the panel; re-running Adapt afterwards picks up+// the populated bibles.+export function BiblesMissingNotice({ charactersMissing, placesMissing, onRunCharacters, onRunPlaces, runningKind }) {+ const isRunning = !!runningKind;+ const missing = [+ charactersMissing && 'character bible',+ placesMissing && 'places bible',+ ].filter(Boolean);+ return (+ <div className="flex items-start gap-2 p-2 mb-1 border border-port-warning/40 bg-port-warning/5 rounded text-[11px]">+ <AlertTriangle size={12} className="text-port-warning mt-0.5 shrink-0" />+ <div className="flex-1 min-w-0">+ <div className="text-port-warning">+ Storyboard built without {missing.join(' or ')}+ </div>+ <div className="text-gray-500">+ Scene visualPrompts re-improvise descriptions every render — populating the bibles and re-running Adapt locks them in.+ </div>+ <div className="flex gap-1.5 mt-1.5">+ {charactersMissing && (+ <button+ onClick={onRunCharacters}+ disabled={isRunning || !onRunCharacters}+ className="flex items-center gap-1 px-2 py-1 border border-port-border text-gray-300 rounded text-[10px] hover:bg-port-border/40 disabled:opacity-50"+ >+ {runningKind === 'characters' ? <Loader2 size={10} className="animate-spin" /> : <Users size={10} />}+ Extract characters+ </button>+ )}+ {placesMissing && (+ <button+ onClick={onRunPlaces}+ disabled={isRunning || !onRunPlaces}+ className="flex items-center gap-1 px-2 py-1 border border-port-border text-gray-300 rounded text-[10px] hover:bg-port-border/40 disabled:opacity-50"+ >+ {runningKind === 'places' ? <Loader2 size={10} className="animate-spin" /> : <MapPinIcon size={10} />}+ Extract places+ </button>+ )}+ </div>+ </div>+ </div>+ );+}++export function StaleBanner({ onRunAdapt, runningAdapt }) {+ return (+ <div className="flex items-start gap-2 p-2 mb-1 border border-port-warning/40 bg-port-warning/5 rounded text-[11px]">+ <AlertTriangle size={12} className="text-port-warning mt-0.5 shrink-0" />+ <div className="flex-1">+ <div className="text-port-warning">Storyboard is older than your current draft.</div>+ <div className="text-gray-500">Re-run Adapt to refresh scenes against the latest prose.</div>+ </div>+ <button+ onClick={onRunAdapt}+ disabled={runningAdapt || !onRunAdapt}+ className="flex items-center gap-1 px-2 py-1 bg-port-warning/20 border border-port-warning/40 text-port-warning rounded text-[10px] hover:bg-port-warning/30 disabled:opacity-50"+ >+ {runningAdapt ? <Loader2 size={10} className="animate-spin" /> : <RefreshCcw size={10} />}+ Re-run+ </button>+ </div>+ );+}diff --git a/client/src/components/writers-room/StoryboardBoardsTab.jsx b/client/src/components/writers-room/StoryboardBoardsTab.jsxnew file mode 100644index 0000000000..e3a94f1efb--- /dev/null+++ b/client/src/components/writers-room/StoryboardBoardsTab.jsx@@ -0,0 +1,151 @@+import { Loader2, Palette } from 'lucide-react';+import { timeAgo } from '../../utils/formatters';+import { STYLE_ID } from '../../lib/wrImageDefaults';+import SceneCard from './SceneCard';+import {+ StoryboardSetup,+ FailedAdaptBanner,+ BiblesMissingNotice,+ StaleBanner,+} from './StoryboardBoardsBanners';++function styleChip(style, presets) {+ if (!style || style.presetId === STYLE_ID.NONE) return null;+ if (style.presetId === STYLE_ID.CUSTOM) return 'Custom style';+ const p = presets.find((x) => x.id === style.presetId);+ return p?.label || style.presetId;+}++// ─── Boards (storyboard scene cards / render dock) ─────────────────────────+export default function StoryboardBoardsTab({+ work,+ scenes,+ sceneImages,+ latestScript,+ latestFailure,+ loading,+ isStale,+ imageCfg,+ imageStyle,+ stylePresets,+ charByKey,+ placeByKey,+ charactersCount,+ placesCount,+ sceneRefs,+ onJumpToScene,+ onDebug,+ onRunAdapt,+ onRunCharacters,+ onRunPlaces,+ onRunFullPipeline,+ runningAdapt,+ runningKind,+ readingTheme,+ activeSceneId,+ onOpenConfig,+ hotRef = null,+ onSceneHover,+ onSceneRenderStart,+}) {+ return (+ <div className="px-3 py-3 space-y-2">+ {/* Live rendering status moved to the page-level WritersRoomDock so it's+ visible from any tab, not just Boards. */}+ {latestScript && (+ <div className="flex items-center gap-2 pb-2 text-[10px] text-gray-500">+ <span>{scenes.length} scene{scenes.length === 1 ? '' : 's'} · {timeAgo(latestScript.completedAt || latestScript.createdAt, 'never')}</span>+ {imageStyle.presetId !== STYLE_ID.NONE && (+ <button+ type="button"+ onClick={onOpenConfig}+ className="text-port-accent/80 hover:text-port-accent flex items-center gap-1"+ title="World style applied — click to edit in Config"+ >+ <Palette size={10} /> {styleChip(imageStyle, stylePresets)}+ </button>+ )}+ </div>+ )}++ {loading && (+ <div className="flex items-center justify-center text-[11px] text-gray-500 gap-2 py-6">+ <Loader2 size={14} className="animate-spin" /> Loading storyboard…+ </div>+ )}++ {!loading && latestFailure && (+ <FailedAdaptBanner+ failure={latestFailure}+ onRunAdapt={onRunAdapt}+ runningAdapt={runningAdapt}+ onOpenConfig={onOpenConfig}+ hasPriorScript={!!latestScript}+ />+ )}++ {!loading && !latestScript && !latestFailure && (+ <StoryboardSetup+ charactersCount={charactersCount}+ placesCount={placesCount}+ onRunCharacters={onRunCharacters}+ onRunPlaces={onRunPlaces}+ onRunAdapt={onRunAdapt}+ onRunFullPipeline={onRunFullPipeline}+ runningKind={runningKind}+ />+ )}++ {!loading && latestScript && isStale && !latestFailure && (+ <StaleBanner onRunAdapt={onRunAdapt} runningAdapt={runningAdapt} />+ )}++ {!loading && latestScript && !isStale && !latestFailure && (charactersCount === 0 || placesCount === 0) && (+ <BiblesMissingNotice+ charactersMissing={charactersCount === 0}+ placesMissing={placesCount === 0}+ onRunCharacters={onRunCharacters}+ onRunPlaces={onRunPlaces}+ runningKind={runningKind}+ />+ )}++ {!loading && latestScript && scenes.length === 0 && (+ <div className="text-[11px] text-gray-500 italic px-1">+ Adapt finished but produced no scenes. Try adding `## Scene` headings to your prose, then re-run.+ </div>+ )}++ {!loading && scenes.map((scene, i) => {+ const sceneId = scene.id || `scene-${i}`;+ return (+ <SceneCard+ key={sceneId}+ ref={(handle) => {+ if (handle) sceneRefs.current[sceneId] = handle;+ else delete sceneRefs.current[sceneId];+ }}+ scene={{ ...scene, id: sceneId }}+ sceneNumber={i + 1}+ workId={work.id}+ analysisId={latestScript.id}+ workTitle={work.title}+ imageCfg={imageCfg}+ imageStyle={imageStyle}+ initialImage={sceneImages[sceneId] || null}+ readingTheme={readingTheme}+ charByKey={charByKey}+ placeByKey={placeByKey}+ isActive={sceneId === activeSceneId}+ onJumpToProse={onJumpToScene ? () => onJumpToScene(scene, i, scenes.length) : null}+ onDebug={onDebug}+ hotRef={hotRef}+ onHoverEnter={onSceneHover ? () => onSceneHover(sceneId) : null}+ onHoverLeave={onSceneHover ? () => onSceneHover(null) : null}+ onRenderStart={onSceneRenderStart}+ />+ );+ })}+ </div>+ );+}diff --git a/client/src/components/writers-room/StoryboardConfigTab.jsx b/client/src/components/writers-room/StoryboardConfigTab.jsxnew file mode 100644index 0000000000..aeead60bed--- /dev/null+++ b/client/src/components/writers-room/StoryboardConfigTab.jsx@@ -0,0 +1,289 @@+import { useEffect, useState } from 'react';+import { Palette, Check, Dice5, Cpu, Settings as SettingsIcon } from 'lucide-react';+import { randomSeed } from '../../lib/genUtils';+import BackendChipStrip from '../media/BackendChipStrip';+import { IMAGE_GEN_MODE } from '../../lib/imageGenBackends';+import StagePromptModelPicker from './StagePromptModelPicker';+import { STYLE_ID, EMPTY_IMAGE_STYLE } from '../../lib/wrImageDefaults';++const SCRIPT_STAGE = 'writers-room-script';++function groupPresetsByCategory(presets) {+ const map = new Map();+ for (const p of presets) {+ const cat = p.category || 'Other';+ if (!map.has(cat)) map.set(cat, []);+ map.get(cat).push(p);+ }+ return Array.from(map.entries());+}++// World style picker — dropdown of curated presets + Custom + None.+// Selecting a preset fills the prompt textarea; the user can edit it freely+// from there, which flips the presetId to 'custom' the moment text diverges.+// Saves are debounced into a single PATCH on blur (not per-keystroke) — the+// onChange contract is "give me the next imageStyle" not "save it now."+function WorldStyleRow({ value, presets, onChange }) {+ const [draftPrompt, setDraftPrompt] = useState(value.prompt || '');+ const [draftNeg, setDraftNeg] = useState(value.negativePrompt || '');++ // Pull the saved value down when the work id swaps (or anything else that+ // replaces the value object identity from the parent).+ useEffect(() => {+ setDraftPrompt(value.prompt || '');+ setDraftNeg(value.negativePrompt || '');+ }, [value.presetId, value.prompt, value.negativePrompt]);++ const pickPreset = (presetId) => {+ if (presetId === STYLE_ID.NONE) {+ onChange?.(EMPTY_IMAGE_STYLE);+ return;+ }+ if (presetId === STYLE_ID.CUSTOM) {+ // Keep whatever's in the textarea — just flip the discriminator.+ onChange?.({ presetId: STYLE_ID.CUSTOM, prompt: draftPrompt, negativePrompt: draftNeg });+ return;+ }+ const preset = presets.find((p) => p.id === presetId);+ if (!preset) return;+ onChange?.({ presetId: preset.id, prompt: preset.prompt, negativePrompt: preset.negativePrompt });+ };++ const commitDraft = () => {+ if (draftPrompt === value.prompt && draftNeg === value.negativePrompt) return;+ // If the user edited a preset's text, flip to 'custom' so the dropdown+ // reflects that the prompt no longer matches the curated preset.+ const matchingPreset = presets.find((p) => p.id === value.presetId);+ const stillMatchesPreset = matchingPreset+ && matchingPreset.prompt === draftPrompt+ && matchingPreset.negativePrompt === draftNeg;+ onChange?.({+ presetId: stillMatchesPreset ? value.presetId : STYLE_ID.CUSTOM,+ prompt: draftPrompt,+ negativePrompt: draftNeg,+ });+ };++ return (+ <div className="space-y-1.5">+ <div className="flex items-center justify-between">+ <span className="text-[9px] uppercase tracking-wider text-gray-500 flex items-center gap-1">+ <Palette size={10} /> World style+ </span>+ {value.presetId !== STYLE_ID.NONE && (+ <button+ type="button"+ onClick={() => pickPreset(STYLE_ID.NONE)}+ className="text-[9px] text-gray-500 hover:text-port-error"+ title="Clear style"+ >+ Clear+ </button>+ )}+ </div>+ <select+ value={value.presetId}+ onChange={(e) => pickPreset(e.target.value)}+ className="w-full bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200"+ >+ <option value={STYLE_ID.NONE}>None — use scene visualPrompt only</option>+ {groupPresetsByCategory(presets).map(([cat, items]) => (+ <optgroup key={cat} label={cat}>+ {items.map((p) => (+ <option key={p.id} value={p.id}>{p.label}</option>+ ))}+ </optgroup>+ ))}+ <option value={STYLE_ID.CUSTOM}>Custom</option>+ </select>+ {value.presetId !== STYLE_ID.NONE && (+ <>+ <label className="block">+ <span className="text-[9px] uppercase tracking-wider text-gray-500">+ Style prompt {value.presetId === STYLE_ID.CUSTOM && <Check size={9} className="inline text-port-accent" />}+ </span>+ <textarea+ value={draftPrompt}+ onChange={(e) => setDraftPrompt(e.target.value)}+ onBlur={commitDraft}+ rows={3}+ placeholder="cinematic still, anamorphic lens…"+ className="w-full mt-0.5 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 font-sans resize-y"+ />+ </label>+ <label className="block">+ <span className="text-[9px] uppercase tracking-wider text-gray-500">Negative prompt (optional)</span>+ <textarea+ value={draftNeg}+ onChange={(e) => setDraftNeg(e.target.value)}+ onBlur={commitDraft}+ rows={2}+ placeholder="cartoon, low quality…"+ className="w-full mt-0.5 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 font-sans resize-y"+ />+ </label>+ <div className="text-[10px] text-gray-500">+ Style is prepended to every scene's image prompt. Re-render scenes to see the change.+ </div>+ </>+ )}+ </div>+ );+}++const RES_PRESETS = [+ { label: '768×512 (3:2)', width: 768, height: 512 },+ { label: '512×512 (1:1)', width: 512, height: 512 },+ { label: '512×768 (2:3)', width: 512, height: 768 },+ { label: '1024×576 (16:9)', width: 1024, height: 576 },+ { label: '1024×1024 (1:1)', width: 1024, height: 1024 },+];++// Per-mode form layout — Codex picks model/steps/seed internally, External+// SD-API loads its model server-side. Showing fields the active backend+// can't act on misleads the user about what's actually controlling renders.+const MODE_HINT = {+ [IMAGE_GEN_MODE.LOCAL]: 'Renders locally via mflux/diffusers on this machine.',+ [IMAGE_GEN_MODE.CODEX]: "Codex's $imagegen skill renders via your logged-in Codex session. Model, steps, and seed are picked by Codex itself.",+ [IMAGE_GEN_MODE.EXTERNAL]: 'External SD-API renders against your configured A1111/Forge endpoint. The active model is set by the SD-API server.',+};++function ImageGenSettingsRow({ cfg, models, availableBackends = [], onChange }) {+ const presetMatch = RES_PRESETS.find((p) => p.width === cfg.width && p.height === cfg.height);+ const currentModel = models.find((m) => m.id === cfg.modelId);+ const inputCls = 'w-full mt-0.5 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 focus:border-port-accent outline-none';+ const labelCls = 'text-[9px] uppercase tracking-wider text-gray-500';+ const isLocalMode = cfg.mode === IMAGE_GEN_MODE.LOCAL;+ const isCodexMode = cfg.mode === IMAGE_GEN_MODE.CODEX;+ return (+ <div className="space-y-1.5">+ {availableBackends.length > 0 && (+ <div>+ <span className={labelCls}>Backend</span>+ <div className="mt-0.5">+ <BackendChipStrip+ availableBackends={availableBackends}+ value={cfg.mode}+ onChange={(id) => onChange({ ...cfg, mode: id })}+ size="sm"+ ariaLabel="Image gen backend"+ titlePrefix="Render storyboard scenes via"+ />+ </div>+ <p className="text-[9px] text-gray-500 mt-1">{MODE_HINT[cfg.mode]}</p>+ </div>+ )}+ <div className="grid grid-cols-2 gap-1.5">+ {isLocalMode && (+ <label className="block">+ <span className={labelCls}>Image model</span>+ <select+ value={cfg.modelId}+ onChange={(e) => onChange({ ...cfg, modelId: e.target.value })}+ className={inputCls}+ >+ {models.length === 0 && <option value={cfg.modelId}>{cfg.modelId}</option>}+ {models.map((m) => (+ <option key={m.id} value={m.id}>{m.name || m.id}</option>+ ))}+ </select>+ </label>+ )}+ <label className="block">+ <span className={labelCls}>Resolution</span>+ <select+ value={presetMatch ? `${cfg.width}x${cfg.height}` : 'custom'}+ onChange={(e) => {+ if (e.target.value === 'custom') return;+ const [w, h] = e.target.value.split('x').map(Number);+ onChange({ ...cfg, width: w, height: h });+ }}+ className={inputCls}+ >+ {RES_PRESETS.map((p) => (+ <option key={p.label} value={`${p.width}x${p.height}`}>{p.label}</option>+ ))}+ {!presetMatch && <option value="custom">Custom ({cfg.width}×{cfg.height})</option>}+ </select>+ </label>+ </div>+ {!isCodexMode && (+ <div className="grid grid-cols-2 gap-1.5">+ <label className="block">+ <span className={labelCls}>+ Steps {isLocalMode && currentModel?.steps && <span className="normal-case text-gray-600">(default {currentModel.steps})</span>}+ </span>+ <input+ type="number" min={1} max={150}+ value={cfg.steps}+ onChange={(e) => onChange({ ...cfg, steps: e.target.value })}+ placeholder={isLocalMode ? String(currentModel?.steps || 'auto') : 'server default'}+ className={inputCls}+ />+ </label>+ <label className="block">+ <span className={labelCls}>Seed</span>+ <div className="flex items-stretch gap-1 mt-0.5">+ <input+ type="number"+ value={cfg.seed}+ onChange={(e) => onChange({ ...cfg, seed: e.target.value })}+ placeholder="random"+ className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 focus:border-port-accent outline-none"+ />+ <button+ type="button"+ onClick={() => onChange({ ...cfg, seed: randomSeed() })}+ className="px-1.5 text-gray-500 hover:text-port-accent border border-port-border rounded"+ title="Randomize seed"+ aria-label="Randomize seed"+ >+ <Dice5 size={11} />+ </button>+ </div>+ </label>+ </div>+ )}+ </div>+ );+}++// ─── Config (image gen + style + Adapt LLM) ───────────────────────────────+export default function StoryboardConfigTab({ imageCfg, models, availableBackends, onCfgChange, stylePresets, imageStyle, onStyleChange, onOpenImageGenSettings }) {+ return (+ <div className="px-3 py-3 space-y-4">+ <section className="space-y-1.5">+ <div className="text-[12px] font-semibold text-gray-200">Adapt LLM</div>+ <StagePromptModelPicker+ stageName={SCRIPT_STAGE}+ label="Adapt LLM"+ icon={<Cpu size={10} />}+ hint="Used when you click Run Adapt to break prose into scenes."+ />+ </section>+ <section className="space-y-1.5 pt-3 border-t border-port-border">+ <div className="text-[12px] font-semibold text-gray-200">World style</div>+ <WorldStyleRow value={imageStyle} presets={stylePresets} onChange={onStyleChange} />+ </section>+ <section className="space-y-1.5 pt-3 border-t border-port-border">+ <div className="flex items-center justify-between gap-2">+ <div className="text-[12px] font-semibold text-gray-200">Image generation</div>+ <button+ type="button"+ onClick={onOpenImageGenSettings}+ className="flex items-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white"+ title="Configure image gen backends — enable Codex $imagegen, set local Python, etc."+ >+ <SettingsIcon size={10} /> Backends+ </button>+ </div>+ {availableBackends.length === 0 && (+ <div className="text-[10px] text-port-warning bg-port-warning/10 border border-port-warning/40 rounded px-2 py-1.5">+ No image gen backend configured. Click <span className="font-medium">Backends</span> to enable Local mflux, Codex <code className="text-gray-400">$imagegen</code>, or an External SD-API endpoint.+ </div>+ )}+ <ImageGenSettingsRow cfg={imageCfg} models={models} availableBackends={availableBackends} onChange={onCfgChange} />+ </section>+ </div>+ );+}diff --git a/client/src/components/writers-room/StoryboardPanel.jsx b/client/src/components/writers-room/StoryboardPanel.jsxindex bb99f0a138..1b69769ed9 100644--- a/client/src/components/writers-room/StoryboardPanel.jsx+++ b/client/src/components/writers-room/StoryboardPanel.jsx@@ -1,11 +1,9 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useSearchParams } from 'react-router-dom';import {- Clapperboard, Loader2, RefreshCcw, AlertTriangle, Palette, Check, Dice5, Cpu,- Users, MapPin as MapPinIcon, ArrowRight, ListTree, SlidersHorizontal,- Settings as SettingsIcon, Package,+ Clapperboard, Loader2, Users, MapPin as MapPinIcon,+ ListTree, SlidersHorizontal, Package,} from 'lucide-react';-import { randomSeed } from '../../lib/genUtils';import toast from '../ui/Toast';import {listWritersRoomAnalyses,@@ -13,33 +11,18 @@ import {} from '../../services/apiWritersRoom';import { getSettings, patchSettingsSlice, listImageStylePresets } from '../../services/apiSystem';import { listImageModels } from '../../services/apiImageVideo';-import BackendChipStrip from '../media/BackendChipStrip';-import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../../lib/imageGenBackends';-import { timeAgo } from '../../utils/formatters';+import { deriveAvailableBackends } from '../../lib/imageGenBackends';import useMounted from '../../hooks/useMounted';import Drawer from '../Drawer';import TabPills from '../ui/TabPills';import { ImageGenTab } from '../settings/ImageGenTab';-import SceneCard from './SceneCard';-import StagePromptModelPicker from './StagePromptModelPicker';-import CharactersBible from './CharactersBible';-import PlacesBible from './PlacesBible';-import ObjectsBible from './ObjectsBible';-import { WR_IMAGE_DEFAULTS, readWrImageSettings, STYLE_ID, EMPTY_IMAGE_STYLE } from '../../lib/wrImageDefaults';+import StoryboardBibleTab from './StoryboardBibleTab';+import StoryboardScenesTab from './StoryboardScenesTab';+import StoryboardBoardsTab from './StoryboardBoardsTab';+import StoryboardConfigTab from './StoryboardConfigTab';+import { WR_IMAGE_DEFAULTS, readWrImageSettings, EMPTY_IMAGE_STYLE } from '../../lib/wrImageDefaults';import { buildCharByKey, buildPlaceByKey } from '../../lib/scenePrompt';-const SCRIPT_STAGE = 'writers-room-script';--function groupPresetsByCategory(presets) {- const map = new Map();- for (const p of presets) {- const cat = p.category || 'Other';- if (!map.has(cat)) map.set(cat, []);- map.get(cat).push(p);- }- return Array.from(map.entries());-}-export const STORYBOARD_TAB = {CHARACTERS: 'characters',WORLD: 'world',@@ -296,7 +279,7 @@ export default function StoryboardPanel({<div className="flex-1 overflow-y-auto">{tab === TAB.CHARACTERS && (- <BibleTab+ <StoryboardBibleTabkind="characters"workId={work.id}items={characters}@@ -309,7 +292,7 @@ export default function StoryboardPanel({/>)}{tab === TAB.WORLD && (- <BibleTab+ <StoryboardBibleTabkind="world"workId={work.id}items={places}@@ -322,7 +305,7 @@ export default function StoryboardPanel({/>)}{tab === TAB.OBJECTS && (- <BibleTab+ <StoryboardBibleTabkind="objects"workId={work.id}items={objects}@@ -335,10 +318,10 @@ export default function StoryboardPanel({/>)}{tab === TAB.SCENES && (- <ScenesTab activeDraft={activeDraft} onJumpToScene={onJumpToScene} />+ <StoryboardScenesTab activeDraft={activeDraft} onJumpToScene={onJumpToScene} />)}{tab === TAB.BOARDS && (- <BoardsTab+ <StoryboardBoardsTabwork={work}scenes={scenes}sceneImages={sceneImages}@@ -371,7 +354,7 @@ export default function StoryboardPanel({/>)}{tab === TAB.CONFIG && (- <ConfigTab+ <StoryboardConfigTabimageCfg={imageCfg}models={models}availableBackends={availableBackends}@@ -390,760 +373,3 @@ export default function StoryboardPanel({</div>);}--const BIBLE_KINDS = {- characters: {- label: 'Character bible',- sub: 'Persisted across runs · feeds image-gen prompts',- refreshNoun: 'characters',- Component: CharactersBible,- propName: 'characters',- changeProp: 'onCharactersChange',- },- world: {- label: 'World / places bible',- sub: 'Locations keyed by slugline · feeds image-gen prompts',- refreshNoun: 'world',- Component: PlacesBible,- propName: 'places',- changeProp: 'onPlacesChange',- },- objects: {- label: 'Recurring objects',- sub: 'Symbolic / recurring items the prose returns to',- refreshNoun: 'objects',- Component: ObjectsBible,- propName: 'objects',- changeProp: 'onObjectsChange',- },-};--function BibleTab({ kind, workId, items, onItemsChange, onRefresh, running, anyRunning, readingTheme, hotRefId = null }) {- const meta = BIBLE_KINDS[kind];- const Bible = meta.Component;- const bibleProps = {- workId,- [meta.propName]: items,- [meta.changeProp]: onItemsChange,- readingTheme,- hotRefId,- };- return (- <div className="px-3 py-3 space-y-3">- <RefreshHeader- noun={meta.refreshNoun}- label={meta.label}- sub={meta.sub}- running={running}- anyRunning={anyRunning}- onRefresh={onRefresh}- empty={items.length === 0}- />- <Bible {...bibleProps} />- </div>- );-}--function RefreshHeader({ noun, label, sub, running, anyRunning, onRefresh, empty }) {- return (- <div className="flex items-start justify-between gap-2 pb-2 border-b border-port-border">- <div className="min-w-0">- <div className="text-[12px] font-semibold text-gray-200">{label}</div>- <div className="text-[10px] text-gray-500">{sub}</div>- </div>- <button- type="button"- onClick={onRefresh}- disabled={anyRunning || !onRefresh}- className="shrink-0 flex items-center gap-1 px-2 py-1 text-[10px] rounded bg-port-bg border border-port-border text-gray-300 hover:bg-port-card hover:text-white disabled:opacity-50 disabled:cursor-not-allowed"- title={empty ? `Extract ${noun} from prose` : `Re-extract ${noun} from prose (merges into existing)`}- >- {running- ? <Loader2 size={10} className="animate-spin text-port-accent" />- : <RefreshCcw size={10} />- }- {running ? 'Refreshing…' : empty ? 'Extract from prose' : 'Refresh from prose'}- </button>- </div>- );-}--// ─── Scenes (outline from prose headings) ─────────────────────────────────-function ScenesTab({ activeDraft, onJumpToScene }) {- const segs = activeDraft?.segmentIndex || [];- if (segs.length === 0) {- return (- <div className="px-3 py-3 text-[11px] text-gray-500 italic">- No segments yet. Use <code className="text-gray-300"># Chapter</code> /{' '}- <code className="text-gray-300">## Scene</code> /{' '}- <code className="text-gray-300">### Beat</code> headings in your prose to populate the outline.- </div>- );- }- return (- <ul className="px-3 py-3 space-y-1 text-[11px]">- {segs.map((seg) => {- const indent = seg.kind === 'beat' ? 'pl-4' : seg.kind === 'scene' ? 'pl-2' : '';- const tone = seg.kind === 'chapter' ? 'text-white font-semibold' : seg.kind === 'scene' ? 'text-gray-200' : 'text-gray-500';- return (- <li key={seg.id} className="flex items-center gap-2">- <button- type="button"- onClick={onJumpToScene ? () => onJumpToScene({ heading: seg.heading }) : undefined}- disabled={!onJumpToScene}- className={`flex-1 truncate text-left hover:text-port-accent disabled:hover:text-inherit ${indent} ${tone}`}- title={onJumpToScene ? 'Jump to this segment in the prose' : seg.heading}- >- {seg.heading}- </button>- <span className="text-[9px] text-gray-600 shrink-0">{seg.wordCount}w</span>- </li>- );- })}- </ul>- );-}--// ─── Boards (storyboard scene cards) ──────────────────────────────────────-function BoardsTab({- work,- scenes,- sceneImages,- latestScript,- latestFailure,- loading,- isStale,- imageCfg,- imageStyle,- stylePresets,- charByKey,- placeByKey,- charactersCount,- placesCount,- sceneRefs,- onJumpToScene,- onDebug,- onRunAdapt,- onRunCharacters,- onRunPlaces,- onRunFullPipeline,- runningAdapt,- runningKind,- readingTheme,- activeSceneId,- onOpenConfig,- hotRef = null,- onSceneHover,- onSceneRenderStart,-}) {- return (- <div className="px-3 py-3 space-y-2">- {/* Live rendering status moved to the page-level WritersRoomDock so it's- visible from any tab, not just Boards. */}- {latestScript && (- <div className="flex items-center gap-2 pb-2 text-[10px] text-gray-500">- <span>{scenes.length} scene{scenes.length === 1 ? '' : 's'} · {timeAgo(latestScript.completedAt || latestScript.createdAt, 'never')}</span>- {imageStyle.presetId !== STYLE_ID.NONE && (- <button- type="button"- onClick={onOpenConfig}- className="text-port-accent/80 hover:text-port-accent flex items-center gap-1"- title="World style applied — click to edit in Config"- >- <Palette size={10} /> {styleChip(imageStyle, stylePresets)}- </button>- )}- </div>- )}-- {loading && (- <div className="flex items-center justify-center text-[11px] text-gray-500 gap-2 py-6">- <Loader2 size={14} className="animate-spin" /> Loading storyboard…- </div>- )}-- {!loading && latestFailure && (- <FailedAdaptBanner- failure={latestFailure}- onRunAdapt={onRunAdapt}- runningAdapt={runningAdapt}- onOpenConfig={onOpenConfig}- hasPriorScript={!!latestScript}- />- )}-- {!loading && !latestScript && !latestFailure && (- <StoryboardSetup- charactersCount={charactersCount}- placesCount={placesCount}- onRunCharacters={onRunCharacters}- onRunPlaces={onRunPlaces}- onRunAdapt={onRunAdapt}- onRunFullPipeline={onRunFullPipeline}- runningKind={runningKind}- />- )}-- {!loading && latestScript && isStale && !latestFailure && (- <StaleBanner onRunAdapt={onRunAdapt} runningAdapt={runningAdapt} />- )}-- {!loading && latestScript && !isStale && !latestFailure && (charactersCount === 0 || placesCount === 0) && (- <BiblesMissingNotice- charactersMissing={charactersCount === 0}- placesMissing={placesCount === 0}- onRunCharacters={onRunCharacters}- onRunPlaces={onRunPlaces}- runningKind={runningKind}- />- )}-- {!loading && latestScript && scenes.length === 0 && (- <div className="text-[11px] text-gray-500 italic px-1">- Adapt finished but produced no scenes. Try adding `## Scene` headings to your prose, then re-run.- </div>- )}-- {!loading && scenes.map((scene, i) => {- const sceneId = scene.id || `scene-${i}`;- return (- <SceneCard- key={sceneId}- ref={(handle) => {- if (handle) sceneRefs.current[sceneId] = handle;- else delete sceneRefs.current[sceneId];- }}- scene={{ ...scene, id: sceneId }}- sceneNumber={i + 1}- workId={work.id}- analysisId={latestScript.id}- workTitle={work.title}- imageCfg={imageCfg}- imageStyle={imageStyle}- initialImage={sceneImages[sceneId] || null}- readingTheme={readingTheme}- charByKey={charByKey}- placeByKey={placeByKey}- isActive={sceneId === activeSceneId}- onJumpToProse={onJumpToScene ? () => onJumpToScene(scene, i, scenes.length) : null}- onDebug={onDebug}- hotRef={hotRef}- onHoverEnter={onSceneHover ? () => onSceneHover(sceneId) : null}- onHoverLeave={onSceneHover ? () => onSceneHover(null) : null}- onRenderStart={onSceneRenderStart}- />- );- })}- </div>- );-}--// ─── Config (image gen + style + Adapt LLM) ───────────────────────────────-function ConfigTab({ imageCfg, models, availableBackends, onCfgChange, stylePresets, imageStyle, onStyleChange, onOpenImageGenSettings }) {- return (- <div className="px-3 py-3 space-y-4">- <section className="space-y-1.5">- <div className="text-[12px] font-semibold text-gray-200">Adapt LLM</div>- <StagePromptModelPicker- stageName={SCRIPT_STAGE}- label="Adapt LLM"- icon={<Cpu size={10} />}- hint="Used when you click Run Adapt to break prose into scenes."- />- </section>- <section className="space-y-1.5 pt-3 border-t border-port-border">- <div className="text-[12px] font-semibold text-gray-200">World style</div>- <WorldStyleRow value={imageStyle} presets={stylePresets} onChange={onStyleChange} />- </section>- <section className="space-y-1.5 pt-3 border-t border-port-border">- <div className="flex items-center justify-between gap-2">- <div className="text-[12px] font-semibold text-gray-200">Image generation</div>- <button- type="button"- onClick={onOpenImageGenSettings}- className="flex items-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white"- title="Configure image gen backends — enable Codex $imagegen, set local Python, etc."- >- <SettingsIcon size={10} /> Backends- </button>- </div>- {availableBackends.length === 0 && (- <div className="text-[10px] text-port-warning bg-port-warning/10 border border-port-warning/40 rounded px-2 py-1.5">- No image gen backend configured. Click <span className="font-medium">Backends</span> to enable Local mflux, Codex <code className="text-gray-400">$imagegen</code>, or an External SD-API endpoint.- </div>- )}- <ImageGenSettingsRow cfg={imageCfg} models={models} availableBackends={availableBackends} onChange={onCfgChange} />- </section>- </div>- );-}--// 3-step setup that replaces the old single "Run Adapt" CTA. Recommended-// order is characters → settings → script so Adapt's prompt has the bibles-// to cite (otherwise the LLM re-improvises descriptions every scene). The-// user can skip any step (clicking later steps directly is allowed) or just-// click "Run all in order" to fire the sequential pipeline.-function StoryboardSetup({- charactersCount,- placesCount,- onRunCharacters,- onRunPlaces,- onRunAdapt,- onRunFullPipeline,- runningKind,-}) {- const isRunning = !!runningKind;- const charDone = charactersCount > 0;- const setDone = placesCount > 0;-- const Step = ({ n, kind, done, label, sublabel, hint, onClick, primary = false }) => {- const running = runningKind === kind;- const Icon = done ? Check : kind === 'characters' ? Users : kind === 'places' ? MapPinIcon : Clapperboard;- return (- <div className={`flex items-start gap-2.5 p-2.5 border rounded ${- done ? 'border-port-success/40 bg-port-success/5' :- running ? 'border-port-accent/60 bg-port-accent/5' :- 'border-port-border bg-port-card/30'- }`}>- <div className={`shrink-0 w-5 h-5 rounded-full border flex items-center justify-center text-[10px] font-semibold ${- done ? 'border-port-success text-port-success' :- running ? 'border-port-accent text-port-accent' :- 'border-port-border text-gray-500'- }`}>- {done ? <Check size={10} /> : running ? <Loader2 size={10} className="animate-spin" /> : n}- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-1.5">- <Icon size={12} className={done ? 'text-port-success' : running ? 'text-port-accent' : 'text-gray-500'} />- <span className="text-[11px] font-medium text-gray-200">{label}</span>- {done && <span className="text-[10px] text-port-success">{sublabel}</span>}- </div>- {!done && (- <div className="text-[10px] text-gray-500 mt-0.5">{hint}</div>- )}- <button- type="button"- onClick={onClick}- disabled={isRunning || !onClick}- className={`mt-1.5 inline-flex items-center gap-1 px-2 py-1 text-[10px] rounded disabled:opacity-50 ${- primary- ? 'bg-port-accent text-white hover:bg-port-accent/80'- : 'border border-port-border text-gray-300 hover:bg-port-border/40'- }`}- >- {running ? <Loader2 size={10} className="animate-spin" /> : null}- {done ? 'Re-run' : running ? 'Running…' : `Run ${kind === 'script' ? 'Adapt' : kind}`}- </button>- </div>- </div>- );- };-- return (- <div className="px-1 py-1 space-y-3">- <div className="text-center space-y-1">- <Clapperboard size={24} className="mx-auto text-gray-600" />- <div className="text-[12px] text-gray-300 font-medium">No storyboard yet</div>- <div className="text-[11px] text-gray-500 max-w-[36ch] mx-auto">- For best results, scan your prose for characters and settings first — Adapt will reference both bibles when generating scene descriptions, keeping people and places visually consistent.- </div>- </div>-- <div className="space-y-1.5">- <Step- n={1}- kind="characters"- done={charDone}- label="Extract characters"- sublabel={`${charactersCount} found`}- hint="Names, image-gen-ready physical descriptions, personality, role"- onClick={onRunCharacters}- />- <Step- n={2}- kind="places"- done={setDone}- label="Extract places / world"- sublabel={`${placesCount} location${placesCount === 1 ? '' : 's'}`}- hint="Locations keyed by slugline (description, palette, era, recurring details)"- onClick={onRunPlaces}- />- <Step- n={3}- kind="script"- done={false}- label="Run Adapt"- sublabel=""- hint="Break prose into scene-by-scene storyboard. Cites the bibles above for consistency."- onClick={onRunAdapt}- primary- />- </div>-- <button- type="button"- onClick={onRunFullPipeline}- disabled={isRunning || !onRunFullPipeline}- className="w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-port-accent text-white text-[11px] rounded hover:bg-port-accent/80 disabled:opacity-50"- title="Runs all three steps sequentially: characters → settings → Adapt. Skip if you want to run them individually."- >- {isRunning ? <Loader2 size={12} className="animate-spin" /> : <ArrowRight size={12} />}- {isRunning ? `Running ${runningKind}…` : 'Run all in order →'}- </button>-- {(charDone || setDone) && (- <div className="text-[10px] text-gray-500 text-center">- Tip: edit either bible in its tab above before running Adapt.- </div>- )}- </div>- );-}--function FailedAdaptBanner({ failure, onRunAdapt, runningAdapt, onOpenConfig, hasPriorScript }) {- const error = failure?.error || 'Adapt failed for an unknown reason';- const isTimeout = /timed out/i.test(error);- return (- <div className="p-3 mb-2 border border-port-error/40 bg-port-error/5 rounded text-[11px] space-y-2">- <div className="flex items-start gap-2">- <AlertTriangle size={14} className="text-port-error mt-0.5 shrink-0" />- <div className="flex-1 min-w-0">- <div className="text-port-error font-medium">Adapt failed</div>- <div className="text-gray-300 break-words">{error}</div>- {isTimeout && (- <div className="text-gray-500 mt-1">- Long drafts are heavy for small/light models — try a faster model- (e.g. an API provider) in the Config tab.- </div>- )}- {!hasPriorScript && (- <div className="text-gray-500 mt-1">- No prior storyboard to fall back to — re-running will create the first one.- </div>- )}- </div>- </div>- <div className="flex gap-2 justify-end">- <button- onClick={onOpenConfig}- className="flex items-center gap-1 px-2 py-1 border border-port-border text-gray-300 rounded text-[10px] hover:bg-port-border/40"- >- <SlidersHorizontal size={10} /> Adjust LLM- </button>- <button- onClick={onRunAdapt}- disabled={runningAdapt || !onRunAdapt}- className="flex items-center gap-1 px-2 py-1 bg-port-error/20 border border-port-error/40 text-port-error rounded text-[10px] hover:bg-port-error/30 disabled:opacity-50"- >- {runningAdapt ? <Loader2 size={10} className="animate-spin" /> : <RefreshCcw size={10} />}- Re-run Adapt- </button>- </div>- </div>- );-}--// Surfaced when the storyboard exists but one or both bibles are empty —-// Adapt's visualPrompts won't be referencing canonical descriptions, so-// the user gets visual drift across scenes. Inline run buttons let them-// fix it without leaving the panel; re-running Adapt afterwards picks up-// the populated bibles.-function BiblesMissingNotice({ charactersMissing, placesMissing, onRunCharacters, onRunPlaces, runningKind }) {- const isRunning = !!runningKind;- const missing = [- charactersMissing && 'character bible',- placesMissing && 'places bible',- ].filter(Boolean);- return (- <div className="flex items-start gap-2 p-2 mb-1 border border-port-warning/40 bg-port-warning/5 rounded text-[11px]">- <AlertTriangle size={12} className="text-port-warning mt-0.5 shrink-0" />- <div className="flex-1 min-w-0">- <div className="text-port-warning">- Storyboard built without {missing.join(' or ')}- </div>- <div className="text-gray-500">- Scene visualPrompts re-improvise descriptions every render — populating the bibles and re-running Adapt locks them in.- </div>- <div className="flex gap-1.5 mt-1.5">- {charactersMissing && (- <button- onClick={onRunCharacters}- disabled={isRunning || !onRunCharacters}- className="flex items-center gap-1 px-2 py-1 border border-port-border text-gray-300 rounded text-[10px] hover:bg-port-border/40 disabled:opacity-50"- >- {runningKind === 'characters' ? <Loader2 size={10} className="animate-spin" /> : <Users size={10} />}- Extract characters- </button>- )}- {placesMissing && (- <button- onClick={onRunPlaces}- disabled={isRunning || !onRunPlaces}- className="flex items-center gap-1 px-2 py-1 border border-port-border text-gray-300 rounded text-[10px] hover:bg-port-border/40 disabled:opacity-50"- >- {runningKind === 'places' ? <Loader2 size={10} className="animate-spin" /> : <MapPinIcon size={10} />}- Extract places- </button>- )}- </div>- </div>- </div>- );-}--function StaleBanner({ onRunAdapt, runningAdapt }) {- return (- <div className="flex items-start gap-2 p-2 mb-1 border border-port-warning/40 bg-port-warning/5 rounded text-[11px]">- <AlertTriangle size={12} className="text-port-warning mt-0.5 shrink-0" />- <div className="flex-1">- <div className="text-port-warning">Storyboard is older than your current draft.</div>- <div className="text-gray-500">Re-run Adapt to refresh scenes against the latest prose.</div>- </div>- <button- onClick={onRunAdapt}- disabled={runningAdapt || !onRunAdapt}- className="flex items-center gap-1 px-2 py-1 bg-port-warning/20 border border-port-warning/40 text-port-warning rounded text-[10px] hover:bg-port-warning/30 disabled:opacity-50"- >- {runningAdapt ? <Loader2 size={10} className="animate-spin" /> : <RefreshCcw size={10} />}- Re-run- </button>- </div>- );-}--function styleChip(style, presets) {- if (!style || style.presetId === STYLE_ID.NONE) return null;- if (style.presetId === STYLE_ID.CUSTOM) return 'Custom style';- const p = presets.find((x) => x.id === style.presetId);- return p?.label || style.presetId;-}--// World style picker — dropdown of curated presets + Custom + None.-// Selecting a preset fills the prompt textarea; the user can edit it freely-// from there, which flips the presetId to 'custom' the moment text diverges.-// Saves are debounced into a single PATCH on blur (not per-keystroke) — the-// onChange contract is "give me the next imageStyle" not "save it now."-function WorldStyleRow({ value, presets, onChange }) {- const [draftPrompt, setDraftPrompt] = useState(value.prompt || '');- const [draftNeg, setDraftNeg] = useState(value.negativePrompt || '');-- // Pull the saved value down when the work id swaps (or anything else that- // replaces the value object identity from the parent).- useEffect(() => {- setDraftPrompt(value.prompt || '');- setDraftNeg(value.negativePrompt || '');- }, [value.presetId, value.prompt, value.negativePrompt]);-- const pickPreset = (presetId) => {- if (presetId === STYLE_ID.NONE) {- onChange?.(EMPTY_IMAGE_STYLE);- return;- }- if (presetId === STYLE_ID.CUSTOM) {- // Keep whatever's in the textarea — just flip the discriminator.- onChange?.({ presetId: STYLE_ID.CUSTOM, prompt: draftPrompt, negativePrompt: draftNeg });- return;- }- const preset = presets.find((p) => p.id === presetId);- if (!preset) return;- onChange?.({ presetId: preset.id, prompt: preset.prompt, negativePrompt: preset.negativePrompt });- };-- const commitDraft = () => {- if (draftPrompt === value.prompt && draftNeg === value.negativePrompt) return;- // If the user edited a preset's text, flip to 'custom' so the dropdown- // reflects that the prompt no longer matches the curated preset.- const matchingPreset = presets.find((p) => p.id === value.presetId);- const stillMatchesPreset = matchingPreset- && matchingPreset.prompt === draftPrompt- && matchingPreset.negativePrompt === draftNeg;- onChange?.({- presetId: stillMatchesPreset ? value.presetId : STYLE_ID.CUSTOM,- prompt: draftPrompt,- negativePrompt: draftNeg,- });- };-- return (- <div className="space-y-1.5">- <div className="flex items-center justify-between">- <span className="text-[9px] uppercase tracking-wider text-gray-500 flex items-center gap-1">- <Palette size={10} /> World style- </span>- {value.presetId !== STYLE_ID.NONE && (- <button- type="button"- onClick={() => pickPreset(STYLE_ID.NONE)}- className="text-[9px] text-gray-500 hover:text-port-error"- title="Clear style"- >- Clear- </button>- )}- </div>- <select- value={value.presetId}- onChange={(e) => pickPreset(e.target.value)}- className="w-full bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200"- >- <option value={STYLE_ID.NONE}>None — use scene visualPrompt only</option>- {groupPresetsByCategory(presets).map(([cat, items]) => (- <optgroup key={cat} label={cat}>- {items.map((p) => (- <option key={p.id} value={p.id}>{p.label}</option>- ))}- </optgroup>- ))}- <option value={STYLE_ID.CUSTOM}>Custom</option>- </select>- {value.presetId !== STYLE_ID.NONE && (- <>- <label className="block">- <span className="text-[9px] uppercase tracking-wider text-gray-500">- Style prompt {value.presetId === STYLE_ID.CUSTOM && <Check size={9} className="inline text-port-accent" />}- </span>- <textarea- value={draftPrompt}- onChange={(e) => setDraftPrompt(e.target.value)}- onBlur={commitDraft}- rows={3}- placeholder="cinematic still, anamorphic lens…"- className="w-full mt-0.5 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 font-sans resize-y"- />- </label>- <label className="block">- <span className="text-[9px] uppercase tracking-wider text-gray-500">Negative prompt (optional)</span>- <textarea- value={draftNeg}- onChange={(e) => setDraftNeg(e.target.value)}- onBlur={commitDraft}- rows={2}- placeholder="cartoon, low quality…"- className="w-full mt-0.5 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 font-sans resize-y"- />- </label>- <div className="text-[10px] text-gray-500">- Style is prepended to every scene's image prompt. Re-render scenes to see the change.- </div>- </>- )}- </div>- );-}--const RES_PRESETS = [- { label: '768×512 (3:2)', width: 768, height: 512 },- { label: '512×512 (1:1)', width: 512, height: 512 },- { label: '512×768 (2:3)', width: 512, height: 768 },- { label: '1024×576 (16:9)', width: 1024, height: 576 },- { label: '1024×1024 (1:1)', width: 1024, height: 1024 },-];--// Per-mode form layout — Codex picks model/steps/seed internally, External-// SD-API loads its model server-side. Showing fields the active backend-// can't act on misleads the user about what's actually controlling renders.-const MODE_HINT = {- [IMAGE_GEN_MODE.LOCAL]: 'Renders locally via mflux/diffusers on this machine.',- [IMAGE_GEN_MODE.CODEX]: "Codex's $imagegen skill renders via your logged-in Codex session. Model, steps, and seed are picked by Codex itself.",- [IMAGE_GEN_MODE.EXTERNAL]: 'External SD-API renders against your configured A1111/Forge endpoint. The active model is set by the SD-API server.',-};--function ImageGenSettingsRow({ cfg, models, availableBackends = [], onChange }) {- const presetMatch = RES_PRESETS.find((p) => p.width === cfg.width && p.height === cfg.height);- const currentModel = models.find((m) => m.id === cfg.modelId);- const inputCls = 'w-full mt-0.5 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 focus:border-port-accent outline-none';- const labelCls = 'text-[9px] uppercase tracking-wider text-gray-500';- const isLocalMode = cfg.mode === IMAGE_GEN_MODE.LOCAL;- const isCodexMode = cfg.mode === IMAGE_GEN_MODE.CODEX;- return (- <div className="space-y-1.5">- {availableBackends.length > 0 && (- <div>- <span className={labelCls}>Backend</span>- <div className="mt-0.5">- <BackendChipStrip- availableBackends={availableBackends}- value={cfg.mode}- onChange={(id) => onChange({ ...cfg, mode: id })}- size="sm"- ariaLabel="Image gen backend"- titlePrefix="Render storyboard scenes via"- />- </div>- <p className="text-[9px] text-gray-500 mt-1">{MODE_HINT[cfg.mode]}</p>- </div>- )}- <div className="grid grid-cols-2 gap-1.5">- {isLocalMode && (- <label className="block">- <span className={labelCls}>Image model</span>- <select- value={cfg.modelId}- onChange={(e) => onChange({ ...cfg, modelId: e.target.value })}- className={inputCls}- >- {models.length === 0 && <option value={cfg.modelId}>{cfg.modelId}</option>}- {models.map((m) => (- <option key={m.id} value={m.id}>{m.name || m.id}</option>- ))}- </select>- </label>- )}- <label className="block">- <span className={labelCls}>Resolution</span>- <select- value={presetMatch ? `${cfg.width}x${cfg.height}` : 'custom'}- onChange={(e) => {- if (e.target.value === 'custom') return;- const [w, h] = e.target.value.split('x').map(Number);- onChange({ ...cfg, width: w, height: h });- }}- className={inputCls}- >- {RES_PRESETS.map((p) => (- <option key={p.label} value={`${p.width}x${p.height}`}>{p.label}</option>- ))}- {!presetMatch && <option value="custom">Custom ({cfg.width}×{cfg.height})</option>}- </select>- </label>- </div>- {!isCodexMode && (- <div className="grid grid-cols-2 gap-1.5">- <label className="block">- <span className={labelCls}>- Steps {isLocalMode && currentModel?.steps && <span className="normal-case text-gray-600">(default {currentModel.steps})</span>}- </span>- <input- type="number" min={1} max={150}- value={cfg.steps}- onChange={(e) => onChange({ ...cfg, steps: e.target.value })}- placeholder={isLocalMode ? String(currentModel?.steps || 'auto') : 'server default'}- className={inputCls}- />- </label>- <label className="block">- <span className={labelCls}>Seed</span>- <div className="flex items-stretch gap-1 mt-0.5">- <input- type="number"- value={cfg.seed}- onChange={(e) => onChange({ ...cfg, seed: e.target.value })}- placeholder="random"- className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-[11px] text-gray-200 focus:border-port-accent outline-none"- />- <button- type="button"- onClick={() => onChange({ ...cfg, seed: randomSeed() })}- className="px-1.5 text-gray-500 hover:text-port-accent border border-port-border rounded"- title="Randomize seed"- aria-label="Randomize seed"- >- <Dice5 size={11} />- </button>- </div>- </label>- </div>- )}- </div>- );-}diff --git a/client/src/components/writers-room/StoryboardScenesTab.jsx b/client/src/components/writers-room/StoryboardScenesTab.jsxnew file mode 100644index 0000000000..6d8fccbd40--- /dev/null+++ b/client/src/components/writers-room/StoryboardScenesTab.jsx@@ -0,0 +1,35 @@+// ─── Scenes (outline from prose headings) ─────────────────────────────────+export default function StoryboardScenesTab({ activeDraft, onJumpToScene }) {+ const segs = activeDraft?.segmentIndex || [];+ if (segs.length === 0) {+ return (+ <div className="px-3 py-3 text-[11px] text-gray-500 italic">+ No segments yet. Use <code className="text-gray-300"># Chapter</code> /{' '}+ <code className="text-gray-300">## Scene</code> /{' '}+ <code className="text-gray-300">### Beat</code> headings in your prose to populate the outline.+ </div>+ );+ }+ return (+ <ul className="px-3 py-3 space-y-1 text-[11px]">+ {segs.map((seg) => {+ const indent = seg.kind === 'beat' ? 'pl-4' : seg.kind === 'scene' ? 'pl-2' : '';+ const tone = seg.kind === 'chapter' ? 'text-white font-semibold' : seg.kind === 'scene' ? 'text-gray-200' : 'text-gray-500';+ return (+ <li key={seg.id} className="flex items-center gap-2">+ <button+ type="button"+ onClick={onJumpToScene ? () => onJumpToScene({ heading: seg.heading }) : undefined}+ disabled={!onJumpToScene}+ className={`flex-1 truncate text-left hover:text-port-accent disabled:hover:text-inherit ${indent} ${tone}`}+ title={onJumpToScene ? 'Jump to this segment in the prose' : seg.heading}+ >+ {seg.heading}+ </button>+ <span className="text-[9px] text-gray-600 shrink-0">{seg.wordCount}w</span>+ </li>+ );+ })}+ </ul>+ );+}