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: add FableLoom story rendering preferences

[._.]/ Adam Eivyc4fe1a904248
diff --git a/client/src/components/fableloom/LoomProductionPanel.jsx b/client/src/components/fableloom/LoomProductionPanel.jsx
index 41fb4784f1..9b3420679f 100644
--- a/client/src/components/fableloom/LoomProductionPanel.jsx
+++ b/client/src/components/fableloom/LoomProductionPanel.jsx
@@ -35,6 +35,7 @@ import {
} from '../../services/api';
import { fableLoomStoryReadiness } from '../../lib/fableLoomReadiness';
import {
+ asFableLoomRenderPreferences,
asFableLoomRenderSettings,
FABLELOOM_RENDER_FORMATS,
} from '../../../../server/lib/fableLoomProduction.js';
@@ -53,9 +54,15 @@ const VIDEO_BACKENDS = [
{ id: 'grok', label: 'Grok', icon: Cloud },
];
-const modelOptions = (models) => (Array.isArray(models) ? models : [])
- .filter((model) => model?.id)
- .map((model) => ({ id: model.id, label: model.name || model.id }));
+const modelOptions = (models, selected) => {
+ const options = (Array.isArray(models) ? models : [])
+ .filter((model) => model?.id)
+ .map((model) => ({ id: model.id, label: model.name || model.id }));
+ if (selected && !options.some((option) => option.id === selected)) {
+ return [{ id: selected, label: `${selected} (unavailable)` }, ...options];
+ }
+ return options;
+};
const productionAssetsForScope = (plan, scope) => {
if (!Array.isArray(plan?.plannedAssets)) return [];
@@ -71,11 +78,12 @@ export default function LoomProductionPanel({ loom, episode, onSelectNode, onLoo
const [plan, setPlan] = useState(null);
const [planKey, setPlanKey] = useState(null);
const [activeBatchRun, setActiveBatchRun] = useState(null);
- const [imageMode, setImageMode] = useState(null);
- const [imageModel, setImageModel] = useState(null);
- const [videoMode, setVideoMode] = useState(null);
- const [videoModel, setVideoModel] = useState(null);
- const [effort, setEffort] = useState(null);
+ const savedRender = asFableLoomRenderPreferences(loom.renderSettings);
+ const [imageMode, setImageMode] = useState(savedRender.imageMode);
+ const [imageModel, setImageModel] = useState(savedRender.imageModel);
+ const [videoMode, setVideoMode] = useState(savedRender.videoMode);
+ const [videoModel, setVideoModel] = useState(savedRender.videoModel);
+ const [effort, setEffort] = useState(savedRender.effort);
const [imageModels, setImageModels] = useState([]);
const [videoModels, setVideoModels] = useState([]);
const renderFormat = asFableLoomRenderSettings(loom.renderSettings);
@@ -149,6 +157,17 @@ export default function LoomProductionPanel({ loom, episode, onSelectNode, onLoo
return () => { mounted = false; };
}, []);
+ // Story settings are durable defaults; keep the per-run controls in sync
+ // when those defaults change while this panel remains mounted. A one-off
+ // panel change does not touch the loom, so it remains an intentional override.
+ useEffect(() => {
+ setImageMode(savedRender.imageMode);
+ setImageModel(savedRender.imageModel);
+ setVideoMode(savedRender.videoMode);
+ setVideoModel(savedRender.videoModel);
+ setEffort(savedRender.effort);
+ }, [loom.id, savedRender.imageMode, savedRender.imageModel, savedRender.videoMode, savedRender.videoModel, savedRender.effort]);
+
useEffect(() => {
setPlan(null);
setPlanKey(null);
@@ -395,7 +414,11 @@ export default function LoomProductionPanel({ loom, episode, onSelectNode, onLoo
<BackendChipStrip
availableBackends={IMAGE_BACKENDS}
value={imageMode || 'auto'}
- onChange={(value) => setImageMode(value === 'auto' ? null : value)}
+ onChange={(value) => {
+ const nextMode = value === 'auto' ? null : value;
+ setImageMode(nextMode);
+ if (nextMode && nextMode !== 'local') setImageModel(null);
+ }}
size="sm"
ariaLabel="Image provider"
/>
@@ -410,7 +433,7 @@ export default function LoomProductionPanel({ loom, episode, onSelectNode, onLoo
className="text-[11px] bg-port-bg border border-port-border rounded px-1.5 py-1 text-port-text"
>
<option value="">Saved image model</option>
- {modelOptions(imageModels).map((modelOption) => (
+ {modelOptions(imageModels, imageModel).map((modelOption) => (
<option key={modelOption.id} value={modelOption.id}>{modelOption.label}</option>
))}
</select>
@@ -422,7 +445,11 @@ export default function LoomProductionPanel({ loom, episode, onSelectNode, onLoo
<BackendChipStrip
availableBackends={VIDEO_BACKENDS}
value={videoMode || 'auto'}
- onChange={(value) => setVideoMode(value === 'auto' ? null : value)}
+ onChange={(value) => {
+ const nextMode = value === 'auto' ? null : value;
+ setVideoMode(nextMode);
+ if (nextMode && nextMode !== 'local') setVideoModel(null);
+ }}
size="sm"
ariaLabel="Video provider"
/>
@@ -437,7 +464,7 @@ export default function LoomProductionPanel({ loom, episode, onSelectNode, onLoo
className="text-[11px] bg-port-bg border border-port-border rounded px-1.5 py-1 text-port-text"
>
<option value="">Saved video model</option>
- {modelOptions(videoModels).map((modelOption) => (
+ {modelOptions(videoModels, videoModel).map((modelOption) => (
<option key={modelOption.id} value={modelOption.id}>{modelOption.label}</option>
))}
</select>
diff --git a/client/src/components/fableloom/LoomSettingsDrawer.jsx b/client/src/components/fableloom/LoomSettingsDrawer.jsx
index e8e68fd0e1..a588e1909b 100644
--- a/client/src/components/fableloom/LoomSettingsDrawer.jsx
+++ b/client/src/components/fableloom/LoomSettingsDrawer.jsx
@@ -1,7 +1,7 @@
/**
* FableLoom story settings — the loom-level choices that steer every AI lane.
*
- * Three things live here:
+ * Four things live here:
* - **Audience participation.** Whether the audience acts as the protagonist
* or helps an autonomous protagonist through a named in-story channel.
* - **Scene format.** Whether scenes are written as narrated prose or as a
@@ -14,22 +14,62 @@
* text into a path during play. Unset means the play stage's own pin (or
* the install's active provider) — a tapped path never calls a provider at
* all, so this only governs typed input.
+ * - **Rendering defaults.** Which image/video backend and local model to use,
+ * plus the shared aspect ratio and Codex image effort for new scene media.
*/
import { useEffect, useRef, useState } from 'react';
-import { CheckCircle2, Loader2, Sparkles } from 'lucide-react';
+import { CheckCircle2, Cloud, Cpu, Layers, Loader2, Sparkles } from 'lucide-react';
import { Link } from 'react-router';
import Drawer from '../Drawer';
+import BackendChipStrip from '../media/BackendChipStrip';
import ProviderModelSelector from '../ProviderModelSelector';
import { FormField } from '../ui/FormField.jsx';
import toast from '../ui/Toast';
import useProviderModels from '../../hooks/useProviderModels';
import { useAsyncAction } from '../../hooks/useAsyncAction';
-import { effectiveModelFor, effortAwareModelOptions } from '../../utils/providers';
-import { reformatLoomEpisode, updateLoom } from '../../services/api';
+import { CODEX_EFFORT_LEVELS, effectiveModelFor, effortAwareModelOptions } from '../../utils/providers';
+import { listImageModels, listVideoModels, reformatLoomEpisode, updateLoom } from '../../services/api';
import { fieldClass, labelClass } from './fieldStyles';
import { LOOM_FORMATS, episodesNeedingReformat, loomFormatHint, loomFormatLabel } from './loomFormats';
import { FABLELOOM_PARTICIPATION_MODES } from '../../../../server/lib/fableLoomParticipation.js';
+import {
+ asFableLoomRenderPreferences,
+ asFableLoomRenderSettings,
+ FABLELOOM_RENDER_FORMATS,
+} from '../../../../server/lib/fableLoomProduction.js';
+
+const IMAGE_RENDER_BACKENDS = [
+ { id: 'auto', label: 'Auto', icon: Layers },
+ { id: 'local', label: 'Local', icon: Cpu },
+ { id: 'codex', label: 'Codex', icon: Cloud },
+ { id: 'grok', label: 'Grok', icon: Cloud },
+ { id: 'agy', label: 'Agy', icon: Sparkles },
+];
+
+const VIDEO_RENDER_BACKENDS = [
+ { id: 'auto', label: 'Auto', icon: Layers },
+ { id: 'local', label: 'Local', icon: Cpu },
+ { id: 'grok', label: 'Grok', icon: Cloud },
+];
+
+const modelOptions = (models, selected) => {
+ const options = (Array.isArray(models) ? models : [])
+ .filter((model) => model?.id)
+ .map((model) => ({ id: model.id, label: model.name || model.id }));
+ if (selected && !options.some((option) => option.id === selected)) {
+ return [{ id: selected, label: `${selected} (unavailable)` }, ...options];
+ }
+ return options;
+};
+
+const replaceModelList = (setModels, nextModels) => setModels((currentModels) => {
+ const unchanged = currentModels.length === nextModels.length
+ && currentModels.every((model, index) => (
+ model?.id === nextModels[index]?.id && model?.name === nextModels[index]?.name
+ ));
+ return unchanged ? currentModels : nextModels;
+});
/**
* The one line of feedback a multi-minute rewrite gives. Built as a single
@@ -57,6 +97,15 @@ export default function LoomSettingsDrawer({ open, onClose, loom, universe, onLo
const [protagonistCharacterId, setProtagonistCharacterId] = useState(loom.protagonistCharacterId || '');
const [protagonistWardrobeId, setProtagonistWardrobeId] = useState(loom.protagonistWardrobeId || '');
const [protagonistWardrobeLocked, setProtagonistWardrobeLocked] = useState(loom.protagonistWardrobeLocked === true);
+ const renderSettings = asFableLoomRenderSettings(loom.renderSettings);
+ const savedRender = asFableLoomRenderPreferences(loom.renderSettings);
+ const [imageMode, setImageMode] = useState(savedRender.imageMode);
+ const [imageModel, setImageModel] = useState(savedRender.imageModel);
+ const [videoMode, setVideoMode] = useState(savedRender.videoMode);
+ const [videoModel, setVideoModel] = useState(savedRender.videoModel);
+ const [renderEffort, setRenderEffort] = useState(savedRender.effort);
+ const [imageModels, setImageModels] = useState([]);
+ const [videoModels, setVideoModels] = useState([]);
useEffect(() => {
if (open) return;
setParticipationMode(loom.participationMode || 'protagonist');
@@ -64,7 +113,24 @@ export default function LoomSettingsDrawer({ open, onClose, loom, universe, onLo
setProtagonistCharacterId(loom.protagonistCharacterId || '');
setProtagonistWardrobeId(loom.protagonistWardrobeId || '');
setProtagonistWardrobeLocked(loom.protagonistWardrobeLocked === true);
- }, [open, loom.participationMode, loom.audienceCommunicationMedium, loom.protagonistCharacterId, loom.protagonistWardrobeId, loom.protagonistWardrobeLocked]);
+ setImageMode(savedRender.imageMode);
+ setImageModel(savedRender.imageModel);
+ setVideoMode(savedRender.videoMode);
+ setVideoModel(savedRender.videoModel);
+ setRenderEffort(savedRender.effort);
+ }, [
+ open,
+ loom.participationMode,
+ loom.audienceCommunicationMedium,
+ loom.protagonistCharacterId,
+ loom.protagonistWardrobeId,
+ loom.protagonistWardrobeLocked,
+ savedRender.imageMode,
+ savedRender.imageModel,
+ savedRender.videoMode,
+ savedRender.videoModel,
+ savedRender.effort,
+ ]);
const play = loom.playSettings || {};
const playProvider = providers.find((p) => p.id === play.providerId);
// Only scenes not already in the target format are sent, so this is what the
@@ -81,6 +147,75 @@ export default function LoomSettingsDrawer({ open, onClose, loom, universe, onLo
{ errorMessage: 'Save failed' },
);
+ useEffect(() => {
+ if (!open) return undefined;
+ const load = (loader) => Promise.resolve()
+ .then(() => loader({ silent: true }))
+ .catch(() => []);
+ let mounted = true;
+ Promise.all([load(listImageModels), load(listVideoModels)]).then(([images, videos]) => {
+ if (!mounted) return;
+ replaceModelList(setImageModels, images);
+ replaceModelList(setVideoModels, videos);
+ });
+ return () => { mounted = false; };
+ }, [open]);
+
+ const pendingRender = useRef(null);
+ if (!pendingRender.current || !saving) {
+ pendingRender.current = {
+ formatId: renderSettings.formatId,
+ imageMode: savedRender.imageMode,
+ imageModel: savedRender.imageModel,
+ videoMode: savedRender.videoMode,
+ videoModel: savedRender.videoModel,
+ effort: savedRender.effort,
+ };
+ }
+
+ const saveRender = (changes) => {
+ pendingRender.current = { ...pendingRender.current, ...changes };
+ return patch({ renderSettings: { ...pendingRender.current } });
+ };
+
+ const chooseImageMode = (value) => {
+ const nextMode = value === 'auto' ? null : value;
+ setImageMode(nextMode);
+ if (nextMode && nextMode !== 'local') setImageModel(null);
+ saveRender({
+ imageMode: nextMode,
+ ...(nextMode && nextMode !== 'local' ? { imageModel: null } : {}),
+ });
+ };
+
+ const chooseImageModel = (event) => {
+ const nextModel = event.target.value || null;
+ setImageModel(nextModel);
+ saveRender({ imageModel: nextModel });
+ };
+
+ const chooseVideoMode = (value) => {
+ const nextMode = value === 'auto' ? null : value;
+ setVideoMode(nextMode);
+ if (nextMode && nextMode !== 'local') setVideoModel(null);
+ saveRender({
+ videoMode: nextMode,
+ ...(nextMode && nextMode !== 'local' ? { videoModel: null } : {}),
+ });
+ };
+
+ const chooseVideoModel = (event) => {
+ const nextModel = event.target.value || null;
+ setVideoModel(nextModel);
+ saveRender({ videoModel: nextModel });
+ };
+
+ const chooseRenderEffort = (event) => {
+ const nextEffort = event.target.value || null;
+ setRenderEffort(nextEffort);
+ saveRender({ effort: nextEffort });
+ };
+
const universeCharacters = Array.isArray(universe?.characters) ? universe.characters : [];
const protagonist = universeCharacters.find((character) => character.id === protagonistCharacterId) || null;
const protagonistWardrobes = Array.isArray(protagonist?.wardrobes) ? protagonist.wardrobes : [];
@@ -385,6 +520,125 @@ export default function LoomSettingsDrawer({ open, onClose, loom, universe, onLo
)}
</section>
+ <section className="border-t border-port-border pt-4 space-y-3">
+ <div>
+ <h4 className="text-sm font-semibold">Rendering defaults</h4>
+ <p className="mt-1 text-xs text-port-text-muted">
+ New scene images, video clips, and batch production use these story defaults. The production panel can still override them for one run.
+ </p>
+ </div>
+ <FormField
+ label="Aspect ratio"
+ labelClassName={labelClass}
+ hint="One format keeps storyboard stills and motion clips consistent."
+ >
+ <select
+ id="loom-render-format"
+ className={fieldClass}
+ value={renderSettings.formatId}
+ disabled={saving || reformatting}
+ onChange={(event) => saveRender({ formatId: event.target.value })}
+ >
+ {FABLELOOM_RENDER_FORMATS.map((option) => (
+ <option key={option.formatId} value={option.formatId}>
+ {option.label} · {option.width}×{option.height}
+ </option>
+ ))}
+ </select>
+ </FormField>
+
+ <div className="space-y-2">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <span className="text-xs font-medium text-port-text-muted">Image renderer</span>
+ <BackendChipStrip
+ availableBackends={IMAGE_RENDER_BACKENDS}
+ value={imageMode || 'auto'}
+ onChange={chooseImageMode}
+ size="sm"
+ ariaLabel="Story image renderer"
+ disabled={saving || reformatting}
+ titlePrefix="Use for story images"
+ />
+ </div>
+ {(imageMode === 'local' || !imageMode) && (
+ <FormField
+ label="Local image model"
+ labelClassName="block text-[11px] text-port-text-muted mb-1"
+ hint="Leave this at the instance default unless this story needs a specific installed model."
+ >
+ <select
+ id="loom-image-model"
+ className={fieldClass}
+ aria-label="Local image model"
+ value={imageModel || ''}
+ disabled={saving || reformatting}
+ onChange={chooseImageModel}
+ >
+ <option value="">Instance default</option>
+ {modelOptions(imageModels, imageModel).map((option) => (
+ <option key={option.id} value={option.id}>{option.label}</option>
+ ))}
+ </select>
+ </FormField>
+ )}
+ </div>
+
+ <div className="space-y-2">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <span className="text-xs font-medium text-port-text-muted">Video renderer</span>
+ <BackendChipStrip
+ availableBackends={VIDEO_RENDER_BACKENDS}
+ value={videoMode || 'auto'}
+ onChange={chooseVideoMode}
+ size="sm"
+ ariaLabel="Story video renderer"
+ disabled={saving || reformatting}
+ titlePrefix="Use for story video"
+ />
+ </div>
+ {(videoMode === 'local' || !videoMode) && (
+ <FormField
+ label="Local video model"
+ labelClassName="block text-[11px] text-port-text-muted mb-1"
+ hint="Leave this at the instance default unless this story needs a specific installed model."
+ >
+ <select
+ id="loom-video-model"
+ className={fieldClass}
+ aria-label="Local video model"
+ value={videoModel || ''}
+ disabled={saving || reformatting}
+ onChange={chooseVideoModel}
+ >
+ <option value="">Instance default</option>
+ {modelOptions(videoModels, videoModel).map((option) => (
+ <option key={option.id} value={option.id}>{option.label}</option>
+ ))}
+ </select>
+ </FormField>
+ )}
+ </div>
+
+ <FormField
+ label="Codex image effort"
+ labelClassName={labelClass}
+ hint="Used when the image renderer is Codex; other renderers use their own controls."
+ >
+ <select
+ id="loom-render-effort"
+ className={fieldClass}
+ value={renderEffort || ''}
+ disabled={saving || reformatting}
+ onChange={chooseRenderEffort}
+ >
+ <option value="">Provider default</option>
+ {CODEX_EFFORT_LEVELS.map((level) => (
+ <option key={level} value={level}>{level[0].toUpperCase() + level.slice(1)}</option>
+ ))}
+ </select>
+ </FormField>
+ </section>
+
<section className="border-t border-port-border pt-4 space-y-2">
<h4 className="text-sm font-semibold">Narrator</h4>
<p className="text-xs text-port-text-muted">
diff --git a/client/src/components/fableloom/LoomSettingsDrawer.test.jsx b/client/src/components/fableloom/LoomSettingsDrawer.test.jsx
index ac66dff627..8a96ce4c10 100644
--- a/client/src/components/fableloom/LoomSettingsDrawer.test.jsx
+++ b/client/src/components/fableloom/LoomSettingsDrawer.test.jsx
@@ -1,9 +1,11 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { render, screen, waitFor } from '@testing-library/react';
+import { render, screen, waitFor, within } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import userEvent from '@testing-library/user-event';
vi.mock('../../services/api', () => ({
+ listImageModels: vi.fn(() => Promise.resolve([])),
+ listVideoModels: vi.fn(() => Promise.resolve([])),
reformatLoomEpisode: vi.fn(),
updateLoom: vi.fn(),
}));
@@ -239,3 +241,44 @@ describe('LoomSettingsDrawer character continuity', () => {
expect(screen.getByRole('checkbox', { name: /Lock this wardrobe across on-screen scenes/ })).toBeChecked();
});
});
+
+describe('LoomSettingsDrawer rendering defaults', () => {
+ it('shows the saved aspect ratio, renderers, models, and effort', () => {
+ renderDrawer({
+ ...makeLoom([]),
+ renderSettings: {
+ formatId: 'portrait-9-16',
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ effort: 'high',
+ },
+ });
+
+ expect(screen.getByLabelText('Aspect ratio')).toHaveValue('portrait-9-16');
+ expect(screen.getByLabelText('Local image model')).toHaveValue('image-model');
+ expect(screen.getByLabelText('Codex image effort')).toHaveValue('high');
+ expect(within(screen.getByRole('group', { name: 'Story image renderer' }))
+ .getByRole('button', { name: 'Local' })).toHaveClass('bg-port-accent');
+ expect(within(screen.getByRole('group', { name: 'Story video renderer' }))
+ .getByRole('button', { name: 'Grok' })).toHaveClass('bg-port-accent');
+ });
+
+ it('saves rendering defaults as one story-level pin', async () => {
+ const user = userEvent.setup();
+ renderDrawer(makeLoom([]));
+
+ await user.selectOptions(screen.getByLabelText('Aspect ratio'), 'square-1-1');
+
+ await waitFor(() => expect(updateLoom).toHaveBeenCalledWith('loom-1', {
+ renderSettings: {
+ formatId: 'square-1-1',
+ imageMode: null,
+ imageModel: null,
+ videoMode: null,
+ videoModel: null,
+ effort: null,
+ },
+ }, { silent: true }));
+ });
+});
diff --git a/client/src/components/fableloom/sceneMediaRequests.js b/client/src/components/fableloom/sceneMediaRequests.js
index 45e7cb3fde..5652014ebd 100644
--- a/client/src/components/fableloom/sceneMediaRequests.js
+++ b/client/src/components/fableloom/sceneMediaRequests.js
@@ -20,7 +20,10 @@
import { composeStyledPrompt } from '../../lib/composeStyledPrompt';
import { FABLELOOM_CAMERA_MOVEMENTS } from '../../../../server/lib/fableLoomCameraMovements.js';
-import { asFableLoomRenderSettings } from '../../../../server/lib/fableLoomProduction.js';
+import {
+ asFableLoomRenderPreferences,
+ asFableLoomRenderSettings,
+} from '../../../../server/lib/fableLoomProduction.js';
const withLoomStyle = (prompt, styleNotes) => {
const notes = typeof styleNotes === 'string' ? styleNotes.trim() : '';
@@ -31,9 +34,15 @@ export function buildFableLoomImageRequest({ loom, episodeId, node, stylePreset
const authoredPrompt = withLoomStyle((node?.imagePrompt || '').trim(), loom?.styleNotes);
const styled = composeStyledPrompt(authoredPrompt, '', stylePreset);
const render = asFableLoomRenderSettings(loom?.renderSettings);
+ const preferences = asFableLoomRenderPreferences(loom?.renderSettings);
return {
prompt: styled.prompt,
...(styled.negativePrompt ? { negativePrompt: styled.negativePrompt } : {}),
+ ...((preferences.imageMode || preferences.imageModel)
+ ? { mode: preferences.imageMode || 'local' }
+ : {}),
+ ...(preferences.imageModel ? { modelId: preferences.imageModel } : {}),
+ ...(preferences.effort ? { effort: preferences.effort } : {}),
width: render.width,
height: render.height,
fableLoom: { loomId: loom.id, episodeId, nodeId: node.id },
@@ -49,10 +58,12 @@ export function buildFableLoomVideoRequest({ loom, episodeId, node, stylePreset
: authoredPrompt;
const styled = composeStyledPrompt(withLoomStyle(directedPrompt, loom?.styleNotes), '', stylePreset);
const render = asFableLoomRenderSettings(loom?.renderSettings);
+ const preferences = asFableLoomRenderPreferences(loom?.renderSettings);
return {
prompt: styled.prompt,
...(styled.negativePrompt ? { negativePrompt: styled.negativePrompt } : {}),
- backend: 'local',
+ backend: preferences.videoMode || 'local',
+ ...(preferences.videoModel ? { modelId: preferences.videoModel } : {}),
mode: node?.image ? 'image' : 'text',
...(node?.image ? { sourceImageFile: node.image } : {}),
disableAudio: true,
diff --git a/client/src/components/fableloom/sceneMediaRequests.test.js b/client/src/components/fableloom/sceneMediaRequests.test.js
index 52d42aa618..916a47273a 100644
--- a/client/src/components/fableloom/sceneMediaRequests.test.js
+++ b/client/src/components/fableloom/sceneMediaRequests.test.js
@@ -90,4 +90,35 @@ describe('FableLoom scene media request composition', () => {
expect(buildFableLoomVideoRequest({ loom: portraitLoom, episodeId: 'ep-1', node }))
.toMatchObject({ width: 576, height: 1024 });
});
+
+ it('carries the saved image renderer and Codex effort into a scene request', () => {
+ const preferredLoom = {
+ ...loom,
+ renderSettings: { formatId: 'landscape-16-9', imageMode: 'codex', effort: 'high' },
+ };
+ expect(buildFableLoomImageRequest({
+ loom: preferredLoom,
+ episodeId: 'ep-1',
+ node: { id: 'node-1', imagePrompt: 'a lantern in the fog' },
+ })).toMatchObject({ mode: 'codex', effort: 'high' });
+ });
+
+ it('carries the saved local video model or cloud backend into a scene request', () => {
+ const localLoom = {
+ ...loom,
+ renderSettings: { formatId: 'landscape-16-9', videoMode: 'local', videoModel: 'video-model' },
+ };
+ expect(buildFableLoomVideoRequest({
+ loom: localLoom,
+ episodeId: 'ep-1',
+ node: { id: 'node-1', videoPrompt: 'A lantern flickers.' },
+ })).toMatchObject({ backend: 'local', modelId: 'video-model' });
+
+ const grokLoom = { ...loom, renderSettings: { formatId: 'landscape-16-9', videoMode: 'grok' } };
+ expect(buildFableLoomVideoRequest({
+ loom: grokLoom,
+ episodeId: 'ep-1',
+ node: { id: 'node-1', videoPrompt: 'A lantern flickers.' },
+ })).toMatchObject({ backend: 'grok' });
+ });
});
diff --git a/scripts/migrations/326-fableloom-render-preferences.js b/scripts/migrations/326-fableloom-render-preferences.js
new file mode 100644
index 0000000000..53c7943377
--- /dev/null
+++ b/scripts/migrations/326-fableloom-render-preferences.js
@@ -0,0 +1,15 @@
+/**
+ * Register additive FableLoom image/video render preferences.
+ *
+ * Existing stories need no eager rewrite: the render-preference normalizer
+ * supplies null defaults on read until an author saves a story-level pin, and
+ * the next ordinary write persists the expanded render-settings shape. The
+ * federation schema gate advances separately so older peers cannot round-trip
+ * the preferences away during an unrelated whole-record update.
+ */
+
+export default {
+ async up() {
+ console.log('🧶 FableLoom render preferences: existing stories keep provider defaults until a story pin is saved');
+ },
+};
diff --git a/server/lib/README.md b/server/lib/README.md
index 3652d585c9..e3f64fc22d 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -37,7 +37,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `fableLoomPlayback.js` | FableLoom node playback modes (`cut` auto-advances; `decision` loops while awaiting input), with the backward-compatible default. |
| `fableLoomParticipation.js` | FableLoom audience roles (helper vs protagonist), per-scene connection availability, prompt contracts, and backward-compatible defaults. |
| `fableLoomFormats.js` | FableLoom scene formats (`LOOM_FORMATS`, `asLoomFormat`, `sceneFormatContract`, …) — how a loom writes scene text, read by validation, the sanitizer, and every generative stage. |
-| `fableLoomProduction.js` | FableLoom production batch planning and topological orchestration: explicit shared still/video render-format presets (16:9 default), ordered episode storyboard gates, DAG resolution, asset enumeration, execution stages, and exact-input provenance verification. |
+| `fableLoomProduction.js` | FableLoom production batch planning and topological orchestration: shared still/video render-format presets and story-level image/video provider preferences (16:9 default), ordered episode storyboard gates, DAG resolution, asset enumeration, execution stages, and exact-input provenance verification. |
| `fableLoomContinuity.js` | FableLoom episodic continuity review: multi-vector deterministic checks for visual entity bindings, convergence clarity, voice profile consistency/drift, pronunciation anchors, and playback safety. |
| `fableLoomOutline.js` | FableLoom story-first episode beat outlines: bounded log-lines, deterministic arc validation, and compact prompt rendering before teleplay expansion. |
| `fableLoomPlaytest.js` | FableLoom branching-playthrough harness: bounded exhaustive path enumeration, ending/loop/coverage diagnostics, aggregate loom reports, and compact traces for narrative-quality review. |
diff --git a/server/lib/conflictJournal.js b/server/lib/conflictJournal.js
index 5c06c3afa6..f88ac935e2 100644
--- a/server/lib/conflictJournal.js
+++ b/server/lib/conflictJournal.js
@@ -497,9 +497,10 @@ export const RESTORABLE_FIELDS = Object.freeze({
// machine-local schedule/runs/assignment/enabled are never in a snapshot
// (stripped from the wire) so they're excluded.
creativeCommission: ['name', 'targetAbility', 'brief', 'generation', 'feedbackWindow'],
- // FableLoom restores the authored story graph and playback configuration.
+ // FableLoom restores the authored story graph, playback configuration, and
+ // story-level render preferences.
// Universe/series ids are structural links and stay on the live record.
- fableLoom: ['name', 'logline', 'premise', 'styleNotes', 'format', 'playSettings', 'seriesPlan', 'participationMode', 'audienceCommunicationMedium', 'episodes'],
+ fableLoom: ['name', 'logline', 'premise', 'styleNotes', 'format', 'playSettings', 'renderSettings', 'seriesPlan', 'participationMode', 'audienceCommunicationMedium', 'episodes'],
// Writers Room exercises (#1645): the user-authored sprint fields the merge can
// restore through `restoreExercise` — the appended prose + the sprint config.
// Server-owned / structural fields are excluded (`id`/`createdAt`/`startedAt`/
diff --git a/server/lib/fableLoomProduction.js b/server/lib/fableLoomProduction.js
index cdd582cd81..8edd750675 100644
--- a/server/lib/fableLoomProduction.js
+++ b/server/lib/fableLoomProduction.js
@@ -7,7 +7,9 @@
*/
import { computeGraphLayers } from './fableLoomGraph.js';
+import { EFFORT_LEVELS } from './providerModels.js';
import { validateAudioOccupancy } from './fableLoomPlayback.js';
+import { QUEUEABLE_IMAGE_MODES, VIDEO_GEN_MODES } from './generationModes.js';
export const FABLELOOM_PRODUCTION_MODES = Object.freeze(['current_canon', 'exact_inputs']);
export const FABLELOOM_PRODUCTION_MODE_DEFAULT = 'current_canon';
@@ -29,6 +31,57 @@ export const FABLELOOM_RENDER_FORMAT_IDS = Object.freeze(
);
export const FABLELOOM_DEFAULT_RENDER_FORMAT_ID = 'landscape-16-9';
+// These preferences are intentionally part of the loom's persisted render
+// settings rather than the production panel's transient request controls. A
+// story can therefore render the same way from a scene card, a batch, or a
+// fresh page load; the production panel may still override them for one run.
+export const FABLELOOM_RENDER_PREFERENCE_KEYS = Object.freeze([
+ 'imageMode', 'imageModel', 'videoMode', 'videoModel', 'effort',
+]);
+
+const isRecord = (value) => value != null && typeof value === 'object' && !Array.isArray(value);
+const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
+const trimModelId = (value) => (typeof value === 'string' && value.trim()
+ ? value.trim().slice(0, 64)
+ : null);
+
+/**
+ * Normalize the optional provider/model preferences on a loom render pin.
+ * Image and video model ids are local-model selections; cloud backends use
+ * their configured model, so a cloud mode clears an accidentally retained
+ * local model rather than presenting a misleading pin to the planner.
+ */
+export function asFableLoomRenderPreferences(raw) {
+ const source = isRecord(raw) ? raw : {};
+ const imageMode = QUEUEABLE_IMAGE_MODES.includes(source.imageMode) ? source.imageMode : null;
+ const videoMode = VIDEO_GEN_MODES.includes(source.videoMode) ? source.videoMode : null;
+ return {
+ imageMode,
+ imageModel: imageMode && imageMode !== 'local' ? null : trimModelId(source.imageModel),
+ videoMode,
+ videoModel: videoMode && videoMode !== 'local' ? null : trimModelId(source.videoModel),
+ effort: EFFORT_LEVELS.includes(source.effort) ? source.effort : null,
+ };
+}
+
+/**
+ * Sanitize the full persisted render-settings shape while keeping legacy
+ * records byte-compatible when they have no provider preferences yet.
+ */
+export function sanitizeFableLoomRenderSettings(raw) {
+ const geometry = asFableLoomRenderSettings(raw);
+ if (!isRecord(raw) || !FABLELOOM_RENDER_PREFERENCE_KEYS.some((key) => hasOwn(raw, key))) {
+ return geometry;
+ }
+ return { ...geometry, ...asFableLoomRenderPreferences(raw) };
+}
+
+/** Merge a partial format/preferences PATCH before the record is re-sanitized. */
+export function mergeFableLoomRenderSettings(current, patch) {
+ if (!isRecord(patch)) return patch;
+ return { ...(isRecord(current) ? current : {}), ...patch };
+}
+
export function asFableLoomRenderSettings(raw) {
const requestedId = typeof raw === 'string' ? raw : raw?.formatId;
const selected = FABLELOOM_RENDER_FORMATS.find((format) => format.formatId === requestedId)
diff --git a/server/lib/fableLoomProduction.test.js b/server/lib/fableLoomProduction.test.js
index db1049d1a7..7a8a11f1b0 100644
--- a/server/lib/fableLoomProduction.test.js
+++ b/server/lib/fableLoomProduction.test.js
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import {
+ asFableLoomRenderPreferences,
asFableLoomRenderSettings,
buildEpisodeProductionPlan,
computeTopologicalNodeOrder,
@@ -76,6 +77,22 @@ describe('fableLoomProduction', () => {
});
});
+ it('normalizes persisted image and video rendering preferences', () => {
+ expect(asFableLoomRenderPreferences({
+ imageMode: 'local',
+ imageModel: ' image-model ',
+ videoMode: 'grok',
+ videoModel: 'stale-local-model',
+ effort: 'high',
+ })).toEqual({
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ videoModel: null,
+ effort: 'high',
+ });
+ });
+
it('computes topological node ordering and detects convergence', () => {
const topo = computeTopologicalNodeOrder(sampleEpisode);
expect(topo.orderedNodes.map((n) => n.id)).toEqual(['node-1', 'node-2', 'node-3', 'node-4']);
diff --git a/server/lib/fableLoomValidation.js b/server/lib/fableLoomValidation.js
index 62c5329bfc..1a8a1b4df3 100644
--- a/server/lib/fableLoomValidation.js
+++ b/server/lib/fableLoomValidation.js
@@ -49,8 +49,28 @@ const format = z.enum(LOOM_FORMATS);
// the runner would clamp an unknown level silently, and the door check is
// where a typo should surface.
const playSettings = llmRoutePinSchema.nullable();
+const optionalRenderMode = (values) => z.preprocess(
+ (value) => value == null || value === '' || value === 'auto' ? null : value,
+ z.enum(values).nullable().optional(),
+);
+const optionalRenderModel = z.preprocess(
+ (value) => value == null || value === '' ? null : value,
+ z.string().trim().min(1).max(64).nullable().optional(),
+);
+const optionalRenderEffort = z.preprocess(
+ (value) => value == null || value === '' ? null : value,
+ z.enum(EFFORT_LEVELS).nullable().optional(),
+);
+// Format, provider, and model preferences travel together as one loom-level
+// pin. The provider/model fields are nullable so the UI can explicitly return
+// to the install default without omitting a sibling preference accidentally.
const renderSettings = z.object({
formatId: z.enum(FABLELOOM_RENDER_FORMAT_IDS),
+ imageMode: optionalRenderMode(QUEUEABLE_IMAGE_MODES),
+ imageModel: optionalRenderModel,
+ videoMode: optionalRenderMode(VIDEO_GEN_MODES),
+ videoModel: optionalRenderModel,
+ effort: optionalRenderEffort,
});
const productionStatus = z.object({
editorialApprovedAt: z.string().max(80).nullable().optional(),
diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.js
index 696019e7c3..cd828f8472 100644
--- a/server/lib/schemaVersions.js
+++ b/server/lib/schemaVersions.js
@@ -371,7 +371,10 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({
// editorial/final-delivery sign-offs let the ordered workflow survive a
// reload. A v4 peer would strip those choices and silently reopen completed
// gates, erase challenge-to-scene mapping, or reintroduce mixed geometry.
- fableLoom: 5,
+ // v6 = the loom-level render pin gained image/video backend, model, and
+ // effort preferences. A v5 peer would preserve the format but strip these
+ // additive preferences during an unrelated whole-record update.
+ fableLoom: 6,
// v1 = Creative Director projects (PostgreSQL `creative_director_projects`)
// federated via the per-record peer-sync push pipeline (record kind
// `creativeDirectorProject`, sync category `creativeDirectorProjects`, #1564).
diff --git a/server/lib/schemaVersions.test.js b/server/lib/schemaVersions.test.js
index 4ddf3a0d70..dfa9e09a41 100644
--- a/server/lib/schemaVersions.test.js
+++ b/server/lib/schemaVersions.test.js
@@ -42,10 +42,11 @@ describe('PORTOS_SCHEMA_VERSIONS', () => {
expect(PORTOS_SCHEMA_VERSIONS.mediaCollections).toBe(1);
});
- it('version-gates the persisted FableLoom render-format shape', () => {
- // v5 adds renderSettings. Older peers stay on the v4 protagonist-
- // continuity shape until they advertise support for the render contract.
- expect(PORTOS_SCHEMA_VERSIONS.fableLoom).toBe(5);
+ it('version-gates the persisted FableLoom render-settings shape', () => {
+ // v5 adds renderSettings; v6 adds its image/video provider preferences.
+ // Older peers stay behind the full render contract until they advertise
+ // support for the additive fields.
+ expect(PORTOS_SCHEMA_VERSIONS.fableLoom).toBe(6);
});
it('version-gates the additive Creative Commission taste brief shape', () => {
diff --git a/server/routes/imageGen.js b/server/routes/imageGen.js
index 140c7b7fce..b841aa6e76 100644
--- a/server/routes/imageGen.js
+++ b/server/routes/imageGen.js
@@ -51,6 +51,7 @@ import {
compileFableLoomVisualRequest, fableLoomImageCapabilities,
} from '../services/fableLoom/visualConditioning.js';
import { loraCompatKey } from '../lib/runners.js';
+import { EFFORT_LEVELS } from '../lib/providerModels.js';
const router = Router();
@@ -76,6 +77,10 @@ const generateSchema = z.object({
// `imageGen.mode` from settings.json.
mode: z.enum(IMAGE_GEN_MODES).optional(),
modelId: z.string().max(64).optional(),
+ // Per-render Codex reasoning effort. Other image backends ignore this
+ // provider-specific preference, preserving the story pin across a backend
+ // switch without inventing a second image request shape.
+ effort: z.enum(EFFORT_LEVELS).optional(),
// Per-render override of a cloud CLI's session model, replacing the saved
// `settings.imageGen.<mode>.model` for this one queue item. Deliberately NOT
// `modelId`: that field carries a *local* model id (`dev`, `schnell`), and a
diff --git a/server/services/fableLoom/production.js b/server/services/fableLoom/production.js
index 21231d547d..e13152477b 100644
--- a/server/services/fableLoom/production.js
+++ b/server/services/fableLoom/production.js
@@ -38,6 +38,7 @@ import {
} from './visualConditioning.js';
import { cancelJob, enqueueJob, mediaJobEvents } from '../mediaJobQueue/index.js';
import {
+ asFableLoomRenderPreferences,
asFableLoomRenderSettings,
buildEpisodeProductionPlan,
exactRenderParameterIssues,
@@ -124,14 +125,23 @@ function cleanStaleRuns() {
}
}
-function normalizedRenderOptions({ imageMode, imageModel, videoMode, videoModel, effort } = {}) {
- return {
- imageMode: QUEUEABLE_IMAGE_MODES.includes(imageMode) ? imageMode : null,
- imageModel: text(imageModel) || null,
- videoMode: VIDEO_GEN_MODES.includes(videoMode) ? videoMode : null,
- videoModel: text(videoModel) || null,
- effort: text(effort) || null,
- };
+const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
+
+function normalizedRenderOptions(options = {}) {
+ const normalized = {};
+ if (hasOwn(options, 'imageMode')) {
+ normalized.imageMode = QUEUEABLE_IMAGE_MODES.includes(options.imageMode) ? options.imageMode : null;
+ if (normalized.imageMode && normalized.imageMode !== IMAGE_GEN_MODE.LOCAL) normalized.imageModel = null;
+ }
+ if (hasOwn(options, 'imageModel')) normalized.imageModel = text(options.imageModel) || null;
+ if (hasOwn(options, 'videoMode')) {
+ normalized.videoMode = VIDEO_GEN_MODES.includes(options.videoMode) ? options.videoMode : null;
+ }
+ if (hasOwn(options, 'videoModel')) normalized.videoModel = text(options.videoModel) || null;
+ if (hasOwn(options, 'effort')) normalized.effort = text(options.effort) || null;
+ if (normalized.imageMode && normalized.imageMode !== IMAGE_GEN_MODE.LOCAL) normalized.imageModel = null;
+ if (normalized.videoMode && normalized.videoMode !== VIDEO_GEN_MODE.LOCAL) normalized.videoModel = null;
+ return normalized;
}
function renderGeometry(run, recordedConditioning = null) {
@@ -838,14 +848,8 @@ for (const event of TERMINAL_JOB_EVENTS) {
}
/** Plan production assets and topological execution for an episode. */
-export async function planEpisodeProduction(loomId, episodeId, {
- mode = FABLELOOM_PRODUCTION_MODE_DEFAULT,
- imageMode,
- imageModel,
- videoMode,
- videoModel,
- effort,
-} = {}) {
+export async function planEpisodeProduction(loomId, episodeId, options = {}) {
+ const { mode = FABLELOOM_PRODUCTION_MODE_DEFAULT } = options;
const loom = await getLoom(loomId);
if (!loom) throw new ServerError('Loom not found', { status: 404, code: 'NOT_FOUND' });
const episode = findEpisode(loom, episodeId);
@@ -867,7 +871,8 @@ export async function planEpisodeProduction(loomId, episodeId, {
resolveAsset: resolveImageInputPath,
});
const render = {
- ...normalizedRenderOptions({ imageMode, imageModel, videoMode, videoModel, effort }),
+ ...asFableLoomRenderPreferences(loom.renderSettings),
+ ...normalizedRenderOptions(options),
...asFableLoomRenderSettings(loom.renderSettings),
};
await flagRenderFormatMismatches(plan, episode, render);
@@ -949,16 +954,12 @@ export async function planEpisodeProduction(loomId, episodeId, {
}
/** Start a user-triggered batch production run. */
-export async function startEpisodeProductionBatch(loomId, episodeId, {
- mode = FABLELOOM_PRODUCTION_MODE_DEFAULT,
- assetTypes = null,
- nodeIds = null,
- imageMode,
- imageModel,
- videoMode,
- videoModel,
- effort,
-} = {}) {
+export async function startEpisodeProductionBatch(loomId, episodeId, options = {}) {
+ const {
+ mode = FABLELOOM_PRODUCTION_MODE_DEFAULT,
+ assetTypes = null,
+ nodeIds = null,
+ } = options;
cleanStaleRuns();
const activeRuns = [..._batchRuns.values()].filter((run) => run.status === 'in_progress').length;
if (activeRuns >= MAX_CONCURRENT_RUNS) {
@@ -968,7 +969,7 @@ export async function startEpisodeProductionBatch(loomId, episodeId, {
});
}
- const requestedRender = normalizedRenderOptions({ imageMode, imageModel, videoMode, videoModel, effort });
+ const requestedRender = normalizedRenderOptions(options);
const plan = await planEpisodeProduction(loomId, episodeId, { mode, ...requestedRender });
const render = plan.renderOptions;
const targetAssets = selectAssets(plan, { assetTypes, nodeIds });
diff --git a/server/services/fableLoom/production.test.js b/server/services/fableLoom/production.test.js
index bef8bac341..b57b1c030b 100644
--- a/server/services/fableLoom/production.test.js
+++ b/server/services/fableLoom/production.test.js
@@ -189,6 +189,32 @@ describe('fableLoom production service', () => {
});
});
+ it('uses the loom render preferences when a production run has no overrides', async () => {
+ const preferredLoom = structuredClone(sampleLoom);
+ preferredLoom.renderSettings = {
+ formatId: 'square-1-1',
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ effort: 'high',
+ };
+ records.getLoom.mockResolvedValueOnce(preferredLoom);
+
+ const plan = await planEpisodeProduction('loom-1', 'ep-1', { mode: 'current_canon' });
+
+ expect(plan.renderOptions).toMatchObject({
+ formatId: 'square-1-1',
+ aspectRatio: '1:1',
+ width: 1024,
+ height: 1024,
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ videoModel: null,
+ effort: 'high',
+ });
+ });
+
it('flags an existing portrait storyboard and its clips for landscape regeneration', async () => {
const portraitLoom = structuredClone(sampleLoom);
portraitLoom.episodes[0].nodes[0].image = 'portrait.png';
diff --git a/server/services/fableLoom/records.js b/server/services/fableLoom/records.js
index 6902706f81..065636b076 100644
--- a/server/services/fableLoom/records.js
+++ b/server/services/fableLoom/records.js
@@ -64,7 +64,11 @@ import {
fableLoomPlotPointKind,
sanitizeStoryOutline,
} from '../../lib/fableLoomOutline.js';
-import { asFableLoomRenderSettings } from '../../lib/fableLoomProduction.js';
+import {
+ FABLELOOM_RENDER_PREFERENCE_KEYS,
+ mergeFableLoomRenderSettings,
+ sanitizeFableLoomRenderSettings,
+} from '../../lib/fableLoomProduction.js';
export { LOOM_LIMITS };
@@ -328,7 +332,7 @@ export function sanitizeLoom(raw) {
// turns a reader's free text into a path. An unset dimension stays null
// ('fall through to the stage pin / active provider').
playSettings: sanitizeLlmRoutePin(raw.playSettings),
- renderSettings: asFableLoomRenderSettings(raw.renderSettings),
+ renderSettings: sanitizeFableLoomRenderSettings(raw.renderSettings),
protagonistCharacterId,
protagonistWardrobeId,
protagonistWardrobeLocked: Boolean(protagonistWardrobeId && raw.protagonistWardrobeLocked !== false),
@@ -587,7 +591,11 @@ export async function updateLoom(id, patch = {}) {
return mutateLoom(id, (loom) => {
const next = { ...loom };
for (const key of PATCH_FIELDS) {
- if (key in patch) next[key] = patch[key];
+ if (key in patch) {
+ next[key] = key === 'renderSettings'
+ ? mergeFableLoomRenderSettings(loom.renderSettings, patch[key])
+ : patch[key];
+ }
}
assertParticipationConfigured(next);
return next;
@@ -599,7 +607,11 @@ export function restoreLoom(id, patch = {}) {
return mutateLoom(id, (loom) => {
const next = { ...loom };
for (const key of RESTORABLE_FIELDS) {
- if (key in patch) next[key] = patch[key];
+ if (key in patch) {
+ next[key] = key === 'renderSettings'
+ ? mergeFableLoomRenderSettings(loom.renderSettings, patch[key])
+ : patch[key];
+ }
}
assertParticipationConfigured(next);
return next;
@@ -627,13 +639,25 @@ export async function deleteLoom(id) {
// them. A sender at the current schema version's present null remains an
// intentional clear.
const preserveLegacyVisualProduction = (remote, local, senderVersion) => {
- if (!local || senderVersion >= 5) return remote;
+ if (!local || senderVersion >= 6) return remote;
const localEpisodes = new Map(local.episodes.map((episode) => [episode.id, episode]));
const localPlotPoints = new Map((local.seriesPlan?.plotPoints || []).map((item) => [item.id, item]));
+ const legacyRenderSettings = senderVersion < 5
+ ? local.renderSettings
+ : {
+ ...remote.renderSettings,
+ ...Object.fromEntries(FABLELOOM_RENDER_PREFERENCE_KEYS
+ .filter((key) => Object.prototype.hasOwnProperty.call(local.renderSettings, key))
+ .map((key) => [key, local.renderSettings[key]])),
+ };
return {
...remote,
+ ...(senderVersion < 6 ? {
+ // v5 peers understand the aspect-ratio format but would strip the
+ // provider/model preferences added in v6 during an unrelated update.
+ renderSettings: legacyRenderSettings,
+ } : {}),
...(senderVersion < 5 ? {
- renderSettings: local.renderSettings,
productionStatus: local.productionStatus,
} : {}),
seriesPlan: senderVersion < 5 ? {
@@ -702,7 +726,7 @@ export async function mergeLoomsFromSync(
remoteLooms,
{
source = { via: 'sync', peerId: null },
- senderSchemaVersions = { fableLoom: 5 },
+ senderSchemaVersions = { fableLoom: 6 },
} = {},
) {
if (!Array.isArray(remoteLooms)) return { applied: false, count: 0 };
diff --git a/server/services/fableLoom/records.test.js b/server/services/fableLoom/records.test.js
index 5b7666cf0b..a262248abc 100644
--- a/server/services/fableLoom/records.test.js
+++ b/server/services/fableLoom/records.test.js
@@ -398,6 +398,39 @@ describe('loom CRUD', () => {
});
});
+ it('preserves render preferences when a v5 peer wins an unrelated LWW edit', async () => {
+ const loom = await makeLoom({
+ name: 'Local production',
+ renderSettings: {
+ formatId: 'portrait-9-16',
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ effort: 'high',
+ },
+ });
+ const remoteV5 = {
+ ...loom,
+ name: 'Renamed by v5 peer',
+ updatedAt: '2099-01-01T00:00:00.000Z',
+ renderSettings: { formatId: 'landscape-16-9' },
+ };
+
+ await mergeLoomsFromSync([remoteV5], { senderSchemaVersions: { fableLoom: 5 } });
+
+ expect(await getLoom(loom.id)).toMatchObject({
+ name: 'Renamed by v5 peer',
+ renderSettings: {
+ formatId: 'landscape-16-9',
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ videoModel: null,
+ effort: 'high',
+ },
+ });
+ });
+
it('preserves playable challenge mappings when a v4 peer wins an unrelated edit', async () => {
let loom = await makeLoom({ name: 'Local challenge plan' });
loom = await addEpisode(loom.id, { title: 'Pilot' });
@@ -562,6 +595,42 @@ describe('format, render, and play settings round-trip', () => {
});
});
+ it('round-trips render preferences and keeps them through a format-only patch', async () => {
+ const loom = await makeLoom({
+ renderSettings: {
+ formatId: 'portrait-9-16',
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ effort: 'high',
+ },
+ });
+ expect(loom.renderSettings).toEqual({
+ formatId: 'portrait-9-16',
+ aspectRatio: '9:16',
+ width: 576,
+ height: 1024,
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ videoModel: null,
+ effort: 'high',
+ });
+
+ const updated = await updateLoom(loom.id, { renderSettings: { formatId: 'square-1-1' } });
+ expect(updated.renderSettings).toEqual({
+ formatId: 'square-1-1',
+ aspectRatio: '1:1',
+ width: 1024,
+ height: 1024,
+ imageMode: 'local',
+ imageModel: 'image-model',
+ videoMode: 'grok',
+ videoModel: null,
+ effort: 'high',
+ });
+ });
+
it('reopens only the production approvals affected by a later change', async () => {
let loom = await makeLoom({ premise: 'A courier must cross the city.' });
loom = await addEpisode(loom.id, { title: 'Pilot' });