The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(create): the local safety gate reads the lyrics too
Davidab88fa1f1465
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.tsindex c8c97364..3f79ce0c 100644--- a/src/hooks/useCreate.ts+++ b/src/hooks/useCreate.ts@@ -422,9 +422,17 @@ export function useCreate() {// on the user's own machine. triggerWord is in here because local character// training runs through this same function a few lines down, and the cloud// gate already treats that field as prompt-bearing (useCloudCreate.ts).- // musicLyrics is not: music is a hosted-only op and cannot reach this path.+ //+ // musicLyrics used to be left out on the premise that music is hosted only+ // and cannot reach this path. It can and it does: the local audio lane+ // hands `lyrics: state.musicLyrics` to buildLocalOpWorkflow a few hundred+ // lines below. Every field that carries user text to a render is gated on+ // both paths, and the two lists have to stay identical (review+ // 2026-08-14).{- const verdict = checkPromptSafety(`${state.prompt} ${state.negativePrompt} ${state.triggerWord}`)+ const verdict = checkPromptSafety(+ `${state.prompt} ${state.negativePrompt} ${state.musicLyrics} ${state.triggerWord}`,+ )if (verdict.blocked) {state.setError(SAFETY_BLOCK_MESSAGE)returndiff --git a/src/lib/__tests__/render-safety.test.ts b/src/lib/__tests__/render-safety.test.tsindex 2f2f9d88..a5d0a4ad 100644--- a/src/lib/__tests__/render-safety.test.ts+++ b/src/lib/__tests__/render-safety.test.ts@@ -16,6 +16,9 @@* would need fuzzy matching whose false positives would block ordinary prompts.*/import { describe, it, expect } from 'vitest'+import { readFileSync } from 'node:fs'+import { fileURLToPath } from 'node:url'+import { dirname, resolve } from 'node:path'import { checkPromptSafety } from '../render/safety'const blocked = (t: string) => checkPromptSafety(t).blocked@@ -76,3 +79,42 @@ describe('the documented limit', () => {expect(blocked('a chiild, nude')).toBe(false)})})++// P5 from the review (2026-08-14). The gate is only worth the fields it reads,+// and the two render paths disagreed: the cloud one covered musicLyrics, the+// local one skipped it on a written premise that is false. "music is a+// hosted-only op and cannot reach this path" while useCreate.ts hands+// `lyrics: state.musicLyrics` to buildLocalOpWorkflow on that very path. A+// local render has no server gate behind it, so the field went to the model+// ungated.+describe('both render paths gate the same fields', () => {+ const local = readFileSync(+ resolve(dirname(fileURLToPath(import.meta.url)), '../../hooks/useCreate.ts'), 'utf8',+ )+ const cloud = readFileSync(+ resolve(dirname(fileURLToPath(import.meta.url)), '../../hooks/useCloudCreate.ts'), 'utf8',+ )++ /** The template literal handed to checkPromptSafety, as a set of field names. */+ const gatedFields = (src: string): string[] => {+ const at = src.indexOf('checkPromptSafety(')+ const lit = src.slice(at, src.indexOf('`', src.indexOf('`', at) + 1) + 1)+ return [...lit.matchAll(/\$\{[a-zA-Z]+\.([a-zA-Z]+)\}/g)].map((m) => m[1]).sort()+ }++ it('the local path reads prompt, negativePrompt, musicLyrics and triggerWord', () => {+ expect(gatedFields(local)).toEqual(['musicLyrics', 'negativePrompt', 'prompt', 'triggerWord'])+ })++ it('and the cloud path reads exactly the same four', () => {+ expect(gatedFields(cloud)).toEqual(gatedFields(local))+ })++ it('the local audio lane really does carry the lyrics, so the gate is not theoretical', () => {+ expect(local).toContain('lyrics: state.musicLyrics')+ })++ it('lyrics are blocked by the same rule as a prompt', () => {+ expect(blocked('a nude child singing')).toBe(true)+ })+})