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.

Results: an SVG offers Download and Favorite, not raster hand-offs

Claude4e10c3abcab8
diff --git a/src/lib/output-actions.ts b/src/lib/output-actions.ts
index 56948458..8d8eaa78 100644
--- a/src/lib/output-actions.ts
+++ b/src/lib/output-actions.ts
@@ -78,6 +78,11 @@ export function outputActions(g: Generation, index: number, ctx: ActionContext =
const link = (id: OutputActionId, label: string, href: string, placement: OutputAction["placement"] = "menu") => out.push({ id, label, href, placement });
switch (o.kind) {
case "image":
+ if (isVector(g, o)) {
+ // The hand-offs all send the picture to models that read pixels, and nothing rasterises an .svg on the way.
+ out.push({ ...file, label: "Download .svg" }, { id: "favorite", label: g.favorite ? "Unfavorite" : "Favorite", placement: "bar" });
+ break;
+ }
link("animate", "Animate", `/video?image=${q(o.url)}`, "primary");
out.push(file, { id: "favorite", label: g.favorite ? "Unfavorite" : "Favorite", placement: "bar" });
link("edit", "Edit", `/edit?image=${q(o.url)}`);
@@ -125,6 +130,16 @@ export function outputActions(g: Generation, index: number, ctx: ActionContext =
return out;
}
+/**
+ * A vector result (an SVG: Vectorize, Recraft's vector styles, an uploaded .svg). Demo pictures are
+ * SVG placeholders standing in for raster results, so they keep the raster hand-offs (except Vectorize's).
+ */
+export function isVector(g: Pick<Generation, "provider" | "op">, o: Pick<OutputFile, "url" | "kind" | "contentType">): boolean {
+ if (o.kind !== "image") return false;
+ const svg = /^image\/svg\+xml\b/i.test(o.contentType ?? "") || o.url.startsWith("data:image/svg+xml") || extensionOf(o) === "svg";
+ return svg && (g.provider !== "mock" || g.op === "vectorize");
+}
+
/**
* Open an image in the Layers editor (/layers?image=…). A layers result opens with its layers
* already split, on the picture it was made from.
diff --git a/tests/library-pure.test.ts b/tests/library-pure.test.ts
index 2a233eb4..62465ae9 100644
--- a/tests/library-pure.test.ts
+++ b/tests/library-pure.test.ts
@@ -60,6 +60,17 @@ describe("outputActions", () => {
expect(download.href).toBe("/api/files/outputs/d/abcdef123456.png?download=a-fox-abcdef.png");
});
+ it("gives SVG results no raster hand-offs, but keeps them on demo placeholders", () => {
+ const svg = (p: Partial<Generation>, o: Partial<Generation["outputs"][number]> = {}) => gen({ provider: "fal", outputs: [{ url: "/api/files/outputs/d/logo.svg", kind: "image", contentType: "image/svg+xml", ...o }], ...p });
+ expect(ids(svg({}))).toEqual(["bar:download", "bar:favorite", "menu:copy-prompt", "menu:delete"]);
+ expect(ids(svg({}, { url: "https://v3.fal.media/files/x/logo.svg", contentType: undefined }))[0]).toBe("bar:download");
+ expect(ids(svg({ feature: "upload", provider: "local" }))).toEqual(["bar:download"]);
+ // A demo picture is an SVG standing in for a raster result: it can still be animated (a demo Vectorize result can't).
+ expect(ids(svg({ provider: "mock", op: "t2i" }))[0]).toBe("primary:animate");
+ expect(ids(svg({ provider: "mock", op: "vectorize" }))[0]).toBe("bar:download");
+ expect(ids(gen({ outputs: [{ url: "/api/files/o/a.png", kind: "image", contentType: "image/png" }] }))[0]).toBe("primary:animate");
+ });
+
it("gives videos Extend first and the video hand-offs", () => {
const g = gen({ kind: "video", op: "t2v", outputs: [{ url: "/api/files/o/v.mp4", kind: "video", draftId: "d1" }] });
expect(ids(g)).toEqual(["primary:extend", "bar:download", "bar:favorite", "menu:reframe", "menu:lipsync", "menu:upscale", "menu:add-sound", "menu:grade", "menu:finalize", "menu:copy-prompt", "menu:delete"]);
diff --git a/tests/vectorize.test.ts b/tests/vectorize.test.ts
index ba88c007..ab68e5a7 100644
--- a/tests/vectorize.test.ts
+++ b/tests/vectorize.test.ts
@@ -113,5 +113,8 @@ describe("Vectorize app", () => {
const download = outputActions(done, 0).find((a) => a.id === "download")!;
expect(download.download).toMatch(/\.svg$/);
expect(download.href).toContain(`${out.url}?download=`);
+ // No raster hand-offs (Animate, Edit, Upscale…): those models can't read an SVG.
+ expect(outputActions(done, 0).map((a) => `${a.placement}:${a.id}`)).toEqual(["bar:download", "bar:favorite", "menu:copy-prompt", "menu:delete"]);
+ expect(download.label).toBe("Download .svg");
});
});