Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: show analyzed prompt and indicator on mood board items
Adam Eivyec6f13a3b71f
diff --git a/client/src/components/media/PinToMoodBoardMenu.jsx b/client/src/components/media/PinToMoodBoardMenu.jsxindex 484951ab70..aaa1278d0f 100644--- a/client/src/components/media/PinToMoodBoardMenu.jsx+++ b/client/src/components/media/PinToMoodBoardMenu.jsx@@ -87,6 +87,7 @@ export default function PinToMoodBoardMenu({ item, size = 'sm' }) {const promptText = typeof item?.prompt === 'string' && item.prompt !== '(no prompt)' ? item.prompt.trim() : '';const captionText = typeof item?.caption === 'string' ? item.caption.trim() : '';const effectiveCaption = captionText || promptText || null;+ if (promptText) payload.prompt = promptText;if (effectiveCaption) payload.caption = effectiveCaption;return payload;}, [mediaKey, thumbUrl, item?.prompt, item?.caption]);diff --git a/client/src/components/moodBoard/MoodBoardReferenceStrip.jsx b/client/src/components/moodBoard/MoodBoardReferenceStrip.jsxindex 3fc0166b12..d142964f57 100644--- a/client/src/components/moodBoard/MoodBoardReferenceStrip.jsx+++ b/client/src/components/moodBoard/MoodBoardReferenceStrip.jsx@@ -29,6 +29,7 @@ import { LayoutGrid, ChevronDown, ChevronRight, ExternalLink, ImageIcon, Plus, Limport toast from '../ui/Toast';import { listMoodBoards, getMoodBoard, createMoodBoard } from '../../services/api';import { moodBoardItemSrc } from '../../lib/moodBoardItemSrc';+import { moodBoardItemPrompt } from '../../lib/moodBoardAnalysis';import { safeReadStorage, safeWriteStorage } from '../../lib/safeStorage';const MAX_THUMBS = 12;@@ -122,7 +123,7 @@ export default function MoodBoardReferenceStrip({const thumbs = useMemo(() => {const items = Array.isArray(detail?.items) ? detail.items : [];return items- .map((it) => ({ id: it.id, src: moodBoardItemSrc(it), caption: it.caption || '' }))+ .map((it) => ({ id: it.id, src: moodBoardItemSrc(it), caption: moodBoardItemPrompt(it) || it.caption || '' })).filter((t) => t.src).slice(0, MAX_THUMBS);}, [detail]);diff --git a/client/src/lib/moodBoardAnalysis.js b/client/src/lib/moodBoardAnalysis.jsindex 49de6144dc..60778255d8 100644--- a/client/src/lib/moodBoardAnalysis.js+++ b/client/src/lib/moodBoardAnalysis.js@@ -38,6 +38,38 @@ export function moodBoardAnalysisFromResult(item, result) {};}+/**+ * Resolves the primary prompt text for a mood board item.+ * Prefers the analyzed prompt from prompt-from-media, then explicit item.prompt,+ * then a gallery item's caption prompt. Returns empty string if no prompt exists.+ */+export function moodBoardItemPrompt(item) {+ if (item?.analysis?.prompt && typeof item.analysis.prompt === 'string' && item.analysis.prompt.trim()) {+ return item.analysis.prompt.trim();+ }+ if (item?.prompt && typeof item.prompt === 'string' && item.prompt.trim()) {+ return item.prompt.trim();+ }+ if ((item?.mediaKey?.startsWith('image:') || item?.mediaKey?.startsWith('video:')) && item?.caption && typeof item.caption === 'string' && item.caption.trim()) {+ return item.caption.trim();+ }+ return '';+}++/**+ * Returns true if the item has an explicit prompt-from-media analysis saved.+ */+export function isMoodBoardItemAnalyzed(item) {+ return Boolean(item?.analysis?.prompt && typeof item.analysis.prompt === 'string' && item.analysis.prompt.trim());+}++/**+ * Returns true if the item has been analyzed OR already has a prompt.+ */+export function moodBoardItemHasPrompt(item) {+ return isMoodBoardItemAnalyzed(item) || Boolean(moodBoardItemPrompt(item));+}+/*** Split a board's items into the ones prompt-from-media can still read and* the ones that already carry a prompt. External URL pins can't be read, so@@ -49,9 +81,7 @@ export function boardAnalyzePlan(items) {let analyzed = 0;let skipped = 0;for (const item of list) {- const stored = (item?.analysis?.prompt && typeof item.analysis.prompt === 'string' && item.analysis.prompt.trim())- || (typeof item?.caption === 'string' && item.caption.trim());- if (stored) {+ if (moodBoardItemHasPrompt(item)) {analyzed += 1;continue;}diff --git a/client/src/lib/moodBoardAnalysis.test.js b/client/src/lib/moodBoardAnalysis.test.jsindex d4519116b9..67348b3c2a 100644--- a/client/src/lib/moodBoardAnalysis.test.js+++ b/client/src/lib/moodBoardAnalysis.test.js@@ -4,7 +4,10 @@ import {BOARD_POSTER_SIZE,boardAnalyzePlan,boardPosterRenderCfg,+ isMoodBoardItemAnalyzed,moodBoardAnalysisFromResult,+ moodBoardItemHasPrompt,+ moodBoardItemPrompt,posterStyleKey,} from './moodBoardAnalysis';@@ -52,6 +55,65 @@ describe('boardAnalyzePlan', () => {expect(plan.pending.map((it) => it.id)).toEqual(['b']);expect(plan.skipped).toBe(1);});++ it('keeps local Pinterest pins with default captions in pending rather than marking as analyzed', () => {+ const plan = boardAnalyzePlan([+ { id: 'pin1', type: 'image', imageUrl: '/data/images/pin1.jpg', caption: 'vintage living room' },+ { id: 'pin2', type: 'image', imageUrl: '/data/images/pin2.jpg', caption: 'modern kitchen', analysis: { prompt: 'a clean modern kitchen' } },+ ]);+ expect(plan.analyzed).toBe(1);+ expect(plan.pending.map((it) => it.id)).toEqual(['pin1']);+ });+});++describe('moodBoardItemPrompt and helpers', () => {+ it('identifies analyzed items and resolves their prompt', () => {+ const item = {+ id: '1',+ type: 'image',+ caption: 'default caption from pin',+ analysis: { prompt: 'analyzed prompt detail' },+ };+ expect(isMoodBoardItemAnalyzed(item)).toBe(true);+ expect(moodBoardItemHasPrompt(item)).toBe(true);+ expect(moodBoardItemPrompt(item)).toBe('analyzed prompt detail');+ });++ it('prefers explicit item.prompt over default caption', () => {+ const item = {+ id: '2',+ type: 'image',+ caption: 'default caption',+ prompt: 'explicit prompt',+ };+ expect(isMoodBoardItemAnalyzed(item)).toBe(false);+ expect(moodBoardItemHasPrompt(item)).toBe(true);+ expect(moodBoardItemPrompt(item)).toBe('explicit prompt');+ });++ it('falls back to caption for gallery mediaKey items when no explicit prompt or analysis exists', () => {+ const galleryImage = {+ id: '3',+ type: 'image',+ mediaKey: 'image:test.png',+ caption: 'gallery prompt stored in caption',+ };+ expect(isMoodBoardItemAnalyzed(galleryImage)).toBe(false);+ expect(moodBoardItemHasPrompt(galleryImage)).toBe(true);+ expect(moodBoardItemPrompt(galleryImage)).toBe('gallery prompt stored in caption');+ });++ it('does not treat external or Pinterest default captions as prompts', () => {+ const pin = {+ id: '4',+ type: 'image',+ imageUrl: '/data/images/pin.jpg',+ caption: 'cute cat photo',+ };+ expect(isMoodBoardItemAnalyzed(pin)).toBe(false);+ expect(moodBoardItemHasPrompt(pin)).toBe(false);+ expect(moodBoardItemPrompt(pin)).toBe('');+ });});describe('boardPosterRenderCfg', () => {diff --git a/client/src/pages/MoodBoardDetail.jsx b/client/src/pages/MoodBoardDetail.jsxindex cc04db449f..3e1a7bc5f4 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 } from 'lucide-react';+import { ArrowLeft, ImageIcon, FileText, Trash2, Plus, Save, Link2, Unlink, RefreshCw, Images, Film, Play, ScanEye, Copy, AtSign, Download, Sparkles } from 'lucide-react';import PageSkeleton from '../components/ui/PageSkeleton';import toast from '../components/ui/Toast';import TabPills from '../components/ui/TabPills';@@ -35,7 +35,12 @@ import {localizeMoodBoardMedia,} from '../services/api';import { moodBoardItemSrc, moodBoardItemVideoSrc, moodBoardItemAnalysisSource } from '../lib/moodBoardItemSrc';-import { moodBoardAnalysisFromResult } from '../lib/moodBoardAnalysis';+import {+ moodBoardAnalysisFromResult,+ moodBoardItemPrompt,+ isMoodBoardItemAnalyzed,+ moodBoardItemHasPrompt,+} from '../lib/moodBoardAnalysis';import { timeAgo } from '../utils/formatters';import useMounted from '../hooks/useMounted';@@ -191,6 +196,7 @@ function MoodBoardEditor({ id }) {type: 'image',mediaKey: typeof picked.key === 'string' && picked.key.startsWith('image:') ? picked.key : null,imageUrl: picked.previewUrl || null,+ prompt: promptText || null,caption: promptText || null,});};@@ -202,17 +208,34 @@ function MoodBoardEditor({ id }) {type: 'video',mediaKey: `video:${picked.filename}`,imageUrl: picked.previewUrl || null,+ prompt: promptText || null,caption: promptText || null,});};- const handleUpdateCaption = async (itemId, nextCaption) => {+ const handleUpdateItemText = async (item, nextText) => {if (!mountedRef.current) return;- const item = await updateMoodBoardItem(id, itemId, { caption: nextCaption || null }, { silent: true }).catch(() => null);+ const isAnalyzed = isMoodBoardItemAnalyzed(item);+ const patch = {};+ if (isAnalyzed) {+ patch.analysis = { ...item.analysis, prompt: nextText || '' };+ patch.prompt = nextText || null;+ if (!item.caption || item.caption.trim() === (item.analysis?.prompt || '').trim()) {+ patch.caption = nextText ? nextText.slice(0, 2000) : null;+ }+ } else if (item.prompt) {+ patch.prompt = nextText || null;+ if (!item.caption || item.caption.trim() === item.prompt.trim()) {+ patch.caption = nextText ? nextText.slice(0, 2000) : null;+ }+ } else {+ patch.caption = nextText || null;+ }+ const updated = await updateMoodBoardItem(id, item.id, patch, { silent: true }).catch(() => null);if (!mountedRef.current) return;- if (!item) { toast.error('Failed to update caption'); return; }+ if (!updated) { toast.error('Failed to update'); return; }setBoard((prev) => (prev- ? { ...prev, items: (prev.items || []).map((it) => (it.id === itemId ? item : it)) }+ ? { ...prev, items: (prev.items || []).map((it) => (it.id === item.id ? updated : it)) }: prev));};@@ -457,79 +480,134 @@ function MoodBoardEditor({ id }) {const src = moodBoardItemSrc(item);const videoSrc = moodBoardItemVideoSrc(item);const analysisSource = moodBoardItemAnalysisSource(item);+ const isAnalyzed = isMoodBoardItemAnalyzed(item);+ const hasPrompt = moodBoardItemHasPrompt(item);+ const promptText = moodBoardItemPrompt(item);+ const displayText = promptText || item.caption || '';return (<div key={item.id} className="bg-port-card border border-port-border rounded-md overflow-hidden flex flex-col">- {item.type === 'video' && videoSrc ? (- playingItemId === item.id ? (- // eslint-disable-next-line jsx-a11y/media-has-caption -- reference clips have no caption track- <video- src={videoSrc}- poster={src || undefined}- controls- autoPlay- playsInline- className="w-full aspect-square object-cover bg-black"- />+ <div className="relative w-full aspect-square bg-port-bg">+ {item.type === 'video' && videoSrc ? (+ playingItemId === item.id ? (+ // eslint-disable-next-line jsx-a11y/media-has-caption -- reference clips have no caption track+ <video+ src={videoSrc}+ poster={src || undefined}+ controls+ autoPlay+ playsInline+ className="w-full h-full object-cover bg-black"+ />+ ) : (+ <button+ type="button"+ onClick={() => setPlayingItemId(item.id)}+ aria-label="Play video"+ className="relative w-full h-full bg-port-bg text-gray-600 group block"+ >+ {src ? (+ <img+ src={src}+ alt={displayText}+ loading="lazy"+ className="w-full h-full object-cover"+ onError={(e) => {+ // A synced board can carry a poster URL whose file+ // only exists on the sending machine (a downloaded+ // video's thumbnail is named `<id>.jpg`, not+ // `<filename-stem>.jpg`). The receiver regenerates+ // the stem-named poster when it pulls the video, so+ // fall back to that derived name on a 404.+ const fallback = moodBoardItemSrc({ ...item, imageUrl: null });+ if (fallback && e.currentTarget.getAttribute('src') !== fallback) {+ e.currentTarget.src = fallback;+ }+ }}+ />+ ) : (+ <span className="w-full h-full flex items-center justify-center">+ <Film className="w-8 h-8" aria-hidden="true" />+ </span>+ )}+ <span className="absolute inset-0 flex items-center justify-center bg-black/30 opacity-80 group-hover:opacity-100 transition-opacity">+ <Play className="w-8 h-8 text-white drop-shadow" aria-hidden="true" />+ </span>+ </button>+ )+ ) : item.type === 'image' || item.type === 'video' ? (+ src ? (+ <img src={src} alt={displayText} loading="lazy" className="w-full h-full object-cover bg-port-bg" />+ ) : (+ <div className="w-full h-full flex items-center justify-center bg-port-bg text-gray-600">+ <ImageIcon className="w-8 h-8" aria-hidden="true" />+ </div>+ )) : (- <button- type="button"- onClick={() => setPlayingItemId(item.id)}- aria-label="Play video"- className="relative w-full aspect-square bg-port-bg text-gray-600 group"- >- {src ? (- <img- src={src}- alt={item.caption || ''}- loading="lazy"- className="w-full h-full object-cover"- onError={(e) => {- // A synced board can carry a poster URL whose file- // only exists on the sending machine (a downloaded- // video's thumbnail is named `<id>.jpg`, not- // `<filename-stem>.jpg`). The receiver regenerates- // the stem-named poster when it pulls the video, so- // fall back to that derived name on a 404.- const fallback = moodBoardItemSrc({ ...item, imageUrl: null });- if (fallback && e.currentTarget.getAttribute('src') !== fallback) {- e.currentTarget.src = fallback;- }- }}- />+ <div className="w-full h-full p-3 overflow-y-auto bg-port-bg text-sm text-gray-200 whitespace-pre-wrap">+ {item.text}+ </div>+ )}++ {/* 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">+ {isAnalyzed ? (+ <span+ data-testid="item-indicator-analyzed"+ className="pointer-events-auto text-[10px] font-medium px-1.5 py-0.5 rounded bg-port-accent/90 text-white shadow-sm flex items-center gap-1 backdrop-blur-sm"+ title="Analyzed with image-to-prompt"+ >+ <ScanEye className="w-3 h-3" aria-hidden="true" />+ Analyzed+ </span>) : (- <span className="w-full h-full flex items-center justify-center">- <Film className="w-8 h-8" aria-hidden="true" />+ <span+ data-testid="item-indicator-prompt"+ className="pointer-events-auto text-[10px] font-medium px-1.5 py-0.5 rounded bg-port-success/90 text-white shadow-sm flex items-center gap-1 backdrop-blur-sm"+ title="Already has a prompt"+ >+ <Sparkles className="w-3 h-3" aria-hidden="true" />+ Prompt</span>)}- <span className="absolute inset-0 flex items-center justify-center bg-black/30 opacity-80 group-hover:opacity-100 transition-opacity">- <Play className="w-8 h-8 text-white drop-shadow" aria-hidden="true" />- </span>- </button>- )- ) : item.type === 'image' || item.type === 'video' ? (- src ? (- <img src={src} alt={item.caption || ''} loading="lazy" className="w-full aspect-square object-cover bg-port-bg" />- ) : (- <div className="w-full aspect-square flex items-center justify-center bg-port-bg text-gray-600">- <ImageIcon className="w-8 h-8" aria-hidden="true" /></div>- )- ) : (- <div className="w-full aspect-square p-3 overflow-y-auto bg-port-bg text-sm text-gray-200 whitespace-pre-wrap">- {item.text}- </div>- )}+ )}+ </div><div className="p-2 flex flex-col gap-1">+ <div className="flex items-center justify-between gap-1">+ <span className="text-[10px] font-medium text-gray-400 flex items-center gap-1">+ {isAnalyzed ? (+ <span className="text-port-accent flex items-center gap-0.5">+ <ScanEye className="w-3 h-3" aria-hidden="true" /> Analyzed prompt+ </span>+ ) : hasPrompt ? (+ <span className="text-port-success flex items-center gap-0.5">+ <Sparkles className="w-3 h-3" aria-hidden="true" /> Prompt+ </span>+ ) : (+ <span>Caption</span>+ )}+ </span>+ {item.caption && promptText && item.caption.trim() !== promptText.trim() ? (+ <span+ className="text-[10px] text-gray-500 truncate max-w-[120px]"+ title={`Default caption: ${item.caption}`}+ >+ {item.caption}+ </span>+ ) : null}+ </div><inputtype="text"- key={item.caption || ""}- aria-label="Item caption"- defaultValue={item.caption || ''}- placeholder="Add a caption…"+ key={`${item.id}-${displayText}`}+ aria-label={isAnalyzed ? "Analyzed prompt" : hasPrompt ? "Item prompt" : "Item caption"}+ defaultValue={displayText}+ title={displayText}+ placeholder={hasPrompt ? "Add a prompt…" : "Add a caption…"}maxLength={2000}onBlur={(e) => {const next = e.target.value.trim();- if (next !== (item.caption || '')) handleUpdateCaption(item.id, next);+ if (next !== displayText) handleUpdateItemText(item, next);}}className="w-full bg-transparent border-0 border-b border-transparent focus:border-port-border text-xs text-gray-300 px-0 py-0.5 outline-none"/>diff --git a/client/src/pages/MoodBoardDetail.test.jsx b/client/src/pages/MoodBoardDetail.test.jsxindex 1676af5779..1d5ed5af59 100644--- a/client/src/pages/MoodBoardDetail.test.jsx+++ b/client/src/pages/MoodBoardDetail.test.jsx@@ -507,6 +507,80 @@ describe('MoodBoardDetail item analysis (#4188 Phase 3)', () => {});await screen.findByRole('button', { name: 'Prompt from media' });});++ it('displays the analyzed prompt indicator and value over the default caption', async () => {+ const analyzedItem = {+ id: 'i1',+ type: 'image',+ mediaKey: 'image:pic.png',+ caption: 'default caption from pin',+ analysis: {+ prompt: 'detailed analyzed prompt',+ },+ };+ mockGetMoodBoard.mockResolvedValueOnce({ id: 'a', name: 'Board A', items: [analyzedItem] });+ mockUpdateMoodBoardItem.mockResolvedValueOnce({+ ...analyzedItem,+ analysis: { prompt: 'updated analyzed prompt' },+ });+ renderPage();+ await waitFor(() => expect(boardNameValue()).toBe('Board A'));++ expect(screen.getByTestId('item-indicator-analyzed')).toBeInTheDocument();+ expect(screen.getByText('Analyzed prompt')).toBeInTheDocument();+ expect(screen.getByText('default caption from pin')).toBeInTheDocument();++ const input = screen.getByLabelText('Analyzed prompt');+ expect(input).toHaveValue('detailed analyzed prompt');++ fireEvent.change(input, { target: { value: 'updated analyzed prompt' } });+ fireEvent.blur(input);++ await waitFor(() => {+ expect(mockUpdateMoodBoardItem).toHaveBeenCalledWith('a', 'i1', {+ analysis: {+ prompt: 'updated analyzed prompt',+ },+ prompt: 'updated analyzed prompt',+ }, { silent: true });+ });+ });++ it('displays the prompt indicator and value for items with prompt but no analysis', async () => {+ const itemWithPrompt = {+ id: 'i2',+ type: 'image',+ mediaKey: 'image:pic2.png',+ prompt: 'explicit prompt text',+ caption: 'default caption',+ };+ mockGetMoodBoard.mockResolvedValueOnce({ id: 'a', name: 'Board A', items: [itemWithPrompt] });+ renderPage();+ await waitFor(() => expect(boardNameValue()).toBe('Board A'));++ expect(screen.getByTestId('item-indicator-prompt')).toBeInTheDocument();+ expect(screen.getByTestId('item-indicator-prompt')).toHaveTextContent('Prompt');+ const input = screen.getByLabelText('Item prompt');+ expect(input).toHaveValue('explicit prompt text');+ });++ it('displays only default caption with no indicator when item has not been analyzed or given a prompt', async () => {+ const pinItem = {+ id: 'i3',+ type: 'image',+ imageUrl: '/data/images/pin.jpg',+ caption: 'simple pin description',+ };+ mockGetMoodBoard.mockResolvedValueOnce({ id: 'a', name: 'Board A', items: [pinItem] });+ renderPage();+ await waitFor(() => expect(boardNameValue()).toBe('Board A'));++ expect(screen.queryByTestId('item-indicator-analyzed')).not.toBeInTheDocument();+ expect(screen.queryByTestId('item-indicator-prompt')).not.toBeInTheDocument();+ expect(screen.getByText('Caption')).toBeInTheDocument();+ const input = screen.getByLabelText('Item caption');+ expect(input).toHaveValue('simple pin description');+ });});describe('MoodBoardDetail desktop layout', () => {diff --git a/server/lib/moodBoardStyleContext.js b/server/lib/moodBoardStyleContext.jsindex 18a1dd1e67..d640a85d57 100644--- a/server/lib/moodBoardStyleContext.js+++ b/server/lib/moodBoardStyleContext.js@@ -43,6 +43,9 @@ export function collectBoardStyleContext(board) {if (typeof it.caption === 'string' && it.caption.trim()) {entry.caption = trimTo(it.caption, CONTEXT_FIELD_MAX);}+ if (typeof it.prompt === 'string' && it.prompt.trim()) {+ entry.prompt = trimTo(it.prompt, CONTEXT_FIELD_MAX);+ }const analysis = it.analysis;if (analysis && typeof analysis === 'object' && typeof analysis.prompt === 'string' && analysis.prompt.trim()) {entry.analyzedPrompt = trimTo(analysis.prompt, CONTEXT_FIELD_MAX);diff --git a/server/lib/moodBoardValidation.js b/server/lib/moodBoardValidation.jsindex 7a43bf6eb8..0a3bfc7f8e 100644--- a/server/lib/moodBoardValidation.js+++ b/server/lib/moodBoardValidation.js@@ -46,6 +46,7 @@ const imageUrlSchema = z.string().trim().min(1).max(2048).refine(const captionSchema = z.string().max(2000).nullable().optional();const sourceSchema = z.string().max(2048).nullable().optional();+const promptSchema = z.string().trim().max(8000).nullable().optional();// Board create. description optional (defaults to '' in the record builder).export const moodBoardCreateSchema = z.object({@@ -99,6 +100,7 @@ export const moodBoardItemCreateSchema = z.object({mediaKey: mediaKeySchema.nullable().optional(),imageUrl: imageUrlSchema.nullable().optional(),text: z.string().trim().max(10000).nullable().optional(),+ prompt: promptSchema,caption: captionSchema,source: sourceSchema,}).strict().superRefine((val, ctx) => {@@ -177,5 +179,6 @@ export const moodBoardItemUpdateSchema = z.object({text: z.string().trim().max(10000).nullable().optional(),imageUrl: imageUrlSchema.nullable().optional(),mediaKey: mediaKeySchema.nullable().optional(),+ prompt: promptSchema,analysis: moodBoardItemAnalysisSchema.nullable().optional(),}).strict();diff --git a/server/lib/moodBoardValidation.test.js b/server/lib/moodBoardValidation.test.jsindex e06962fbf0..98f7c21615 100644--- a/server/lib/moodBoardValidation.test.js+++ b/server/lib/moodBoardValidation.test.js@@ -112,6 +112,10 @@ describe('moodBoardItemCreateSchema', () => {it('rejects a video item whose ref is a bare id (no extension) — it would 404 as a filename', () => {expect(moodBoardItemCreateSchema.safeParse({ type: 'video', mediaKey: 'video:job-123' }).success).toBe(false);});+ it('accepts an image item with prompt alongside imageUrl', () => {+ const item = moodBoardItemCreateSchema.parse({ type: 'image', imageUrl: 'https://x/y.png', prompt: 'a prompt' });+ expect(item.prompt).toBe('a prompt');+ });});describe('isVideoItemMediaKey', () => {@@ -134,6 +138,9 @@ describe('moodBoardItemUpdateSchema', () => {it('accepts a caption-only patch', () => {expect(moodBoardItemUpdateSchema.parse({ caption: 'c' }).caption).toBe('c');});+ it('accepts a prompt patch', () => {+ expect(moodBoardItemUpdateSchema.parse({ prompt: 'new prompt' }).prompt).toBe('new prompt');+ });it('accepts a null caption (clear)', () => {expect(moodBoardItemUpdateSchema.parse({ caption: null }).caption).toBeNull();});diff --git a/server/services/moodBoard/index.js b/server/services/moodBoard/index.jsindex 4155cc780b..290a17292b 100644--- a/server/services/moodBoard/index.js+++ b/server/services/moodBoard/index.js@@ -117,7 +117,7 @@ async function resolveGalleryItemCaption(input) {const { metadata } = await readImageSidecar(filename).catch(() => ({}));const prompt = typeof metadata?.prompt === 'string' ? metadata.prompt.trim() : '';if (prompt && prompt !== '(no prompt)') {- return { ...input, caption: prompt };+ return { ...input, prompt: input.prompt || prompt, caption: input.caption || prompt };}}} else if (input.type === 'video') {@@ -131,7 +131,7 @@ async function resolveGalleryItemCaption(input) {const entry = (history || []).find((row) => row && (row.id === ref || row.filename === ref || row.thumbnail === ref));const prompt = typeof entry?.prompt === 'string' ? entry.prompt.trim() : '';if (prompt && prompt !== '(no prompt)') {- return { ...input, caption: prompt };+ return { ...input, prompt: input.prompt || prompt, caption: input.caption || prompt };}}}diff --git a/server/services/moodBoard/logic.js b/server/services/moodBoard/logic.jsindex 7aa2b578c1..b4e61b17f0 100644--- a/server/services/moodBoard/logic.js+++ b/server/services/moodBoard/logic.js@@ -193,6 +193,7 @@ function normalizeItem(input, { id, now = nowIso() } = {}) {mediaKey: hasMedia ? (input.mediaKey ?? null) : null,imageUrl: hasMedia ? (input.imageUrl ?? null) : null,text: input.type === 'text' ? input.text : null,+ prompt: hasMedia ? (input.prompt ?? null) : null,caption: input.caption ?? null,source: input.source ?? null,createdAt: now,@@ -245,7 +246,7 @@ export function updateItem(board, itemId, patch) {const updated = { ...current };const isMediaItem = current.type === 'image' || current.type === 'video';const editableKeys = isMediaItem- ? ['caption', 'source', 'imageUrl', 'mediaKey']+ ? ['caption', 'source', 'imageUrl', 'mediaKey', 'prompt']: ['caption', 'source', 'text'];for (const key of editableKeys) {if (patch[key] !== undefined) updated[key] = patch[key];diff --git a/server/services/moodBoard/logic.test.js b/server/services/moodBoard/logic.test.jsindex 324297fdbb..bb2dc43e49 100644--- a/server/services/moodBoard/logic.test.js+++ b/server/services/moodBoard/logic.test.js@@ -121,6 +121,12 @@ describe('addItem', () => {expect(item.imageUrl).toBe('/data/video-thumbnails/upload-ab12cd34.jpg');expect(item.text).toBeNull();});+ it('normalizes prompt on media items and nulls on text items', () => {+ const { item: img } = addItem(base, { type: 'image', mediaKey: 'image:a.png', prompt: 'an image prompt' });+ expect(img.prompt).toBe('an image prompt');+ const { item: txt } = addItem(base, { type: 'text', text: 'note', prompt: 'ignored prompt' });+ expect(txt.prompt).toBeNull();+ });it('throws BOARD_FULL at the item cap', () => {const full = { ...base, items: Array.from({ length: MAX_ITEMS_PER_BOARD }, (_, i) => ({ id: `i${i}` })) };expect(() => addItem(full, { type: 'text', text: 'x' })).toThrow(/full/i);@@ -139,6 +145,12 @@ describe('updateItem', () => {expect(item.caption).toBe('new');expect(item.text).toBe('orig');});+ it('patches prompt on a media item', () => {+ const fresh = buildBoardRecord({ name: 'A' }, { id: 'mb-1', now: 't0' });+ const { board: withImg, item: img } = addItem(fresh, { type: 'image', mediaKey: 'image:p.png' });+ const { item: patched } = updateItem(withImg, img.id, { prompt: 'updated prompt' });+ expect(patched.prompt).toBe('updated prompt');+ });it('throws NOT_FOUND for an unknown item id', () => {expect(() => updateItem(withItem, 'nope', { caption: 'x' })).toThrow(/not found/i);});diff --git a/server/services/moodBoardCompositeStyle.js b/server/services/moodBoardCompositeStyle.jsindex 0f990c297b..62d98eb3dc 100644--- a/server/services/moodBoardCompositeStyle.js+++ b/server/services/moodBoardCompositeStyle.js@@ -20,6 +20,7 @@ const REASON_MAX = 1200;function analyzedItems(board) {const items = Array.isArray(board?.items) ? board.items : [];return items.filter((it) => (it?.analysis && typeof it.analysis.prompt === 'string' && it.analysis.prompt.trim())+ || (typeof it?.prompt === 'string' && it.prompt.trim())|| (typeof it?.caption === 'string' && it.caption.trim()));}@@ -31,6 +32,7 @@ function withAnalysesFirst(board) {const rest = [];for (const it of items) {const hasPrompt = (it?.analysis && typeof it.analysis.prompt === 'string' && it.analysis.prompt.trim())+ || (typeof it?.prompt === 'string' && it.prompt.trim())|| (typeof it?.caption === 'string' && it.caption.trim());if (hasPrompt) analyzed.push(it);else rest.push(it);