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: address review (claude) reference input edges
Adam Eivy8807ab28f416
diff --git a/server/routes/imageGen.js b/server/routes/imageGen.jsindex 109e667287..80a7ecf5d6 100644--- a/server/routes/imageGen.js+++ b/server/routes/imageGen.js@@ -240,11 +240,11 @@ function coerceFormFields(body) {const raw = Array.isArray(body.referenceStrengths) ? body.referenceStrengths : [body.referenceStrengths];body.referenceStrengths = raw.map((v) => (typeof v === 'string' && v !== '' ? Number(v) : v));}- // LoRA fields are repeated multipart keys (one per selected LoRA). A SINGLE- // selected LoRA arrives as a bare string, not a one-element array — wrap it- // so Zod's `z.array(...)` accepts it. `loraScales` numbers also arrive as- // strings, so coerce element-wise like referenceStrengths above.- for (const f of ['loraFilenames', 'loraPaths']) {+ // Array fields are repeated multipart keys. A single selected value arrives+ // as a bare string, not a one-element array — wrap it so Zod accepts it.+ // `loraScales` numbers also arrive as strings, so coerce element-wise like+ // referenceStrengths above.+ for (const f of ['loraFilenames', 'loraPaths', 'referenceImageFiles']) {if (body[f] != null && !Array.isArray(body[f])) body[f] = [body[f]];}if (body.loraScales != null) {diff --git a/server/routes/imageGen.multipart.test.js b/server/routes/imageGen.multipart.test.jsindex 1badf6c592..b59b116515 100644--- a/server/routes/imageGen.multipart.test.js+++ b/server/routes/imageGen.multipart.test.js@@ -240,6 +240,41 @@ describe('POST /api/image-gen/generate — multipart reference-image packing', (expect(params.referenceImageFiles).toBeUndefined();});+ it('returns the stable missing-reference code for a gallery image that no longer exists', async () => {+ mockedSettings = { imageGen: { mode: 'codex', codex: { enabled: true } } };++ const res = await postJson(app, '/api/image-gen/generate', {+ prompt: 'the same scout from a new camera angle',+ referenceImageFiles: ['missing-shot.png'],+ });++ expect(res.status).toBe(400);+ expect(res.body.code).toBe('REFERENCE_IMAGE_NOT_FOUND');+ expect(enqueueJob).not.toHaveBeenCalled();+ });++ it('rejects more than four named and uploaded references before staging uploads', async () => {+ mockedSettings = { imageGen: { mode: 'codex', codex: { enabled: true } } };+ await Promise.all(['prior-a.png', 'prior-b.png']+ .map((filename) => writeFile(join(imagesSandbox, filename), PNG_FIXTURE)));++ const res = await postMultipart(app, '/api/image-gen/generate', [+ { name: 'prompt', value: 'the same scout from a new camera angle' },+ { name: 'referenceImageFiles', value: 'prior-a.png' },+ { name: 'referenceImageFiles', value: 'prior-b.png' },+ { name: 'referenceImage1', filename: 'a.png', contentType: 'image/png', value: PNG_FIXTURE },+ { name: 'referenceImage2', filename: 'b.png', contentType: 'image/png', value: PNG_FIXTURE },+ { name: 'referenceImage3', filename: 'c.png', contentType: 'image/png', value: PNG_FIXTURE },+ ]);++ expect(res.status).toBe(400);+ expect(res.body.code).toBe('TOO_MANY_REFERENCE_IMAGES');+ expect(enqueueJob).not.toHaveBeenCalled();+ await new Promise((resolve) => setTimeout(resolve, 50));+ const refDirContents = await readdir(refsSandbox).catch(() => []);+ expect(refDirContents.filter((filename) => filename.startsWith('ref-'))).toHaveLength(0);+ });+it('packs only the filled slots (gaps in the slot numbering collapse to a packed array)', async () => {const res = await postMultipart(app, '/api/image-gen/generate', [{ name: 'prompt', value: 'sparse multi-ref' },