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

render mood board text notes into images, and have autopilot render its board notes

[._.]/ Adam Eivyacd3e9e7f644
diff --git a/client/src/pages/MoodBoardDetail.jsx b/client/src/pages/MoodBoardDetail.jsx
index 8509318366..564bbb4416 100644
--- a/client/src/pages/MoodBoardDetail.jsx
+++ b/client/src/pages/MoodBoardDetail.jsx
@@ -11,7 +11,7 @@
import { useEffect, useState, useCallback, useMemo, useRef } from 'react';
import { useParams, useNavigate, Link } from 'react-router';
-import { ArrowLeft, ImageIcon, FileText, Trash2, Plus, Save, Link2, Unlink, RefreshCw, Images, Film, Play, ScanEye, Copy, AtSign, Download, Sparkles, Clapperboard } from 'lucide-react';
+import { ArrowLeft, ImageIcon, FileText, Trash2, Plus, Save, Link2, Unlink, RefreshCw, Images, Film, Play, ScanEye, Copy, AtSign, Download, Sparkles, Clapperboard, Paintbrush } from 'lucide-react';
import PageSkeleton from '../components/ui/PageSkeleton';
import toast from '../components/ui/Toast';
import TabPills from '../components/ui/TabPills';
@@ -37,7 +37,9 @@ import {
importMoodBoardXPost,
localizeMoodBoardMedia,
extractMoodBoardItemFrames,
+ renderMoodBoardItem,
} from '../services/api';
+import socket from '../services/socket';
import { moodBoardItemSrc, moodBoardItemVideoSrc, moodBoardItemAnalysisSource } from '../lib/moodBoardItemSrc';
import {
moodBoardAnalysisFromResult,
@@ -86,6 +88,12 @@ function MoodBoardEditor({ id }) {
const [frameCount, setFrameCount] = useState(4);
const [extractingItemId, setExtractingItemId] = useState(null);
+ // Text note → image render (#10531): the note whose request is in flight.
+ // The queued state itself lives on the item (`item.render`).
+ const [renderingItemId, setRenderingItemId] = useState(null);
+ // The request already toasts its own refusal; the echoed socket event must not.
+ const renderRequestRef = useRef(null);
+
// Pinterest link/sync.
const [pinUrl, setPinUrl] = useState('');
const [linking, setLinking] = useState(false);
@@ -136,6 +144,20 @@ function MoodBoardEditor({ id }) {
useEffect(() => { load(); }, [load]);
+ // A note render was queued, finished or failed — possibly started by
+ // autopilot or another tab — so swap in the board's current items.
+ useEffect(() => {
+ const onRender = async (evt) => {
+ if (evt?.boardId !== id) return;
+ const fresh = await getMoodBoard(id, { silent: true }).catch(() => null);
+ if (!mountedRef.current || !fresh) return;
+ setBoard((prev) => (prev ? { ...prev, items: fresh.items, updatedAt: fresh.updatedAt } : fresh));
+ if (evt.status === 'failed' && evt.error && renderRequestRef.current !== evt.itemId) toast.error(`Render failed: ${evt.error}`);
+ };
+ socket.on('mood-board:item-render', onRender);
+ return () => socket.off('mood-board:item-render', onRender);
+ }, [id, mountedRef]);
+
const metaDirty = board && (name.trim() !== (board.name || '') || description !== (board.description || ''));
// The item under analysis (#4188 Phase 3), re-derived from board state so the
@@ -313,6 +335,21 @@ function MoodBoardEditor({ id }) {
toast.success(res.added ? `Added ${res.added} frame${res.added === 1 ? '' : 's'} to the board` : 'Those frames are already on the board');
};
+ const handleRenderItem = async (itemId) => {
+ if (!mountedRef.current) return;
+ setRenderingItemId(itemId);
+ renderRequestRef.current = itemId;
+ const res = await renderMoodBoardItem(id, itemId, { silent: true })
+ .catch((err) => { toast.error(err?.message || 'Could not render this note'); return null; });
+ renderRequestRef.current = null;
+ if (!mountedRef.current) return;
+ setRenderingItemId(null);
+ if (!res?.item) return;
+ setBoard((prev) => (prev
+ ? { ...prev, items: (prev.items || []).map((it) => (it.id === itemId && it.type === 'text' ? res.item : it)) }
+ : prev));
+ };
+
const handleRemoveItem = async (itemId) => {
if (!mountedRef.current) return;
setConfirmingItemId(null);
@@ -603,6 +640,15 @@ function MoodBoardEditor({ id }) {
</div>
)}
+ {item.type === 'text' && item.render?.status === 'queued' ? (
+ <div
+ data-testid="item-rendering"
+ className="absolute inset-x-0 bottom-0 flex items-center justify-center gap-1.5 bg-black/60 py-1.5 text-xs text-white"
+ >
+ <Paintbrush className="w-3.5 h-3.5 animate-pulse" aria-hidden="true" /> Rendering…
+ </div>
+ ) : null}
+
{/* Status indicator: whether it has been analyzed (or already has a prompt) */}
{(isAnalyzed || hasPrompt) && (
<div className="absolute top-1.5 right-1.5 flex flex-col items-end gap-1 pointer-events-none z-10">
@@ -669,6 +715,11 @@ function MoodBoardEditor({ id }) {
{item.source ? (
<span className="min-w-0 text-[10px] text-gray-500 truncate" title={item.source}>{item.source}</span>
) : null}
+ {item.type === 'text' && item.render?.status === 'failed' ? (
+ <span className="min-w-0 text-[10px] text-port-error break-words">
+ Render failed{item.render.error ? `: ${item.render.error}` : ''}
+ </span>
+ ) : null}
<div className="flex flex-wrap items-center justify-end gap-1">
{/* Keep the frame count with its extraction action when wrapping. */}
{videoSrc ? (
@@ -694,6 +745,18 @@ function MoodBoardEditor({ id }) {
</button>
</span>
) : null}
+ {item.type === 'text' ? (
+ <button
+ type="button"
+ onClick={() => handleRenderItem(item.id)}
+ disabled={renderingItemId === item.id || item.render?.status === 'queued'}
+ title="Render this note as an image on the default image backend"
+ className="min-h-[44px] shrink-0 inline-flex items-center gap-1.5 px-2 mr-auto text-xs text-gray-300 hover:text-white disabled:opacity-50 transition-colors"
+ >
+ <Paintbrush className={`w-3.5 h-3.5 ${renderingItemId === item.id ? 'animate-pulse' : ''}`} aria-hidden="true" />
+ {item.render?.status === 'queued' ? 'Rendering…' : 'Render'}
+ </button>
+ ) : null}
{analysisSource ? (
<button
type="button"
diff --git a/client/src/pages/MoodBoardDetail.test.jsx b/client/src/pages/MoodBoardDetail.test.jsx
index 70bff21a52..d0535ce346 100644
--- a/client/src/pages/MoodBoardDetail.test.jsx
+++ b/client/src/pages/MoodBoardDetail.test.jsx
@@ -13,6 +13,15 @@ const mockSyncMoodBoardPinterest = vi.fn();
const mockImportMoodBoardPinterest = vi.fn();
const mockImportMoodBoardXPost = vi.fn();
const mockLocalizeMoodBoardMedia = vi.fn();
+const mockRenderMoodBoardItem = vi.fn();
+const socketHandlers = new Map();
+
+vi.mock('../services/socket', () => ({
+ default: {
+ on: (evt, fn) => socketHandlers.set(evt, fn),
+ off: (evt) => socketHandlers.delete(evt),
+ },
+}));
vi.mock('../services/api', () => ({
getMoodBoard: (...args) => mockGetMoodBoard(...args),
@@ -26,6 +35,7 @@ vi.mock('../services/api', () => ({
importMoodBoardPinterest: (...args) => mockImportMoodBoardPinterest(...args),
importMoodBoardXPost: (...args) => mockImportMoodBoardXPost(...args),
localizeMoodBoardMedia: (...args) => mockLocalizeMoodBoardMedia(...args),
+ renderMoodBoardItem: (...args) => mockRenderMoodBoardItem(...args),
}));
const mockToastError = vi.fn();
@@ -651,3 +661,36 @@ describe('MoodBoardDetail desktop layout', () => {
expect(addAside).toContainElement(screen.getByRole('button', { name: 'Import' }));
});
});
+
+describe('MoodBoardDetail note render', () => {
+ it('renders a text note and swaps in the image when the render event lands', async () => {
+ const note = { id: 'n1', type: 'text', text: 'Palette: violet and cyan' };
+ mockGetMoodBoard.mockResolvedValueOnce({ id: 'a', name: 'Board A', items: [note] });
+ mockRenderMoodBoardItem.mockResolvedValueOnce({
+ jobId: 'job-1', item: { ...note, render: { status: 'queued', jobId: 'job-1', error: null } },
+ });
+ renderPage();
+ fireEvent.click(await screen.findByRole('button', { name: 'Render' }));
+ expect(mockRenderMoodBoardItem).toHaveBeenCalledWith('a', 'n1', { silent: true });
+ expect(await screen.findByRole('button', { name: 'Rendering…' })).toBeDisabled();
+ expect(screen.getByTestId('item-rendering')).toBeInTheDocument();
+
+ mockGetMoodBoard.mockResolvedValueOnce({
+ id: 'a', name: 'Board A',
+ items: [{ id: 'n1', type: 'image', mediaKey: 'image:job-1.png', caption: note.text }],
+ });
+ await act(async () => { await socketHandlers.get('mood-board:item-render')({ boardId: 'a', itemId: 'n1', status: 'done' }); });
+ expect(await screen.findByRole('button', { name: 'Preview image' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /^Render/ })).toBeNull();
+ });
+
+ it('shows why a render failed and offers it again', async () => {
+ mockGetMoodBoard.mockResolvedValueOnce({
+ id: 'a', name: 'Board A',
+ items: [{ id: 'n1', type: 'text', text: 'Motif', render: { status: 'failed', jobId: 'j', error: 'out of memory' } }],
+ });
+ renderPage();
+ expect(await screen.findByText('Render failed: out of memory')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Render' })).toBeEnabled();
+ });
+});
diff --git a/client/src/services/apiMoodBoard.js b/client/src/services/apiMoodBoard.js
index c4aaa566ec..2c528a78b8 100644
--- a/client/src/services/apiMoodBoard.js
+++ b/client/src/services/apiMoodBoard.js
@@ -140,3 +140,13 @@ export const extractMoodBoardItemFrames = (id, itemId, count, options) =>
body: JSON.stringify({ count }),
...options,
});
+
+// Render a text note into an image (#10531) on the install's default image
+// backend. Resolves to `{ item, jobId }` once queued; the note becomes an image
+// item when the job completes (`mood-board:item-render` follows it).
+export const renderMoodBoardItem = (id, itemId, options) =>
+ request(`/mood-boards/${encodeURIComponent(id)}/items/${encodeURIComponent(itemId)}/render`, {
+ method: 'POST',
+ body: JSON.stringify({}),
+ ...options,
+ });
diff --git a/server/lib/moodBoardValidation.js b/server/lib/moodBoardValidation.js
index 69f69a0c7f..fb6b8821bc 100644
--- a/server/lib/moodBoardValidation.js
+++ b/server/lib/moodBoardValidation.js
@@ -197,3 +197,10 @@ export const moodBoardCollageSchema = z.object({
export const moodBoardExtractFramesSchema = z.object({
count: z.number().int().min(1).max(24),
}).strict();
+
+// Render a text note into an image (#10531). Both optional: an omitted backend
+// renders on the install's default image backend.
+export const moodBoardItemRenderSchema = z.object({
+ mode: z.string().trim().min(1).max(32).optional(),
+ model: z.string().trim().min(1).max(256).optional(),
+}).strict();
diff --git a/server/lib/socketEventContracts.js b/server/lib/socketEventContracts.js
index 220adf4647..242bc6d7ba 100644
--- a/server/lib/socketEventContracts.js
+++ b/server/lib/socketEventContracts.js
@@ -357,6 +357,21 @@ export const SOCKET_EVENT_CONTRACTS = Object.freeze({
additionalProperties: false,
},
},
+ 'mood-board:item-render': {
+ direction: 'server-to-client',
+ summary: 'A mood board text note render was queued, finished (the note is now an image item) or failed; reload the board.',
+ payloadSchema: {
+ type: 'object',
+ properties: {
+ boardId: { type: 'string' },
+ itemId: { type: 'string' },
+ status: { type: 'string', enum: ['queued', 'done', 'failed'] },
+ error: { type: 'string' },
+ },
+ required: ['boardId', 'itemId', 'status'],
+ additionalProperties: false,
+ },
+ },
'brain:changed': {
direction: 'server-to-client',
summary: 'Invalidate Brain summary/settings after a persisted change.',
diff --git a/server/routes/moodBoard.js b/server/routes/moodBoard.js
index 9b81f1b52a..7267a5b2bd 100644
--- a/server/routes/moodBoard.js
+++ b/server/routes/moodBoard.js
@@ -20,6 +20,7 @@ import {
moodBoardXPostImportSchema,
moodBoardCollageSchema,
moodBoardExtractFramesSchema,
+ moodBoardItemRenderSchema,
isPaginationRequested,
paginateArray,
} from '../lib/validation.js';
@@ -47,6 +48,7 @@ import {
localizeBoardMedia,
composeBoardCollage,
extractItemFrames,
+ renderBoardItem,
} from '../services/moodBoard/index.js';
const router = Router();
@@ -103,6 +105,13 @@ router.patch('/:id/items/:itemId', asyncHandler(async (req, res) => {
res.json(item);
}));
+// Render a text note into an image (#10531). 202: the job is queued; the note
+// becomes an image item when it completes (mood-board:item-render follows it).
+router.post('/:id/items/:itemId/render', asyncHandler(async (req, res) => {
+ const route = validateRequest(moodBoardItemRenderSchema, req.body ?? {});
+ res.status(202).json(await renderBoardItem(req.params.id, req.params.itemId, route));
+}));
+
router.delete('/:id/items/:itemId', asyncHandler(async (req, res) => {
const board = await removeBoardItem(req.params.id, req.params.itemId);
res.json(board);
diff --git a/server/routes/moodBoard.test.js b/server/routes/moodBoard.test.js
index f157190463..67cdf2c1f8 100644
--- a/server/routes/moodBoard.test.js
+++ b/server/routes/moodBoard.test.js
@@ -22,6 +22,7 @@ vi.mock('../services/moodBoard/index.js', () => ({
importXPost: vi.fn(),
composeBoardCollage: vi.fn(),
extractItemFrames: vi.fn(),
+ renderBoardItem: vi.fn(),
}));
// The synthesis service pulls the aiProvider/promptRunner stack — stub it so
@@ -206,5 +207,13 @@ describe('mood-board routes', () => {
expect(svc.extractItemFrames).toHaveBeenCalledWith('mb-1', 'i1', { count: 4 });
expect((await request(makeApp()).post('/api/mood-boards/mb-1/items/i1/extract-frames').send({})).status).toBe(400);
});
+
+ it('queues a note render (202) on an optional backend pin', async () => {
+ svc.renderBoardItem.mockResolvedValueOnce({ jobId: 'job-1', item: { id: 'i1' } });
+ const ok = await request(makeApp()).post('/api/mood-boards/mb-1/items/i1/render').send({});
+ expect(ok.status).toBe(202);
+ expect(svc.renderBoardItem).toHaveBeenCalledWith('mb-1', 'i1', {});
+ expect((await request(makeApp()).post('/api/mood-boards/mb-1/items/i1/render').send({ target: 'deck' })).status).toBe(400);
+ });
});
});
diff --git a/server/services/bootstrap.js b/server/services/bootstrap.js
index 01eb664c51..1c1408c9f3 100644
--- a/server/services/bootstrap.js
+++ b/server/services/bootstrap.js
@@ -158,6 +158,7 @@ import { initCreativeDirectorMusicBedHook } from './creativeDirectorMusicBedHook
import { initMusicStudioHook } from './musicStudioHook.js';
import { initImageGenQuotaHook } from './imageGenQuota.js';
import { initSpriteReferenceImageHook } from './spriteReferenceImageHook.js';
+import { initMoodBoardItemRenderHook } from './moodBoardItemRenderHook.js';
import { initDeckRenderHook } from './deckRenderHook.js';
import { initCreativeDirectorSceneImageHook } from './creativeDirectorSceneImageHook.js';
import { initCreativeDirectorRenderFailureHook } from './creativeDirector/renderFailureHook.js';
@@ -718,6 +719,9 @@ const initMediaJobDependentHooks = () => {
// render into the sprite record's reference/candidates/ with a generation
// sidecar (#2896).
initSpriteReferenceImageHook();
+ // Mood board note render hook — turns a rendered text note into its image
+ // item (#10531). It only listens.
+ initMoodBoardItemRenderHook();
// Deck card hook — files a completed card render onto its deck card row.
initDeckRenderHook();
// Creative Director scene-frame hook — durably files a queued first-pass
diff --git a/server/services/moodBoard/db.js b/server/services/moodBoard/db.js
index 391168041f..6c0d185eab 100644
--- a/server/services/moodBoard/db.js
+++ b/server/services/moodBoard/db.js
@@ -31,6 +31,9 @@ import {
addItem,
updateItem,
removeItem,
+ claimItemRender,
+ settleItemRender,
+ applyRenderedItem,
mergeBoardRecord,
applyPinterestLink,
healPinterestFeedRecord,
@@ -248,6 +251,32 @@ export async function updateBoardItem(id, itemId, patch) {
return result;
}
+// Text note render lifecycle (#10531) — see the logic.js transforms. The two
+// settle steps skip the write when the note moved on (stale job).
+export async function claimBoardItemRender(id, itemId, opts) {
+ const { result } = await withLockedBoard(id, (b) => {
+ const { board, item } = claimItemRender(b, itemId, opts);
+ return { board, result: item };
+ });
+ return result;
+}
+
+export async function settleBoardItemRender(id, itemId, patch) {
+ const { result } = await withLockedBoard(id, (b) => {
+ const { board, item, changed } = settleItemRender(b, itemId, patch);
+ return { board, result: changed ? item : null, skipPersist: !changed };
+ });
+ return result;
+}
+
+export async function applyBoardItemRender(id, itemId, rendered) {
+ const { result } = await withLockedBoard(id, (b) => {
+ const { board, item, changed } = applyRenderedItem(b, itemId, rendered);
+ return { board, result: changed ? item : null, skipPersist: !changed };
+ });
+ return result;
+}
+
// ─── Pinterest board link (mood-board importer) ──────────────────────────────
// Link (or re-link) the board to a Pinterest RSS feed.
diff --git a/server/services/moodBoard/index.js b/server/services/moodBoard/index.js
index 55e3ea387c..4df1910a19 100644
--- a/server/services/moodBoard/index.js
+++ b/server/services/moodBoard/index.js
@@ -52,6 +52,9 @@ export { localizeBoardMedia } from './localize.js';
// Collage compilation + video frame extraction (fires its own federation emits).
export { composeBoardCollage, extractItemFrames } from './collage.js';
+// Render a text note into an image (#10531); the completion hook converts it.
+export { renderBoardItem } from './renderItem.js';
+
// Announce a newly-created board to the per-record peer-sync pipeline: emit the
// 'updated' event so any existing subscription pushes it, AND auto-subscribe
// every moodBoards-enabled peer so brand-new boards (and their later tombstones)
diff --git a/server/services/moodBoard/logic.js b/server/services/moodBoard/logic.js
index 1d2c144844..1bc7513a4d 100644
--- a/server/services/moodBoard/logic.js
+++ b/server/services/moodBoard/logic.js
@@ -278,6 +278,87 @@ export function updateItem(board, itemId, patch) {
return { board: next, item: updated };
}
+// ─── Text note → image render (#10531) ───────────────────────────────────────
+// A text note can be rendered into an image. While the job runs the note carries
+// `render: { status, jobId, error, queuedAt }`; when it completes the note turns
+// into an image item in place (same id and position) — the one sanctioned type
+// change, since the render IS the note's visual form.
+
+function findItemIndex(board, itemId) {
+ const items = Array.isArray(board.items) ? board.items : [];
+ const idx = items.findIndex((it) => it && it.id === itemId);
+ if (idx === -1) throw new ServerError('Item not found', { status: 404, code: 'NOT_FOUND' });
+ return { items, idx };
+}
+
+function replaceItem(board, items, idx, item) {
+ const nextItems = [...items];
+ nextItems[idx] = item;
+ return { ...board, items: nextItems, updatedAt: nowIso() };
+}
+
+// Mark a text note queued before its job is enqueued, so a second click (or an
+// autopilot retry) can't queue a duplicate. `isLive(jobId)` says whether an
+// earlier render's job is still queued/running; a dead one may be replaced. A
+// claim that never got its job id (the process died mid-enqueue) expires.
+const RENDER_CLAIM_TTL_MS = 10 * 60 * 1000;
+
+export function claimItemRender(board, itemId, { isLive = () => false, now = nowIso() } = {}) {
+ const { items, idx } = findItemIndex(board, itemId);
+ const current = items[idx];
+ if (current.type !== 'text') {
+ throw new ServerError('Only a text note can be rendered', { status: 409, code: 'MOOD_BOARD_ITEM_NOT_TEXT' });
+ }
+ const render = current.render;
+ const pending = render?.status === 'queued' && (render.jobId
+ ? isLive(render.jobId)
+ : Date.parse(now) - Date.parse(render.queuedAt) < RENDER_CLAIM_TTL_MS);
+ if (pending) {
+ throw new ServerError('This note is already rendering', { status: 409, code: 'MOOD_BOARD_RENDER_BUSY' });
+ }
+ const item = { ...current, render: { status: 'queued', jobId: null, error: null, queuedAt: now } };
+ return { board: replaceItem(board, items, idx, item), item };
+}
+
+// Record the queued job id, or a failure. Applies only while the note is still
+// the text item this render claimed: a job that already finished (the note is
+// now an image) or a newer claim (a different jobId) leaves the board untouched.
+export function settleItemRender(board, itemId, { jobId, status, error = null }) {
+ const { items, idx } = findItemIndex(board, itemId);
+ const current = items[idx];
+ const render = current.render;
+ if (current.type !== 'text' || !render || (render.jobId && render.jobId !== jobId)) {
+ return { board, item: current, changed: false };
+ }
+ const item = { ...current, render: { ...render, jobId: jobId ?? render.jobId, status, error } };
+ return { board: replaceItem(board, items, idx, item), item, changed: true };
+}
+
+// Turn the rendered note into an image item. The note text becomes the caption
+// (the schema's caption bound) and the submitted prompt the item prompt, so the
+// board's analyze step skips it. Skips a stale job, as settleItemRender does.
+export function applyRenderedItem(board, itemId, { jobId, filename, prompt }) {
+ const { items, idx } = findItemIndex(board, itemId);
+ const current = items[idx];
+ const render = current.render;
+ if (current.type !== 'text' || !render || (render.jobId && render.jobId !== jobId)) {
+ return { board, item: current, changed: false };
+ }
+ const item = {
+ id: current.id,
+ type: 'image',
+ mediaKey: `image:${filename}`,
+ imageUrl: null,
+ text: null,
+ prompt: isStr(prompt) && prompt.trim() ? prompt.trim().slice(0, 8000) : null,
+ caption: current.text.slice(0, 2000),
+ source: current.source ?? null,
+ createdAt: current.createdAt,
+ renderedAt: nowIso(),
+ };
+ return { board: replaceItem(board, items, idx, item), item, changed: true };
+}
+
// Remove an item by id. Returns `removed: false` (no write) when the id is
// absent so the db layer can skip a wasted row rewrite.
export function removeItem(board, itemId) {
diff --git a/server/services/moodBoard/logic.test.js b/server/services/moodBoard/logic.test.js
index bb2dc43e49..b4561ba32a 100644
--- a/server/services/moodBoard/logic.test.js
+++ b/server/services/moodBoard/logic.test.js
@@ -23,6 +23,9 @@ import {
appendImportedItems,
externalImageItems,
applyLocalizedImageUrls,
+ claimItemRender,
+ settleItemRender,
+ applyRenderedItem,
} from './logic.js';
describe('buildBoardRecord', () => {
@@ -539,3 +542,44 @@ describe('re-hosting external media', () => {
expect(applyLocalizedImageUrls(b, [{ id: 'zzz', from: 'x', to: 'y' }])).toEqual({ board: b, changed: 0 });
});
});
+
+describe('text note render lifecycle (#10531)', () => {
+ const note = { id: 'n1', type: 'text', text: 'Palette: violet and cyan', caption: null, source: 'autonomous music video', createdAt: '2026-01-01T00:00:00.000Z' };
+ const board = () => ({ id: 'mb-1', items: [{ id: 'i0', type: 'image', mediaKey: 'image:a.png' }, note, { id: 'n2', type: 'text', text: 'Motif' }] });
+
+ it('turns the claimed note into an image in place, keeping its words as the caption', () => {
+ const claimed = claimItemRender(board(), 'n1').board;
+ const queued = settleItemRender(claimed, 'n1', { jobId: 'job-1', status: 'queued' }).board;
+ const { board: done, item, changed } = applyRenderedItem(queued, 'n1', { jobId: 'job-1', filename: 'job-1.png', prompt: ' the prompt ' });
+ expect(changed).toBe(true);
+ expect(done.items.map((it) => it.id)).toEqual(['i0', 'n1', 'n2']);
+ expect(item).toMatchObject({
+ id: 'n1', type: 'image', mediaKey: 'image:job-1.png', text: null, prompt: 'the prompt',
+ caption: note.text, source: note.source, createdAt: note.createdAt,
+ });
+ expect(item.render).toBeUndefined();
+ });
+
+ it('drops a stale job once a newer render owns the note', () => {
+ const queued = settleItemRender(claimItemRender(board(), 'n1').board, 'n1', { jobId: 'job-2', status: 'queued' }).board;
+ expect(applyRenderedItem(queued, 'n1', { jobId: 'job-1', filename: 'job-1.png' }).changed).toBe(false);
+ expect(settleItemRender(queued, 'n1', { jobId: 'job-1', status: 'failed', error: 'x' }).changed).toBe(false);
+ });
+
+ it('refuses a duplicate render while the job lives, and replaces a dead one', () => {
+ const queued = settleItemRender(claimItemRender(board(), 'n1').board, 'n1', { jobId: 'job-1', status: 'queued' }).board;
+ expect(() => claimItemRender(queued, 'n1', { isLive: () => true })).toThrow(expect.objectContaining({ code: 'MOOD_BOARD_RENDER_BUSY' }));
+ expect(claimItemRender(queued, 'n1', { isLive: () => false }).item.render).toMatchObject({ status: 'queued', jobId: null });
+ });
+
+ it('expires a claim that never got its job id', () => {
+ const claimed = claimItemRender(board(), 'n1', { now: '2026-01-01T00:00:00.000Z' }).board;
+ expect(() => claimItemRender(claimed, 'n1', { now: '2026-01-01T00:05:00.000Z' })).toThrow(expect.objectContaining({ code: 'MOOD_BOARD_RENDER_BUSY' }));
+ expect(claimItemRender(claimed, 'n1', { now: '2026-01-01T00:11:00.000Z' }).item.render.queuedAt).toBe('2026-01-01T00:11:00.000Z');
+ });
+
+ it('only renders text notes', () => {
+ expect(() => claimItemRender(board(), 'i0')).toThrow(expect.objectContaining({ code: 'MOOD_BOARD_ITEM_NOT_TEXT' }));
+ expect(() => claimItemRender(board(), 'missing')).toThrow(expect.objectContaining({ code: 'NOT_FOUND' }));
+ });
+});
diff --git a/server/services/moodBoard/renderItem.js b/server/services/moodBoard/renderItem.js
new file mode 100644
index 0000000000..9ea5ccced7
--- /dev/null
+++ b/server/services/moodBoard/renderItem.js
@@ -0,0 +1,125 @@
+/**
+ * Render a mood board text note into an image (#10531).
+ *
+ * A board built from words alone (the autonomous Music Video brief writes one)
+ * shows nothing visual. This queues an image job for a text note — the note's
+ * words plus the board's composed style — and the completion hook
+ * (moodBoardItemRenderHook.js) turns the note into an image item in place.
+ *
+ * The backend is the caller's pin when given, else the render target's saved
+ * default, else the install's default image backend. Only queueable backends
+ * (local + the cloud lanes) apply: the completion hook rides the media queue.
+ */
+
+import { ServerError } from '../../lib/errorHandler.js';
+import { QUEUEABLE_IMAGE_MODES } from '../../lib/generationModes.js';
+import { isNonBlankStr } from '../../lib/textUtils.js';
+import { emitRecordUpdated } from '../sharing/recordEvents.js';
+import * as store from './db.js';
+
+export const MOOD_BOARD_RENDER_TAG = 'moodBoardRender';
+const RENDER_SIZE = Object.freeze({ width: 1024, height: 1024 });
+const PROMPT_MAX = 8000;
+
+// Overridable for tests (queue, settings and socket are process singletons).
+const deps = {
+ getSettings: async () => (await import('../settings.js')).getSettings(),
+ enqueue: async (job) => (await import('../mediaJobQueue/index.js')).enqueueJob(job),
+ getJob: async (jobId) => (await import('../mediaJobQueue/index.js')).getJob(jobId),
+ imageParams: (settings, route, common) => itemRenderParams(settings, route, common),
+ emit: (payload) => import('../socket.js')
+ .then(({ getIo }) => getIo()?.emit('mood-board:item-render', payload))
+ .catch((err) => console.error(`❌ mood-board item-render emit failed: ${err.message}`)),
+};
+export const __setDepsForTests = (overrides) => Object.assign(deps, overrides);
+
+/** The image prompt for a note: its words, then the board's composed look. */
+function buildItemRenderPrompt(board, item) {
+ const text = String(item?.text || '').trim();
+ const style = isNonBlankStr(board?.style?.prompt) ? board.style.prompt.trim() : '';
+ const subject = `Mood board reference image: ${text}`;
+ return (style ? `${subject}\n\nVisual style: ${style}` : subject).slice(0, PROMPT_MAX);
+}
+
+/** Job params for the chosen backend: a cloud provider bag, or the local model. */
+async function itemRenderParams(settings, { mode = null, model = null, target = null }, common) {
+ const [{ resolveRenderTargetConfig }, { resolveImageCleaners }, { resolveLocalImageModel }] = await Promise.all([
+ import('../imageGen/cloudProviderConfig.js'),
+ import('../imageGen/index.js'),
+ import('../imageGen/prepareParams.js'),
+ ]);
+ const resolved = resolveRenderTargetConfig(settings, target, { mode, model, usableInstallFallback: true });
+ if ((mode && resolved.mode !== mode) || !QUEUEABLE_IMAGE_MODES.includes(resolved.mode)) {
+ throw new ServerError(`The ${mode || resolved.mode} image backend cannot render board notes`, {
+ status: 409, code: 'MOOD_BOARD_RENDER_UNAVAILABLE',
+ });
+ }
+ if (resolved.cloud && !resolved.cloud.enabled) throw resolved.cloud.disabledError;
+ const { cleanC2PA, denoise } = resolveImageCleaners(undefined, settings, resolved.mode);
+ if (resolved.cloud) return { ...resolved.cloud.jobParams, ...common, cleanC2PA, denoise };
+ const { pythonPath, selectedModel } = resolveLocalImageModel(settings, { modelId: model || undefined });
+ return { ...common, cleanC2PA, denoise, pythonPath, ...(selectedModel?.id ? { modelId: selectedModel.id } : {}) };
+}
+
+function announce(boardId, itemId, status, error = null) {
+ emitRecordUpdated('moodBoard', boardId);
+ deps.emit({ boardId, itemId, status, ...(error ? { error } : {}) });
+}
+
+const isLiveStatus = (job) => job?.status === 'queued' || job?.status === 'running';
+
+/**
+ * Queue a render for one text note. Resolves to `{ item, jobId }` with the
+ * note's queued render state. Throws NOT_FOUND / MOOD_BOARD_ITEM_NOT_TEXT /
+ * MOOD_BOARD_RENDER_BUSY / MOOD_BOARD_RENDER_UNAVAILABLE.
+ *
+ * @param {string} boardId
+ * @param {string} itemId
+ * @param {{ mode?: string, model?: string, target?: string }} [route]
+ */
+export async function renderBoardItem(boardId, itemId, route = {}) {
+ const board = await store.getBoard(boardId);
+ if (!board) throw new ServerError('Mood board not found', { status: 404, code: 'NOT_FOUND' });
+ const priorJobId = board.items?.find((it) => it?.id === itemId)?.render?.jobId;
+ const priorLive = priorJobId ? isLiveStatus(await deps.getJob(priorJobId)) : false;
+ const claimed = await store.claimBoardItemRender(boardId, itemId, { isLive: () => priorLive });
+
+ const prompt = buildItemRenderPrompt(board, claimed);
+ const negativePrompt = isNonBlankStr(board.style?.negativePrompt) ? board.style.negativePrompt.trim() : undefined;
+ let jobId;
+ try {
+ const settings = await deps.getSettings();
+ const params = await deps.imageParams(settings, route, {
+ prompt,
+ ...(negativePrompt ? { negativePrompt } : {}),
+ ...RENDER_SIZE,
+ [MOOD_BOARD_RENDER_TAG]: { boardId, itemId },
+ });
+ ({ jobId } = await deps.enqueue({ kind: 'image', params, owner: `mood-board-render:${boardId}` }));
+ if (!jobId) throw new Error('The image job was not queued');
+ } catch (err) {
+ // A refused render never strands the note in "rendering".
+ await store.settleBoardItemRender(boardId, itemId, { jobId: null, status: 'failed', error: err.message.slice(0, 500) });
+ announce(boardId, itemId, 'failed', err.message);
+ throw err;
+ }
+ const item = await store.settleBoardItemRender(boardId, itemId, { jobId, status: 'queued' });
+ announce(boardId, itemId, 'queued');
+ console.log(`🖼️ Mood board ${boardId.slice(0, 11)} note ${itemId.slice(0, 12)} → image job ${String(jobId).slice(0, 8)}`);
+ return { item: item || claimed, jobId };
+}
+
+/** Completion: turn the note into the rendered image. Null when the job was stale. */
+export async function attachRenderedItem({ boardId, itemId, jobId, filename, prompt }) {
+ const item = await store.applyBoardItemRender(boardId, itemId, { jobId, filename, prompt });
+ if (item) announce(boardId, itemId, 'done');
+ return item;
+}
+
+/** A failed or canceled job puts the note back to text with the reason. */
+export async function failRenderedItem({ boardId, itemId, jobId }, status, error) {
+ const reason = status === 'canceled' ? 'The render was canceled' : (error || 'The render failed');
+ const item = await store.settleBoardItemRender(boardId, itemId, { jobId, status: 'failed', error: String(reason).slice(0, 500) });
+ if (item) announce(boardId, itemId, 'failed', reason);
+ return item;
+}
diff --git a/server/services/moodBoard/renderItem.test.js b/server/services/moodBoard/renderItem.test.js
new file mode 100644
index 0000000000..97a8ef3d8a
--- /dev/null
+++ b/server/services/moodBoard/renderItem.test.js
@@ -0,0 +1,106 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+
+const store = {
+ getBoard: vi.fn(),
+ claimBoardItemRender: vi.fn(),
+ settleBoardItemRender: vi.fn(),
+ applyBoardItemRender: vi.fn(),
+};
+vi.mock('./db.js', () => store);
+vi.mock('../sharing/recordEvents.js', () => ({ emitRecordUpdated: vi.fn() }));
+
+const { renderBoardItem, __setDepsForTests } = await import('./renderItem.js');
+const { mediaJobEvents } = await import('../mediaJobQueue/index.js');
+const hook = await import('../moodBoardItemRenderHook.js');
+
+const note = { id: 'n1', type: 'text', text: 'Palette: violet and cyan' };
+const board = {
+ id: 'mb-1',
+ items: [note],
+ style: { prompt: 'neon chiaroscuro', negativePrompt: 'text, logos' },
+};
+
+async function waitFor(predicate, { timeoutMs = 1000 } = {}) {
+ const deadline = Date.now() + timeoutMs;
+ while (Date.now() < deadline) {
+ if (predicate()) return;
+ await new Promise((r) => setTimeout(r, 5));
+ }
+ throw new Error('waitFor: predicate never became true');
+}
+
+describe('renderBoardItem', () => {
+ const enqueue = vi.fn();
+ const emit = vi.fn();
+ const imageParams = vi.fn(async (_settings, route, common) => ({ ...common, mode: route.mode || 'local' }));
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ __setDepsForTests({ getSettings: async () => ({}), getJob: async () => null, enqueue, emit, imageParams });
+ store.getBoard.mockResolvedValue(board);
+ store.claimBoardItemRender.mockImplementation(async () => ({ ...note, render: { status: 'queued', jobId: null } }));
+ store.settleBoardItemRender.mockImplementation(async (_b, _i, { jobId, status }) => ({ ...note, render: { status, jobId } }));
+ });
+
+ it('queues the note words plus the board look, tagged for the completion hook', async () => {
+ enqueue.mockResolvedValueOnce({ jobId: 'job-1' });
+ const out = await renderBoardItem('mb-1', 'n1', { mode: 'codex' });
+ const { params, kind } = enqueue.mock.calls[0][0];
+ expect(kind).toBe('image');
+ expect(params.prompt).toContain('Palette: violet and cyan');
+ expect(params.prompt).toContain('neon chiaroscuro');
+ expect(params).toMatchObject({ negativePrompt: 'text, logos', mode: 'codex', moodBoardRender: { boardId: 'mb-1', itemId: 'n1' } });
+ expect(store.settleBoardItemRender).toHaveBeenCalledWith('mb-1', 'n1', { jobId: 'job-1', status: 'queued' });
+ expect(out).toMatchObject({ jobId: 'job-1', item: { render: { status: 'queued', jobId: 'job-1' } } });
+ expect(emit).toHaveBeenCalledWith({ boardId: 'mb-1', itemId: 'n1', status: 'queued' });
+ });
+
+ it('marks the note failed instead of leaving it rendering when the backend refuses', async () => {
+ imageParams.mockRejectedValueOnce(new Error('The external image backend cannot render board notes'));
+ await expect(renderBoardItem('mb-1', 'n1')).rejects.toThrow('cannot render board notes');
+ expect(enqueue).not.toHaveBeenCalled();
+ expect(store.settleBoardItemRender).toHaveBeenCalledWith('mb-1', 'n1', expect.objectContaining({ jobId: null, status: 'failed' }));
+ expect(emit).toHaveBeenCalledWith(expect.objectContaining({ itemId: 'n1', status: 'failed' }));
+ });
+
+ it('lets a new render replace one whose job is no longer live', async () => {
+ store.getBoard.mockResolvedValueOnce({ ...board, items: [{ ...note, render: { status: 'queued', jobId: 'old' } }] });
+ __setDepsForTests({ getJob: async (id) => (id === 'old' ? { status: 'failed' } : null) });
+ enqueue.mockResolvedValueOnce({ jobId: 'job-2' });
+ await renderBoardItem('mb-1', 'n1');
+ expect(store.claimBoardItemRender.mock.calls[0][2].isLive('old')).toBe(false);
+ });
+});
+
+describe('moodBoardItemRenderHook', () => {
+ const job = (params, extra = {}) => ({
+ id: 'job-1', kind: 'image', params, queuedAt: '2026-01-01T00:00:00.000Z', result: { filename: 'job-1.png' }, ...extra,
+ });
+ const tag = { boardId: 'mb-1', itemId: 'n1' };
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ __setDepsForTests({ emit: vi.fn() });
+ hook.__testing.reset();
+ hook.initMoodBoardItemRenderHook();
+ });
+ afterEach(() => hook.__testing.reset());
+
+ it('turns the tagged note into its rendered image and ignores other jobs', async () => {
+ store.applyBoardItemRender.mockResolvedValueOnce({ id: 'n1', type: 'image', mediaKey: 'image:job-1.png' });
+ mediaJobEvents.emit('completed', job({ prompt: 'unrelated' }));
+ mediaJobEvents.emit('completed', job({ prompt: 'the prompt', moodBoardRender: tag }));
+ await waitFor(() => store.applyBoardItemRender.mock.calls.length > 0);
+ expect(store.applyBoardItemRender).toHaveBeenCalledTimes(1);
+ expect(store.applyBoardItemRender).toHaveBeenCalledWith('mb-1', 'n1', { jobId: 'job-1', filename: 'job-1.png', prompt: 'the prompt' });
+ });
+
+ it('returns the note to text with the reason when the job fails or is canceled', async () => {
+ store.settleBoardItemRender.mockResolvedValue({ id: 'n1' });
+ mediaJobEvents.emit('failed', job({ moodBoardRender: tag }, { error: 'out of memory' }));
+ mediaJobEvents.emit('canceled', job({ moodBoardRender: tag }, { id: 'job-2' }));
+ await waitFor(() => store.settleBoardItemRender.mock.calls.length === 2);
+ expect(store.settleBoardItemRender).toHaveBeenNthCalledWith(1, 'mb-1', 'n1', { jobId: 'job-1', status: 'failed', error: 'out of memory' });
+ expect(store.settleBoardItemRender).toHaveBeenNthCalledWith(2, 'mb-1', 'n1', { jobId: 'job-2', status: 'failed', error: 'The render was canceled' });
+ });
+});
diff --git a/server/services/moodBoardItemRenderHook.js b/server/services/moodBoardItemRenderHook.js
new file mode 100644
index 0000000000..4c823ea636
--- /dev/null
+++ b/server/services/moodBoardItemRenderHook.js
@@ -0,0 +1,37 @@
+/**
+ * Mood board note render completion hook (#10531).
+ *
+ * For each finished image job tagged `params.moodBoardRender`, turns the text
+ * note it was rendered from into an image item in place — server-side, so the
+ * render lands after the user navigated away or while autopilot moves on. A
+ * failed or canceled job returns the note to text with the reason. Serialized
+ * per board; the row lock and the job-id check in logic.js drop a stale render.
+ */
+
+import { createMediaJobImageHook } from './mediaJobImageHook.js';
+import { MOOD_BOARD_RENDER_TAG, attachRenderedItem, failRenderedItem } from './moodBoard/renderItem.js';
+
+const hook = createMediaJobImageHook({
+ label: 'mood board note render',
+ initLog: '🖼️ Mood board note render hook initialized',
+ tagKey: MOOD_BOARD_RENDER_TAG,
+ identify: (tag, job) => (typeof tag?.boardId === 'string' && typeof tag?.itemId === 'string'
+ ? { boardId: tag.boardId, itemId: tag.itemId, jobId: job?.id || null }
+ : null),
+ serializeKey: ({ boardId }) => boardId,
+ describe: ({ boardId, itemId }) => `${boardId}/${itemId}`,
+ attach: ({ boardId, itemId, jobId, filename, job }) => attachRenderedItem({
+ boardId, itemId, jobId, filename, prompt: job?.params?.prompt,
+ }),
+ onAttached: ({ boardId, itemId }, item) => {
+ console.log(`🖼️ Mood board ${boardId}/${itemId} note rendered ← ${item.mediaKey}`);
+ },
+ onTerminal: (ctx, status, job) => failRenderedItem(ctx, status, job?.error),
+});
+
+export function initMoodBoardItemRenderHook() {
+ hook.init();
+}
+
+// Test-only reset so suites that re-init can do so cleanly.
+export const __testing = hook.__testing;
diff --git a/server/services/musicVideo/autonomousBoard.js b/server/services/musicVideo/autonomousBoard.js
index 359d783c7f..4e396f10f8 100644
--- a/server/services/musicVideo/autonomousBoard.js
+++ b/server/services/musicVideo/autonomousBoard.js
@@ -4,19 +4,25 @@
* A board of text notes plus a composite style (the same `style.prompt` /
* `negativePrompt` shape the board's own "compose style" action writes), so
* the project's authored style snapshot (styleSnapshots.js) reads the look
- * description first. Only text items are created: nothing here renders or
- * downloads an image, so the stage costs no media quota.
+ * description first. When the run may make images, each note is then queued
+ * for a render on the run's image route (#10531), so the board shows the look
+ * instead of only describing it; the completion hook turns each note into its
+ * image. A render that can't be queued leaves its note as text and never fails
+ * the stage.
*/
-import { addBoardItem, createBoard, updateBoard } from '../moodBoard/index.js';
+import { addBoardItem, createBoard, updateBoard, renderBoardItem } from '../moodBoard/index.js';
/**
* @param {{ name: string, description: string, notes: string[], stylePrompt: string, negativePrompt: string }} spec
+ * @param {{ renderRoute?: { mode?: string, model?: string, target?: string } | null }} [opts]
+ * the image route that renders the notes; omitted or null keeps them text
* @returns the created board (with its items and style)
*/
-export async function createAutonomousMoodBoard(spec) {
+export async function createAutonomousMoodBoard(spec, { renderRoute = null } = {}) {
const board = await createBoard({ name: spec.name, description: spec.description });
+ const notes = [];
for (const text of spec.notes || []) {
- await addBoardItem(board.id, { type: 'text', text, source: 'autonomous music video' });
+ notes.push(await addBoardItem(board.id, { type: 'text', text, source: 'autonomous music video' }));
}
if (spec.stylePrompt) {
await updateBoard(board.id, {
@@ -28,6 +34,16 @@ export async function createAutonomousMoodBoard(spec) {
},
});
}
- console.log(`🖼️ Autonomous music video mood board "${spec.name}" created (${(spec.notes || []).length} notes)`);
+ let queued = 0;
+ if (renderRoute) {
+ for (const note of notes) {
+ const sent = await renderBoardItem(board.id, note.id, renderRoute).catch((err) => {
+ console.warn(`⚠️ Autonomous mood board note render not queued: ${err.message}`);
+ return null;
+ });
+ if (sent) queued += 1;
+ }
+ }
+ console.log(`🖼️ Autonomous music video mood board "${spec.name}" created (${notes.length} notes, ${queued} rendering)`);
return board;
}
diff --git a/server/services/musicVideo/autonomousBoard.test.js b/server/services/musicVideo/autonomousBoard.test.js
new file mode 100644
index 0000000000..01b81aa64a
--- /dev/null
+++ b/server/services/musicVideo/autonomousBoard.test.js
@@ -0,0 +1,35 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+const calls = [];
+const board = {
+ createBoard: vi.fn(async () => ({ id: 'mb-1' })),
+ addBoardItem: vi.fn(async (_id, input) => ({ id: `n-${input.text}` })),
+ updateBoard: vi.fn(async () => { calls.push('style'); }),
+ renderBoardItem: vi.fn(async (_id, itemId) => { calls.push(`render:${itemId}`); return { jobId: 'j' }; }),
+};
+vi.mock('../moodBoard/index.js', () => board);
+
+const { createAutonomousMoodBoard } = await import('./autonomousBoard.js');
+const spec = { name: 'B', description: 'd', notes: ['a', 'b'], stylePrompt: 'neon', negativePrompt: 'text' };
+
+describe('createAutonomousMoodBoard', () => {
+ beforeEach(() => { vi.clearAllMocks(); calls.length = 0; });
+
+ it('renders every note on the run route after the style is set, so the prompt carries the look', async () => {
+ const route = { target: 'music-video', mode: 'local', model: 'qwen-image-2.1' };
+ await createAutonomousMoodBoard(spec, { renderRoute: route });
+ expect(calls).toEqual(['style', 'render:n-a', 'render:n-b']);
+ expect(board.renderBoardItem).toHaveBeenCalledWith('mb-1', 'n-a', route);
+ });
+
+ it('keeps a note as text when its render cannot be queued, and keeps going', async () => {
+ board.renderBoardItem.mockRejectedValueOnce(new Error('backend off'));
+ await expect(createAutonomousMoodBoard(spec, { renderRoute: { mode: 'local' } })).resolves.toEqual({ id: 'mb-1' });
+ expect(board.renderBoardItem).toHaveBeenCalledTimes(2);
+ });
+
+ it('builds a text-only board without a render route', async () => {
+ await createAutonomousMoodBoard(spec);
+ expect(board.renderBoardItem).not.toHaveBeenCalled();
+ });
+});
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.js
index 7774a2ad91..f7ae7ae8a5 100644
--- a/server/services/musicVideo/autonomousService.js
+++ b/server/services/musicVideo/autonomousService.js
@@ -59,6 +59,7 @@ import { PATHS } from '../../lib/fileUtils.js';
import { probeVideoDuration } from '../../lib/ffmpeg.js';
import { ServerError } from '../../lib/errorHandler.js';
import { trimTo } from '../../lib/textUtils.js';
+import { RENDER_TARGET } from '../../lib/renderTargets.js';
import { assertFootageVideoModelsCapable, loadPoolEnv } from './productionPool.js';
import { PRODUCTION_RESUMABLE_STATUSES } from './production.js';
import {
@@ -97,7 +98,7 @@ const defaults = {
draftCreativeBrief: async (args) => (await import('./autonomousBrief.js')).draftCreativeBrief(args),
writeLyrics: async (args) => (await import('../musicDesigner.js')).writeLyrics(args),
reviewLyrics: async (args) => (await import('../musicDesigner.js')).reviewLyrics(args),
- createMoodBoard: async (spec) => (await import('./autonomousBoard.js')).createAutonomousMoodBoard(spec),
+ createMoodBoard: async (spec, opts) => (await import('./autonomousBoard.js')).createAutonomousMoodBoard(spec, opts),
generateSunoSong: async (fields, opts) => (await import('./autonomousSuno.js')).generateSunoSong(fields, opts),
generateLocalSong: async (args) => (await import('./autonomousLocalSong.js')).generateLocalSong(args),
cancelLocalSong: async (jobId) => (await import('../mediaJobQueue/index.js')).cancelJob(jobId),
@@ -837,13 +838,25 @@ async function writeRunLyrics({ project, run, save }) {
} };
}
+// The board's notes render on the run's first image tool with its pinned model,
+// or on the install's Music Video default when the run names no image tool.
+// Only reached in a mode that allows images (code-only builds no board).
+function boardRenderRoute(run) {
+ const tool = (run.brief.tools || []).find((id) => id.startsWith('image:'));
+ return {
+ target: RENDER_TARGET.MUSIC_VIDEO,
+ ...(tool ? { mode: tool.slice('image:'.length), model: run.brief.models?.[tool] || undefined } : {}),
+ };
+}
+
async function createRunStyle({ project, run }) {
if (musicVideoMediaMode(project) === 'code-only') {
await deps.updateProject(project.id, { concept: { prompt: run.output.concept.prompt, style: run.output.concept.style || run.output.moodBoard?.stylePrompt || '' } });
return { output: { moodBoardId: null } };
}
const board = run.output.moodBoard;
- const moodBoardId = run.brief.moodBoardId || run.output.moodBoardId || (await deps.createMoodBoard(board)).id;
+ const moodBoardId = run.brief.moodBoardId || run.output.moodBoardId
+ || (await deps.createMoodBoard(board, { renderRoute: boardRenderRoute(run) })).id;
// The board is also the project's linked mood board; the server derives the
// authored style snapshot from it (styleSnapshots.js).
await deps.updateProject(project.id, {
diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.js
index 64b0e87c22..85cb184150 100644
--- a/server/services/musicVideo/autonomousService.test.js
+++ b/server/services/musicVideo/autonomousService.test.js
@@ -1188,7 +1188,9 @@ describe('orchestrated mode (brief.orchestrator)', () => {
expect(reviews()).toEqual(['lyrics:revise', 'lyrics:approve', 'style:revise', 'style:approve', 'song:retake', 'song:approve']);
// The revisions are what the song and mood board were made from.
expect(runOf().output).toMatchObject({ lyrics: '[Chorus]\nrain rain on glass', sunoStyle: 'synthwave, 96 bpm, airy female vocal' });
- expect(doubles.createMoodBoard).toHaveBeenCalledWith(expect.objectContaining({ stylePrompt: 'wet neon, teal and magenta' }));
+ // Its notes render on the run's own image tool (#10531).
+ expect(doubles.createMoodBoard).toHaveBeenCalledWith(expect.objectContaining({ stylePrompt: 'wet neon, teal and magenta' }),
+ { renderRoute: { target: 'music-video', mode: 'local', model: undefined } });
expect(doubles.generateLocalSong).toHaveBeenCalledTimes(2);
expect(doubles.generateLocalSong.mock.calls[0][0]).toMatchObject({ lyrics: '[Chorus]\nrain rain on glass', prompt: expect.stringContaining('96 bpm') });
// The orchestrator also judges production's plates and drafts.