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
fix: share one universe style preset between browser and FableLoom compiler (#8442)
[._.]/ Adam Eivyfbc784ab0d9a
diff --git a/client/src/components/fableloom/sceneMediaRequests.js b/client/src/components/fableloom/sceneMediaRequests.jsindex 5652014ebd..6ef49c29fe 100644--- a/client/src/components/fableloom/sceneMediaRequests.js+++ b/client/src/components/fableloom/sceneMediaRequests.js@@ -13,9 +13,9 @@* loom (no universe reachable from the loom or its series) gets no compiled* request back, and the browser preset is the only style it would ever see.* The compiler drops style tokens the authored prompt already carries- * (`dropTokensPresentIn` in server/lib/universeVisualStyle.js), so the linked- * path does not emit the token list twice — do not fix the overlap by- * deleting either side.+ * (`stripStyleClause` matched against the same `universeStylePreset` clause,+ * both in server/lib/universeVisualStyle.js), so the linked path does not+ * emit the token list twice — do not fix the overlap by deleting either side.*/import { composeStyledPrompt } from '../../lib/composeStyledPrompt';diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 8902898a93..4de88cb3b5 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -40,7 +40,7 @@ grep -i "what you want to do" client/src/lib/README.md|---|---|| `canonPrompt.js` | Re-export of `server/lib/canonPrompt.js`. SHORT/RICH/PREVIEW spec + `flattenCanonDescriptorFragments` / `mapCanonDescriptorFragments` / `descriptorForCanonEntry`. Named exports only, so the server-only `flatten*` helpers stay out of the client barrel. || `scenePrompt.js` | Re-export of `server/lib/scenePrompt.js`. Scene-prompt composer + bible matchers. |-| `composeStyledPrompt.js` | Compose user prompt + negative with an optional style preset. `composeCanonStyledPrompt` builds the `"<name>: <description>"` + universe-preset render the canon section and characters step share. |+| `composeStyledPrompt.js` | `composeStyledPrompt` re-exported from `server/lib/composeStyledPrompt.js` (accepts a single preset or an array). `composeCanonStyledPrompt` (client-only) builds the `"<name>: <description>"` + universe-preset render the canon section and characters step share. || `cleanPlatePrompt.js` | Clean-plate prompt builder for setting canon entries (Cluster A — A4). || `personaTraitBlend.js` | Re-export of `server/lib/personaTraitBlend.js`. Digital-twin persona trait-blending (M34 P7) — `describeTraitAdjustments` / `renderTraitBlendDirective` / `BIG_FIVE_LEAN` for the Personas UI preview. || `seasonStructure.js` | Re-export of `server/lib/seasonStructure.js`. |@@ -49,7 +49,7 @@ grep -i "what you want to do" client/src/lib/README.md| `shotContinuity.js` | The storyboards / episode-video stages' INLINE pre-render continuity warnings (#1468). `findAxisReversals` / `findShotTypeMonotony` are re-exported from `server/lib/editorial/shotContinuity.js`, the same detectors the authoritative `visual.shot-continuity` check runs; `sceneShotWarnings(scene, opts)` is the client-only composer (the server emits findings in a different shape). Pure/DOM-free. || `shotGrammar.js` | Storyboard shot-grammar display labels. `SHOT_TYPES` / `SCREEN_DIRECTIONS` are re-exported from `server/lib/shotGrammar.js`, so a hand-set value in the editor always passes `storyboardShotSchema`; `SHOT_TYPE_LABELS` / `SCREEN_DIRECTION_LABELS` are the client-only selects (#1468). || `untrustedContentSources.js` | Untrusted-content source display labels. `UNTRUSTED_CONTENT_SOURCES` / `PRIVATE_UNTRUSTED_CONTENT_SOURCES` are re-exported from `server/lib/untrustedContentSources.js`, so the Abuse Guard panel always offers every source the server screens; `UNTRUSTED_CONTENT_SOURCE_LABELS` is the client-only select (#7680). |-| `universeStylePreset.js` | Build the client-side style preset that `composeStyledPrompt` layers on top. |+| `universeStylePreset.js` | `universeStylePreset(universe, series)` re-exported from `server/lib/universeVisualStyle.js` — the style preset `composeStyledPrompt` layers on top, shared with the FableLoom visual-canon compiler so a series style override composes identically on both sides (#8442). || `universeRunTag.js` | `buildUniverseSectionRenderTag(universe, kindKey, entry)` — the durable `universeRun` job tag the canon-render call sites (UniverseCanonSection, NounsStage, Story Builder characters step) pass to `generateImage` so the server auto-files the render into the universe collection AND appends it to the entry's `imageRefs[]` (no client follow-up PATCH). || `autopilotMilestones.js` | Series-Autopilot milestone map. `buildAutopilotMilestones(plan, progress, {terminal})` folds the run's projected plan (the `start` frame) and its live progress snapshot (`progress` frames / the status route) into ordered rows with a `MILESTONE_STATUS` each — a furthest-index cursor, so a gate the run revisits can't un-finish the milestones after it; `summarizeAutopilotMilestones(rows)` rolls them into the header meter (a settled-but-unstepped milestone counts as complete); `describeAutopilotVerification(kind, verification)` renders what a gate actually validated — shared with the panel's `frameLabel`, since the milestone row and the activity log render the same telemetry; `isStoppedTerminal(terminal)` is the one definition of "the run stopped mid-plan"; `autopilotMarkerTerminal(status)` translates a persisted `autopilot.status` into the terminal frame type the fold reads, so a map rebuilt from the marker after a reload (#4140) flags the step a paused run stopped on. Also owns `AUTOPILOT_STEP_LABELS` / `autopilotStepLabel(kind)`, the one set of human labels for conductor step kinds (shared by the map and the panel's live status line). Used by `components/pipeline/AutopilotMilestones.jsx` + `AutopilotPanel.jsx`. || `beeperMessageBody.js` | Beeper message bodies: `decodeHtmlEntities` (the five predefined entities plus ` `, mirroring `server/lib/xmlEntities.js`), `looksLikeHtmlBody`, `parseMessageBody(body)` → blocks of marked spans (`p`/`div`/`br`/`blockquote`/`strong`/`b`/`em`/`i`/`a[href]`, `null` when the body carries none of them) and `messagePreviewText(body)` for the one-line rail row. Some networks deliver HTML (Discord, Matrix) and the mirror stores it verbatim, so the thread and the preview parse it into a data model and render React elements — never `dangerouslySetInnerHTML`; a non-http(s) `href` degrades to plain text. |@@ -159,7 +159,7 @@ grep -i "what you want to do" client/src/lib/README.md| `repoUrl.js` | `parseRepoUrl(url)` / `isRepoUrl(url)` / `repoBrowseUrl(parsed)` / `parseGitHubUrl(url)` / `isGitHubRepoUrl(url)` — re-exported from `server/lib/repoUrl.js`, the authoritative repo-URL rule. || `healthProvenance.js` | `PROVENANCE_LEVELS` / `getProvenanceLevel(level)` — the `data-backed`/`inferred`/`experimental`/`speculative` trust taxonomy (label, tone, description, "what would change this?" copy) behind the `ProvenanceChip` source-style chips on MeatSpace / genome / death-clock / longevity views. Pure data; the chip component maps tone→color and id→icon. || `healthStyle.js` | Shared health status styles and threshold-aware percentage/bar tones for system health views. |-| `joinInfluenceList.js` | Mirror of `joinInfluenceList` in server universe builder. |+| `joinInfluenceList.js` | `joinInfluenceList` re-exported from `server/lib/universeVisualStyle.js`. || `kanbanColumns.js` | `bucketTickets` / `ticketInColumn` / `columnConfig` / `FALLBACK_COLUMNS` — pure column logic for the Jira Kanban board (`components/KanbanBoard.jsx`). Buckets tickets into resolved workflow columns (by status name, or statusCategory for the fallback board), assigns each column a stable unique `id` (Jira `name` is not unique — same-named columns map to different statuses), appends an orphan column for any unmatched status, and precomputes per-column Tailwind color config (Blocked→red, Review/QA→purple, else by category). || `localLlmBackends.js` | `LOCAL_LLM_BACKENDS` (id/label/lucide icon for Ollama + LM Studio) and `localLlmBackendLabel(id)`. The two backends PortOS keeps a model catalog for, shared by the Runtimes view's backend cards and the Model Library's backend picker so a third backend is added in one place. Exported under qualified names because the barrel is flat and `BACKENDS`/`labelFor` are too generic to claim there. || `localLlmTargetKey.js` | `localLlmTargetKey({ backend, modelId })` — stable string key for a local-LLM compare target. Shared by the LocalLlmTab checkbox grid and the LocalLlmPlayground compare URL so a delimiter change can't desync the round-trip. |diff --git a/client/src/lib/composeStyledPrompt.js b/client/src/lib/composeStyledPrompt.jsindex 9fd9e6bc2e..cf276e1e21 100644--- a/client/src/lib/composeStyledPrompt.js+++ b/client/src/lib/composeStyledPrompt.js@@ -1,27 +1,10 @@-// Compose user prompt + negative with optional style preset(s).-// Preset prompts prefix the user prompt — diffusion models weight earlier-// tokens heaviest, so the broad aesthetic carries over the user's content.-// Preset negatives append to the user negative so user-specified avoids stay-// first-class. An array is accepted when a caller combines independent style-// sources, such as a universe style and a built-in preset.-+// `composeStyledPrompt` (single preset or an array of presets) is a pure leaf+// re-exported from server/lib/composeStyledPrompt.js so the browser and the+// server compose style presets with identical logic (#8442).+import { composeStyledPrompt } from '../../../server/lib/composeStyledPrompt.js';import { universeStylePreset } from './universeStylePreset';-export function composeStyledPrompt(userPrompt, userNegative, preset) {- const prompt = (userPrompt || '').trim();- const negative = (userNegative || '').trim();- const presets = Array.isArray(preset) ? preset : [preset];- const stylePart = presets.map((item) => (item?.prompt || '').trim()).filter(Boolean).join('. ');- const styleNeg = presets.map((item) => (item?.negativePrompt || '').trim()).filter(Boolean).join(', ');- // Avoid trailing ". " when only one of the two parts is non-empty so the- // composed prompt is clean and deterministic regardless of which input- // is missing.- const composedPrompt = stylePart && prompt ? `${stylePart}. ${prompt}` : (stylePart || prompt);- return {- prompt: composedPrompt,- negativePrompt: [negative, styleNeg].filter(Boolean).join(', '),- };-}+export { composeStyledPrompt };// Build the styled `{ prompt, negativePrompt }` for a single named canon subject// (character / place / object) layered on the universe's style preset. This isdiff --git a/client/src/lib/joinInfluenceList.js b/client/src/lib/joinInfluenceList.jsindex 810651f4c0..00bdcd0693 100644--- a/client/src/lib/joinInfluenceList.js+++ b/client/src/lib/joinInfluenceList.js@@ -1,8 +1,6 @@-// Mirror of `joinInfluenceList` in server/services/universeBuilder.js — keep-// in sync. Joins a universe's chip-token list (embrace OR avoid) into the-// comma-separated string the renderer's composeStyledPrompt consumes.-// Tokens are already deduped + capped at write time, so this is a thin join.-export function joinInfluenceList(structured = []) {- if (!Array.isArray(structured)) return '';- return structured.filter((t) => typeof t === 'string' && t.trim()).join(', ');-}+// Joins a universe's chip-token list (embrace OR avoid) into the+// comma-separated string the renderer's composeStyledPrompt consumes. A pure+// leaf re-exported from server/lib/universeVisualStyle.js — see+// `universeVisualStyleTokens` there, which applies the same per-token+// trim/filter to a whole universe (#8442).+export { joinInfluenceList } from '../../../server/lib/universeVisualStyle.js';diff --git a/client/src/lib/universeStylePreset.js b/client/src/lib/universeStylePreset.jsindex 1b9c873fa9..3e51acee83 100644--- a/client/src/lib/universeStylePreset.js+++ b/client/src/lib/universeStylePreset.js@@ -1,30 +1,7 @@-import { joinInfluenceList } from './joinInfluenceList';--// Build the client-side style preset that `composeStyledPrompt` layers on top-// of per-entity image-gen prompts. Mirrors `applyWorldStyle` /-// `buildStyleClause` on the server so canon ref renders share the same visual-// language as comic-page renders.-//-// `universe` may be null — the server-side path still applies the series-// override when only the series has style content (orphan or failed load), so-// the client must do the same. `series` is optional; when omitted the result-// is the universe-only preset (Universe Builder canon section).-//-// `series.stylePromptOverrideMode` (when present) controls composition:-// 'prepend' (default) — override leads, universe embrace trails-// 'append' — universe embrace leads, override trails-// 'override' — drop the universe embrace tokens entirely-// Avoid (negative) tokens always come from the universe; the mode only-// composes the positive embrace clause.-export const universeStylePreset = (universe, series = null) => {- const override = (series?.stylePromptOverride || '').trim();- const mode = series?.stylePromptOverrideMode || 'prepend';- const embrace = universe && (mode !== 'override' || !override)- ? joinInfluenceList(universe.influences?.embrace)- : '';- const avoid = universe ? joinInfluenceList(universe.influences?.avoid) : '';- const positiveParts = mode === 'append' ? [embrace, override] : [override, embrace];- const prompt = positiveParts.filter(Boolean).join('. ');- if (!prompt && !avoid) return null;- return { prompt, negativePrompt: avoid };-};+// `universeStylePreset(universe, series)` is a pure leaf re-exported from+// server/lib/universeVisualStyle.js so the browser (this file's former home)+// and the server's FableLoom visual-canon compiler compose the same series+// override — prepend / append / override — against the universe's embrace+// tokens. A drift between the two used to leave a series override applied in+// the preview but repeated/ignored in the actual render (#8442).+export { universeStylePreset } from '../../../server/lib/universeVisualStyle.js';diff --git a/server/lib/README.md b/server/lib/README.mdindex 5420c8ac44..966f8a3cc4 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -175,7 +175,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `catalogUniverseTags.js` | Pure transform that rewrites legacy machine universe tags (`from-universe`, `universe:<id>`) on backfilled catalog ingredients into friendly universe-NAME tags, preserving user tags + the structured `catalog_ingredient_refs` link. Used by the boot-time repair and the bible→catalog backfill. || `comicScriptParser.js` | Marvel/DC-format comic script parser. || `aspectRatio.js` | Describe a pixel canvas as the ratio phrase a prompt can use — `aspectRatioTerms(w, h)` (bounded best rational approximation, so 1096x1536 reads as 5:7 rather than 137:192) and `aspectRatioPhrase(w, h)` → `"5:7 portrait"` / `"16:9 landscape"` / `"1:1 square"`. Use it wherever a prompt has to state a framing the canvas already fixes, so the sentence and the canvas cannot drift. Pure. |-| `composeStyledPrompt.js` | Compose user prompt + negative with an optional style preset. |+| `composeStyledPrompt.js` | Compose user prompt + negative with an optional style preset, or an array of presets layered in order. Re-exported (unmodified) by `client/src/lib/composeStyledPrompt.js`. || `scriptVideoCompiler.js` | Compiles a scene script + bible into beat-level continuous-video clip specs (duration/frame-grid snapping, byte-stable descriptor injection, chain-length fresh-cut rule). || `creativeDirectorPresets.js` | Locked-at-creation aspect ratio + quality presets for the Creative Director. || `creativeLatitude.js` | The IP-latitude clause every creative LLM request carries (`withCreativeLatitude`, `CREATIVE_LATITUDE_TOKENS`), plus the one creative-vs-operational table both stamp keys are matched against (`isCreativeStage` for stage names, `isCreativeRunSource` for run `source` tags). |@@ -183,7 +183,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `universeBibleLimits.js` | Universe bible field size limits shared between server (sanitizer, pipeline) and client (form inputs). || `universeMarkdown.js` | `universeToMarkdown(record)` / `parseUniverseMarkdown(text)` for the Universe Builder's Markdown world-bible export and import, plus safe download filename helpers. || `universePromptRenderers.js` | Renderers that turn a universe's `categories` map + canon into prompt context, including the authored character-engine block and the shared story canon digest. |-| `universeVisualStyle.js` | The style a universe contributes to an IMAGE prompt: `buildVisualStyleClause(universe, {override, mode})` (curated `influences.embrace` tokens + a series `stylePromptOverride`, NEVER the free-text `styleNotes`, which is writing-stage direction), `universeAestheticLine` (the labeled variant canon sheet/LoRA renders lead with), `universeVisualStyleTokens`, `splitPromptTokens`, `stripStyleClause(text, clause)` (removes the copy the browser already prefixed, so the compiler keeps the LEADING one — matched on the joined clause so a token with its own punctuation like `M.C. Escher` still matches) and `mergeNegativePromptTokens` (token-level union of comma-joined negatives). |+| `universeVisualStyle.js` | The style a universe contributes to an IMAGE prompt: `buildVisualStyleClause(universe, {override, mode})` (curated `influences.embrace` tokens + a series `stylePromptOverride`, NEVER the free-text `styleNotes`, which is writing-stage direction), `universeStylePreset(universe, series)` (the `{prompt, negativePrompt}` preset `composeStyledPrompt` consumes — the one definition shared by the browser and the FableLoom visual-canon compiler, `client/src/lib/universeStylePreset.js` re-exports it), `universeAestheticLine` (the labeled variant canon sheet/LoRA renders lead with), `universeVisualStyleTokens`, `joinInfluenceList` (thin trim+join over one chip-token list, re-exported by `client/src/lib/joinInfluenceList.js` and `server/services/universeBuilder/compile.js`), `splitPromptTokens`, `stripStyleClause(text, clause)` (removes the copy the browser already prefixed, so the compiler keeps the LEADING one — matched on the joined clause so a token with its own punctuation like `M.C. Escher` still matches) and `mergeNegativePromptTokens` (token-level union of comma-joined negatives). || `writersRoomPresets.js` | Writers Room enums (WORK_KINDS, WORK_STATUSES, ANALYSIS_KINDS). || `writersRoomStylePresets.js` | Curated style presets for storyboards + universe. |diff --git a/server/lib/composeStyledPrompt.js b/server/lib/composeStyledPrompt.jsindex 5dd28b8305..57a081f170 100644--- a/server/lib/composeStyledPrompt.js+++ b/server/lib/composeStyledPrompt.js@@ -1,24 +1,26 @@/**- * Compose a user prompt + negative with an optional style preset.+ * Compose a user prompt + negative with an optional style preset — or several,+ * for a caller layering independent style sources (e.g. a universe style and a+ * built-in preset).*- * Mirror of `client/src/lib/composeStyledPrompt.js` — kept in sync manually- * since client and server are separate bundles (same convention as- * `server/lib/scenePrompt.js` ↔ `client/src/lib/scenePrompt.js`).+ * `client/src/lib/composeStyledPrompt.js` re-exports `composeStyledPrompt`+ * from here (it keeps `composeCanonStyledPrompt`, a client-only wrapper).*- * Preset prompt prefixes the user prompt — diffusion models weight earlier+ * Preset prompt(s) prefix the user prompt — diffusion models weight earlier* tokens heaviest, so the broad aesthetic carries over the user's content.- * Preset negative appends to user negative so user-specified avoids stay+ * Preset negative(s) append to user negative so user-specified avoids stay* first-class.*- * Used by Universe Builder's batch-prompt compiler and any future server-side- * caller that needs the same style-prefix convention.+ * Used by Universe Builder's batch-prompt compiler, the pipeline's visual+ * stages, and any future server-side caller that needs the same style-prefix+ * convention.*/export function composeStyledPrompt(userPrompt, userNegative, preset) {const prompt = (userPrompt || '').trim();const negative = (userNegative || '').trim();- if (!preset) return { prompt, negativePrompt: negative };- const stylePart = (preset.prompt || '').trim();- const styleNeg = (preset.negativePrompt || '').trim();+ const presets = Array.isArray(preset) ? preset : [preset];+ const stylePart = presets.map((item) => (item?.prompt || '').trim()).filter(Boolean).join('. ');+ const styleNeg = presets.map((item) => (item?.negativePrompt || '').trim()).filter(Boolean).join(', ');// Avoid trailing ". " when only one of the two parts is non-empty so the// composed prompt is clean and deterministic regardless of which input// is missing.diff --git a/server/lib/universeVisualStyle.js b/server/lib/universeVisualStyle.jsindex 4d23ce78b3..2605c4f5b2 100644--- a/server/lib/universeVisualStyle.js+++ b/server/lib/universeVisualStyle.js@@ -43,6 +43,17 @@ export function universeVisualStyleTokens(universe) {};}+/**+ * Join a chip-token list (embrace OR avoid) into the comma-separated string+ * `composeStyledPrompt` consumes. Tokens are trimmed and blank entries+ * dropped — the same normalization `universeVisualStyleTokens` applies to a+ * whole universe, exposed here for a caller (`universeBuilder/compile.js`'s+ * prompt assembly) that already has just the raw array, not the universe.+ */+export function joinInfluenceList(structured) {+ return tokenList(structured).join(', ');+}+/*** Positive style clause for an image prompt.*@@ -115,3 +126,28 @@ export function universeAestheticLine(universe, options) {const clause = buildVisualStyleClause(universe, options);return clause ? `Universe aesthetic: ${clause}` : '';}++/**+ * The ONE style preset a universe (plus an optional series override) hands to+ * `composeStyledPrompt` — `{ prompt, negativePrompt } | null`. Both the browser+ * (Universe Builder canon renders, FableLoom's scene composer) and the server+ * (the FableLoom visual-canon compiler) must apply the exact same override+ * composition, or a series override drifts out of sync between what the+ * preview shows and what a render actually receives (#8442) — the browser+ * used to carry its own copy (`client/src/lib/universeStylePreset.js`, now a+ * re-export of this).+ *+ * `series` is optional; when omitted the result is the universe-only preset.+ * Avoid (negative) tokens always come from the universe — the mode only+ * composes the positive embrace clause. See `buildVisualStyleClause` for the+ * prepend/append/override semantics of `stylePromptOverrideMode`.+ */+export function universeStylePreset(universe, series = null) {+ const prompt = buildVisualStyleClause(universe, {+ override: series?.stylePromptOverride,+ mode: series?.stylePromptOverrideMode,+ });+ const negativePrompt = universeVisualStyleTokens(universe).avoid.join(', ');+ if (!prompt && !negativePrompt) return null;+ return { prompt, negativePrompt };+}diff --git a/server/services/fableLoom/visualConditioning.js b/server/services/fableLoom/visualConditioning.jsindex f4e5cc82b8..bc323859d9 100644--- a/server/services/fableLoom/visualConditioning.js+++ b/server/services/fableLoom/visualConditioning.js@@ -18,7 +18,7 @@ import {import { resolveFableLoomProtagonistPresence } from '../../lib/fableLoomPlayback.js';import { REACTOR_MAX_PROMPT_LENGTH } from '../../lib/reactorVideoClip.js';import {- mergeNegativePromptTokens, stripStyleClause, universeVisualStyleTokens,+ mergeNegativePromptTokens, stripStyleClause, universeStylePreset, universeVisualStyleTokens,} from '../../lib/universeVisualStyle.js';import { getUniverse } from '../universeBuilder.js';import { resolveCharacterLoras } from '../characterLoraResolver.js';@@ -222,7 +222,7 @@ export async function compileFableLoomVisualRequest({const episode = loom?.episodes?.find((item) => item.id === tag.episodeId);const node = episode?.nodes?.find((item) => item.id === tag.nodeId);if (!loom || !episode || !node) throw new ServerError('FableLoom scene not found', { status: 404, code: 'NOT_FOUND' });- const series = !loom.universeId && loom.seriesId ? await loadSeries(loom.seriesId).catch(() => null) : null;+ const series = loom.seriesId ? await loadSeries(loom.seriesId).catch(() => null) : null;const universeId = loom.universeId || series?.universeId || null;const universe = universeId ? await loadUniverse(universeId) : null;// Legacy/unlinked scenes keep their pre-compiler prompt-only behavior. A@@ -356,10 +356,17 @@ export async function compileFableLoomVisualRequest({]).join('. '));// Curated visual tokens only — `universe.styleNotes` is writing-stage// direction (see lib/universeVisualStyle.js). The browser composes this same- // preset onto the scene prompt before POSTing, so strip ITS copy and keep- // ours: the clause below leads the prompt, and only a leading copy gets the- // early-token weighting a diffusion model gives style.- const universeStyle = universeVisualStyleTokens(universe).embrace.join(', ');+ // preset (universe embrace tokens PLUS the series style override, in+ // whichever mode the series is set to) onto the scene prompt before+ // POSTing, so build the identical clause here and strip ITS copy rather+ // than emitting the tokens again: the clause below leads the prompt, and+ // only a leading copy gets the early-token weighting a diffusion model+ // gives style. Using the shared `universeStylePreset` (not just the raw+ // embrace tokens) is what keeps a series override — prepend, append, or+ // override — in sync between the FableLoom preview and the actual render+ // (#8442); the plain embrace-only clause never matched an authored prompt+ // that led with an override.+ const universeStyle = universeStylePreset(universe, series)?.prompt || '';const authoredBody = stripStyleClause(authoredPrompt, universeStyle);const protagonistName = (universe.characters || []).find((character) => character.id === bindings.protagonistId)?.name || 'the canonical protagonist';const visibleCast = bindings.boundCharacters.map(({ character }) => character.name).filter(Boolean);diff --git a/server/services/fableLoom/visualConditioning.test.js b/server/services/fableLoom/visualConditioning.test.jsindex 80cd5ed24e..5a01f3e2f1 100644--- a/server/services/fableLoom/visualConditioning.test.js+++ b/server/services/fableLoom/visualConditioning.test.js@@ -186,6 +186,51 @@ describe('FableLoom visual conditioning compiler', () => {expect(result.negativePrompt.match(/gore/g)).toHaveLength(1);});+ it('strips a series style override the browser prepended so the tokens survive exactly once (#8442)', async () => {+ // Mirrors what `universeStylePreset(universe, series)` composes in the+ // browser (client/src/lib/universeStylePreset.js, now a re-export of the+ // server's) for a 'prepend'-mode (the default) series override: the+ // override leads, the universe embrace tokens trail.+ const loom = loomWith(lockedBinding);+ loom.seriesId = 'series-1';+ const series = { id: 'series-1', universeId: universe.id, stylePromptOverride: 'washed sepia tone', stylePromptOverrideMode: 'prepend' };+ const result = await compileFableLoomVisualRequest({+ tag: { loomId: loom.id, episodeId: 'episode-1', nodeId: 'shot' },+ kind: 'image',+ capability: fableLoomImageCapabilities({ mode: 'codex', model: { id: 'gpt-image' }, inputBudget: 4 }),+ authoredPrompt: 'washed sepia tone. ligne claire, flat matte color fields. A cautious arrival',+ loadSeries: vi.fn(async () => series),+ ...deps(loom),+ });++ expect(result.prompt.startsWith('Universe style: washed sepia tone. ligne claire, flat matte color fields')).toBe(true);+ expect(result.prompt.match(/ligne claire/g)).toHaveLength(1);+ expect(result.prompt.match(/flat matte color fields/g)).toHaveLength(1);+ expect(result.prompt.match(/washed sepia tone/g)).toHaveLength(1);+ expect(result.prompt).toContain('A cautious arrival');+ });++ it('drops the universe embrace tokens entirely for a series in override mode (#8442)', async () => {+ const loom = loomWith(lockedBinding);+ loom.seriesId = 'series-1';+ const series = { id: 'series-1', universeId: universe.id, stylePromptOverride: 'washed sepia tone', stylePromptOverrideMode: 'override' };+ const result = await compileFableLoomVisualRequest({+ tag: { loomId: loom.id, episodeId: 'episode-1', nodeId: 'shot' },+ kind: 'image',+ capability: fableLoomImageCapabilities({ mode: 'codex', model: { id: 'gpt-image' }, inputBudget: 4 }),+ authoredPrompt: 'washed sepia tone. A cautious arrival',+ loadSeries: vi.fn(async () => series),+ ...deps(loom),+ });++ expect(result.prompt.startsWith('Universe style: washed sepia tone')).toBe(true);+ expect(result.prompt).not.toContain('ligne claire');+ expect(result.prompt).not.toContain('flat matte color fields');+ expect(result.prompt).toContain('A cautious arrival');+ // Avoid tokens still come from the universe regardless of override mode.+ expect(result.negativePrompt).toContain('photoreal');+ });+it('still contributes the curated style tokens a render prompt has not already named', async () => {const loom = loomWith(lockedBinding);const result = await compileFableLoomVisualRequest({diff --git a/server/services/universeBuilder/compile.js b/server/services/universeBuilder/compile.jsindex 34c53fb1e5..1d08076d26 100644--- a/server/services/universeBuilder/compile.js+++ b/server/services/universeBuilder/compile.js@@ -10,19 +10,15 @@*/import { composeStyledPrompt } from '../../lib/composeStyledPrompt.js';+import { joinInfluenceList } from '../../lib/universeVisualStyle.js';import { flattenCanonDescriptorFragments, richCanonDescriptorFragments } from '../../lib/canonPrompt.js';import { getWorldCategoryKeys, normalizeCategoryKey, ENTRY_REF_KIND } from './sanitize.js';-// Join an influence list (embrace or avoid) into the comma-separated string-// shape the renderer's `composeStyledPrompt` consumes. Tokens have already-// been deduped + capped by `sanitizeInfluenceList` at write time, so this is-// just a thin join — exported so downstream consumers (universeCanon,-// pipeline/visualStages) read a single helper instead of each open-coding-// `(arr || []).join(', ')`.-export function joinInfluenceList(structured = []) {- if (!Array.isArray(structured)) return '';- return structured.filter((t) => typeof t === 'string' && t.trim()).join(', ');-}+// Re-exported so this module's existing importers (universeCanon.js,+// pipeline/seriesTitleLogo.js, seriesVoiceDiscover.js, seriesGenerate.js) are+// unchanged — the canonical definition now lives in universeVisualStyle.js,+// shared with the browser (#8442).+export { joinInfluenceList };// Collapse newlines + control chars in user-supplied free text before// embedding in a prompt. Defense-in-depth against a logline / styleNotes /