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
Allow empty prompt in the generation services (i2i / edit / unconditional)
[._.]/ Adam Eivyd63ed0314fdf
diff --git a/server/services/imageGen/codex.js b/server/services/imageGen/codex.jsindex 70f4f7ea4d..23e7194411 100644--- a/server/services/imageGen/codex.js+++ b/server/services/imageGen/codex.js@@ -145,9 +145,6 @@ export async function generateImage({cleanC2PA = false,denoise = false,}) {- if (!prompt?.trim()) {- throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });- }await ensureDir(PATHS.images);// Defense-in-depth: HTTP routes already resolve basenames to absolute paths,@@ -157,6 +154,12 @@ export async function generateImage({? resolveGalleryImage(initImagePath): null;+ // An empty prompt is fine when editing an init image (the attached image is+ // the instruction); a pure text-to-image codex render still needs a prompt.+ if (!validInitImagePath && !prompt?.trim()) {+ throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });+ }+const jobId = providedJobId || randomUUID();const filename = `${jobId}.png`;const outputPath = join(PATHS.images, filename);diff --git a/server/services/imageGen/codex.test.js b/server/services/imageGen/codex.test.jsindex 558f7601a2..7654d9b9f9 100644--- a/server/services/imageGen/codex.test.js+++ b/server/services/imageGen/codex.test.js@@ -132,10 +132,24 @@ describe('codex provider — generateImage', () => {await flush();});- it('rejects when prompt is empty', async () => {+ it('rejects when prompt is empty and there is no init image', async () => {await expect(codex.generateImage({ prompt: ' ' })).rejects.toThrow(/Prompt is required/);});+ it('allows an empty prompt when editing an init image', async () => {+ // resolveGalleryImage requires the file to exist under PATHS.images.+ await mkdir(FAKE_IMAGES_DIR, { recursive: true });+ await writeFile(join(FAKE_IMAGES_DIR, 'editme.png'), 'fake');+ await codex.generateImage({ prompt: '', initImagePath: 'editme.png', initImageStrength: 0.2 });+ const { args } = spawnCalls[0];+ expect(args.indexOf('-i')).toBeGreaterThan(-1);+ // Edit-prefix still drives the render even with no text target.+ expect(args[args.length - 1]).toMatch(/edit the attached reference image/i);+ spawnCalls[0].child.exitCode = 1;+ spawnCalls[0].child.emit('close', 1, null);+ await flush();+ });+it('forwards initImagePath via `-i <FILE>` and reshapes the prompt for image-edit', async () => {// resolveGalleryImage requires the file to exist under PATHS.images.await mkdir(FAKE_IMAGES_DIR, { recursive: true });diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.jsindex eec8bad752..c79da5526d 100644--- a/server/services/imageGen/local.js+++ b/server/services/imageGen/local.js@@ -405,11 +405,10 @@ export function buildSidecarMeta({}export async function generateImage({ pythonPath, prompt, negativePrompt = '', modelId = 'dev', width = 1024, height = 1024, steps, guidance, seed, quantize = '8', loraFilenames = [], loraPaths = [], loraScales = [], initImagePath = null, initImageStrength = null, referenceImagePaths = [], referenceImageStrengths = [], jobId: providedJobId = null, cleanC2PA = false, denoise = false, regenOf = null, upscaleTo = null }) {- // A regen pass (issue #912) deliberately runs with an EMPTY prompt for- // minimal-mutation, watermark-overwriting img2img — so the usual- // prompt-required guard is waived when `regenOf` is set (the init image is- // what conditions the render, not text).- if (!regenOf && !prompt?.trim()) throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });+ // Empty prompt is allowed: img2img / edit / unconditional renders are driven+ // by the init image (or run unconditionally), so text isn't required. The+ // mflux/diffusers runners accept an empty `--prompt` — the regen pass (#912)+ // has always relied on this for minimal-mutation, watermark-overwriting img2img.// Single-flight is enforced by the mediaJobQueue worker upstream. Direct// callers that bypass the queue must not run two concurrent renders — the// activeProcess handle below would be clobbered and cancel() would orphan