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

[issue-1809] Image gen × Catalog: editable, canon-grounded portrait prompts

Adam Eivy215dbb329826
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index d230a1add7..54e72385f2 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -17,6 +17,7 @@
## Catalog
+- **[issue-1809] Generate a catalog ingredient's image from an editable, canon-grounded prompt.** The **Generate** button on an ingredient's media panel no longer fires a fixed one-line prompt — it opens an inline editor pre-filled with a prompt composed from the ingredient itself: every populated visual field (physical description, visual notes/identity, silhouette/posture, special traits, with description/summary as fallback) folded together, the ingredient's tags appended as style tokens, and — when the ingredient is linked to a universe — that universe's style preset layered on top so renders stay on-model. You can tweak the prompt and negative prompt before rendering, or write your own from scratch even for an ingredient with no visual text yet. The result attaches back to the ingredient as its **portrait** (first render) or a **reference** (later renders), durably filed by the server even if you navigate away mid-render. (Closes #1809)
- **[issue-1762] Catalog gains universe/series/tag filters, real pagination, and an Albums grouped view.** The Catalog page had outgrown a flat, hard-capped list of 200 ingredients with only type chips + search. It now exposes the universe, series, and tag facets the server already understood as filter dropdowns (series scoped to the chosen universe), all reflected in the URL (`?type=&universe=&series=&tag=&q=&view=`) so a filtered catalog is shareable and back-button-safe. The flat Grid view paginates past the old cap with a "Load more" button (60/page) and an honest "showing X of N" line. A new **Albums** view groups ingredients by universe with a pinned **"Unsorted / Raw"** album (ingredients linked to nothing yet) and an **"Orphaned"** album (refs whose universe/series was deleted) — each lazy-loading its cards on first expand. The multi-select action bar can now **place a selection into a universe/series** directly, closing the raw → placed loop. Server-side: `listIngredients` gained `refKind`/`refId`/`unlinked`/`orphaned` filters, a new `GET /api/catalog/facets` aggregates type/universe/series/tag facets plus unlinked/orphaned bucket counts in one round-trip, and the shared `<CatalogCard>` is extracted so the grid and albums render identical cards. (`server/services/catalogDB.js`, `server/routes/catalog.js`, `server/lib/catalogValidation.js`, `client/src/pages/Catalog.jsx`, `client/src/components/catalog/`, `client/src/services/apiCatalog.js`)
## Creative Director
diff --git a/client/src/pages/CatalogIngredient.jsx b/client/src/pages/CatalogIngredient.jsx
index e461970446..7ec0492b34 100644
--- a/client/src/pages/CatalogIngredient.jsx
+++ b/client/src/pages/CatalogIngredient.jsx
@@ -26,6 +26,7 @@ import {
import { listImageGallery } from '../services/apiImageVideo';
import { generateImage } from '../services/apiSystem';
import { composeCanonStyledPrompt } from '../lib/composeStyledPrompt';
+import { getUniverse } from '../services/apiUniverseBuilder';
import useMounted from '../hooks/useMounted';
import MediaJobThumb from '../components/pipeline/MediaJobThumb';
import IngredientPicker from '../components/IngredientPicker';
@@ -67,20 +68,41 @@ function REFKIND_LABEL(kind) {
// Build the image-generation prompt source from the (live, editable) payload:
// the type's primary content field first, then a curated set of *visual*
-// description fields, so a character renders from physicalDescription and a
-// place/object/idea from description/summary. Intentionally narrower than the
-// type's full snippetFallbackKeys — keys like `role`/`notes`/`significance`
-// describe the entity but don't depict it, and would seed weak prompts.
-// Returns '' when nothing usable is present — the generate button gates on it.
-const GENERATION_DESCRIPTION_KEYS = ['physicalDescription', 'description', 'summary'];
-function deriveGenerationDescription(payload, typeDef) {
- if (!payload || typeof payload !== 'object') return '';
- const keys = [typeDef?.primaryContentKey, ...GENERATION_DESCRIPTION_KEYS].filter(Boolean);
- for (const k of keys) {
- const v = payload[k];
- if (typeof v === 'string' && v.trim()) return v.trim();
+// description fields, so a character renders from its full appearance and a
+// place/object/idea from description/summary. The keys are the ones that DEPICT a
+// subject — `role`/`notes`/`significance` describe the entity but don't depict it
+// and would seed weak prompts, so they're excluded. Unlike the old single-field
+// derive, this folds EVERY populated visual field together (#1809) so a character
+// renders from physicalDescription PLUS visualNotes/visualIdentity/etc., and
+// appends the ingredient's tags as extra prompt tokens. Capped so a verbose canon
+// entry can't blow up the prompt. Returns '' when nothing usable is present (the
+// editor prefill falls back to the name alone). Exported for unit tests.
+export const GENERATION_VISUAL_KEYS = [
+ 'physicalDescription', 'visualNotes', 'visualIdentity',
+ 'silhouetteNotes', 'postureNotes', 'specialTraits',
+ 'description', 'summary',
+];
+const GENERATION_SEED_MAX = 700;
+export function buildGenerationPromptSeed(payload, typeDef, tags = []) {
+ const parts = [];
+ if (payload && typeof payload === 'object') {
+ const keys = [typeDef?.primaryContentKey, ...GENERATION_VISUAL_KEYS].filter(Boolean);
+ const seen = new Set();
+ for (const k of keys) {
+ if (seen.has(k)) continue;
+ seen.add(k);
+ const v = payload[k];
+ if (typeof v === 'string' && v.trim()) parts.push(v.trim());
+ }
}
- return '';
+ const tagList = Array.isArray(tags)
+ ? tags.filter((t) => typeof t === 'string' && t.trim()).map((t) => t.trim())
+ : [];
+ let seed = parts.join('. ');
+ if (tagList.length) seed = seed ? `${seed}. ${tagList.join(', ')}` : tagList.join(', ');
+ return seed.length > GENERATION_SEED_MAX
+ ? `${seed.slice(0, GENERATION_SEED_MAX - 1).trimEnd()}…`
+ : seed;
}
export default function CatalogIngredient() {
@@ -333,8 +355,10 @@ export default function CatalogIngredient() {
const isUserType = typeDef.system === false;
const badgeClass = CATALOG_BADGE_BY_ID[record.type] || 'bg-gray-500/20 text-gray-300 border-gray-500/40';
// Prompt source for the Media panel's "Generate" affordance — derived from the
- // currently-edited payload so tweaks to the description feed the next render.
- const genDescription = deriveGenerationDescription(payload, typeDef);
+ // currently-edited payload (+ tags) so tweaks to the description feed the next
+ // render's default prompt. The user can still edit the composed prompt before
+ // generating (#1809).
+ const genDescription = buildGenerationPromptSeed(payload, typeDef, record.tags);
// Group refs by kind for the "Appears in" panel. Tolerates either an array
// of `{ refKind, refId, role }` or a server-grouped shape.
@@ -468,6 +492,7 @@ export default function CatalogIngredient() {
genIngredientId={record.id}
genName={name}
genDescription={genDescription}
+ genUniverseId={universeRef?.refId || null}
onGenerated={handleGeneratedImage}
/>
@@ -854,23 +879,54 @@ function RelationsPanel({ record, relations, onAdd, onRemove }) {
// `MediaJobThumb` surfaces the live diffusion preview and fires `onFilename`
// once complete, which routes to `onComplete` to attach it onto the ingredient.
// Disabled when the description is blank — there's nothing to render from.
-function GenerateImageControl({ ingredientId, name, description, onComplete }) {
+function GenerateImageControl({ ingredientId, name, description, universeId, onComplete }) {
const mountedRef = useMounted();
const [jobId, setJobId] = useState(null);
const [starting, setStarting] = useState(false);
- const canGenerate = !!(description && description.trim());
+ // Editable-prompt panel state (#1809): the user opens an inline editor,
+ // tweaks the auto-composed prompt, then renders — instead of firing a fixed
+ // prompt on the first click.
+ const [editing, setEditing] = useState(false);
+ const [prefilling, setPrefilling] = useState(false);
+ const [prompt, setPrompt] = useState('');
+ const [negativePrompt, setNegativePrompt] = useState('');
+
+ // Open the editor and prefill the prompt with the composed default: the
+ // ingredient's visual seed + tags, layered on the linked universe's style
+ // preset (fetched lazily — the page deliberately doesn't load the universe up
+ // front). A failed/missing universe just omits the preset; the seed still
+ // renders. Don't clobber a prompt the user already edited (re-open keeps it).
+ const openEditor = async () => {
+ setEditing(true);
+ if (prompt.trim()) return; // keep prior edits when re-opening
+ setPrefilling(true);
+ let universe = null;
+ if (universeId) {
+ universe = await getUniverse(universeId, { silent: true }).catch(() => null);
+ }
+ const styled = composeCanonStyledPrompt({
+ name: name || 'Subject',
+ description: description || '',
+ universe,
+ });
+ if (!mountedRef.current) return;
+ // Trim a dangling "Name:" when the ingredient had no visual description yet.
+ setPrompt((styled.prompt || name || '').replace(/:\s*$/, ''));
+ setNegativePrompt(styled.negativePrompt || '');
+ setPrefilling(false);
+ };
- const handleGenerate = async () => {
- if (!canGenerate) {
- toast.error('Add a description before generating an image');
+ const handleRender = async () => {
+ const finalPrompt = prompt.trim();
+ if (!finalPrompt) {
+ toast.error('Enter a prompt before generating an image');
return;
}
setStarting(true);
- const styled = composeCanonStyledPrompt({ name: name || 'Subject', description, universe: null });
const queued = await generateImage(
{
- prompt: styled.prompt,
- negativePrompt: styled.negativePrompt || undefined,
+ prompt: finalPrompt,
+ negativePrompt: negativePrompt.trim() || undefined,
// Durable attach (#1359): tag the queued job with the target ingredient
// so the server-side completion hook files the render even if this page
// unmounts before a long local/Codex render finishes. The onComplete
@@ -883,6 +939,7 @@ function GenerateImageControl({ ingredientId, name, description, onComplete }) {
if (!mountedRef.current) return;
setStarting(false);
if (!queued) return;
+ setEditing(false);
if (queued.jobId) {
// Local/Codex modes enqueue a job — track it live via MediaJobThumb,
// which fires onFilename on completion to attach the result optimistically.
@@ -919,30 +976,72 @@ function GenerateImageControl({ ingredientId, name, description, onComplete }) {
}, []);
return (
- <span className="inline-flex items-center gap-2">
+ <span className="relative inline-flex items-center gap-2">
{jobId && (
<MediaJobThumb jobId={jobId} label="Generated image" size="xs"
onFilename={handleFilename} onStatus={handleStatus} />
)}
- <button
- type="button"
- onClick={handleGenerate}
- disabled={!canGenerate || starting || !!jobId}
- title={canGenerate
- ? 'Generate an image from this item’s description'
- : 'Add a description first to generate an image'}
- className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-port-border text-gray-300 hover:text-white hover:border-port-accent disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {starting || jobId
- ? <Loader2 size={12} className="animate-spin" aria-hidden="true" />
- : <Sparkles size={12} aria-hidden="true" />}
- {jobId ? 'Generating…' : 'Generate'}
- </button>
+ {!editing && (
+ <button
+ type="button"
+ onClick={openEditor}
+ disabled={starting || !!jobId}
+ title="Compose a prompt and generate an image for this item"
+ className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-port-border text-gray-300 hover:text-white hover:border-port-accent disabled:opacity-50 disabled:cursor-not-allowed"
+ >
+ {jobId
+ ? <Loader2 size={12} className="animate-spin" aria-hidden="true" />
+ : <Sparkles size={12} aria-hidden="true" />}
+ {jobId ? 'Generating…' : 'Generate'}
+ </button>
+ )}
+
+ {editing && (
+ <div className="absolute right-0 z-20 mt-2 w-80 max-w-[90vw] rounded-lg border border-port-border bg-port-card p-3 shadow-xl space-y-2"
+ style={{ top: '100%' }}>
+ <div className="flex items-center justify-between">
+ <span className="text-xs font-semibold text-white">Generate image</span>
+ {prefilling && <Loader2 size={12} className="animate-spin text-gray-400" aria-hidden="true" />}
+ </div>
+ <label className="block">
+ <span className="text-[11px] text-gray-400">Prompt</span>
+ <textarea
+ value={prompt}
+ onChange={(e) => setPrompt(e.target.value)}
+ rows={4}
+ placeholder="Describe the image to render…"
+ className="mt-1 w-full text-xs bg-port-bg border border-port-border rounded px-2 py-1 text-gray-200 resize-y"
+ />
+ </label>
+ <label className="block">
+ <span className="text-[11px] text-gray-400">Negative prompt (optional)</span>
+ <textarea
+ value={negativePrompt}
+ onChange={(e) => setNegativePrompt(e.target.value)}
+ rows={2}
+ className="mt-1 w-full text-xs bg-port-bg border border-port-border rounded px-2 py-1 text-gray-200 resize-y"
+ />
+ </label>
+ <div className="flex items-center justify-end gap-2 pt-1">
+ <button type="button" onClick={() => setEditing(false)}
+ className="text-xs px-2 py-1 rounded border border-port-border text-gray-400 hover:text-white">
+ Cancel
+ </button>
+ <button type="button" onClick={handleRender} disabled={starting || prefilling || !prompt.trim()}
+ className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded bg-port-accent text-white hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed">
+ {starting
+ ? <Loader2 size={12} className="animate-spin" aria-hidden="true" />
+ : <Sparkles size={12} aria-hidden="true" />}
+ Render
+ </button>
+ </div>
+ </div>
+ )}
</span>
);
}
-function MediaPanel({ media, missingMedia, onAttach, onSetPortrait, onDetach, genIngredientId, genName, genDescription, onGenerated }) {
+function MediaPanel({ media, missingMedia, onAttach, onSetPortrait, onDetach, genIngredientId, genName, genDescription, genUniverseId, onGenerated }) {
const [pickerOpen, setPickerOpen] = useState(false);
const [dragOver, setDragOver] = useState(false);
const list = Array.isArray(media) ? media : [];
@@ -965,7 +1064,7 @@ function MediaPanel({ media, missingMedia, onAttach, onSetPortrait, onDetach, ge
<ImageIcon size={14} aria-hidden="true" /> Media
</h2>
<div className="flex items-center gap-2">
- <GenerateImageControl ingredientId={genIngredientId} name={genName} description={genDescription} onComplete={onGenerated} />
+ <GenerateImageControl ingredientId={genIngredientId} name={genName} description={genDescription} universeId={genUniverseId} onComplete={onGenerated} />
<button type="button" onClick={() => setPickerOpen(true)}
className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-port-border text-gray-300 hover:text-white hover:border-port-accent">
<Plus size={12} aria-hidden="true" /> Pick from gallery
diff --git a/client/src/pages/CatalogIngredient.test.jsx b/client/src/pages/CatalogIngredient.test.jsx
index c1d050e52b..de2692eaf9 100644
--- a/client/src/pages/CatalogIngredient.test.jsx
+++ b/client/src/pages/CatalogIngredient.test.jsx
@@ -73,6 +73,10 @@ vi.mock('../services/apiCatalog', () => ({
}));
vi.mock('../services/apiSystem', () => ({ generateImage: vi.fn() }));
+// The editable-prompt panel lazily fetches the linked universe to layer its
+// style preset onto the composed prompt; default to "no universe" so the seed
+// renders bare unless a test overrides it.
+vi.mock('../services/apiUniverseBuilder', () => ({ getUniverse: vi.fn(async () => null) }));
// Stand-in for the live image-gen thumb: fire onFilename as soon as a jobId is
// handed in, simulating a completed render without the socket/job machinery.
vi.mock('../components/pipeline/MediaJobThumb', async () => {
@@ -95,7 +99,7 @@ vi.mock('../components/MediaImage', () => ({ default: ({ src, alt }) => <img src
vi.mock('../components/TagPicker', () => ({ default: () => <div data-testid="tag-picker" /> }));
vi.mock('../components/ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn(), info: vi.fn() } }));
-import CatalogIngredient from './CatalogIngredient';
+import CatalogIngredient, { buildGenerationPromptSeed } from './CatalogIngredient';
import { getCatalogIngredientDetails } from '../services/apiCatalog';
const renderPage = () => render(<MemoryRouter><CatalogIngredient /></MemoryRouter>);
@@ -183,7 +187,7 @@ describe('CatalogIngredient — character sheet', () => {
expect(screen.getByText(/Re-render in Universe Builder/i)).toBeTruthy();
});
- it('generates an image from the description and sets it as the portrait', async () => {
+ it('composes the prompt from name + visual fields + tags, then renders and sets the portrait', async () => {
const { generateImage } = await import('../services/apiSystem');
const { setCatalogIngredientPortrait } = await import('../services/apiCatalog');
generateImage.mockResolvedValue({ jobId: 'job-1' });
@@ -191,13 +195,23 @@ describe('CatalogIngredient — character sheet', () => {
renderPage();
await waitFor(() => expect(screen.getByDisplayValue('Sharp eyes, ink-stained cuffs.')).toBeTruthy());
+ // Step 1: open the editor — the prompt prefills with the composed seed.
fireEvent.click(screen.getByRole('button', { name: /^Generate$/i }));
+ await waitFor(() => expect(screen.getByPlaceholderText(/Describe the image to render/i)).toBeTruthy());
+ const promptBox = screen.getByPlaceholderText(/Describe the image to render/i);
+ await waitFor(() => expect(promptBox.value).toMatch(/Ada Lovelace/));
+ // Composed from the name + the type's visual fields + the ingredient's tags.
+ expect(promptBox.value).toMatch(/Sharp eyes/);
+ expect(promptBox.value).toMatch(/mentor/);
+
+ // Step 2: render the (possibly-edited) prompt.
+ fireEvent.click(screen.getByRole('button', { name: /^Render$/i }));
await waitFor(() => expect(generateImage).toHaveBeenCalled());
- // Prompt is composed from the name + the type's primary description field.
const [genPayload] = generateImage.mock.calls[0];
expect(genPayload.prompt).toMatch(/Ada Lovelace/);
expect(genPayload.prompt).toMatch(/Sharp eyes/);
+ expect(genPayload.catalogIngredientId).toBe('cat-chr-1');
// The MediaJobThumb stub fires onFilename → with no existing portrait the
// render is attached as THE portrait.
await waitFor(() => expect(setCatalogIngredientPortrait).toHaveBeenCalledWith(
@@ -214,6 +228,10 @@ describe('CatalogIngredient — character sheet', () => {
await waitFor(() => expect(screen.getByDisplayValue('Sharp eyes, ink-stained cuffs.')).toBeTruthy());
fireEvent.click(screen.getByRole('button', { name: /^Generate$/i }));
+ await waitFor(() => expect(screen.getByRole('button', { name: /^Render$/i })).toBeTruthy());
+ // Wait for the async prefill so Render is enabled before clicking.
+ await waitFor(() => expect(screen.getByRole('button', { name: /^Render$/i })).toHaveProperty('disabled', false));
+ fireEvent.click(screen.getByRole('button', { name: /^Render$/i }));
await waitFor(() => expect(setCatalogIngredientPortrait).toHaveBeenCalledWith(
'cat-chr-1', { mediaKey: 'ext.png' }, { silent: true },
@@ -227,22 +245,38 @@ describe('CatalogIngredient — character sheet', () => {
await waitFor(() => expect(screen.getByDisplayValue('Sharp eyes, ink-stained cuffs.')).toBeTruthy());
fireEvent.click(screen.getByRole('button', { name: /^Generate$/i }));
+ await waitFor(() => expect(screen.getByRole('button', { name: /^Render$/i })).toHaveProperty('disabled', false));
+ fireEvent.click(screen.getByRole('button', { name: /^Render$/i }));
// The MediaJobThumb stub drives onStatus('failed') for 'fail-job'; the
- // control must clear the job and re-enable rather than hang on "Generating…".
+ // control must clear the job, close the editor, and re-enable Generate
+ // rather than hang on "Generating…".
await waitFor(() => {
const btn = screen.getByRole('button', { name: /^Generate$/i });
expect(btn).toHaveProperty('disabled', false);
});
});
- it('disables Generate when the ingredient has no description text', async () => {
+ it('disables Render until a prompt is present (no description → name-only prefill still renders)', async () => {
getCatalogIngredientDetails.mockImplementation(async () => detailsOf({
...CHAR_FIXTURE,
+ tags: [],
payload: { role: 'Mentor' }, // no physicalDescription/description/summary
}));
renderPage();
await waitFor(() => expect(screen.getByRole('button', { name: /^Generate$/i })).toBeTruthy());
- expect(screen.getByRole('button', { name: /^Generate$/i })).toHaveProperty('disabled', true);
+ // Generate is always enabled now — it opens the editor so the user can
+ // compose a prompt even when no visual seed exists.
+ expect(screen.getByRole('button', { name: /^Generate$/i })).toHaveProperty('disabled', false);
+
+ fireEvent.click(screen.getByRole('button', { name: /^Generate$/i }));
+ // The name still seeds the prompt, so Render becomes enabled.
+ await waitFor(() => expect(screen.getByRole('button', { name: /^Render$/i })).toHaveProperty('disabled', false));
+ const promptBox = screen.getByPlaceholderText(/Describe the image to render/i);
+ expect(promptBox.value).toMatch(/Ada Lovelace/);
+
+ // Clearing the prompt disables Render.
+ fireEvent.change(promptBox, { target: { value: ' ' } });
+ await waitFor(() => expect(screen.getByRole('button', { name: /^Render$/i })).toHaveProperty('disabled', true));
});
it('collapses a sheet section when its header is clicked', async () => {
@@ -252,3 +286,63 @@ describe('CatalogIngredient — character sheet', () => {
await waitFor(() => expect(screen.queryByDisplayValue('she/her')).toBeNull());
});
});
+
+describe('buildGenerationPromptSeed', () => {
+ const charType = { primaryContentKey: 'physicalDescription' };
+
+ it('folds every populated visual field together in order', () => {
+ const seed = buildGenerationPromptSeed({
+ physicalDescription: 'Sharp eyes',
+ visualNotes: 'ink-stained cuffs',
+ visualIdentity: 'brass goggles',
+ }, charType);
+ expect(seed).toBe('Sharp eyes. ink-stained cuffs. brass goggles');
+ });
+
+ it('dedupes the primaryContentKey against the visual keys (no double-render)', () => {
+ // physicalDescription is BOTH the primary key and a visual key — it must
+ // only appear once.
+ const seed = buildGenerationPromptSeed({ physicalDescription: 'Once only' }, charType);
+ expect(seed).toBe('Once only');
+ });
+
+ it('appends string tags as comma-joined prompt tokens after the seed', () => {
+ const seed = buildGenerationPromptSeed(
+ { physicalDescription: 'Sharp eyes' }, charType, ['mentor', 'My Cool Universe'],
+ );
+ expect(seed).toBe('Sharp eyes. mentor, My Cool Universe');
+ });
+
+ it('falls back to tags alone when no visual field is present', () => {
+ expect(buildGenerationPromptSeed({ role: 'Mentor' }, charType, ['villain'])).toBe('villain');
+ });
+
+ it('falls back to description / summary when the primary visual key is absent', () => {
+ expect(buildGenerationPromptSeed({ description: 'A quiet place' }, { primaryContentKey: 'name' }))
+ .toBe('A quiet place');
+ expect(buildGenerationPromptSeed({ summary: 'In brief' }, null)).toBe('In brief');
+ });
+
+ it('ignores non-string and blank tags', () => {
+ const seed = buildGenerationPromptSeed(
+ { physicalDescription: 'Sharp eyes' }, charType, [' ', 42, null, 'real'],
+ );
+ expect(seed).toBe('Sharp eyes. real');
+ });
+
+ it('tolerates a non-array tags argument', () => {
+ expect(buildGenerationPromptSeed({ physicalDescription: 'Sharp eyes' }, charType, 'nope'))
+ .toBe('Sharp eyes');
+ });
+
+ it('returns an empty string when nothing usable is present', () => {
+ expect(buildGenerationPromptSeed({ role: 'Mentor' }, charType, [])).toBe('');
+ expect(buildGenerationPromptSeed(null, null, [])).toBe('');
+ });
+
+ it('caps an overly long seed with an ellipsis (≤ 700 chars)', () => {
+ const seed = buildGenerationPromptSeed({ physicalDescription: 'x'.repeat(900) }, charType);
+ expect(seed.length).toBeLessThanOrEqual(700);
+ expect(seed.endsWith('…')).toBe(true);
+ });
+});