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: pipeline sidebar shows all series, lettered-balloon image rule

[._.]/ Adam Eivyddc95667850d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 265665bbd5..521b0f8330 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -161,6 +161,32 @@
## Changed
+- **Sidebar Pipeline submenu — all series, not 10 recent issues.** The
+ Create → Pipeline grandchildren now list every series alphabetically
+ (links to `/pipeline/series/:id`) instead of the 10 most recently updated
+ issues. Series-level entries stay coherent across many series — individual
+ issues live under their series page. Sort happens in the fetch effect so
+ the memoized nav tree doesn't re-sort when unrelated `sidebarApps` state
+ changes.
+
+- **Comic-page image prompts — balloon lettering rule.** `composeComicPagePrompt`
+ in `server/services/pipeline/visualStages.js` now formats each dialogue
+ line as `Speech balloon reads: "<text>" (spoken by NAME[, balloon style: <hint>])`
+ and translates `(EARPIECE)` / `(WHISPERED)` / `(THOUGHT)` parentheticals
+ into visual styling hints. The page-layout clause explicitly tells the
+ diffusion model to letter ONLY the quoted text — speaker names and
+ parentheticals were previously being lettered verbatim inside balloons.
+
+- **Prose stage — present tense, non-negotiable.** `data.sample/prompts/stages/pipeline-prose.md`
+ now demands present tense throughout so the upstream draft matches the
+ downstream comic and TV-script adaptations, keeping visual beats
+ translatable across formats.
+
+- **Comic-script stage — target a standard 22-page issue.** The comic-script
+ prompt now anchors on the industry-standard 22-page count (100–140 panels)
+ and tells the LLM to expand action across more panels when the prose draft
+ is short rather than cutting page count.
+
- **Pipeline nav — shorter tab labels.** *Comic Pages* → *Comic*,
*Episode Video* → *Video*. The full names were redundant inside the
Pipeline page where every tab is obviously a pipeline stage.
@@ -201,6 +227,11 @@
## Fixed
+- **Media Jobs Queue — empty prompt tooltip.** Job rows without a prompt
+ no longer render an empty `title=""` tooltip. Rows with a prompt now
+ show the full prompt on hover (the visible cell is still truncated to
+ 80 chars).
+
- **Codex image gen — "Codex returned no session id" false negative.** With
long pipeline prompts (multi-KB comic-script payloads), codex emits the
banner + echoed prompt in a single stderr chunk that exceeds the
@@ -211,3 +242,7 @@
the session-id line either. Adds regression tests for both paths.
## Removed
+
+- **Dead `listRecentPipelineIssues` client API.** Sidebar no longer fetches
+ recent issues, so the corresponding `apiPipeline.js` wrapper is removed.
+ The server route + tests stay for now in case future surfaces want it.
diff --git a/PLAN.md b/PLAN.md
index 69147139b9..efb289a74e 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -176,6 +176,6 @@ Skeleton landed in `server/services/pipeline/` + `client/src/pages/Pipeline*.jsx
- [ ] **Episode-video provider picker (RunwayML / third-party).** Stubs are commented in `server/services/videoGen/`. Once that abstraction lands, the `episodeVideo` handoff should expose a provider picker on the EpisodeVideoStage UI (local LTX vs Runway vs …).
- [ ] **Comic-book PDF export.** Once `stages.comicPages` carries enough panel data + rendered images, export a print-ready PDF.
- [ ] **Voice-controlled stage advancement.** "Next stage", "rerun comic script" via the existing voice agent. Register pipeline stage navigation actions in `server/services/voice/tools.js`.
-- [ ] **Recent-issues dynamic children under the Pipeline sidebar entry.** Currently Pipeline is a single sidebar link; could mirror Apps' `dynamic: 'apps'` pattern in `client/src/components/Layout.jsx`. **Wrinkle:** Apps is a TOP-LEVEL nav entry; Pipeline lives 2 levels deep under Create. The existing `renderNavItem`'s child render is flat — it emits a NavLink per child and ignores `child.children`. Needs either (a) recursive child render (cleaner, but bigger UX questions: indentation/collapsibility/auto-expand-depth) or (b) promoting Pipeline to a top-level nav entry (changes IA; might be the right call once it has its own subnav anyway). Attempted in this PR, backed out as out-of-scope.
+- [x] **Recent-issues dynamic children under the Pipeline sidebar entry.** Shipped — Layout.jsx's `decoratePipelineChild` now hydrates Pipeline with one grandchild per series (`dynamic: 'pipelineSeries'`), focus-debounced refresh, alphabetical sort. Originally landed showing 10 recent issues; reworked 2026-05-14 to show all series so the sidebar stays coherent across many series. Recursive grandchildren render works in `renderNavItem`.
- [ ] **AI-assisted panel/scene prompt generation.** Reserve `pipeline-comic-panel-image-prompt.md` and `pipeline-storyboard-image-prompt.md` template files for a future "AI: turn the script fragment into N image-gen prompts" button on the ComicPages and Storyboards stages.
- [ ] **Per-panel/scene image progress in the Pipeline UI.** Right now ComicPages and Storyboards record `jobId` but don't subscribe to the media-job SSE for live preview. Tie into the existing per-job progress hook so each panel shows live render thumbnails.
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index cfb6b8f883..56953954ea 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -193,7 +193,7 @@ const navItems = [
defaultTo: '/media',
children: [
{ to: '/media', label: 'Media Gen', icon: Layers },
- { to: '/pipeline', label: 'Pipeline', icon: WorkflowIcon, dynamic: 'pipelineRecent' },
+ { to: '/pipeline', label: 'Pipeline', icon: WorkflowIcon, dynamic: 'pipelineSeries' },
{ to: '/world-builder', label: 'World Builder', icon: Globe },
{ to: '/writers-room', label: 'Writers Room', icon: NotebookPen }
]
@@ -383,38 +383,31 @@ export default function Layout() {
return () => socket.off('apps:changed', fetchApps);
}, []);
- // Fetch recent pipeline issues for the Create > Pipeline grandchildren.
- // Refresh on focus so freshly-created/updated issues show up without a
- // full reload — but debounced: alt-tabbing back after 2s shouldn't refetch.
- // Signature guard on setState avoids re-rendering the whole sidebar tree
- // when the items haven't actually changed.
- const [recentPipelineIssues, setRecentPipelineIssues] = useState([]);
+ // Fetch all pipeline series for the Create > Pipeline grandchildren.
+ // Refresh on focus (debounced 30s) so freshly-created or renamed series
+ // surface without a reload. Signature guard avoids re-rendering the whole
+ // sidebar tree when nothing changed.
+ const [pipelineSeries, setPipelineSeries] = useState([]);
useEffect(() => {
- // Track successful fetches only — a failed fetch shouldn't lock out the
- // next focus retry for 30 seconds.
let lastSuccessAt = 0;
- // Include EVERY rendered field — id/updatedAt alone misses cases like
- // a series rename (which doesn't bump the issue's updatedAt) where the
- // sidebar label would stay stale because `sigOf(prev) === sigOf(next)`
- // suppresses the state update.
- const sigOf = (items) => items
- .map((i) => `${i.id}@${i.updatedAt}|${i.number}|${i.title}|${i.seriesName}`)
- .join('||');
- const loadRecent = () => {
- api.listRecentPipelineIssues(10)
+ const sigOf = (items) => items.map((s) => `${s.id}|${s.name}`).join('||');
+ const loadSeries = () => {
+ api.listPipelineSeries()
.then((items) => {
lastSuccessAt = Date.now();
- const next = Array.isArray(items) ? items : [];
- setRecentPipelineIssues((prev) => sigOf(prev) === sigOf(next) ? prev : next);
+ const next = (Array.isArray(items) ? items : []).slice().sort((a, b) =>
+ (a.name || '').localeCompare(b.name || '', undefined, { sensitivity: 'base' }),
+ );
+ setPipelineSeries((prev) => sigOf(prev) === sigOf(next) ? prev : next);
})
.catch((err) => {
- console.warn(`⚠️ Sidebar pipeline-recent fetch failed: ${err?.message || err}`);
+ console.warn(`⚠️ Sidebar pipeline-series fetch failed: ${err?.message || err}`);
});
};
- loadRecent();
+ loadSeries();
const onFocus = () => {
if (Date.now() - lastSuccessAt < 30_000) return;
- loadRecent();
+ loadSeries();
};
window.addEventListener('focus', onFocus);
return () => window.removeEventListener('focus', onFocus);
@@ -424,23 +417,24 @@ export default function Layout() {
localStorage.setItem(SIDEBAR_KEY, String(collapsed));
}, [collapsed]);
- // Build dynamic nav items with app children + recent pipeline issues.
+ // Build dynamic nav items with app children + pipeline series.
// `decoratePipelineChild` is defined inside the memo so its closure over
- // `recentPipelineIssues` doesn't require an eslint-disable, and so it
- // isn't reallocated on every render.
+ // `pipelineSeries` doesn't require an eslint-disable, and so it isn't
+ // reallocated on every render.
const resolvedNavItems = useMemo(() => {
const decoratePipelineChild = (child) => {
- if (child.dynamic !== 'pipelineRecent') return child;
+ if (child.dynamic !== 'pipelineSeries') return child;
return {
...child,
- grandChildren: recentPipelineIssues.map((iss) => ({
- to: `/pipeline/issues/${iss.id}/idea`,
- label: `#${iss.number} ${iss.title}`.slice(0, 60),
- title: `${iss.seriesName} — #${iss.number} ${iss.title}`,
- // Active-detection prefix — the actual to-link points at /idea
- // for a clean default, but the sidebar should highlight when the
- // user is on ANY stage of this issue.
- activePathPrefix: `/pipeline/issues/${iss.id}`,
+ grandChildren: pipelineSeries.map((s) => ({
+ to: `/pipeline/series/${s.id}`,
+ label: s.name || '(untitled series)',
+ title: s.name || '(untitled series)',
+ // Active-detection prefix — highlight while on the series page
+ // OR any issue belonging to that series. The issue page itself
+ // doesn't carry seriesId in its URL, so per-issue highlighting
+ // stays handled inside PipelineIssue's own breadcrumb.
+ activePathPrefix: `/pipeline/series/${s.id}`,
})),
};
};
@@ -464,7 +458,7 @@ export default function Layout() {
}
return item;
});
- }, [sidebarApps, recentPipelineIssues]);
+ }, [sidebarApps, pipelineSeries]);
// Auto-expand sections when on a child page
useEffect(() => {
diff --git a/client/src/components/media/MediaJobsQueue.jsx b/client/src/components/media/MediaJobsQueue.jsx
index c4a9fb7e9b..3ea62148a4 100644
--- a/client/src/components/media/MediaJobsQueue.jsx
+++ b/client/src/components/media/MediaJobsQueue.jsx
@@ -214,7 +214,7 @@ function JobRow({ job, onCancel, onRetry, onRunNow, onDelete }) {
<span className="text-port-text-muted"> · #{job.position} in queue</span>
)}
</div>
- <div className="text-xs text-port-text-muted truncate">
+ <div className="text-xs text-port-text-muted truncate" title={job.params?.prompt || undefined}>
{job.params?.prompt ? `"${job.params.prompt.slice(0, 80)}${job.params.prompt.length > 80 ? '…' : ''}"` : 'no prompt'}
{job.owner && <span> · {job.owner}</span>}
</div>
diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.js
index 5fcd1f1e0f..2f4fc6762a 100644
--- a/client/src/services/apiPipeline.js
+++ b/client/src/services/apiPipeline.js
@@ -85,11 +85,6 @@ export const extractPipelineBibles = (seriesId, { issueId, corpus, kinds, provid
export const listPipelineIssues = (seriesId) =>
request(`/pipeline/series/${encodeURIComponent(seriesId)}/issues`);
-// Recently-updated issues across all series. Used by the sidebar to surface
-// in-flight pipeline work without forcing the user to drill in.
-export const listRecentPipelineIssues = (limit = 10) =>
- request(`/pipeline/issues/recent?limit=${encodeURIComponent(limit)}`);
-
export const createPipelineIssue = (seriesId, data) =>
request(`/pipeline/series/${encodeURIComponent(seriesId)}/issues`, {
method: 'POST',
diff --git a/data.sample/prompts/stages/pipeline-comic-script.md b/data.sample/prompts/stages/pipeline-comic-script.md
index ee599c3bb4..a077679422 100644
--- a/data.sample/prompts/stages/pipeline-comic-script.md
+++ b/data.sample/prompts/stages/pipeline-comic-script.md
@@ -47,10 +47,11 @@ Return a markdown document with this exact structure:
## Rules
-- Plan **5–7 panels per page**, with rare 1-panel splash pages for big reveals. A typical 22-page issue lands at 100–140 panels — but for a single-issue script driven by an ~800-word prose draft, target **8–12 pages** unless the prose is exceptionally action-heavy.
+- Target a standard **22-page** comic issue (100–140 panels total). Plan **5–7 panels per page**, with rare 1-panel splash pages for big reveals. If the prose draft is short, expand the action — pace beats across more panels, add reaction shots, environmental establishing panels, and visual transitions — rather than cutting page count. Only deviate from 22 pages if the issue genuinely demands it (e.g. a designated double-sized special).
- Panel descriptions stay in **present tense** and describe only what's on the page.
- Dialogue is short — comic balloons hold about 25 words max. Break long speeches across panels.
- Use **CAPS for character names** in dialogue attributions (`LINA:`), and call out **emphasis** with bold.
+- **Balloon contents = quoted text only.** The CAPS speaker name and any parenthetical modifier (`(EARPIECE)`, `(WHISPERED)`, `(THOUGHT)`, `(OFF-PANEL)`, etc.) are *attribution* — they tell the artist whose mouth/earpiece the balloon points to and what shape to draw (jagged for radio, dashed for whisper, cloud for thought). **Never repeat the speaker name or modifier inside the quoted line** (write `ETTA (EARPIECE): "Stall forty-one is the buy."`, NOT `ETTA (EARPIECE): "ETTA (EARPIECE): Stall forty-one is the buy."` — and never inline speaker tags like `"— Etta"` inside the quoted text either). Downstream image-gen leaks any text it sees into the lettered balloon.
- Captions for time/place jumps (`CAPTION: THREE HOURS LATER`) or interiority that can't be drawn.
- SFX sparingly — only when they add to the page's energy.
- Never re-describe a character's permanent appearance once introduced; just name them.
diff --git a/data.sample/prompts/stages/pipeline-prose.md b/data.sample/prompts/stages/pipeline-prose.md
index b2538c2318..ca78a6c44e 100644
--- a/data.sample/prompts/stages/pipeline-prose.md
+++ b/data.sample/prompts/stages/pipeline-prose.md
@@ -30,7 +30,7 @@ You are a short-fiction author drafting one issue / episode of an ongoing series
A self-contained short-story draft for this issue, **800–1500 words**. Structure it with H2 markdown scene breaks (`## Scene N — Slugline`) every time the location, time, or POV shifts — these scene breaks become the anchor points for the later script adaptations, so be deliberate about them.
-- Use third-person past tense unless the series notes specify otherwise.
+- Write in **present tense** throughout — every action, every beat. Present tense reads "she opens the door," not "she opened the door." This is non-negotiable: the downstream comic and TV adaptations both work in present tense, and matching tense upstream keeps the visual beats translatable. Use third-person POV unless the series notes specify otherwise.
- Open *in scene*, not on exposition.
- Show character through action and dialogue, not narration.
- Hit every beat from the beat sheet, but feel free to inflate one beat into multiple scenes if it has more weight.
diff --git a/server/services/pipeline/visualStages.js b/server/services/pipeline/visualStages.js
index bee5526cb3..3d22a1ec6b 100644
--- a/server/services/pipeline/visualStages.js
+++ b/server/services/pipeline/visualStages.js
@@ -107,6 +107,51 @@ export function composeVisualPrompt({ series, description, slugline = '', extraS
return applyWorldStyle(scenePrompt, world);
}
+// Marvel/DC scripts attach parentheticals to speakers — `ETTA (EARPIECE):`,
+// `KESSA (WHISPERED):`, `LINA (THOUGHT):`. These tell a human artist HOW to
+// draw the balloon (jagged for transmitted voices, dashed for whispers,
+// cloud-outline for thoughts), but a diffusion model treats them as more text
+// to letter. Map them to visual balloon-style hints so the artist still gets
+// the cue without the label leaking into the lettering.
+const BALLOON_STYLE_HINTS = [
+ { test: /\b(EARPIECE|RADIO|COMM|TRANSMISSION|PHONE|HOLO|HOLOGRAM|INTERCOM|SPEAKER|TV|MONITOR|VIDEO)\b/, hint: 'jagged electronic/transmission balloon with bolt-shaped tail' },
+ { test: /\b(WHISPER(?:ED|S|ING)?|SOTTO|HUSHED|QUIET)\b/, hint: 'dashed-outline whisper balloon' },
+ { test: /\b(SHOUT(?:ED|S|ING)?|YELL(?:ED|S|ING)?|SCREAM(?:ED|S|ING)?|ANGRY|BURST)\b/, hint: 'spiked/burst-shaped balloon' },
+ { test: /\b(THOUGHT|THINKING|INTERNAL)\b/, hint: 'cloud-outline thought balloon with chain-of-bubbles tail' },
+ { test: /\b(SING(?:S|ING)?|SONG|MUSICAL)\b/, hint: 'wavy musical balloon with musical-note flourish' },
+ { test: /\b(OFF[\- ]?PANEL|OFF[\- ]?SCREEN|O\.?S\.?|O\.?P\.?)\b/, hint: 'off-panel balloon with tail pointing past the panel border' },
+ { test: /\b(NARRATION|VOICE[\- ]?OVER|V\.?O\.?)\b/, hint: 'rectangular narration caption rather than a speech balloon' },
+];
+
+/**
+ * Build one balloon attribution string: `Speech balloon reads: "<text>" (spoken
+ * by NAME[, <style hint>]).` Leads with the lettered text so the diffusion
+ * model anchors on the balloon's contents; parses any parenthetical modifier
+ * on the speaker into a visual styling hint (radio, whisper, thought, etc.).
+ * Returns null if `line` is blank — the caller filters those out.
+ */
+function formatBalloon(character, line) {
+ const text = (line || '').trim();
+ if (!text) return null;
+ const raw = (character || '').trim() || 'CHAR';
+ // Split `NAME (MODIFIER)` → speaker base + modifier text. Tolerate stacked
+ // parens (`NAME (EARPIECE, WHISPERED)`) by treating the whole inner-paren
+ // blob as one modifier string for hint detection.
+ const m = raw.match(/^([^(]+?)\s*\(([^)]*)\)\s*$/);
+ const speaker = (m ? m[1] : raw).trim() || 'CHAR';
+ const modifier = m ? m[2].trim() : '';
+ const cleanText = text.replace(/^"+|"+$/g, '').trim();
+ const styleHint = modifier
+ ? BALLOON_STYLE_HINTS.find((h) => h.test.test(modifier.toUpperCase()))?.hint
+ : null;
+ const attribution = styleHint
+ ? `(spoken by ${speaker}; ${styleHint})`
+ : `(spoken by ${speaker})`;
+ // Terminator handled here so endPunct() at the call site doesn't have to
+ // navigate the closing paren — we always end with `).`.
+ return `Speech balloon reads: "${cleanText}" ${attribution}.`;
+}
+
export function composeComicPagePrompt({
series, world, page, pageNumber, extraStyle = '',
matchedCharacters = [], matchedSettings = [], matchedObjects = [],
@@ -157,22 +202,26 @@ export function composeComicPagePrompt({
const idx = i + 1;
const desc = (p.description || '').trim() || 'continuation of previous beat';
const parts = [`Panel ${idx}: ${endPunct(desc)}`];
- if (p.caption && p.caption.trim()) parts.push(`Caption: "${endPunct(p.caption.trim())}"`);
+ if (p.caption && p.caption.trim()) parts.push(`Narration caption box reads: "${endPunct(p.caption.trim())}"`);
if (Array.isArray(p.dialogue) && p.dialogue.length > 0) {
- // Trim first so whitespace-only character / line fields don't pass the
- // truthy guard and emit malformed `: ""` entries. Drop dialogue rows
- // whose line is empty — they have nothing for the artist to render.
+ // Format each dialogue line as `Speech balloon reads: "<text>" (spoken
+ // by NAME[, balloon style: <hint>])`. Lettered content (the quoted
+ // text) leads so the diffusion model anchors on it; speaker + style
+ // hints trail as attribution. The previous `NAME (MODIFIER): "text"`
+ // shape (Marvel/DC script convention) was being lettered verbatim
+ // INTO balloons by the image model — including the speaker name and
+ // parentheticals like "(EARPIECE)". Dropping speaker into the
+ // attribution slot and translating common parentheticals to balloon
+ // styling hints (jagged for radio/earpiece, dashed for whisper, cloud
+ // for thought) preserves the artistic intent without leaking labels
+ // into the lettered text.
const dlg = p.dialogue
- .map((d) => {
- const character = (d.character || '').trim() || 'CHAR';
- const line = (d.line || '').trim();
- return line ? `${character}: "${line}"` : null;
- })
+ .map((d) => formatBalloon(d.character, d.line))
.filter(Boolean)
- .join(' / ');
- if (dlg) parts.push(`Dialogue: ${endPunct(dlg)}`);
+ .join(' ');
+ if (dlg) parts.push(dlg);
}
- if (p.sfx && p.sfx.trim()) parts.push(`SFX: ${endPunct(p.sfx.trim())}`);
+ if (p.sfx && p.sfx.trim()) parts.push(`SFX lettering: ${endPunct(p.sfx.trim())}`);
return parts.join(' ');
});
@@ -180,7 +229,7 @@ export function composeComicPagePrompt({
const styleClause = styleStack ? ` Art style: ${styleStack}.` : '';
const seriesClause = series?.name ? ` from the series "${series.name}"` : '';
- const layout = `A single full printable comic book page${seriesClause}, page ${pageNumber}. Render a balanced multi-panel comic page layout with ${panels.length} clearly bordered panel${panels.length === 1 ? '' : 's'} arranged for left-to-right, top-to-bottom reading. Include lettered speech balloons for dialogue, rectangular narration captions, and stylized SFX where indicated. Each panel must be visually distinct, with consistent character designs across panels.${styleClause}`;
+ const layout = `A single full printable comic book page${seriesClause}, page ${pageNumber}. Render a balanced multi-panel comic page layout with ${panels.length} clearly bordered panel${panels.length === 1 ? '' : 's'} arranged for left-to-right, top-to-bottom reading. Include lettered speech balloons for dialogue, rectangular narration boxes for captions, and stylized SFX where indicated. **Balloon lettering rule: each speech balloon contains ONLY the quoted text shown after "Speech balloon reads:". NEVER letter the speaker's name, role, or any parenthetical attribution (e.g. "(EARPIECE)", "(WHISPERED)", "(OFF-PANEL)") inside the balloon — those are tail-direction and balloon-styling cues for the artist, not lettered content.** Each panel must be visually distinct, with consistent character designs across panels.${styleClause}`;
const featuringClause = featuring ? `\n\nFeaturing — ${featuring}` : '';
const settingClause = settingsClause ? `\n\nSetting — ${settingsClause}` : '';
const notableClause = notable ? `\n\nNotable — ${notable}` : '';
diff --git a/server/services/pipeline/visualStages.test.js b/server/services/pipeline/visualStages.test.js
index 5b22a3c4c6..d143ecbb37 100644
--- a/server/services/pipeline/visualStages.test.js
+++ b/server/services/pipeline/visualStages.test.js
@@ -115,9 +115,45 @@ describe('composeComicPagePrompt', () => {
expect(prompt).toMatch(/Art style: gritty ink-wash/);
expect(prompt).toMatch(/Panel 1: Wide establishing shot/);
expect(prompt).toMatch(/Panel 2: Tight close-up/);
- expect(prompt).toMatch(/Caption: "The titan died/);
- expect(prompt).toMatch(/Dialogue: KESSA: "If you had any sense/);
- expect(prompt).toMatch(/SFX: fmp/);
+ expect(prompt).toMatch(/Narration caption box reads: "The titan died/);
+ expect(prompt).toMatch(/Speech balloon reads: "If you had any sense, you'd stow away\." \(spoken by KESSA\)\./);
+ expect(prompt).toMatch(/SFX lettering: fmp/);
+ });
+
+ it('lifts parenthetical speaker modifiers into balloon-style hints without leaking them into the lettered text', () => {
+ const page = {
+ panels: [{
+ description: 'Lina ducks behind a market stall, hand to her ear.',
+ dialogue: [
+ { character: 'ETTA (EARPIECE)', line: 'Stall forty-one is the buy.' },
+ { character: 'LINA (WHISPERED)', line: "Don't get clever." },
+ { character: 'LINA (THOUGHT)', line: 'He always gets clever.' },
+ ],
+ }],
+ };
+ const prompt = composeComicPagePrompt({ series: SERIES, page, pageNumber: 1 });
+ // The lettered text is exactly the quoted line — no speaker label, no parenthetical.
+ expect(prompt).toMatch(/Speech balloon reads: "Stall forty-one is the buy\." \(spoken by ETTA; jagged electronic\/transmission balloon[^)]*\)\./);
+ expect(prompt).toMatch(/Speech balloon reads: "Don't get clever\." \(spoken by LINA; dashed-outline whisper balloon\)\./);
+ expect(prompt).toMatch(/Speech balloon reads: "He always gets clever\." \(spoken by LINA; cloud-outline thought balloon[^)]*\)\./);
+ // Defensive: the raw "(EARPIECE)" / "(WHISPERED)" / "(THOUGHT)" labels must
+ // never appear inside the lettered balloon text. Scope the check to the
+ // `Speech balloon reads: "..."` segments only — the layout instruction
+ // itself legitimately cites these labels in quotes as a forbid-list.
+ const balloonTexts = [...prompt.matchAll(/Speech balloon reads: "([^"]+)"/g)].map((m) => m[1]);
+ expect(balloonTexts).toHaveLength(3);
+ for (const text of balloonTexts) {
+ expect(text).not.toMatch(/\(EARPIECE\)/);
+ expect(text).not.toMatch(/\(WHISPERED\)/);
+ expect(text).not.toMatch(/\(THOUGHT\)/);
+ expect(text).not.toMatch(/^[A-Z]+:/); // no `NAME:` prefix inside balloon
+ }
+ });
+
+ it('forbids speaker labels inside balloon lettering via the layout instruction', () => {
+ const prompt = composeComicPagePrompt({ series: SERIES, page: PAGE, pageNumber: 1 });
+ expect(prompt).toMatch(/balloon contains ONLY the quoted text/i);
+ expect(prompt).toMatch(/NEVER letter the speaker's name/i);
});
it('uses singular "panel" wording for a one-panel splash page', () => {
@@ -183,7 +219,7 @@ describe('composeComicPagePrompt', () => {
const page = { panels: [{ description: 'A solitary frame', sfx: 'fmp' }] };
const prompt = composeComicPagePrompt({ series: SERIES, page, pageNumber: 1 });
expect(prompt).toMatch(/Panel 1: A solitary frame\./);
- expect(prompt).toMatch(/SFX: fmp\./);
+ expect(prompt).toMatch(/SFX lettering: fmp\./);
});
});