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

fix: address FableLoom playback review

Adam Eivy88e7b4a2bf71
diff --git a/client/src/components/fableloom/LoomNodeEditor.jsx b/client/src/components/fableloom/LoomNodeEditor.jsx
index 70214ab7fe..d682a3f683 100644
--- a/client/src/components/fableloom/LoomNodeEditor.jsx
+++ b/client/src/components/fableloom/LoomNodeEditor.jsx
@@ -191,7 +191,8 @@ export default function LoomNodeEditor({ loom, episode, node, onLoomUpdate, onCl
// An existing rendered still seeds image-to-video when one is available.
await saveField('videoPrompt', form.videoPrompt);
const movement = FABLELOOM_CAMERA_MOVEMENTS.find((move) => move.value === form.cameraMovement);
- const prompt = movement ? `${authoredPrompt}\n\nCamera direction: ${movement.prompt}` : authoredPrompt;
+ const direction = movement?.prompt || form.cameraMovement.trim();
+ const prompt = direction ? `${authoredPrompt}\n\nCamera direction: ${direction}` : authoredPrompt;
await generateVideo({
prompt: loom.styleNotes ? `${prompt}\n\nStyle: ${loom.styleNotes}` : prompt,
backend: 'local',
diff --git a/client/src/components/fableloom/LoomPlayPanel.jsx b/client/src/components/fableloom/LoomPlayPanel.jsx
index 02c320b28c..d9cd70aa81 100644
--- a/client/src/components/fableloom/LoomPlayPanel.jsx
+++ b/client/src/components/fableloom/LoomPlayPanel.jsx
@@ -157,14 +157,6 @@ export default function LoomPlayPanel({ loom, episode: initialEpisode }) {
</select>
</div>
<div ref={scrollRef} className="flex-1 overflow-y-auto p-4 space-y-4">
- <SceneCard
- node={scene}
- isOpening={scene?.id === start.id}
- format={loom.format}
- previewMode={previewMode}
- onCutEnded={advanceCut}
- automaticCut={automaticCut}
- />
{transcript.map((turn, i) => {
if (turn.role === 'scene') return null;
return (
@@ -181,6 +173,14 @@ export default function LoomPlayPanel({ loom, episode: initialEpisode }) {
</div>
);
})}
+ <SceneCard
+ node={scene}
+ isOpening={scene?.id === start.id}
+ format={loom.format}
+ previewMode={previewMode}
+ onCutEnded={advanceCut}
+ automaticCut={automaticCut}
+ />
{ended && (
<div className="flex items-center gap-2 justify-center text-port-success text-sm font-medium py-2">
<Flag size={14} />
@@ -208,7 +208,7 @@ export default function LoomPlayPanel({ loom, episode: initialEpisode }) {
<button
type="button"
onClick={advanceCut}
- disabled={sending}
+ disabled={sending || (previewMode === 'video' && !!scene.videoHistoryId)}
className="w-full px-3 py-2 rounded bg-port-accent text-white text-sm disabled:opacity-50"
>
{sending ? 'Loading next cut…' : previewMode === 'video' && scene.videoHistoryId ? 'Video advances automatically' : 'Next cut'}
diff --git a/client/src/components/fableloom/LoomPlayPanel.test.jsx b/client/src/components/fableloom/LoomPlayPanel.test.jsx
index 8c578ebf4b..4070d1ac97 100644
--- a/client/src/components/fableloom/LoomPlayPanel.test.jsx
+++ b/client/src/components/fableloom/LoomPlayPanel.test.jsx
@@ -136,6 +136,8 @@ describe('LoomPlayPanel', () => {
render(<LoomPlayPanel loom={{ ...loom, episodes: [cutEpisode] }} episode={cutEpisode} />);
await user.selectOptions(screen.getByLabelText('Preview stage'), 'video');
+ expect(screen.getByRole('button', { name: 'Video advances automatically' })).toBeDisabled();
+
fireEvent.ended(screen.getByLabelText('Setup'));
await waitFor(() => expect(playLoomTurn).toHaveBeenCalledWith(
diff --git a/client/src/pages/FableLoomStory.jsx b/client/src/pages/FableLoomStory.jsx
index e774e26a6f..9a83820441 100644
--- a/client/src/pages/FableLoomStory.jsx
+++ b/client/src/pages/FableLoomStory.jsx
@@ -476,7 +476,7 @@ function EpisodeSetupDrawer({ open, onClose, loom, episode, onLoomUpdate, onFeed
</p>
{hasScenes && (
<p className="text-xs text-port-warning">
- Weaving replaces this episode's {episode.nodes.length} existing scene{episode.nodes.length === 1 ? '' : 's'}.
+ Weaving replaces this episode's {episode.nodes.length} existing scene{episode.nodes.length === 1 ? '' : 's'} and drops their rendered stills and video clips.
</p>
)}
<button
diff --git a/data.reference/prompts/stages/fableloom-branch-node.md b/data.reference/prompts/stages/fableloom-branch-node.md
index d9a34f01d9..8334096839 100644
--- a/data.reference/prompts/stages/fableloom-branch-node.md
+++ b/data.reference/prompts/stages/fableloom-branch-node.md
@@ -32,7 +32,7 @@ You are a branching-narrative designer growing new paths out of ONE scene of an
- A new scene may be an ending (`isEnding: true` + `endingLabel`) when the branch naturally concludes the story; otherwise write it as one continuous camera cut that ends at a decision point (its own paths will be authored later).
- Each new scene's `imagePrompt` is one sentence of concrete visual description.
- Each new scene's `videoPrompt` directs one renderable clip: visible action, one primary camera movement, pace, atmosphere, and final beat. Never put a cut or angle change inside it.
-- Set `playbackMode` to `cut` for a one-pass node with exactly one future Continue path, or `decision` for a seamlessly looping node that waits for viewer choice/feedback. A decision loop must depict repeatable ongoing action, not an irreversible beat.
+- Set `playbackMode` to `decision`: a newly branched node has no outgoing path yet, so it must wait for viewer choice/feedback. Its loop must depict repeatable ongoing action, not an irreversible beat.
- Choose `cameraMovement` from this vocabulary (the stable id before the parentheses):
{{cameraMovementCatalog}}
diff --git a/docs/features/fableloom.md b/docs/features/fableloom.md
index d2825fda17..a978f63968 100644
--- a/docs/features/fableloom.md
+++ b/docs/features/fableloom.md
@@ -149,6 +149,10 @@ the exactly-one-next-path contract for automatic cuts —
and renders in the editor's Structure panel via
`GET /api/fableloom/:id/episodes/:episodeId/validate`.
+Reweaving preserves story events and path meanings, but it replaces node ids;
+existing rendered stills and clips are therefore dropped. The setup drawer
+warns about that production cost before the author starts the reweave.
+
## Scene media
Each node carries an `imagePrompt`; **Generate** posts to the shared
diff --git a/scripts/migrations/288-fableloom-scene-format.js b/scripts/migrations/288-fableloom-scene-format.js
index 90cc2d54e6..abee5833ba 100644
--- a/scripts/migrations/288-fableloom-scene-format.js
+++ b/scripts/migrations/288-fableloom-scene-format.js
@@ -26,7 +26,7 @@ export const ACCEPTED_OLD_MD5 = {
// Post-change shipped hashes (format contract rendered from the loom record).
export const NEW_SHIPPED_MD5 = {
'fableloom-weave-episode.md': '4c9454d1537c4ebb3becbfa04fae3ed8',
- 'fableloom-branch-node.md': 'ff5d40b3090c775fc9c1f48c2ea96bbd',
+ 'fableloom-branch-node.md': 'c14e2b9c435e43a8c3b134a62cd66d08',
'fableloom-play-turn.md': 'e35ad91aae263e3adf28d1e047a46661',
};
diff --git a/scripts/migrations/310-fableloom-camera-cuts.js b/scripts/migrations/310-fableloom-camera-cuts.js
index e66b2523c6..ebabad322c 100644
--- a/scripts/migrations/310-fableloom-camera-cuts.js
+++ b/scripts/migrations/310-fableloom-camera-cuts.js
@@ -13,7 +13,7 @@ export const ACCEPTED_OLD_MD5 = {
export const NEW_SHIPPED_MD5 = {
'fableloom-weave-episode.md': '4c9454d1537c4ebb3becbfa04fae3ed8',
- 'fableloom-branch-node.md': 'ff5d40b3090c775fc9c1f48c2ea96bbd',
+ 'fableloom-branch-node.md': 'c14e2b9c435e43a8c3b134a62cd66d08',
'fableloom-feedback-episode.md': 'd09bb405478d24c294b0c658ef365cd1',
};
diff --git a/server/lib/fableLoomCameraMovements.js b/server/lib/fableLoomCameraMovements.js
index e790534916..ae4793e816 100644
--- a/server/lib/fableLoomCameraMovements.js
+++ b/server/lib/fableLoomCameraMovements.js
@@ -58,6 +58,16 @@ export const FABLELOOM_CAMERA_MOVEMENT_VALUES = Object.freeze(
FABLELOOM_CAMERA_MOVEMENTS.map(({ value }) => value),
);
+export const normalizeFableLoomCameraMovement = (raw) => {
+ if (typeof raw !== 'string') return '';
+ const candidate = raw.trim();
+ const normalized = candidate.toLowerCase();
+ const match = FABLELOOM_CAMERA_MOVEMENTS.find(({ value, label }) => (
+ value.toLowerCase() === normalized || label.toLowerCase() === normalized
+ ));
+ return match?.value || candidate;
+};
+
export const fableLoomCameraMovementCatalogForPrompt = () => FABLELOOM_CAMERA_MOVEMENTS
.map(({ value, label, prompt }) => `- ${value} (${label}): ${prompt}`)
.join('\n');
diff --git a/server/lib/fableLoomCameraMovements.test.js b/server/lib/fableLoomCameraMovements.test.js
index a73d40371f..b75771bd9e 100644
--- a/server/lib/fableLoomCameraMovements.test.js
+++ b/server/lib/fableLoomCameraMovements.test.js
@@ -4,6 +4,7 @@ import {
FABLELOOM_CAMERA_MOVEMENTS,
FABLELOOM_CAMERA_MOVEMENT_VALUES,
fableLoomCameraMovementCatalogForPrompt,
+ normalizeFableLoomCameraMovement,
} from './fableLoomCameraMovements.js';
describe('FableLoom camera movements', () => {
@@ -13,4 +14,10 @@ describe('FableLoom camera movements', () => {
expect(FABLELOOM_CAMERA_MOVEMENTS.every(({ value, label, prompt }) => value && label && prompt)).toBe(true);
expect(fableLoomCameraMovementCatalogForPrompt()).toContain('slider-parallax (Slider parallax)');
});
+
+ it('canonicalizes ids and labels while preserving custom directions', () => {
+ expect(normalizeFableLoomCameraMovement('SLOW-DOLLY-IN')).toBe('slow-dolly-in');
+ expect(normalizeFableLoomCameraMovement('Slow dolly in')).toBe('slow-dolly-in');
+ expect(normalizeFableLoomCameraMovement('gentle shoulder drift')).toBe('gentle shoulder drift');
+ });
});
diff --git a/server/lib/fableLoomGraph.js b/server/lib/fableLoomGraph.js
index d8ad6b2089..89a762f6fa 100644
--- a/server/lib/fableLoomGraph.js
+++ b/server/lib/fableLoomGraph.js
@@ -169,12 +169,14 @@ export function describeGraphForPrompt(episode, { proseLimit = 400 } = {}) {
const flags = [
node.id === episode?.startNodeId ? 'START' : null,
node?.isEnding ? `ENDING${isStr(node?.endingLabel) ? `: ${node.endingLabel}` : ''}` : null,
- node?.playbackMode === 'cut' ? 'AUTO CUT' : 'DECISION LOOP',
+ node?.isEnding ? null : (node?.playbackMode === 'cut' ? 'AUTO CUT' : 'DECISION LOOP'),
].filter(Boolean);
lines.push(`[${node.id}] ${node.title || 'Untitled scene'}${flags.length ? ` (${flags.join(') (')})` : ''}`);
const prose = typeof node.prose === 'string' ? node.prose.trim() : '';
if (prose) lines.push(prose.length > proseLimit ? `${prose.slice(0, proseLimit)}…` : prose);
- if (isStr(node.videoPrompt)) lines.push(`Video: ${node.videoPrompt}`);
+ if (isStr(node.videoPrompt)) {
+ lines.push(`Video: ${node.videoPrompt.length > proseLimit ? `${node.videoPrompt.slice(0, proseLimit)}…` : node.videoPrompt}`);
+ }
if (isStr(node.cameraMovement)) lines.push(`Camera movement: ${node.cameraMovement}`);
for (const tr of asArray(node.transitions)) {
const triggers = asArray(tr?.triggers).filter(isStr);
diff --git a/server/lib/fableLoomGraph.test.js b/server/lib/fableLoomGraph.test.js
index 05c9be0cc6..24f5d31e71 100644
--- a/server/lib/fableLoomGraph.test.js
+++ b/server/lib/fableLoomGraph.test.js
@@ -153,15 +153,19 @@ describe('describeGraphForPrompt', () => {
const text = describeGraphForPrompt(soundEpisode());
expect(text).toContain('[n1] The Gate (START)');
expect(text).toContain('[n4] The Vault (ENDING: Treasure found)');
+ expect(text).not.toContain('The Vault (ENDING: Treasure found) (DECISION LOOP)');
expect(text).toContain('-> [n2] intent "enter the gate"');
});
- it('truncates long prose at proseLimit', () => {
+ it('truncates long prose and video direction at proseLimit', () => {
const ep = soundEpisode();
ep.nodes[0].prose = 'x'.repeat(500);
+ ep.nodes[0].videoPrompt = 'y'.repeat(500);
const text = describeGraphForPrompt(ep, { proseLimit: 100 });
expect(text).toContain(`${'x'.repeat(100)}…`);
+ expect(text).toContain(`Video: ${'y'.repeat(100)}…`);
expect(text).not.toContain('x'.repeat(101));
+ expect(text).not.toContain('y'.repeat(101));
});
it('includes trigger examples', () => {
diff --git a/server/lib/fableLoomValidation.js b/server/lib/fableLoomValidation.js
index 46314d56b0..70825812d4 100644
--- a/server/lib/fableLoomValidation.js
+++ b/server/lib/fableLoomValidation.js
@@ -146,8 +146,6 @@ const llmPickFields = llmRoutePinSchema.shape;
export const weaveSchema = z.object({
guidance: z.string().max(4000).optional(),
- nodeTarget: z.number().int().min(3).max(60).optional(),
- endingTarget: z.number().int().min(1).max(12).optional(),
replace: z.boolean().optional(),
...llmPickFields,
});
diff --git a/server/routes/fableLoom.test.js b/server/routes/fableLoom.test.js
index d4e6eb5b61..52a7828e7a 100644
--- a/server/routes/fableLoom.test.js
+++ b/server/routes/fableLoom.test.js
@@ -221,17 +221,11 @@ describe('FableLoom routes', () => {
expect(response.body.issues).toEqual([]);
});
- it('POST weave validates bounds and forwards options', async () => {
- const invalid = await request(makeApp())
- .post('/api/fableloom/loom-1/episodes/ep-1/weave')
- .send({ nodeTarget: 999 });
- expect(invalid.status).toBe(400);
- expect(fableLoom.weaveEpisode).not.toHaveBeenCalled();
-
+ it('POST weave ignores legacy count hints and forwards current options', async () => {
fableLoom.weaveEpisode.mockResolvedValueOnce({ loom: { id: 'loom-1' }, runId: 'r' });
const ok = await request(makeApp())
.post('/api/fableloom/loom-1/episodes/ep-1/weave')
- .send({ guidance: 'darker', replace: true });
+ .send({ guidance: 'darker', replace: true, nodeTarget: 999, endingTarget: 999 });
expect(ok.status).toBe(200);
expect(fableLoom.weaveEpisode).toHaveBeenCalledWith('loom-1', 'ep-1', { guidance: 'darker', replace: true });
});
diff --git a/server/services/fableLoom/records.js b/server/services/fableLoom/records.js
index 80d7e0123c..70068449be 100644
--- a/server/services/fableLoom/records.js
+++ b/server/services/fableLoom/records.js
@@ -28,6 +28,7 @@ import {
import { LOOM_LIMITS } from './limits.js';
import { asLoomFormat, isLoomFormat } from './formats.js';
import { asFableLoomPlaybackMode } from '../../lib/fableLoomPlayback.js';
+import { normalizeFableLoomCameraMovement } from '../../lib/fableLoomCameraMovements.js';
export { LOOM_LIMITS };
@@ -70,7 +71,7 @@ function sanitizeNode(raw) {
image: isSafeImageFilename(raw.image) ? raw.image : null,
imageJobId: isStr(raw.imageJobId) && raw.imageJobId ? raw.imageJobId.slice(0, 200) : null,
videoPrompt: trimTo(raw.videoPrompt, LOOM_LIMITS.VIDEO_PROMPT_MAX),
- cameraMovement: trimTo(raw.cameraMovement, LOOM_LIMITS.CAMERA_MOVEMENT_MAX),
+ cameraMovement: trimTo(normalizeFableLoomCameraMovement(raw.cameraMovement), LOOM_LIMITS.CAMERA_MOVEMENT_MAX),
playbackMode: asFableLoomPlaybackMode(raw.playbackMode),
videoHistoryId: isSafeVideoHistoryId(raw.videoHistoryId) ? raw.videoHistoryId : null,
isEnding: raw.isEnding === true,
diff --git a/server/services/fableLoom/weave.js b/server/services/fableLoom/weave.js
index 211f3f0efd..9cef9a8596 100644
--- a/server/services/fableLoom/weave.js
+++ b/server/services/fableLoom/weave.js
@@ -20,6 +20,7 @@ import { resolveLlmRoutePin } from '../../lib/llmRoutePin.js';
import { renderCanonForPrompt } from '../../lib/universePromptRenderers.js';
import { analyzeEpisodeGraph, describeGraphForPrompt } from '../../lib/fableLoomGraph.js';
import { fableLoomCameraMovementCatalogForPrompt } from '../../lib/fableLoomCameraMovements.js';
+import { isFableLoomPlaybackMode } from '../../lib/fableLoomPlayback.js';
import { getUniverse } from '../universeBuilder.js';
import { LOOM_LIMITS, findEpisode, findNode, getLoom, mutateLoom } from './records.js';
import { asLoomFormat, loomFormatLabel, narrationFormatContract, sceneFormatContract } from './formats.js';
@@ -194,7 +195,7 @@ export async function weaveEpisode(loomId, episodeId, {
canonDigest: canonDigest || '(none — invent what the story needs)',
guidance: guidance || '(none)',
existingGraph: episode.nodes.length
- ? describeGraphForPrompt(episode, { proseLimit: 4000 })
+ ? describeGraphForPrompt(episode, { proseLimit: 1200 })
: '(none — create the episode from the story context)',
cameraMovementCatalog: fableLoomCameraMovementCatalogForPrompt(),
sceneFormatContract: sceneFormatContract(loom.format),
@@ -249,7 +250,14 @@ export async function branchNode(loomId, episodeId, nodeId, {
source.playbackMode = 'decision';
for (const branch of branches) {
if (ep.nodes.length >= LOOM_LIMITS.NODES_MAX) break;
- const newNode = { id: `node-${randomUUID()}`, ...generatedNodeFields(branch.node), format: asLoomFormat(loom.format), transitions: [], pos: null };
+ const newNode = {
+ id: `node-${randomUUID()}`,
+ ...generatedNodeFields(branch.node),
+ playbackMode: 'decision',
+ format: asLoomFormat(loom.format),
+ transitions: [],
+ pos: null,
+ };
ep.nodes.push(newNode);
source.transitions = [...(source.transitions || []), {
targetNodeId: newNode.id,
@@ -300,7 +308,7 @@ export async function reviewEpisode(loomId, episodeId, { providerId, model, effo
const FEEDBACK_NODE_FIELDS = ['title', 'prose', 'imagePrompt', 'videoPrompt', 'cameraMovement', 'playbackMode', 'isEnding', 'endingLabel'];
const FEEDBACK_TRANSITION_FIELDS = ['targetNodeId', 'intent', 'triggers', 'description'];
-const FEEDBACK_STRING_NODE_FIELDS = new Set(['title', 'prose', 'imagePrompt', 'videoPrompt', 'cameraMovement', 'playbackMode', 'endingLabel']);
+const FEEDBACK_STRING_NODE_FIELDS = new Set(['title', 'prose', 'imagePrompt', 'videoPrompt', 'cameraMovement', 'endingLabel']);
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
@@ -328,6 +336,8 @@ const normalizeFeedbackPatch = (content, episode) => {
if (!hasOwn(rawScene, key)) continue;
if (FEEDBACK_STRING_NODE_FIELDS.has(key) && typeof value === 'string') {
nodePatch[key] = value;
+ } else if (key === 'playbackMode' && isFableLoomPlaybackMode(value)) {
+ nodePatch[key] = value;
} else if (key === 'isEnding' && typeof value === 'boolean') {
nodePatch[key] = value;
}
diff --git a/server/services/fableLoom/weave.test.js b/server/services/fableLoom/weave.test.js
index 8f0a9f0fd7..18cf42acea 100644
--- a/server/services/fableLoom/weave.test.js
+++ b/server/services/fableLoom/weave.test.js
@@ -147,6 +147,7 @@ describe('branchNode', () => {
expect(source.transitions.map((t) => t.intent)).toEqual(['scale the wall', 'bribe the guard']);
const ending = ep.nodes.find((n) => n.title === 'A Deal');
expect(ending).toMatchObject({ isEnding: true, endingLabel: 'Bought passage' });
+ expect(ep.nodes.filter((n) => n.id !== nodeId).every((n) => n.playbackMode === 'decision')).toBe(true);
});
it('rejects when the model returns no usable branches', async () => {
@@ -240,6 +241,19 @@ describe('feedbackEpisode', () => {
id: withNode.episodes[0].nodes[0].id, title: 'Opening', prose: 'Original.',
});
});
+
+ it('preserves playback mode when feedback returns an invalid placeholder', async () => {
+ const { loomId, episodeId } = await setup();
+ const withNode = await addNode(loomId, episodeId, { title: 'Opening', playbackMode: 'cut' });
+ const nodeId = withNode.episodes[0].nodes[0].id;
+ runStagedLLM.mockResolvedValue({
+ content: { scenes: [{ id: nodeId, playbackMode: 'cut or decision, only when changed', title: 'Revised' }] },
+ });
+
+ const result = await feedbackEpisode(loomId, episodeId, { feedback: 'Revise the title.' });
+
+ expect(result.loom.episodes[0].nodes[0]).toMatchObject({ title: 'Revised', playbackMode: 'cut' });
+ });
});
describe('playTurn', () => {