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
address review (local): match whole style tokens, not substrings
[._.]/ Adam Eivy5e755d5d36a7
diff --git a/server/lib/universeVisualStyle.js b/server/lib/universeVisualStyle.jsindex 2cbcc58460..604c9aaf10 100644--- a/server/lib/universeVisualStyle.js+++ b/server/lib/universeVisualStyle.js@@ -27,12 +27,21 @@ const tokenList = (values) => (Array.isArray(values) ? values : []).map((token) => (typeof token === 'string' ? token.trim() : '')).filter(Boolean);-const normalize = (token) => token.toLowerCase().replace(/\s+/g, ' ');+// Trailing trim is load-bearing: the dedupe below splits a composed prompt on+// its separators, so every part after the first arrives with a leading space.+const normalize = (token) => token.toLowerCase().replace(/\s+/g, ' ').trim();/** Split a comma-joined prompt/negative string back into trimmed tokens. */export const splitPromptTokens = (text) => (typeof text === 'string' ? text : '').split(',').map((token) => token.trim()).filter(Boolean);+// Every separator a composed prompt can put between two style tokens: the+// comma inside a joined token list, and the '. ' / newline that+// `composeStyledPrompt` and the compiler use to butt the style clause against+// the scene sentence. Splitting on all of them is what lets the dedupe below+// compare whole tokens instead of substrings.+const PROMPT_TOKEN_SEPARATORS = /[,.;\n]+/;+/** Curated visual token lists for a universe (`[]` for a missing universe). */export function universeVisualStyleTokens(universe) {return {@@ -68,9 +77,14 @@ export function buildVisualStyleClause(universe, { override = '', mode = 'prepen* pure budget with no effect on the image.*/export function dropTokensPresentIn(tokens, authoredText) {- const haystack = normalize(typeof authoredText === 'string' ? authoredText : '');- if (!haystack) return tokenList(tokens);- return tokenList(tokens).filter((token) => !haystack.includes(normalize(token)));+ const text = typeof authoredText === 'string' ? authoredText : '';+ if (!text.trim()) return tokenList(tokens);+ // Compare WHOLE tokens, never substrings: a plain `includes` would drop+ // `flat colors` because the scene sentence happens to say "flat colors of+ // dusk", silently stripping a style token the render still needed.+ const present = new Set(text.split(PROMPT_TOKEN_SEPARATORS)+ .map((part) => normalize(part)).filter(Boolean));+ return tokenList(tokens).filter((token) => !present.has(normalize(token)));}/**diff --git a/server/lib/universeVisualStyle.test.js b/server/lib/universeVisualStyle.test.jsindex b1ca052c9c..c0b563c7b0 100644--- a/server/lib/universeVisualStyle.test.js+++ b/server/lib/universeVisualStyle.test.js@@ -43,6 +43,17 @@ describe('universeVisualStyle', () => {expect(dropTokensPresentIn(['ligne claire'], '')).toEqual(['ligne claire']);});+ it('matches whole tokens, so scene prose that merely contains one keeps it', () => {+ // A substring test would drop 'flat colors' here and quietly weaken the render.+ const prose = 'Tala watches the flat colors of dusk bleed over the ridge.';+ expect(dropTokensPresentIn(['flat colors', 'ligne claire'], prose))+ .toEqual(['flat colors', 'ligne claire']);+ // A token the composed prompt genuinely carries is still dropped, whether the+ // separator before it is a comma or the '. ' that butts style against scene.+ expect(dropTokensPresentIn(['flat colors'], 'ligne claire, flat colors. Tala kneels.'))+ .toEqual([]);+ });+it('unions negatives at token level so a joined authored negative does not repeat the list', () => {expect(mergeNegativePromptTokens(['photoreal, gore, blurry',diff --git a/server/services/fableLoom/visualConditioning.js b/server/services/fableLoom/visualConditioning.jsindex c21d70c721..ad69e36f51 100644--- a/server/services/fableLoom/visualConditioning.js+++ b/server/services/fableLoom/visualConditioning.js@@ -17,8 +17,7 @@ import {} from '../../lib/scenePrompt.js';import { resolveFableLoomProtagonistPresence } from '../../lib/fableLoomPlayback.js';import {- buildVisualStyleClause, dropTokensPresentIn, mergeNegativePromptTokens, splitPromptTokens,- universeVisualStyleTokens,+ dropTokensPresentIn, mergeNegativePromptTokens, universeVisualStyleTokens,} from '../../lib/universeVisualStyle.js';import { getUniverse } from '../universeBuilder.js';import { resolveCharacterLoras } from '../characterLoraResolver.js';@@ -354,7 +353,7 @@ export async function compileFableLoomVisualRequest({// preset onto the scene prompt before POSTing, so drop whatever it already// sent rather than emitting the token list a second time.const universeStyle = dropTokensPresentIn(- splitPromptTokens(buildVisualStyleClause(universe)),+ universeVisualStyleTokens(universe).embrace,authoredPrompt,);const protagonistFraming = bindings.protagonistPresence === 'offscreen'