Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Layout N7-2: fal's seed goes only on text-to-image and edit pictures

Claude571a4f13e756
diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.ts
index 5e9807e1..6654ccd1 100644
--- a/src/lib/catalog/payload.ts
+++ b/src/lib/catalog/payload.ts
@@ -997,16 +997,16 @@ export function extractOutputs(response: unknown, op?: Operation): ExtractedOutp
// cut-out (meta.mask) instead of landing in the feed as a second result.
const mask = fileOf(r.mask)?.url;
if (mask && out.some((o) => o.url !== mask)) out = out.filter((o) => o.url !== mask).map((o) => ({ ...o, meta: { ...o.meta, mask } }));
- // The seed fal drew the pictures with is kept on each one, so Edit layout (and a layout's Reuse) draws it again with
- // the same seed: a layout run turns the API's prompt expansion off, and FLUX.3 and Ideogram never return
- // actual_prompt, so the seed can't wait for it. fal's MOSS-Image also returns the layout its expansion planned
- // (actual_prompt): kept with the picture's own size, so Edit layout can reopen it as boxes (decodeMoss).
+ // The seed fal drew a picture with (text to image, edits: the runs a layout is drawn for) is kept on each one, so
+ // Edit layout draws it again with the same seed: a layout run turns the API's prompt expansion off, and FLUX.3 and
+ // Ideogram never return actual_prompt, so the seed can't wait for it. fal's MOSS-Image also returns the layout its
+ // expansion planned (actual_prompt): kept with the picture's own size, so Edit layout can reopen it as boxes (decodeMoss).
const seed = num(r.seed);
const actualPrompt = str(r.actual_prompt)?.trim();
if (actualPrompt) {
const sizes = new Map((Array.isArray(r.images) ? r.images : []).filter(isObj).map((im) => [str(im.url), { width: num(im.width), height: num(im.height) }] as const));
out = out.map((o) => (o.kind === "image" ? { ...o, meta: { ...o.meta, ...compact({ actualPrompt, seed, ...sizes.get(o.url) }) } } : o));
- } else if (seed !== undefined) out = out.map((o) => (o.kind === "image" ? { ...o, meta: { ...o.meta, seed } } : o));
+ } else if (seed !== undefined && (op === "t2i" || op === "edit")) out = out.map((o) => (o.kind === "image" ? { ...o, meta: { ...o.meta, seed } } : o));
}
return out;
}
diff --git a/tests/layout-mode.test.ts b/tests/layout-mode.test.ts
index 2b3ff089..8f67fa88 100644
--- a/tests/layout-mode.test.ts
+++ b/tests/layout-mode.test.ts
@@ -259,7 +259,10 @@ describe("Edit layout", () => {
expect(editableLayout(gen({ outputs: [{ url: "/a.png", kind: "image", meta: { actualPrompt: fixture.actual_prompt } }] }), 0)).toBeNull();
// fal's other models' outputs never carry an actual_prompt, only the seed.
expect(extractOutputs({ images: [{ url: "https://x/a.png", width: 1, height: 1 }], seed: 3 }, "t2i")[0]).toMatchObject({ meta: { seed: 3 } });
+ expect(extractOutputs({ images: [{ url: "https://x/a.png", width: 1, height: 1 }], seed: 3 }, "edit")[0]).toMatchObject({ meta: { seed: 3 } });
expect(extractOutputs({ images: [{ url: "https://x/a.png", width: 1, height: 1 }] }, "t2i")[0]).not.toHaveProperty("meta");
+ // Other image tools (a background removal, layers) keep their outputs as they were.
+ expect(extractOutputs({ images: [{ url: "https://x/a.png", width: 1, height: 1 }], seed: 3 }, "bg-remove")[0]).not.toHaveProperty("meta");
// A run with Layout on but no box drawn has nothing to reopen.
const empty = { feature: "image", modelId: "moss-image", prompt: "A poster", params: { extra: { layout: { ...poster, items: [] } } } } as GenerationRequest;
expect(editableLayout(gen({ request: empty }), 0)).toBeNull();