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.

Character swap in 2K: the composite as its own step, the Quality line wraps with its price, Sharpen rests once every take has its version, and a browser check

Claude495a4fa78590
diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjs
index 3c1d2e7e..e1120e96 100644
--- a/scripts/comfy/library.spec.mjs
+++ b/scripts/comfy/library.spec.mjs
@@ -4454,7 +4454,7 @@ export const SPEC = [
{
id: 'video-composite-mask',
title: 'Put only the swapped character back over the original footage: the 768p swap, then the regenerated one, each through the approved mask (grown, feathered), with the footage\'s sound (core nodes, no model)',
- capability: 'overlay',
+ capability: 'composite',
handBuilt: 'hand-built/video-composite-mask.json',
bindings: {
video: [b('source', 'file')], video2: [b('regen', 'file')], video3: [b('take', 'file')], mask: [b('mask', 'file')],
diff --git a/src/components/genjutsu/character-panel.tsx b/src/components/genjutsu/character-panel.tsx
index ac120baa..aae337cb 100644
--- a/src/components/genjutsu/character-panel.tsx
+++ b/src/components/genjutsu/character-panel.tsx
@@ -33,10 +33,17 @@ import type { GenjutsuTarget, Maker } from "@/lib/catalog/genjutsu";
import { cloudSharpenUsd, SHARPEN_COPY } from "@/lib/catalog/sharpen";
import type { Engine } from "@/lib/catalog/types";
+/** The Quality field's short hint: H3's own sizes in words, a finishing size's price (cloud) or "Free · your GPU". */
+export function qualityShort(engine: Engine, q: CharacterChoice): string {
+ const finish = characterFinish(q);
+ if (!finish) return q === "480p" ? "Faster and cheaper" : "H3's native top";
+ return engine === "open" ? "Free · your GPU" : `$${(cloudSharpenUsd(finish, 5) ?? 0).toFixed(2)} for 5 s`;
+}
+
/** What a quality does, in a line: H3's own sizes, or a finishing size with its price (cloud) or GPU time (open). */
export function qualityHint(engine: Engine, q: CharacterChoice): string {
const finish = characterFinish(q);
- if (!finish) return q === "480p" ? "Faster and cheaper" : "H3's native top";
+ if (!finish) return qualityShort(engine, q);
if (engine === "open") return `${SHARPEN_COPY.hintOpen} Free on your GPU, about 3 min more per 5 s on a 72 GB GPU, never above your clip's own size.`;
const usd = (s: number) => `$${(cloudSharpenUsd(finish, s) ?? 0).toFixed(2)}`;
return `${SHARPEN_COPY.hint} ${usd(5)} for 5 s, ${usd(15)} for 15 s.`;
@@ -145,8 +152,9 @@ export function CharacterControls({
)}
{h3 && (
- <Field label="Quality" hint={qualityHint(engine, shown)}>
+ <Field label="Quality" hint={qualityShort(engine, shown)}>
<Segmented label="Quality" value={shown} onChange={onQuality} options={offered.map((q) => ({ value: q, label: q }))} />
+ {characterFinish(shown) && <p className="text-[12px] leading-snug text-pretty text-muted-foreground">{qualityHint(engine, shown)}</p>}
</Field>
)}
diff --git a/src/components/swap-studio/stage-review.tsx b/src/components/swap-studio/stage-review.tsx
index 4a13c0ea..86ce466d 100644
--- a/src/components/swap-studio/stage-review.tsx
+++ b/src/components/swap-studio/stage-review.tsx
@@ -165,6 +165,8 @@ function FinishPanel({ id, project, clip, gens, estimate }: Pick<StageProps, "id
const finishes = chosen.map((p) => p.take.finish).filter((f) => !!f && (!tier || f.tier === tier));
const states = finishes.map((f) => jobState(f!.genId, f!.stepIds, gens).status);
const busy = states.some((x) => x === "queued" || x === "running");
+ // Every chosen take has a version at this size made or on its way: nothing for Sharpen to do.
+ const allMade = chosen.length > 0 && finishes.length === chosen.length && states.every((x) => x !== "failed" && x !== "canceled" && x !== "missing");
const ready = states.filter((x) => x === "succeeded").length;
const est = estimate?.sharpen[clip.id];
const seconds = est?.seconds ?? chosen.reduce((n, p) => n + (p.end - p.start) / SWAP_STUDIO.fps, 0);
@@ -199,7 +201,7 @@ function FinishPanel({ id, project, clip, gens, estimate }: Pick<StageProps, "id
<div className="flex flex-wrap items-center gap-2">
<Button
className="h-9 rounded-full"
- disabled={!!problem || !tier || sharpen.isPending || busy}
+ disabled={!!problem || !tier || sharpen.isPending || busy || allMade}
onClick={() => tier && sharpen.mutate({ clipId: clip.id, tier }, { onSuccess: () => toast(`Sharpening the chosen takes to ${tier}`), onError: (e) => toastError(e) })}
>
{sharpen.isPending ? <Loader2 className="size-4 animate-spin" /> : <Sparkles className="size-4" />} Sharpen{tier ? ` to ${tier}` : ""}
diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.ts
index 3edb1289..ac694393 100644
--- a/src/lib/catalog/canvas.ts
+++ b/src/lib/catalog/canvas.ts
@@ -348,7 +348,7 @@ export function nodeLabel(n: Pick<CanvasNode, "type" | "data">): string {
* Ops the canvas can't feed (masks, browser-only tools, multi-speaker scripts, draft finishing, and
* inputs it has no port for: a 3D model to rig, a list of audio clips to join).
*/
-const UNSUPPORTED_OPS = new Set<Operation>(["grade", "inpaint", "finalize", "dialogue", "rig-3d", "audio-join"]);
+const UNSUPPORTED_OPS = new Set<Operation>(["grade", "inpaint", "finalize", "dialogue", "rig-3d", "audio-join", "composite"]);
/** Models that only run on a painted mask or clicked points (VACE inpaint, Bria's point eraser): the canvas has neither. */
const needsMarks = (m: ModelDef) => !!(m.options.requires?.mask || m.options.requires?.points);
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 817383e2..1e648e2a 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1136,7 +1136,7 @@ const open: ModelDef[] = [
family: "utility",
kind: "video",
tagline: "Puts only the swapped character back over the original footage, with its own sound · CPU",
- routes: [comfy("overlay", COMPOSITE_WORKFLOW, "the swap, then its regenerate, each through the person's mask (grown, feathered); a few seconds a pass")],
+ routes: [comfy("composite", COMPOSITE_WORKFLOW, "the swap, then its regenerate, each through the person's mask (grown, feathered); a few seconds a pass")],
options: {},
hidden: true,
}),
diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.ts
index 6441ce18..963130cf 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -238,7 +238,7 @@ const PROMPTLESS = new Set<Operation>([
// av-tools: the dub voice track (clips placed on the video's timeline)
"timeline",
// round 4: tools that work from their inputs (removing an object needs a prompt only on models that read one)
- "sdr-to-hdr", "export-video", "ocr", "still-motion", "audio-loop", "audio-join", "scene-3d", "splat", "rig-3d", "extract-frames", "images-to-video", "overlay",
+ "sdr-to-hdr", "export-video", "ocr", "still-motion", "audio-loop", "audio-join", "scene-3d", "splat", "rig-3d", "extract-frames", "images-to-video", "overlay", "composite",
// round 5 (O11): the face mosaic names the faces itself ("face")
"face-mosaic",
// archive-restore: the scene's words help (period, place, light) but a run without them gets a neutral one
@@ -785,6 +785,8 @@ const NEEDS: Partial<
"extract-frames": { video: true, msg: "Add the video to take frames from" },
"images-to-video": { images: 1, msg: "Add the images, in order" },
overlay: { images: 2, msg: "Add the picture and the overlay to put on it" },
+ // Character swap in 2K: the footage, the redrawn swap and the swap (the person's mask goes in inputs.mask).
+ composite: { videos: 2, msg: "Add the footage and the redrawn clip to put the character back over it" },
// N7-5 (the open engine also needs the browser's render along the path: its model's options.requires.video)
"camera-path": { images: 1, msg: "Add the still to film along the path" },
};
diff --git a/src/lib/catalog/sharpen.ts b/src/lib/catalog/sharpen.ts
index cace7a7b..fe5fd0e0 100644
--- a/src/lib/catalog/sharpen.ts
+++ b/src/lib/catalog/sharpen.ts
@@ -66,7 +66,7 @@ export const SHARPEN_COPY = {
usingIt: (tier: string) => `The assembly uses the ${tier} version`,
noMask: "Sharpen puts your character back through the shot's mask: approve a mask in Who to swap and make the take with it",
small: "This clip is filmed below 1080p, so the 768p takes already match it",
- noSize: "Couldn't read the clip's size: open the clip once in Shots so it is measured",
+ noSize: "Couldn't read this clip's size, so it can't be sharpened: save it as an MP4 (H.264) and add it again",
none: "Choose a take for every swapped segment first",
} as const;
@@ -307,7 +307,7 @@ export function sharpenSteps(s: SharpenStepsInput): { steps: PlanStep[]; final:
request: {
...s.helper,
modelId: COMPOSITE_MODEL,
- op: "overlay",
+ op: "composite",
inputs: { ...(own.length ? { videos: own } : {}), ...(mk.url ? { mask: mk.url } : {}) },
params: {
startTime: Math.round((s.source.start + sec(from)) * 1e6) / 1e6,
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index a32a7d6a..eba84c58 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -85,6 +85,7 @@ export type Operation =
// round 5 (O11)
| "face-mosaic" // image → the same picture with the faces (or what the prompt names) pixelated: SAM 3.1 mask + mosaic
// N7-5
+ | "composite" // footage + its redrawn swap + the swap + the person's mask → only the person over the footage (Character swap in 2K)
| "camera-path" // image + params.cameraPath (+ inputs.video: the open engine's render along the path) → the camera following the path
// archive-restore
| "restore-video"; // archive video (+ prompt: period, place, light; negative: what not to invent) → the same shot clean, in colour, larger
@@ -157,6 +158,7 @@ export const OPERATION_LABELS: Record<Operation, string> = {
overlay: "Overlay image",
"face-mosaic": "Pixelate faces",
"camera-path": "Fly path",
+ composite: "Character over the footage",
"restore-video": "Restore & colourise",
};
@@ -229,6 +231,7 @@ export const OPERATION_OUTPUT: Record<Operation, MediaKind> = {
overlay: "image",
"face-mosaic": "image",
"camera-path": "video",
+ composite: "video",
"restore-video": "video",
};
diff --git a/src/server/gpu/tools.ts b/src/server/gpu/tools.ts
index e155e365..dec2fdeb 100644
--- a/src/server/gpu/tools.ts
+++ b/src/server/gpu/tools.ts
@@ -229,7 +229,7 @@ export const STUDIO_ROWS: StudioRowDef[] = [
group: "Video tools",
steps: [
{ modelId: REGEN_MODEL, op: "upscale-video" },
- { modelId: COMPOSITE_MODEL, op: "overlay" },
+ { modelId: COMPOSITE_MODEL, op: "composite" },
{ modelId: REGEN_JOIN, op: "concat" },
],
},
diff --git a/tests/character-swap-2k.test.ts b/tests/character-swap-2k.test.ts
index b1fdb486..5bd000e9 100644
--- a/tests/character-swap-2k.test.ts
+++ b/tests/character-swap-2k.test.ts
@@ -95,7 +95,10 @@ describe("prices", () => {
});
it("the cloud's Quality hint carries the price; your GPU's the time", async () => {
- const { qualityHint } = await import("@/components/genjutsu/character-panel");
+ const { qualityHint, qualityShort } = await import("@/components/genjutsu/character-panel");
+ expect(qualityShort("cloud", "2K")).toBe("$0.81 for 5 s");
+ expect(qualityShort("open", "4K")).toBe("Free · your GPU");
+ expect(qualityShort("cloud", "768p")).toBe("H3's native top");
expect(qualityHint("cloud", "2K")).toBe("2K and 4K redraw the 768p swap at the higher size. $0.81 for 5 s, $2.44 for 15 s.");
expect(qualityHint("cloud", "4K")).toBe("2K and 4K redraw the 768p swap at the higher size. $1.00 for 5 s, $3.00 for 15 s.");
expect(qualityHint("open", "2K")).toMatch(/^1080p, 2K and 4K redraw the 768p swap at the higher size\. Free on your GPU, about 3 min more per 5 s on a 72 GB GPU/);
@@ -210,7 +213,7 @@ describe("Genjutsu's Character swap", () => {
expect(regen.request.prompt).toMatch(/^Replace the selected person in the clip with the character in the reference/);
expect(regen.after).toEqual(["swap"]);
const c1 = step(p, "sharpen-comp1");
- expect(c1.request).toMatchObject({ modelId: "oss-composite-mask", op: "overlay", params: { startTime: 2.5, endTime: 5, extra: { windowStart: 2.5, takeStart: 2.5, maskStart: 2.5 } } });
+ expect(c1.request).toMatchObject({ modelId: "oss-composite-mask", op: "composite", params: { startTime: 2.5, endTime: 5, extra: { windowStart: 2.5, takeStart: 2.5, maskStart: 2.5 } } });
expect(c1.after).toEqual(["sharpen-regen0", "fit", "swap", "mask"]);
expect(c1.chain).toEqual([{ slot: "videos", at: 1 }, { slot: "videos", at: 0 }, { slot: "videos", at: 2 }, { slot: "mask" }]);
expect(step(p, "sharpen-join").request).toMatchObject({ modelId: "oss-join-encoded", feature: "genjutsu-step" });
@@ -374,7 +377,7 @@ describe("video-composite-mask", () => {
const { manifest } = getWorkflow(S.COMPOSITE_WORKFLOW);
it("is core nodes only, validated, with the bindings the plan fills", () => {
- expect(manifest).toMatchObject({ capability: "overlay", vramGb: 0, validated: true });
+ expect(manifest).toMatchObject({ capability: "composite", vramGb: 0, validated: true });
expect(Object.keys(manifest.bindings).sort()).toEqual(
["video", "video2", "video3", "mask", "startTime", "windowStart", "takeStart", "maskStart", "duration", "canvasWidth", "canvasHeight", "takeX", "takeY", "regionWidth", "regionHeight", "regionX", "regionY", "maskGrow", "feather", "filenamePrefix"].sort(),
);
@@ -393,7 +396,7 @@ describe("video-composite-mask", () => {
const { workflow: wf } = await prepareWorkflow(
S.COMPOSITE_WORKFLOW,
{ video: undefined, videos: ["src.mp4", "regen.mp4", "take.mp4"], mask: "mask.mp4", startTime: c.params!.startTime, endTime: c.params!.endTime, extra: { ...extra } } as GenInput,
- { generationId: "g1", op: "overlay", upload: async (_d, _t, name) => `up_${name}`, media: () => undefined },
+ { generationId: "g1", op: "composite", upload: async (_d, _t, name) => `up_${name}`, media: () => undefined },
);
const at = (node: string, input: string) => (wf as Record<string, { inputs: Record<string, unknown> }>)[node].inputs[input];
expect([at("source", "file"), at("regen", "file"), at("take", "file"), at("mask", "file")]).toEqual(["src.mp4", "regen.mp4", "take.mp4", "mask.mp4"]);
diff --git a/tests/e2e/character-swap-2k.mjs b/tests/e2e/character-swap-2k.mjs
new file mode 100644
index 00000000..e5b3d457
--- /dev/null
+++ b/tests/e2e/character-swap-2k.mjs
@@ -0,0 +1,206 @@
+// Browser check of Character swap in 2K (n7-4-character-swap-2k).
+// Usage: node tests/e2e/character-swap-2k.mjs [appUrl] [outDir] (the app in demo mode: no keys, no ComfyUI)
+// At 1440 px and 390 px, light and dark: Character Swap Studio's Assemble → Finish with "Sharpen to 1080p / 2K / 4K"
+// (the sizes picked by keyboard and by touch, the price or GPU time, Run) beside "Clean backplate + alpha" (not
+// available), on a cloud project with a chosen take and on a project on your GPU; a run on the cloud makes a 2K version
+// that Takes & review shows beside the take with "Use the 2K version"; Genjutsu's Character swap Quality with 2K and 4K
+// and their prices (the cloud) or GPU time (your GPU, with 1080p). No sideways scroll anywhere. Screenshots go to outDir.
+import { execFileSync } from "node:child_process";
+import fs from "node:fs";
+import path from "node:path";
+import { DESKTOP, PHONE, launch, openRoute, root } from "./_browser.mjs";
+
+const args = process.argv.slice(2).filter((a) => !a.startsWith("--"));
+const app = (args[0] ?? "http://localhost:3000").replace(/\/$/, "");
+const out = args[1] ?? fs.mkdtempSync("/tmp/fuobe-swap-2k-");
+fs.mkdirSync(out, { recursive: true });
+
+const failures = [];
+const check = (ok, what) => {
+ console.log(`${ok ? "✓" : "✗"} ${what}`);
+ if (!ok) failures.push(what);
+};
+const json = async (p, init) => {
+ const res = await fetch(app + p, { headers: { "Content-Type": "application/json" }, ...init });
+ const body = await res.json();
+ if (!res.ok) throw new Error(`${p}: ${body.error ?? res.status}`);
+ return body;
+};
+const upload = async (file, type) => {
+ const form = new FormData();
+ form.append("file", new Blob([fs.readFileSync(file)], { type }), path.basename(file));
+ const res = await fetch(`${app}/api/uploads`, { method: "POST", body: form });
+ const body = await res.json();
+ if (!res.ok) throw new Error(`upload: ${body.error}`);
+ return body.url;
+};
+const noSideScroll = async (page, label) => {
+ const over = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
+ check(over <= 0, `${label}: no horizontal scroll (${over}px)`);
+};
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+
+// A 6 s 1920×1080 clip with sound (H.264: the server reads its header; the checks don't play it), and the character.
+const clipFile = path.join(out, "street.mp4");
+execFileSync("ffmpeg", ["-v", "error", "-y", "-i", path.join(root, "scripts/eval/fixtures/walk-6s.mp4"), "-t", "6", "-vf", "scale=1920:1080,setsar=1", "-c:v", "libx264", "-preset", "ultrafast", "-pix_fmt", "yuv420p", "-c:a", "aac", "-movflags", "+faststart", clipFile]);
+const clipUrl = await upload(clipFile, "video/mp4");
+const heroUrl = await upload(path.join(root, "scripts/eval/fixtures/character/drawn-face-2.png"), "image/png");
+
+// A rerun starts clean.
+for (const p of (await json("/api/swap-studio/projects")).items ?? []) if (/^2K check/.test(p.name)) await fetch(`${app}/api/swap-studio/projects/${p.id}`, { method: "DELETE" });
+
+/** A project with the clip, no scene anchor, one 6 s segment; on the cloud its take is made (demo) and chosen. */
+async function project(engine) {
+ const p = await json("/api/swap-studio/projects", { method: "POST", body: JSON.stringify({ name: `2K check · ${engine}`, engine, character: { image: heroUrl, description: "a cartoon man with round glasses" } }) });
+ let v = await json(`/api/swap-studio/projects/${p.id}/clips`, { method: "POST", body: JSON.stringify({ url: clipUrl, name: "street.mp4" }) });
+ const c = v.clips[0];
+ const shot = c.shots[0];
+ const edit = (e) => json(`/api/swap-studio/projects/${p.id}`, { method: "PATCH", body: JSON.stringify(e) });
+ await edit({ type: "shot", clipId: c.id, shotId: shot.id, patch: { settings: { useAnchor: false } } });
+ v = await edit({ type: "layout", clipId: c.id, shotId: shot.id, op: { op: "partition", frames: 144 } });
+ if (engine === "cloud") {
+ const seg = v.clips[0].shots[0].segments[0];
+ await json(`/api/swap-studio/projects/${p.id}/queue`, { method: "POST", body: JSON.stringify({ clipId: c.id, shotId: shot.id, segmentId: seg.id, mode: "all" }) });
+ for (let i = 0; i < 120; i++) {
+ const view = await json(`/api/swap-studio/projects/${p.id}`);
+ const s = view.project.clips[0].shots[0].segments[0];
+ if (s.selectedTake && view.gens[s.takes[0].genId]?.status === "succeeded") break;
+ await sleep(1000);
+ }
+ }
+ return { id: p.id, clipId: c.id, shotId: shot.id };
+}
+
+const cloud = await project("cloud");
+const open = await project("open");
+
+const browser = await launch();
+try {
+ for (const [dname, device] of [
+ ["1440", DESKTOP],
+ ["390", PHONE],
+ ]) {
+ for (const theme of ["light", "dark"]) {
+ const label = `${dname} ${theme}`;
+ const ctx = await browser.newContext({ ...device, colorScheme: theme });
+ await ctx.route((u) => u.origin !== new URL(app).origin && /^https?:$/.test(u.protocol), (rt) => rt.abort());
+ const page = await ctx.newPage();
+ page.on("pageerror", (e) => !/Hydration failed[\s\S]*ViewerRowPlaceholder/.test(e.message) && failures.push(`${label} page error: ${e.message.split("\n")[0]}`));
+ const touch = !!device.hasTouch;
+ const press = (loc) => (touch ? loc.tap() : loc.click());
+
+ // ---- Character Swap Studio on the cloud: Assemble → Finish.
+ await openRoute(page, `${app}/character-swap/${cloud.id}`);
+ await press(page.getByRole("tab", { name: "Assemble" }));
+ const sharpenTitle = page.getByRole("heading", { name: "Sharpen to 1080p / 2K / 4K" });
+ await sharpenTitle.waitFor({ timeout: 60_000 });
+ check(await sharpenTitle.isVisible(), `${label} cloud: the Sharpen card`);
+ // The owner's card (it waits for who is looking).
+ const backplate = page.getByRole("heading", { name: "Clean backplate + alpha" });
+ await backplate.waitFor({ timeout: 30_000 }).catch(() => undefined);
+ check(await backplate.isVisible(), `${label} cloud: Clean backplate + alpha beside it`);
+ await page.getByText(/1 chosen take/).waitFor({ timeout: 30_000 }).catch(() => undefined);
+ check((await page.getByText("Not available", { exact: false }).count()) > 0, `${label} cloud: the backplate card says Not available`);
+ const sizes = page.getByRole("radiogroup", { name: "Sharpen to" });
+ const r = (n) => sizes.getByRole("radio", { name: n, exact: true });
+ check(await r("1080p").isDisabled(), `${label} cloud: 1080p is off (fal makes 2K or 4K)`);
+ check((await r("2K").getAttribute("aria-checked")) === "true", `${label} cloud: 2K is picked`);
+ check(await r("4K").isDisabled(), `${label} cloud: 4K is off (the film is joined at 1920×1080)`);
+ check((await r("4K").getAttribute("title"))?.includes("Joined at 1920×1080") ?? false, `${label} cloud: 4K says why`);
+ await page.waitForFunction(() => /Placeholder · free|≈ \$/.test(document.body.innerText), null, { timeout: 30_000 }).catch(() => undefined);
+ const body = await page.evaluate(() => document.body.innerText);
+ check(/Makes each chosen take again at 2K on MiniMax H3/.test(body), `${label} cloud: the cloud's copy (a new render, the whole frame)`);
+ check(/1 chosen take · 6 s · MiniMax H3 at 2K/.test(body), `${label} cloud: the takes and seconds`);
+ check(/Placeholder · free|≈ \$/.test(body), `${label} cloud: a price before running`);
+ check(/joined at 1920×1080/i.test(body), `${label} cloud: the join's size`);
+ // Keyboard reaches the size and the button.
+ await r("2K").focus();
+ check(await page.evaluate(() => document.activeElement?.getAttribute("role") === "radio"), `${label} cloud: keyboard focus on the size`);
+ const run = page.getByRole("button", { name: /^Sharpen to 2K/ });
+ if (await run.isEnabled()) {
+ await run.focus();
+ check(await page.evaluate(() => /Sharpen to 2K/.test(document.activeElement?.textContent ?? "")), `${label} cloud: keyboard focus on Sharpen`);
+ } else check(/1 of 1 ready/.test(body), `${label} cloud: Sharpen rests once every chosen take has its 2K version`);
+ await noSideScroll(page, `${label} cloud Assemble`);
+ await page.screenshot({ path: path.join(out, `assemble-cloud-${dname}-${theme}.png`), fullPage: true });
+
+ // Run once (the first pass), then the version beside the take in Takes & review.
+ if (dname === "1440" && theme === "light") {
+ await run.click();
+ await page.getByText(/of 1 ready/).waitFor({ timeout: 30_000 });
+ check(true, `${label} cloud: Sharpen runs (a 2K version on its way)`);
+ await page.getByText(/1 of 1 ready/).waitFor({ timeout: 120_000 });
+ }
+ await press(page.getByRole("tab", { name: "Takes & review" }));
+ await page.getByText("2K version").first().waitFor({ timeout: 60_000 });
+ const use = page.getByRole("button", { name: "Use the 2K version" });
+ const using = page.getByText("The assembly uses the 2K version");
+ if ((await use.count()) > 0) {
+ check(true, `${label} cloud: the 2K version beside the take, with Use the 2K version`);
+ await press(use);
+ await using.waitFor({ timeout: 15_000 });
+ }
+ check(await using.isVisible(), `${label} cloud: picked, the assembly uses it`);
+ await noSideScroll(page, `${label} cloud Takes & review`);
+ await page.screenshot({ path: path.join(out, `review-cloud-${dname}-${theme}.png`), fullPage: true });
+ // Back to the take for the next pass.
+ await press(page.getByRole("button", { name: "Use the take instead" }));
+ await use.waitFor({ timeout: 15_000 });
+
+ // ---- On your GPU: 1080p only (the footage is 1080p), free, the GPU time.
+ await openRoute(page, `${app}/character-swap/${open.id}`);
+ await press(page.getByRole("tab", { name: "Assemble" }));
+ await page.getByRole("heading", { name: "Sharpen to 1080p / 2K / 4K" }).waitFor({ timeout: 60_000 });
+ const og = page.getByRole("radiogroup", { name: "Sharpen to" });
+ check((await og.getByRole("radio", { name: "1080p", exact: true }).getAttribute("aria-checked")) === "true", `${label} GPU: 1080p is picked`);
+ check(await og.getByRole("radio", { name: "2K", exact: true }).isDisabled(), `${label} GPU: 2K is off (never above the footage)`);
+ const ob = await page.evaluate(() => document.body.innerText);
+ check(/Redraws each chosen take at 2K, then puts only your character back over the original footage/.test(ob), `${label} GPU: the card's copy`);
+ check(/Free on your GPU · about \d+ min on a 72 GB GPU|Placeholder · free/.test(ob), `${label} GPU: free, with the GPU time`);
+ check(/Choose a take for every swapped segment first/.test(ob), `${label} GPU: says what's missing before it can run`);
+ check(await page.getByRole("button", { name: /^Sharpen to 1080p/ }).isDisabled(), `${label} GPU: Run waits for the takes`);
+ await noSideScroll(page, `${label} GPU Assemble`);
+ await page.screenshot({ path: path.join(out, `assemble-open-${dname}-${theme}.png`), fullPage: true });
+
+ // ---- Genjutsu's Character swap: Quality with 2K and 4K.
+ for (const engine of ["cloud", "open"]) {
+ await page.evaluate((e) => localStorage.setItem("fuobe.engine", e), engine);
+ await openRoute(page, `${app}/genjutsu?mode=character&video=${encodeURIComponent(clipUrl)}&image=${encodeURIComponent(heroUrl)}`);
+ const q = page.getByRole("radiogroup", { name: "Quality" });
+ await q.waitFor({ timeout: 60_000 });
+ const names = await q.getByRole("radio").allInnerTexts();
+ check(
+ JSON.stringify(names.map((s) => s.trim())) === JSON.stringify(engine === "cloud" ? ["480p", "768p", "2K", "4K"] : ["480p", "768p", "1080p", "2K", "4K"]),
+ `${label} Genjutsu ${engine}: Quality offers ${names.join(", ")}`,
+ );
+ // Keyboard: from 768p, the arrow picks the next size.
+ await q.getByRole("radio", { name: "768p", exact: true }).focus();
+ await page.keyboard.press("ArrowRight");
+ await page.waitForTimeout(300);
+ const next = engine === "cloud" ? "2K" : "1080p";
+ check((await q.getByRole("radio", { name: next, exact: true }).getAttribute("aria-checked")) === "true", `${label} Genjutsu ${engine}: the arrow key picks ${next}`);
+ await press(q.getByRole("radio", { name: "2K", exact: true }));
+ await page.waitForTimeout(300);
+ const g = await page.evaluate(() => document.body.innerText);
+ // The whole line is on the page, not cut short (the field's hint holds the short price).
+ const line = page.getByText(/redraw the 768p swap at the higher size/);
+ const fits = await line.evaluate((el) => el.scrollWidth <= el.clientWidth + 1 && getComputedStyle(el).textOverflow !== "ellipsis").catch(() => false);
+ check(fits, `${label} Genjutsu ${engine}: the size's line wraps instead of being cut`);
+ if (engine === "cloud") {
+ check(/2K and 4K redraw the 768p swap at the higher size\. \$0\.81 for 5 s, \$2\.44 for 15 s\./.test(g), `${label} Genjutsu cloud: 2K's price ($0.81 for 5 s)`);
+ await press(q.getByRole("radio", { name: "4K", exact: true }));
+ await page.waitForTimeout(300);
+ check(/\$1\.00 for 5 s, \$3\.00 for 15 s/.test(await page.evaluate(() => document.body.innerText)), `${label} Genjutsu cloud: 4K's price`);
+ } else check(/1080p, 2K and 4K redraw the 768p swap at the higher size\. Free on your GPU, about 3 min more per 5 s/.test(g), `${label} Genjutsu GPU: free, with the GPU time`);
+ await noSideScroll(page, `${label} Genjutsu ${engine}`);
+ await page.screenshot({ path: path.join(out, `genjutsu-${engine}-${dname}-${theme}.png`), fullPage: true });
+ }
+ await ctx.close();
+ }
+ }
+} finally {
+ await browser.close();
+}
+for (const p of [cloud, open]) await fetch(`${app}/api/swap-studio/projects/${p.id}`, { method: "DELETE" });
+console.log(failures.length ? `\n${failures.length} failed:\n- ${failures.join("\n- ")}` : "\nAll checks passed");
+process.exit(failures.length ? 1 : 0);
diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.json
index 247df415..5fca54d3 100644
--- a/workflows/comfyui/manifest.json
+++ b/workflows/comfyui/manifest.json
@@ -20155,7 +20155,7 @@
{
"id": "video-composite-mask",
"title": "Put only the swapped character back over the original footage: the 768p swap, then the regenerated one, each through the approved mask (grown, feathered), with the footage's sound (core nodes, no model)",
- "capability": "overlay",
+ "capability": "composite",
"file": "video-composite-mask.json",
"source": "hand-built (scripts/comfy/hand-built/video-composite-mask.json)",
"bindings": {