Skip to content

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

feat(writers-room): auto-queue every missing scene image when Adapt completes

Adam Eivyf59265cddeaf
diff --git a/client/src/components/writers-room/SceneCard.jsx b/client/src/components/writers-room/SceneCard.jsx
index 84ca34be25..29957067e7 100644
--- a/client/src/components/writers-room/SceneCard.jsx
+++ b/client/src/components/writers-room/SceneCard.jsx
@@ -1,4 +1,4 @@
-import { useEffect, useMemo, useRef, useState } from 'react';
+import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
import {
Image as ImageIcon,
Loader2,
@@ -22,7 +22,7 @@ import {
normCharKey,
} from './sceneCardHelpers';
-export default function SceneCard({
+const SceneCard = forwardRef(function SceneCard({
scene,
workId,
analysisId,
@@ -35,7 +35,7 @@ export default function SceneCard({
isActive = false,
onJumpToProse = null,
onDebug = null,
-}) {
+}, ref) {
const light = readingTheme === 'light';
const matchedCharacters = useMemo(
() => matchSceneCharacters(scene.characters, charByKey),
@@ -168,6 +168,16 @@ export default function SceneCard({
}
};
+ // Expose generate() to the parent so the storyboard can batch-trigger
+ // renders (e.g. auto-queue every missing image after Adapt completes).
+ // canGenerate() returns false for cards that already have an image, are
+ // mid-render, or lack a visualPrompt — the parent uses this to skip
+ // ineligible scenes silently.
+ useImperativeHandle(ref, () => ({
+ generate,
+ canGenerate: () => genStatus === 'idle' && !!scene.visualPrompt?.trim(),
+ }), [genStatus, scene.visualPrompt]);
+
const progressPct = progress?.progress != null ? Math.round(progress.progress * 100) : null;
const view = progress?.currentImage ? 'live'
: genStatus === 'done' && generated?.path ? 'final'
@@ -320,7 +330,9 @@ export default function SceneCard({
)}
</div>
);
-}
+});
+
+export default SceneCard;
function DebugMenuItem({ icon: Icon, label, onClick }) {
return (
diff --git a/client/src/components/writers-room/StoryboardPanel.jsx b/client/src/components/writers-room/StoryboardPanel.jsx
index 3d6b17dcd1..1129485a5c 100644
--- a/client/src/components/writers-room/StoryboardPanel.jsx
+++ b/client/src/components/writers-room/StoryboardPanel.jsx
@@ -79,14 +79,44 @@ export default function StoryboardPanel({
}, [loadLatestScript]);
// Refetch when Adapt completes — parent toggles runningAdapt true→false.
+ // Also flag this as a freshly-finished Adapt so the next latestScript
+ // load triggers an auto-queue of every missing image render.
const prevRunning = useRef(runningAdapt);
+ const justFinishedAdaptRef = useRef(false);
useEffect(() => {
if (prevRunning.current && !runningAdapt) {
+ justFinishedAdaptRef.current = true;
loadLatestScript();
}
prevRunning.current = runningAdapt;
}, [runningAdapt, loadLatestScript]);
+ // Refs to each SceneCard's imperative API so we can call .generate() on
+ // every card without each card needing to know whether it's auto-queued.
+ // Map keyed by sceneId — replaced wholesale on each script load.
+ const sceneRefs = useRef({});
+
+ // Auto-queue every missing image when latestScript updates *because* of a
+ // just-finished Adapt run. requestAnimationFrame defers until the cards
+ // have actually mounted with the new scenes — useImperativeHandle has to
+ // commit before .canGenerate()/.generate() exist on the refs.
+ useEffect(() => {
+ if (!latestScript || !justFinishedAdaptRef.current) return;
+ justFinishedAdaptRef.current = false;
+ const handle = requestAnimationFrame(() => {
+ let queued = 0;
+ for (const sceneId in sceneRefs.current) {
+ const handle = sceneRefs.current[sceneId];
+ if (handle?.canGenerate?.()) {
+ handle.generate();
+ queued += 1;
+ }
+ }
+ if (queued > 0) toast.success(`Queued ${queued} scene render${queued === 1 ? '' : 's'}`);
+ });
+ return () => cancelAnimationFrame(handle);
+ }, [latestScript]);
+
const persistCfg = useCallback(async (next) => {
setImageCfg(next);
const current = await getSettings().catch(() => ({}));
@@ -169,6 +199,10 @@ export default function StoryboardPanel({
return (
<SceneCard
key={sceneId}
+ ref={(handle) => {
+ if (handle) sceneRefs.current[sceneId] = handle;
+ else delete sceneRefs.current[sceneId];
+ }}
scene={{ ...scene, id: sceneId }}
workId={work.id}
analysisId={latestScript.id}