Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: save reusable media prompt examinations and remove instruction prefixes

[._.]/ Adam Eivy59c80ace91b2
diff --git a/client/src/App.jsx b/client/src/App.jsx
index edfc6cffd9..e191380205 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -486,6 +486,7 @@ export default function App() {
<Route path="image" element={<ImageGen />} />
<Route path="video" element={<RedirectWithSearch to="/video/generate" />} />
<Route path="prompt" element={<PromptFromMediaPage />} />
+ <Route path="prompt/:examinationId" element={<PromptFromMediaPage />} />
<Route path="history" element={<MediaHistory />} />
<Route path="annotate" element={<MediaAnnotate />} />
<Route path="annotate/:mediaKey" element={<MediaAnnotate />} />
diff --git a/client/src/components/media/PromptFromMedia.jsx b/client/src/components/media/PromptFromMedia.jsx
index 4b133cdc4e..aa4230f760 100644
--- a/client/src/components/media/PromptFromMedia.jsx
+++ b/client/src/components/media/PromptFromMedia.jsx
@@ -1,20 +1,23 @@
import { useCallback, useEffect, useId, useState } from 'react';
-import { useNavigate } from 'react-router';
+import { useNavigate, useParams } from 'react-router';
import { ScanEye, ChevronDown, ChevronUp, Image as ImageIcon, Film, X, Copy } from 'lucide-react';
import ProviderModelSelector from '../ProviderModelSelector';
import useProviderModels from '../../hooks/useProviderModels';
+import { useSocketResource } from '../../hooks/useSocketResource';
import useVisionModelIds from '../../hooks/useVisionModelIds';
import GalleryImagePicker from '../imageGen/GalleryImagePicker';
import GalleryVideoPicker from '../videoGen/GalleryVideoPicker';
import Modal from '../ui/Modal';
import { FormField } from '../ui/FormField';
-import { promptFromMedia } from '../../services/apiMediaJobs';
+import { promptFromMedia, listMediaPromptExaminations, getMediaPromptExamination } from '../../services/apiMediaJobs';
import { isVisionCapableCliProvider, visionLocalModelFilter } from '../../utils/providers';
import { copyToClipboard } from '../../lib/clipboard';
import { safeReadStorage, safeRemoveStorage, safeWriteStorage } from '../../lib/safeStorage';
import toast from '../ui/Toast';
import BrailleSpinner from '../BrailleSpinner';
+const HISTORY_EVENTS = ['media-prompt-history:changed'];
+
const LS_KEY_PROVIDER = 'portos_prompt_from_media_provider';
const LS_KEY_MODEL = 'portos_prompt_from_media_model';
const LS_KEY_EFFORT = 'portos_prompt_from_media_effort';
@@ -71,6 +74,9 @@ export default function PromptFromMedia({
}) {
const navigate = useNavigate();
const idPrefix = useId();
+ const { examinationId } = useParams();
+ const [historyOffset, setHistoryOffset] = useState(0);
+ const [detailError, setDetailError] = useState('');
const [isOpen, setIsOpen] = useState(!!initialSource || alwaysOpen);
const [source, setSource] = useState(() => sourceFromItem(initialSource));
const [imagePickerOpen, setImagePickerOpen] = useState(false);
@@ -117,6 +123,24 @@ export default function PromptFromMedia({
setResult(null);
}, [initialSource]);
+ const { data: history, error: historyError, updateData: setHistory } = useSocketResource(
+ ({ signal }) => listMediaPromptExaminations(historyOffset, { silent: true, signal }),
+ { events: HISTORY_EVENTS, resourceKey: historyOffset, enabled: isOpen },
+ );
+
+ useEffect(() => {
+ if (!examinationId) return;
+ let active = true;
+ setResult(null);
+ setDetailError('');
+ getMediaPromptExamination(examinationId, { silent: true }).then((record) => {
+ if (!active) return;
+ setSource(record.source);
+ setResult({ ...record.result, examinationId: record.id });
+ }).catch(() => { if (active) setDetailError('Saved examination could not be loaded.'); });
+ return () => { active = false; };
+ }, [examinationId]);
+
const persistProvider = (id) => {
if (id) safeWriteStorage(LS_KEY_PROVIDER, id);
else safeRemoveStorage(LS_KEY_PROVIDER);
@@ -179,6 +203,14 @@ export default function PromptFromMedia({
toast.success('Prompts ready');
}
if (onResult) onResult(data);
+ if (data.examinationId) {
+ setHistoryOffset(0);
+ setHistory((previous) => ({
+ items: [{ id: data.examinationId, createdAt: new Date().toISOString(), source }, ...(previous?.items || [])].slice(0, 20),
+ hasMore: previous?.hasMore || previous?.items.length >= 20,
+ }));
+ if (alwaysOpen && !initialSource && !setPrompt) navigate(`/media/prompt/${data.examinationId}`);
+ }
};
const apply = (kind) => {
@@ -223,6 +255,23 @@ export default function PromptFromMedia({
{isOpen && (
<div className={alwaysOpen ? 'space-y-3' : 'p-3 bg-port-bg/70 border border-port-border rounded-lg space-y-3'}>
+ <div className="space-y-2">
+ <h3 className="text-sm text-white">Saved examinations</h3>
+ <p className="text-xs text-gray-400">Each analysis saves both requested prompts. Reopen a reference to render either without analyzing again.</p>
+ {historyError && <p role="alert" className="text-xs text-port-warning">Could not load examination history.</p>}
+ {detailError && <p role="alert" className="text-xs text-port-warning">{detailError}</p>}
+ {history?.items.map((entry) => (
+ <button key={entry.id} type="button" disabled={running} onClick={() => navigate(`/media/prompt/${entry.id}`)}
+ className="block text-left text-xs text-port-accent break-all min-h-[36px]">
+ {entry.source.filename || entry.source.videoId} · {entry.createdAt}
+ </button>
+ ))}
+ {history && !history.items.length && <p className="text-xs text-gray-400">No saved examinations yet.</p>}
+ <div className="flex gap-3 text-xs text-port-accent">
+ {historyOffset > 0 && <button type="button" onClick={() => setHistoryOffset((value) => Math.max(0, value - 20))}>Previous examinations</button>}
+ {history?.hasMore && <button type="button" onClick={() => setHistoryOffset((value) => value + 20)}>Older examinations</button>}
+ </div>
+ </div>
<div className="flex flex-wrap items-center gap-2">
<button
type="button"
@@ -255,6 +304,7 @@ export default function PromptFromMedia({
type="button"
onClick={() => { setSource(null); setResult(null); }}
className="min-h-[44px] min-w-[44px] flex items-center justify-center p-1.5 text-gray-400 hover:text-white"
+ disabled={running}
aria-label="Clear selected media"
>
<X className="w-3.5 h-3.5" />
diff --git a/client/src/components/media/PromptFromMedia.test.jsx b/client/src/components/media/PromptFromMedia.test.jsx
index dc7d510e17..8753254b38 100644
--- a/client/src/components/media/PromptFromMedia.test.jsx
+++ b/client/src/components/media/PromptFromMedia.test.jsx
@@ -1,9 +1,11 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
-import { MemoryRouter } from 'react-router';
+import { MemoryRouter, Routes, Route } from 'react-router';
import PromptFromMedia from './PromptFromMedia';
import * as api from '../../services/apiMediaJobs';
+vi.mock('../../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() } }));
+
vi.mock('../../hooks/useProviderModels', () => ({
default: vi.fn(() => ({
providers: [
@@ -24,6 +26,8 @@ vi.mock('../../hooks/useVisionModelIds', () => ({
vi.mock('../../services/apiMediaJobs', () => ({
promptFromMedia: vi.fn(),
+ listMediaPromptExaminations: vi.fn(async () => ({ items: [], hasMore: false })),
+ getMediaPromptExamination: vi.fn(),
}));
vi.mock('../imageGen/GalleryImagePicker', () => ({ default: () => null }));
@@ -142,9 +146,26 @@ describe('PromptFromMedia', () => {
expect(onResult).toHaveBeenCalledWith(payload);
});
- it('skips the disclosure toggle when hosted as an always-open card', () => {
+ it('skips the disclosure toggle when hosted as an always-open card', async () => {
renderPanel({ alwaysOpen: true, initialSource: null });
+ await screen.findByText('No saved examinations yet.');
expect(screen.queryByRole('button', { name: /toggle prompt from media/i })).toBeNull();
expect(screen.getByRole('button', { name: /pick image/i })).toBeInTheDocument();
});
});
+
+// Returning from either renderer restores the complete examination without a provider call.
+it('reopens both saved prompts from a durable examination URL', async () => {
+ api.getMediaPromptExamination.mockResolvedValue({
+ id: 'saved', source: { sourceKind: 'image', filename: 'still.png' },
+ result: { imagePrompt: 'Moonlit mountains', videoPrompt: 'Clouds drift over mountains', imageNegativePrompt: 'blur' },
+ });
+ render(<MemoryRouter initialEntries={['/media/prompt/saved']}><Routes>
+ <Route path="/media/prompt/:examinationId" element={<PromptFromMedia alwaysOpen />} />
+ </Routes></MemoryRouter>);
+ await screen.findByDisplayValue('Moonlit mountains');
+ expect(screen.getByDisplayValue('Clouds drift over mountains')).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Open in Image Gen' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Open in Video Gen' })).toBeTruthy();
+ expect(api.promptFromMedia).not.toHaveBeenCalled();
+});
diff --git a/client/src/services/apiMediaJobs.js b/client/src/services/apiMediaJobs.js
index b77d1285a2..34efe4a3c8 100644
--- a/client/src/services/apiMediaJobs.js
+++ b/client/src/services/apiMediaJobs.js
@@ -67,3 +67,6 @@ export const listMediaVideoHolds = (options = {}) => request('/media-jobs/holds'
// Resume only the retained jobs covered by this local video hold.
export const resumeMediaVideoHold = (holdId, options = {}) =>
request(`/media-jobs/holds/${encodeURIComponent(holdId)}/resume`, { method: 'POST', ...options });
+
+export const listMediaPromptExaminations = (offset = 0, options) => request(`/media-jobs/prompt-history?offset=${offset}`, options);
+export const getMediaPromptExamination = (id, options) => request(`/media-jobs/prompt-history/${encodeURIComponent(id)}`, options);
diff --git a/docs/STORAGE.md b/docs/STORAGE.md
index 51d1577e7f..2024ebc17f 100644
--- a/docs/STORAGE.md
+++ b/docs/STORAGE.md
@@ -690,3 +690,7 @@ continues its unchanged allowlist (`metadata.json`, `output.txt`, `prompt.txt`).
Filesystem backups include both gzip assets and their sidecars, and restore keeps
them readable without a conversion. Data Management's backup export keeps its
originals and is distinct from space reclamation.
+
+### Media prompt examinations
+
+`media_prompt_examinations` is db-primary, machine-local history of explicit media analyses. Each immutable UUID record retains the source kind and filename/video ID, both requested prompts and negatives, rationale, and provider/model attribution. Source references are descriptive locators, not foreign keys: examinations remain usable after source media deletion. No binary data or credentials are stored. Lists are paginated and details loaded on demand. PostgreSQL dumps cover the records; migration 418 registers additive boot DDL with no seed or backfill. The JSON adapter is only for development/tests. No federation is added.
diff --git a/scripts/migrations/418-media-prompt-examinations.js b/scripts/migrations/418-media-prompt-examinations.js
new file mode 100644
index 0000000000..f05e5efe16
--- /dev/null
+++ b/scripts/migrations/418-media-prompt-examinations.js
@@ -0,0 +1,6 @@
+export default {
+ async up() {
+ console.log('📚 Media prompt examination history is installed by ensureSchema at boot');
+ return { success: true };
+ },
+};
diff --git a/server/lib/db/schema/media.js b/server/lib/db/schema/media.js
index 47eef114f4..6745ae68cf 100644
--- a/server/lib/db/schema/media.js
+++ b/server/lib/db/schema/media.js
@@ -2,6 +2,13 @@
// boards, and media assets. Extracted verbatim from ensureSchemaImpl() in
// server/lib/db.js (#2832); idempotent, runs on every boot.
export const mediaDdl = [
+ `CREATE TABLE IF NOT EXISTS media_prompt_examinations (
+ id TEXT PRIMARY KEY,
+ source_key TEXT NOT NULL,
+ data JSONB NOT NULL,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
+ )`,
+ `CREATE INDEX IF NOT EXISTS idx_media_prompt_examinations_created ON media_prompt_examinations (created_at DESC, id DESC)`,
// Creative Director projects (Phase 3, issue #997). One row per project;
// the full record lives in `data` JSONB, with status/created_at/updated_at
// mirrored into columns (kept in lockstep on every write) for future
diff --git a/server/lib/socketEventContracts.js b/server/lib/socketEventContracts.js
index 0c484be967..ae0e861d86 100644
--- a/server/lib/socketEventContracts.js
+++ b/server/lib/socketEventContracts.js
@@ -460,6 +460,11 @@ export const SOCKET_EVENT_CONTRACTS = Object.freeze({
required: ['recordId', 'kind', 'tagKey'], additionalProperties: false,
},
},
+ 'media-prompt-history:changed': {
+ direction: 'server-to-client',
+ summary: 'A media examination was saved; reconcile history without exposing prompt content.',
+ payloadSchema: { type: 'object', properties: {}, additionalProperties: false },
+ },
'media-jobs:changed': {
direction: 'server-to-client',
summary: 'Invalidate queue snapshots after job, progress, archive or hold changes.',
diff --git a/server/routes/mediaJobs.js b/server/routes/mediaJobs.js
index d1b300b601..77adffdcb2 100644
--- a/server/routes/mediaJobs.js
+++ b/server/routes/mediaJobs.js
@@ -11,6 +11,7 @@ import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { validateRequest } from '../lib/validation.js';
import { listJobs, listQueueJobs, getJob, cancelJob, cancelQueuedJobs, enqueueJob, removeArchivedJob, runJobNow, listVideoHolds, resumeVideoHold, JOB_KINDS, JOB_STATUSES, MEDIA_QUEUE_SHUTTING_DOWN } from '../services/mediaJobQueue/index.js';
import { refineMediaPrompt } from '../services/mediaPromptRefiner.js';
+import { saveMediaPromptExamination, listMediaPromptExaminations, getMediaPromptExamination } from '../services/mediaPromptHistory.js';
import { promptFromMedia } from '../services/mediaPromptFromMedia.js';
import { CODEX_EFFORT_LEVELS } from '../lib/providerModels.js';
import { sanitizeJob } from '../services/mediaJobQueue/sanitizeJob.js';
@@ -147,9 +148,23 @@ router.post('/refine-prompt', asyncHandler(async (req, res) => {
res.json(await refineMediaPrompt(data));
}));
+router.get('/prompt-history', asyncHandler(async (req, res) => {
+ const { offset } = validateRequest(z.object({ offset: z.coerce.number().int().min(0).max(1000000).default(0) }), req.query);
+ res.json(await listMediaPromptExaminations(offset));
+}));
+router.get('/prompt-history/:id', asyncHandler(async (req, res) => {
+ const { id } = validateRequest(z.object({ id: z.string().uuid() }), req.params);
+ const record = await getMediaPromptExamination(id);
+ if (!record) throw new ServerError('Examination not found', { status: 404 });
+ res.json(record);
+}));
+
router.post('/prompt-from-media', asyncHandler(async (req, res) => {
const data = validateRequest(promptFromMediaSchema, req.body);
- res.json(await promptFromMedia(data));
+ const result = await promptFromMedia(data);
+ const source = { sourceKind: data.sourceKind, filename: data.filename, videoId: data.videoId };
+ const record = await saveMediaPromptExamination(source, result);
+ res.json({ ...result, examinationId: record.id });
}));
const resumeHoldParamsSchema = z.object({ holdId: z.string().uuid() });
diff --git a/server/scripts/init-db.sql b/server/scripts/init-db.sql
index 0c6a9bf7c3..94091bd5bc 100644
--- a/server/scripts/init-db.sql
+++ b/server/scripts/init-db.sql
@@ -2271,3 +2271,11 @@ CREATE TABLE IF NOT EXISTS catalog_pending_applies (
payload JSONB NOT NULL,
PRIMARY KEY (kind, id)
);
+
+CREATE TABLE IF NOT EXISTS media_prompt_examinations (
+ id TEXT PRIMARY KEY,
+ source_key TEXT NOT NULL,
+ data JSONB NOT NULL,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
+ );
+CREATE INDEX IF NOT EXISTS idx_media_prompt_examinations_created ON media_prompt_examinations (created_at DESC, id DESC);
diff --git a/server/services/mediaPromptFromMedia.js b/server/services/mediaPromptFromMedia.js
index 771c44b9d4..92b4ef8976 100644
--- a/server/services/mediaPromptFromMedia.js
+++ b/server/services/mediaPromptFromMedia.js
@@ -79,6 +79,7 @@ export function buildPromptFromMediaPrompt({ targets, mediaKind, frameCount, max
const rules = [
'- Output ONLY valid JSON. Replace every <…> with real content; do NOT emit the literal angle-bracket text.',
'- Each prompt field must be the COMPLETE ready-to-render text, paragraph-style — not a summary, not a caption of the file, not a list of changes.',
+ '- Start directly with the subject or scene content. Never prefix prompts with instructions such as Create, Generate, Make, or Render an image/video of. No conversational preamble.',
'- Describe what is actually visible: subject, setting, materials, lighting, color, composition, camera, mood, style.',
'- Do not invent brands, logos, or named characters that are not visible.',
];
@@ -131,8 +132,11 @@ export function parsePromptFromMediaJson(raw, targets) {
throw new Error(lastError?.message || 'Invalid JSON in AI response');
}
- const imagePrompt = wantImage ? trimTo(value.imagePrompt, MAX_PROMPT_LEN) : '';
- const videoPrompt = wantVideo ? trimTo(value.videoPrompt, MAX_PROMPT_LEN) : '';
+ // Some models still return imperative wrappers despite the content-only contract.
+ const contentPrompt = (text) => trimTo(text, MAX_PROMPT_LEN)
+ .replace(/^(?:please\s+)?(?:create|generate|render|make)\s+(?:(?:an?|the)\s+(?:image|video|picture|clip)\s+(?:of|showing|depicting)\s+)?/i, '').trim();
+ const imagePrompt = wantImage ? contentPrompt(value.imagePrompt) : '';
+ const videoPrompt = wantVideo ? contentPrompt(value.videoPrompt) : '';
if (wantImage && (isPlaceholderPrompt(value.imagePrompt) || !imagePrompt)) {
throw new Error('LLM returned an empty image prompt');
}
diff --git a/server/services/mediaPromptFromMedia.test.js b/server/services/mediaPromptFromMedia.test.js
index d633ce048f..d13e03f6d0 100644
--- a/server/services/mediaPromptFromMedia.test.js
+++ b/server/services/mediaPromptFromMedia.test.js
@@ -312,3 +312,14 @@ describe('promptFromMedia', () => {
})).rejects.toMatchObject({ code: 'PROVIDER_NOT_FOUND', status: 404 });
});
});
+
+it('requests subject-first render content without conversational instructions', () => {
+ expect(buildPromptFromMediaPrompt({ targets: ['image', 'video'], mediaKind: 'image', frameCount: 1 }))
+ .toContain('Never prefix prompts with instructions such as Create');
+});
+
+it('removes model instruction wrappers while retaining scene content', () => {
+ const result = parsePromptFromMediaJson(JSON.stringify({ imagePrompt: 'Create a moonlit mountain landscape', videoPrompt: 'Generate a video of clouds drifting over mountains' }), ['image', 'video']);
+ expect(result.imagePrompt).toBe('a moonlit mountain landscape');
+ expect(result.videoPrompt).toBe('clouds drifting over mountains');
+});
diff --git a/server/services/mediaPromptHistory.js b/server/services/mediaPromptHistory.js
new file mode 100644
index 0000000000..61c4218d4d
--- /dev/null
+++ b/server/services/mediaPromptHistory.js
@@ -0,0 +1,49 @@
+import { EventEmitter } from 'node:events';
+import { randomUUID } from 'node:crypto';
+import { join } from 'node:path';
+import { query } from '../lib/db.js';
+import { createPgFileFacade, resolvePgBackend } from '../lib/pgFileFacade.js';
+import { atomicWrite, readJSONFile, PATHS } from '../lib/fileUtils.js';
+import { createFileWriteQueue } from '../lib/fileWriteQueue.js';
+
+export const mediaPromptHistoryEvents = new EventEmitter();
+
+const queueWrite = createFileWriteQueue();
+const file = () => join(PATHS.data, 'media-prompt-examinations.json');
+const read = () => readJSONFile(file(), [], { allowArray: true, strict: true });
+const store = createPgFileFacade({
+ makeFile: () => ({
+ save: (record) => queueWrite(async () => {
+ const records = await read();
+ await atomicWrite(file(), [record, ...records]);
+ }),
+ list: async (offset) => (await read()).slice(offset, offset + 21),
+ get: async (id) => (await read()).find((record) => record.id === id),
+ }),
+ makePg: () => resolvePgBackend({
+ requirement: 'PostgreSQL is required for media prompt history',
+ loadDb: () => import('../lib/db.js'),
+ makePg: () => ({
+ save: (record) => query('INSERT INTO media_prompt_examinations (id, source_key, data, created_at) VALUES ($1, $2, $3, $4)',
+ [record.id, JSON.stringify(record.source), record, record.createdAt]),
+ list: async (offset) => (await query('SELECT data FROM media_prompt_examinations ORDER BY created_at DESC, id DESC LIMIT 21 OFFSET $1', [offset])).rows.map((row) => row.data),
+ get: async (id) => (await query('SELECT data FROM media_prompt_examinations WHERE id = $1', [id])).rows[0]?.data,
+ }),
+ }),
+});
+
+export async function saveMediaPromptExamination(source, result) {
+ const record = { id: randomUUID(), createdAt: new Date().toISOString(), source, result };
+ await (await store.getBackend()).save(record);
+ mediaPromptHistoryEvents.emit('changed');
+ return record;
+}
+
+export async function listMediaPromptExaminations(offset = 0) {
+ const rows = await (await store.getBackend()).list(offset);
+ return { items: rows.slice(0, 20).map(({ id, createdAt, source }) => ({ id, createdAt, source })), hasMore: rows.length > 20 };
+}
+
+export async function getMediaPromptExamination(id) {
+ return (await store.getBackend()).get(id);
+}
diff --git a/server/services/mediaPromptHistory.test.js b/server/services/mediaPromptHistory.test.js
new file mode 100644
index 0000000000..7fc0c27b15
--- /dev/null
+++ b/server/services/mediaPromptHistory.test.js
@@ -0,0 +1,28 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+const state = vi.hoisted(() => ({ records: [] }));
+vi.mock('../lib/fileUtils.js', () => ({
+ PATHS: { data: '/test' },
+ readJSONFile: vi.fn(async () => structuredClone(state.records)),
+ atomicWrite: vi.fn(async (_path, records) => { state.records = structuredClone(records); }),
+}));
+import { saveMediaPromptExamination, listMediaPromptExaminations, getMediaPromptExamination } from './mediaPromptHistory.js';
+
+beforeEach(() => { state.records = []; });
+describe('saved media examination workflow', () => {
+ it('retains both prompts and source across independent and concurrent analyses', async () => {
+ const source = { sourceKind: 'image', filename: 'example.png' };
+ const result = { imagePrompt: 'Mountains', videoPrompt: 'Drifting clouds', imageNegativePrompt: 'blur', model: 'example-model' };
+ const records = await Promise.all([saveMediaPromptExamination(source, result), saveMediaPromptExamination(source, { imagePrompt: 'Another interpretation' })]);
+ expect((await listMediaPromptExaminations()).items).toHaveLength(2);
+ expect(await getMediaPromptExamination(records[0].id)).toMatchObject({ source, result });
+ expect(await getMediaPromptExamination('missing')).toBeUndefined();
+ });
+ it('pages summaries without returning full prompt bodies', async () => {
+ for (let i = 0; i < 22; i++) await saveMediaPromptExamination({ filename: 'example.png' }, { imagePrompt: 'Mountains' });
+ const first = await listMediaPromptExaminations();
+ expect(first.items).toHaveLength(20);
+ expect(first.hasMore).toBe(true);
+ expect(first.items[0]).not.toHaveProperty('result');
+ expect((await listMediaPromptExaminations(20)).items).toHaveLength(2);
+ });
+});
diff --git a/server/services/socket.js b/server/services/socket.js
index 2f2ddee84b..9e5f04aa7c 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -31,6 +31,7 @@ import { reviewEvents } from './review.js';
import { loopEvents } from './loops.js';
import { imageGenEvents } from './imageGenEvents.js';
import { trainingEvents } from './loraTraining/events.js';
+import { mediaPromptHistoryEvents } from './mediaPromptHistory.js';
import { mediaJobEvents } from './mediaJobQueue/index.js';
import { importerEvents, getImporterProgressFrames } from './importerEvents.js';
import { catalogEvents } from './catalogEvents.js';
@@ -934,6 +935,8 @@ function setupMediaGenEventForwarding() {
// consumers (catalog et al.) uniformly — no per-domain event needed. For a
// job canceled *while running* this fires alongside the gen module's `failed`;
// both clear the spinner and the handlers are idempotent.
+ mediaPromptHistoryEvents.on('changed', () => { ioInstance?.emit('media-prompt-history:changed', {}); });
+
mediaJobEvents.on('canceled', (job) => {
if (!ioInstance || !job?.id) return;
const prefix = genEvtPrefix(job.kind);