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(writers-room): 3-step storyboard setup CTA + bibles-missing notice
Adam Eivy6c864d7bafdf
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 1d20b2329f..23137ba86d 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Added+- **Writers Room — 3-step storyboard setup (Characters → Settings → Adapt) replaces the lone "Run Adapt" CTA.** A fresh story used to greet the user with a single "Run Adapt" button, but Adapt's quality depends on the character + setting bibles being populated first (otherwise the LLM re-improvises descriptions every scene, breaking visual continuity). The empty-state CTA now shows a guided 3-step panel: each step has a status pill (numbered → spinner → green check), its own `Run characters` / `Run settings` / `Run Adapt` button, and a prominent `Run all in order →` master action that fires the sequential pipeline (`runFullPipeline`) so the user can one-click the whole flow. Once Adapt has run, a separate `BiblesMissingNotice` banner shows above the scenes if either bible is empty, with inline "Extract characters" / "Extract settings" buttons — so users who ran Adapt before populating bibles get a clear path to fix the visual drift without leaving the panel. `runAnalysis` now returns success/failure so the pipeline can bail on first error rather than silently chaining through a broken state. Touched: `client/src/components/writers-room/{StoryboardPanel,WorkEditor}.jsx`.+- **Writers Room — setting / world bible (`Refresh settings`) + bibles fed back into Adapt for cross-scene continuity.** New analysis kind `settings` extracts a per-location bible from prose: each entry keyed by screenplay slugline (`INT. CURRY OCITY — NIGHT`) with `description`, `palette`, `era`, `weather`, `recurringDetails`, plus prose evidence + missing-fields hints. Same merge semantics as the character bible — re-runs preserve user edits, only fill blanks, and add new locations. New stage `writers-room-settings` (md prompt + stage-config seed); new service `server/services/writersRoom/settings.js`; new routes `GET/POST /api/writers-room/works/:id/settings`, `PATCH/DELETE /api/writers-room/works/:id/settings/:settingId`; new `SettingsBible.jsx` drawer in WorkEditor with create/edit/delete; new `Refresh settings` menu item. Sluglines normalize identically on client + server (uppercase, em-dash → space, punctuation stripped) so `INT. KITCHEN — NIGHT` and `INT KITCHEN - NIGHT` resolve to the same entry. The script (Adapt) prompt now also receives both bibles as variables (`existingCharactersJson`, `existingSettingsJson`) and is instructed to (a) cite canonical character `physicalDescription` rather than re-improvising and (b) reuse the bible's slugline string verbatim so the storyboard pipeline auto-matches. SceneCard's image-prompt composition now layers the matched setting between world-style and characters: `{worldStyle} . {workTitle} . {setting.description} {setting.palette} {setting.recurring} . Featuring — {chars} . {scene.visualPrompt}` (priority order: visualPrompt always survives, then setting baseline, then characters drop one-by-one to fit the 1900-char budget). End-to-end verified — gemini-2.5-pro extracted 5 locations from a 4,800-word draft in 66s, merged with the user-edited entry, and now feeds image gen for visual continuity across scenes set in the same place. New files: `server/services/writersRoom/settings.js`, `client/src/components/writers-room/SettingsBible.jsx`, `data{,sample}/prompts/stages/writers-room-settings.md`. Touched: `server/lib/{validation,writersRoomPresets}.js`, `server/services/writersRoom/evaluator.js`, `server/routes/writersRoom.js`, `data{,sample}/prompts/{stages/writers-room-script.md,stage-config.json}`, `client/src/{services/apiWritersRoom.js,components/writers-room/{WorkEditor,StoryboardPanel,SceneCard,sceneCardHelpers}.jsx}`.- **Writers Room — Codex / Claude Code CLI support for AI passes, and tail-truncated CLI errors so failures are actually readable.** `callCliProvider` previously branched on `gemini-cli` and treated everything else as "spawn the binary, pipe prompt to stdin" — which Codex and Claude Code reject because they need a subcommand to run non-interactively. Picking Codex as the Adapt LLM exited code 1 with `Error: stdin is not a terminal` because `codex` defaulted to its REPL; Claude Code would have the same gap. Replaced the binary `isGeminiCli` switch with a `buildCliInvocation(provider, model)` dispatcher mirroring `runner.js` / `agentCliSpawning.js`: `codex` → `exec [--model <m>] -`, `claude-code` / `claude-code-bedrock` → `-p - [--model <m>]`, `gemini-cli` → unchanged (`--prompt` arg + `stdio[0] = 'ignore'`), default → spawn binary and pipe prompt to stdin. Also flipped CLI error truncation from `slice(0, 500)` → `slice(-2000)` since the actual failure (e.g. `"The 'gpt-5' model is not supported when using Codex with a ChatGPT account"`) lives at the end of stderr — the head-truncation was clipping the banner and hiding the real cause. Touched: `server/services/writersRoom/evaluator.js`.diff --git a/client/src/components/writers-room/StoryboardPanel.jsx b/client/src/components/writers-room/StoryboardPanel.jsxindex 4055eec554..28d3b533bc 100644--- a/client/src/components/writers-room/StoryboardPanel.jsx+++ b/client/src/components/writers-room/StoryboardPanel.jsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react';-import { Clapperboard, Loader2, RefreshCcw, Settings as SettingsIcon, AlertTriangle, Palette, Check, Dice5, Cpu } from 'lucide-react';+import { Clapperboard, Loader2, RefreshCcw, Settings as SettingsIcon, AlertTriangle, Palette, Check, Dice5, Cpu, Users, MapPin as MapPinIcon, ArrowRight } from 'lucide-react';import { randomSeed } from '../../lib/genUtils';import toast from '../ui/Toast';import {@@ -31,7 +31,11 @@ export default function StoryboardPanel({onJumpToScene,onDebug,onRunAdapt,+ onRunCharacters,+ onRunSettings,+ onRunFullPipeline,runningAdapt = false,+ runningKind = null,readingTheme = 'dark',activeSceneId = null,onStyleChange,@@ -213,13 +217,31 @@ export default function StoryboardPanel({)}{!loading && !latestScript && !latestFailure && (- <EmptyAdaptCTA onRunAdapt={onRunAdapt} runningAdapt={runningAdapt} />+ <StoryboardSetup+ charactersCount={characters.length}+ settingsCount={settings.length}+ onRunCharacters={onRunCharacters}+ onRunSettings={onRunSettings}+ onRunAdapt={onRunAdapt}+ onRunFullPipeline={onRunFullPipeline}+ runningKind={runningKind}+ />)}{!loading && latestScript && isStale && !latestFailure && (<StaleBanner onRunAdapt={onRunAdapt} runningAdapt={runningAdapt} />)}+ {!loading && latestScript && !isStale && !latestFailure && (characters.length === 0 || settings.length === 0) && (+ <BiblesMissingNotice+ charactersMissing={characters.length === 0}+ settingsMissing={settings.length === 0}+ onRunCharacters={onRunCharacters}+ onRunSettings={onRunSettings}+ 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.@@ -256,22 +278,124 @@ export default function StoryboardPanel({);}-function EmptyAdaptCTA({ onRunAdapt, runningAdapt }) {+// 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,+ settingsCount,+ onRunCharacters,+ onRunSettings,+ onRunAdapt,+ onRunFullPipeline,+ runningKind,+}) {+ const isRunning = !!runningKind;+ const charDone = charactersCount > 0;+ const setDone = settingsCount > 0;++ const Step = ({ n, kind, done, label, sublabel, hint, onClick, primary = false }) => {+ const running = runningKind === kind;+ const Icon = done ? Check : kind === 'characters' ? Users : kind === 'settings' ? 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="text-center px-3 py-8 space-y-3">- <Clapperboard size={28} 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-[28ch] mx-auto">- Run Adapt to break your prose into scenes and start visualizing how the AI is reading your story.+ <div className="px-3 py-4 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="settings"+ done={setDone}+ label="Extract settings / world"+ sublabel={`${settingsCount} location${settingsCount === 1 ? '' : 's'}`}+ hint="Locations keyed by slugline (description, palette, era, recurring details)"+ onClick={onRunSettings}+ />+ <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- onClick={onRunAdapt}- disabled={runningAdapt || !onRunAdapt}- className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-port-accent text-white text-[11px] rounded hover:bg-port-accent/80 disabled:opacity-50"+ 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.">- {runningAdapt ? <Loader2 size={12} className="animate-spin" /> : <Clapperboard size={12} />}- {runningAdapt ? 'Running Adapt…' : 'Run Adapt'}+ {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 the Work overflow menu before running Adapt.+ </div>+ )}</div>);}@@ -319,6 +443,54 @@ function FailedAdaptBanner({ failure, onRunAdapt, runningAdapt, onOpenSettings,);}+// 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, settingsMissing, onRunCharacters, onRunSettings, runningKind }) {+ const isRunning = !!runningKind;+ const missing = [+ charactersMissing && 'character bible',+ settingsMissing && 'setting 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>+ )}+ {settingsMissing && (+ <button+ onClick={onRunSettings}+ disabled={isRunning || !onRunSettings}+ 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 === 'settings' ? <Loader2 size={10} className="animate-spin" /> : <MapPinIcon size={10} />}+ Extract settings+ </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]">diff --git a/client/src/components/writers-room/WorkEditor.jsx b/client/src/components/writers-room/WorkEditor.jsxindex b94c8df75e..a0553bd117 100644--- a/client/src/components/writers-room/WorkEditor.jsx+++ b/client/src/components/writers-room/WorkEditor.jsx@@ -228,7 +228,7 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseO// back out by simply not saving. Characters refreshes the bible cache so// the storyboard's prompt enrichment picks up new profiles immediately.const runAnalysis = useCallback(async (kind) => {- if (runningKind) return;+ if (runningKind) return false;setRunningKind(kind);const snapshot = await runWritersRoomAnalysis(work.id, { kind }).catch((err) => {if (mountedRef.current) toast.error(`${ANALYSIS_LABELS[kind] || kind} failed: ${err.message}`);@@ -236,13 +236,13 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseO});if (!mountedRef.current) {setRunningKind(null);- return;+ return false;}setRunningKind(null);- if (!snapshot) return;+ if (!snapshot) return false;if (snapshot.status === 'failed') {toast.error(`${ANALYSIS_LABELS[kind] || kind} failed: ${snapshot.error || 'unknown'}`);- return;+ return false;}toast.success(`${ANALYSIS_LABELS[kind] || kind} complete`);if (kind === 'characters' && Array.isArray(snapshot.result?.mergedProfiles)) {@@ -255,8 +255,21 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseOsetBody(snapshot.result.formattedBody);toast('Format applied to draft buffer — save to persist', { icon: '💾' });}+ return true;}, [runningKind, work.id]);+ // Sequential pipeline for the 3-step storyboard setup. Run characters →+ // settings → script in order so each later step has the earlier bible to+ // reference. Bails on first failure (the failed step's toast already fired).+ const runFullPipeline = useCallback(async () => {+ if (runningKind) return;+ const okChars = await runAnalysis('characters');+ if (!okChars || !mountedRef.current) return;+ const okSettings = await runAnalysis('settings');+ if (!okSettings || !mountedRef.current) return;+ await runAnalysis('script');+ }, [runAnalysis, runningKind]);+const applyFormatText = (text) => {setBody(text);toast('Applied to editor — save to persist', { icon: '💾' });@@ -509,7 +522,11 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseOonJumpToScene={jumpToScene}onDebug={handleDebug}onRunAdapt={() => runAnalysis(ANALYSIS_KIND.SCRIPT)}+ onRunCharacters={() => runAnalysis(ANALYSIS_KIND.CHARACTERS)}+ onRunSettings={() => runAnalysis(ANALYSIS_KIND.SETTINGS)}+ onRunFullPipeline={runFullPipeline}runningAdapt={runningKind === ANALYSIS_KIND.SCRIPT}+ runningKind={runningKind}readingTheme={readingTheme}activeSceneId={activeSceneId}onStyleChange={commitImageStyle}