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.

Genjutsu: Group swap and Fix colours open to everyone

Adarsh5232bee4e1ec
diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsx
index c7a3caeb..8e636f5b 100644
--- a/src/components/genjutsu/genjutsu-studio.tsx
+++ b/src/components/genjutsu/genjutsu-studio.tsx
@@ -49,6 +49,7 @@ import {
MODE_TARGETS,
OPEN_TARGET_PROBLEM,
resolutionWords,
+ SCENE_ACTIONS,
SOURCE_LABELS,
TARGET_LABELS,
type GenjutsuLook,
@@ -225,6 +226,13 @@ export function GenjutsuStudio({ examples, live }: { examples?: ExampleRowData |
const options = keepOffered(makersFor(engine, mode, target, open), (m) => makerOffered(m, isOn)).filter((m) => mode !== "finish" || m.tool === finish.tool);
const group = isCharacter && !!maker?.group;
const sceneEdit = mode === "swap" && !!maker?.actions;
+ // Scene edit with only some of its actions open to this viewer: start on one that is.
+ const actionOpen = open(SCENE_ACTIONS.find((a) => a.id === action)!.feature);
+ const firstOpenAction = SCENE_ACTIONS.find((a) => open(a.feature))?.id;
+ if (sceneEdit && !actionOpen && firstOpenAction && firstOpenAction !== action) {
+ setAction(firstOpenAction);
+ setObjectEdit((o) => ({ ...o, action: firstOpenAction }));
+ }
const fresh = !!(maker?.group || maker?.actions || maker?.review || maker?.tool);
const references = mode === "restyle" || (sceneEdit && action === "remove") || (mode === "picture" && picture.ownPerson) || (mode === "finish" && finish.tool === "colours") ? [] : ready(refs);
const showRefs = mode !== "restyle" && !(sceneEdit && action === "remove") && !(mode === "picture" && picture.ownPerson) && !(mode === "finish" && finish.tool === "colours");
diff --git a/tests/e2e/genjutsu-openjutsu.mjs b/tests/e2e/genjutsu-openjutsu.mjs
index b62165cb..17759e74 100644
--- a/tests/e2e/genjutsu-openjutsu.mjs
+++ b/tests/e2e/genjutsu-openjutsu.mjs
@@ -2,8 +2,9 @@
// tabs show and every tab is 44 px tall; Character swap with four characters shows Who becomes who, and a tap on the
// part's first frame writes where that person stands; From picture's two-step header with step 2 locked until a frame
// is used; Finish's tool switch; nothing scrolls sideways at 390 px. With --guest (a studio with a password and public
-// sign-up, nothing open yet): only the five existing tabs, ?mode=picture and ?mode=finish land on Motion transfer, and
-// nothing scrolls sideways at 390 or 1440 px.
+// sign-up): the five existing tabs plus the new ones whose features passed their GPU test (workflows/comfyui/gpu-tested.json
+// and the manifest's validated flags), a closed mode's ?mode= lands on Motion transfer, Finish offers only its open tools,
+// and nothing scrolls sideways at 390 or 1440 px.
// Usage: node tests/e2e/genjutsu-openjutsu.mjs [appUrl] [--guest] [--shots <dir>] (app running in demo mode). Exits 1 on a failed check.
import fs from "node:fs";
import path from "node:path";
@@ -21,6 +22,14 @@ const check = (label, ok, extra = "") => {
if (!ok) failures.push(label);
};
const EXISTING = ["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"];
+// What the committed gate opens (src/server/genjutsu-live.ts): a feature's workflows validated and its render passed.
+const readJson = (p) => JSON.parse(fs.readFileSync(path.join(root, p), "utf8"));
+const validated = new Set(readJson("workflows/comfyui/manifest.json").workflows.filter((w) => w.validated === true).map((w) => w.id));
+const passed = readJson("workflows/comfyui/gpu-tested.json").features ?? {};
+const FEATURE_WORKFLOWS = { picture: ["image-from-picture-prepare", "video-scene-describe", "video-from-picture-solar"], "finish-faces": ["video-fix-faces-h3"], "finish-colours": ["video-fix-colours"] };
+const live = (k) => passed[k]?.passed === true && FEATURE_WORKFLOWS[k].every((id) => validated.has(id));
+const OPEN_MODES = { picture: live("picture"), finish: live("finish-faces") || live("finish-colours") };
+const GUEST_TABS = [...EXISTING, ...(OPEN_MODES.picture ? ["From picture"] : []), ...(OPEN_MODES.finish ? ["Finish"] : [])];
async function upload(file, type, name) {
const form = new FormData();
@@ -56,13 +65,21 @@ try {
if (guest) {
await open("/genjutsu");
- check(`${width}: a guest sees the five existing tabs only`, JSON.stringify(await tabs()) === JSON.stringify(EXISTING), JSON.stringify(await tabs()));
+ check(`${width}: a guest sees the existing tabs and the open ones only`, JSON.stringify(await tabs()) === JSON.stringify(GUEST_TABS), JSON.stringify(await tabs()));
check(`${width}: no "Only you" for a guest`, !(await page.evaluate(() => document.body.innerText.includes("Only you"))));
check(`${width}: /genjutsu fits the screen`, (await sideways()) <= 0);
await shot("guest-genjutsu");
- for (const m of ["picture", "finish"]) {
+ for (const [m, label] of [["picture", "From picture"], ["finish", "Finish"]]) {
await open(`/genjutsu?mode=${m}`);
- check(`${width}: ?mode=${m} lands on Motion transfer for a guest`, (await selected()) === "Motion transfer", String(await selected()));
+ const want = OPEN_MODES[m] ? label : "Motion transfer";
+ check(`${width}: ?mode=${m} lands on ${want} for a guest`, (await selected()) === want, String(await selected()));
+ if (m === "finish" && OPEN_MODES.finish) {
+ const body = await page.evaluate(() => document.body.innerText);
+ check(`${width}: Finish offers Fix colours to a guest`, body.includes("Fix colours") === live("finish-colours"));
+ check(`${width}: Finish offers Fix faces only once it is open`, body.includes("Fix faces") === live("finish-faces"));
+ check(`${width}: Finish fits the screen`, (await sideways()) <= 0);
+ await shot("guest-finish");
+ }
}
await page.goto(`${app}/character-swap`, { waitUntil: "load", timeout: 120_000 });
await page.waitForTimeout(1500);
diff --git a/tests/genjutsu-live.test.ts b/tests/genjutsu-live.test.ts
index b57a0205..97718d0f 100644
--- a/tests/genjutsu-live.test.ts
+++ b/tests/genjutsu-live.test.ts
@@ -44,9 +44,10 @@ describe("Genjutsu's live gate", () => {
expect(Object.values(genjutsuLive(validated, write("bad.json", "{not json"))).some(Boolean)).toBe(false);
});
- it("the committed record opens nothing yet, and the page passes the gate to the studio", () => {
- expect(JSON.parse(fs.readFileSync(path.join(ROOT, "workflows/comfyui/gpu-tested.json"), "utf8"))).toEqual({ features: {} });
- expect(Object.values(genjutsuLive()).some(Boolean)).toBe(false);
+ it("the committed record opens only the features that passed, and the page passes the gate to the studio", () => {
+ const record = JSON.parse(fs.readFileSync(path.join(ROOT, "workflows/comfyui/gpu-tested.json"), "utf8")) as { features: Record<string, { passed: boolean }> };
+ expect(Object.keys(record.features).sort()).toEqual(["finish-colours", "group-swap"]);
+ expect(Object.entries(genjutsuLive()).filter(([, on]) => on).map(([k]) => k).sort()).toEqual(["finish-colours", "group-swap"]);
const page = fs.readFileSync(path.join(ROOT, "src/app/(studio)/genjutsu/page.tsx"), "utf8");
expect(page).toMatch(/<GenjutsuStudio examples=\{exampleRow\("tool:genjutsu"\)\} live=\{genjutsuLive\(\)\} \/>/);
// The studio shows a feature when it is live or the viewer is the owner.
diff --git a/tests/genjutsu-openjutsu-access.test.ts b/tests/genjutsu-openjutsu-access.test.ts
index afd04d80..5b23687a 100644
--- a/tests/genjutsu-openjutsu-access.test.ts
+++ b/tests/genjutsu-openjutsu-access.test.ts
@@ -29,6 +29,7 @@ const sceneRoute = await import("@/app/api/genjutsu/scene/route");
const { estimateGenjutsu, NOT_HERE } = await import("@/server/genjutsu");
const generationsRoute = await import("@/app/api/generations/route");
const { directRunFeatures } = await import("@/lib/catalog/genjutsu");
+const { genjutsuLive } = await import("@/server/genjutsu-live");
const passed = (r: Response) => r.headers.get("x-middleware-next") === "1";
const req = (url: string, init: { method?: string; cookie?: string } = {}) => {
@@ -52,14 +53,21 @@ afterEach(() => {
});
const src = { duration: 12, fps: 16, width: 72, height: 128, hasAudio: true };
+// Features that haven't passed their GPU test yet (workflows/comfyui/gpu-tested.json).
const bodies = () => [
- { engine: "open", mode: "finish", finish: { tool: "colours" }, source: { url: clip, ...src }, range: { start: 0, end: 12 } },
+ { engine: "open", mode: "finish", finish: { tool: "faces" }, references: [clip], source: { url: clip, ...src }, range: { start: 0, end: 10 } },
{ engine: "open", mode: "picture", picture: { stage: "frame" }, references: [clip], source: { url: clip, ...src }, range: { start: 0, end: 6 } },
{ engine: "open", mode: "swap", target: "type", object: { action: "remove", target: "the handbag" }, source: { url: clip, ...src }, range: { start: 0, end: 6 } },
+ { engine: "open", mode: "swap", target: "type", object: { action: "background", target: "the people" }, source: { url: clip, ...src }, range: { start: 0, end: 6 } },
+ { engine: "open", mode: "character", modelId: "oss-h3-group-swap", references: [clip, clip], character: { onePerPerson: true }, source: { url: clip, ...src }, range: { start: 0, end: 6 } },
+];
+// Features that passed: a visitor's price check isn't refused by the gate.
+const opened = () => [
+ { engine: "open", mode: "finish", finish: { tool: "colours" }, source: { url: clip, ...src }, range: { start: 0, end: 12 } },
{ engine: "open", mode: "character", modelId: "oss-h3-group-swap", references: [clip, clip], source: { url: clip, ...src }, range: { start: 0, end: 6 } },
];
-describe("Genjutsu's Openjutsu features before they open", () => {
+describe("Genjutsu's Openjutsu features before and after they open", () => {
it("a guest's and an account's price check is refused in words; the owner's goes through", async () => {
process.env.FUOBE_PUBLIC_SIGNUP = "1";
const cookie = auth.createSession(auth.createAccount(`oj${++n}@example.com`, "long enough").id).value;
@@ -77,6 +85,14 @@ describe("Genjutsu's Openjutsu features before they open", () => {
}
});
+ it("a feature that passed its GPU test opens to visitors", async () => {
+ process.env.FUOBE_PUBLIC_SIGNUP = "1";
+ for (const b of opened()) {
+ const r = await estimateRoute.POST(call("/api/genjutsu/estimate", b));
+ expect((await r.json()).error ?? "", b.mode).not.toBe(NOT_HERE);
+ }
+ });
+
it("a visitor's existing Genjutsu modes are as before", async () => {
process.env.FUOBE_PUBLIC_SIGNUP = "1";
const r = await estimateRoute.POST(call("/api/genjutsu/estimate", { engine: "open", mode: "motion", references: [clip], source: { url: clip, ...src }, range: { start: 0, end: 6 } }));
@@ -90,6 +106,8 @@ describe("Genjutsu's Openjutsu features before they open", () => {
const runs = [
{ feature: "genjutsu", modelId: "oss-h3-group-swap", op: "group-swap", inputs: { video: clip, images: [clip] } },
{ feature: "genjutsu", modelId: "oss-h3-scene-edit", op: "scene-edit", inputs: { video: clip }, params: { extra: { openjutsu: { action: "remove" } } } },
+ { feature: "genjutsu", modelId: "oss-h3-scene-edit", op: "scene-edit", inputs: { video: clip }, params: { extra: { openjutsu: { action: "background" } } } },
+ { feature: "genjutsu", modelId: "oss-h3-group-swap", op: "group-swap", inputs: { video: clip, images: [clip, clip] }, params: { extra: { openjutsu: { onePerPerson: true } } } },
{ feature: "genjutsu", modelId: "oss-from-picture-frame", op: "picture-frame", inputs: { video: clip, images: [clip] } },
{ feature: "genjutsu", modelId: "oss-scene-describe", op: "describe-video", inputs: { video: clip } },
{ feature: "genjutsu", modelId: "oss-from-picture", op: "picture-video", inputs: { video: clip, images: [clip] } },
@@ -104,11 +122,18 @@ describe("Genjutsu's Openjutsu features before they open", () => {
body: JSON.stringify(body),
}),
);
+ const live = genjutsuLive();
for (const b of runs) {
+ const open = directRunFeatures(b.modelId, (b.params?.extra?.openjutsu ?? {}) as Record<string, unknown>)!.every((f) => live[f]);
for (const [who, preview] of [[cookie, false], [cookie, true], [undefined, true]] as const) {
const r = await send(b, who, preview);
- expect(r.status, `${b.modelId} ${who ? "account" : "guest"}${preview ? " price check" : ""}`).toBe(403);
const j = await r.json();
+ // A feature that passed goes past the gate (other rules may still stop it: here the clip isn't the visitor's).
+ if (open) {
+ expect(j.code ?? "", `${b.modelId} ${who ? "account" : "guest"}${preview ? " price check" : ""}`).not.toBe("own-gpu-tool");
+ continue;
+ }
+ expect(r.status, `${b.modelId} ${who ? "account" : "guest"}${preview ? " price check" : ""}`).toBe(403);
expect(j.code).toBe("own-gpu-tool");
expect(j.error).toBe(access.OWN_GPU_TOOL_MESSAGE);
}
diff --git a/workflows/comfyui/gpu-tested.json b/workflows/comfyui/gpu-tested.json
index 219acb6b..392295e8 100644
--- a/workflows/comfyui/gpu-tested.json
+++ b/workflows/comfyui/gpu-tested.json
@@ -1,3 +1,6 @@
{
- "features": {}
+ "features": {
+ "group-swap": { "passed": true, "date": "2026-11-04" },
+ "finish-colours": { "passed": true, "date": "2026-11-04" }
+ }
}