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 Studio: Dismiss clears detected edits; cloud Update frame cuts half a second

Claude7105a3333583
diff --git a/src/components/swap-studio/stage-shots.tsx b/src/components/swap-studio/stage-shots.tsx
index 9ba38d65..f986e53a 100644
--- a/src/components/swap-studio/stage-shots.tsx
+++ b/src/components/swap-studio/stage-shots.tsx
@@ -108,7 +108,7 @@ export function ShotsStage({ project, clip, edit, src }: StageProps) {
<Button size="sm" className="h-7 rounded-full px-2.5 text-[12px]" onClick={() => setDraft(tidyCuts(clip.detected!))}>
<Check className="size-3.5" /> Use them
</Button>
- <Button size="sm" variant="ghost" className="h-7 rounded-full px-2.5 text-[12px]" onClick={() => void edit({ type: "detected", clipId: clip.id, cuts: [] })}>
+ <Button size="sm" variant="ghost" className="h-7 rounded-full px-2.5 text-[12px]" onClick={() => void edit({ type: "detected", clipId: clip.id, cuts: [], dismiss: true })}>
<X className="size-3.5" /> Dismiss
</Button>
</div>
diff --git a/src/lib/catalog/swap-studio-edit.ts b/src/lib/catalog/swap-studio-edit.ts
index 48afce67..d6bc7b22 100644
--- a/src/lib/catalog/swap-studio-edit.ts
+++ b/src/lib/catalog/swap-studio-edit.ts
@@ -68,7 +68,7 @@ export type SwapEdit =
| { type: "defaults"; settings: Partial<SwapSettings> }
| { type: "clip"; clipId: string; name?: string; review?: Decision; reviewNotes?: string }
| { type: "remove-clip"; clipId: string }
- | { type: "detected"; clipId: string; cuts: number[] }
+ | { type: "detected"; clipId: string; cuts: number[]; dismiss?: boolean }
| { type: "cuts"; clipId: string; cuts: number[]; modes?: ShotMode[] }
| { type: "voices"; clipId: string; voices: Record<string, SwapRole> }
| { type: "shot"; clipId: string; shotId: string; patch: ShotPatch }
@@ -201,6 +201,8 @@ export function applyEdit(project: SwapProject, edit: SwapEdit, o: { active: (ge
}
case "detected": {
const c = mustClip(p, edit.clipId);
+ // Dismissed: nothing waits to be confirmed (an empty list is a finding: "no edits").
+ if (edit.dismiss) return mapClip(p, c.id, (x) => ({ ...x, detected: null }));
const cuts = tidyCuts(edit.cuts.filter((n) => Number.isInteger(n) && n > 0 && n < c.frames));
return mapClip(p, c.id, (x) => ({ ...x, detected: cuts }));
}
diff --git a/src/lib/catalog/swap-studio-plan.ts b/src/lib/catalog/swap-studio-plan.ts
index ba50aff3..2006a86d 100644
--- a/src/lib/catalog/swap-studio-plan.ts
+++ b/src/lib/catalog/swap-studio-plan.ts
@@ -180,7 +180,9 @@ export function planMask(m: MaskPlanInput): PlanStep[] {
];
}
const from = shot.start + m.frame;
- const to = m.kind === "frame" ? from + 1 : shot.end;
+ // Update frame reads half a second from the frame (a one-frame cut is too short to trim and track); its piece is the
+ // first frame of that mask.
+ const to = m.kind === "frame" ? Math.min(shot.end, from + 12) : shot.end;
return [
{ key: "cut", request: { ...helper(title), modelId: STUDIO_MODELS.cloud.cut, op: "trim", inputs: { video: clip.source.url }, params: { startTime: at(from), endTime: at(to) }, step: { label: "Cut from the frame", index: 0, of: 2 } } },
{
diff --git a/src/server/swap-studio.ts b/src/server/swap-studio.ts
index e954c3e9..b6154780 100644
--- a/src/server/swap-studio.ts
+++ b/src/server/swap-studio.ts
@@ -463,7 +463,7 @@ export const EditSchema = z.discriminatedUnion("type", [
z.object({ type: z.literal("defaults"), settings }),
z.object({ type: z.literal("clip"), clipId: id, name: z.string().max(200).optional(), review: decision.optional(), reviewNotes: text(SWAP_STUDIO.maxNotesChars).optional() }),
z.object({ type: z.literal("remove-clip"), clipId: id }),
- z.object({ type: z.literal("detected"), clipId: id, cuts: z.array(z.number().int()).max(2000) }),
+ z.object({ type: z.literal("detected"), clipId: id, cuts: z.array(z.number().int()).max(2000), dismiss: z.boolean().optional() }),
z.object({ type: z.literal("cuts"), clipId: id, cuts: z.array(z.number().int()).max(2000), modes: z.array(z.enum(["generate", "preserve"])).max(2001).optional() }),
z.object({ type: z.literal("voices"), clipId: id, voices: z.record(z.string().max(80), role) }),
z.object({
diff --git a/tests/swap-studio-edit.test.ts b/tests/swap-studio-edit.test.ts
index 79d1ab45..7c53e7b6 100644
--- a/tests/swap-studio-edit.test.ts
+++ b/tests/swap-studio-edit.test.ts
@@ -16,7 +16,7 @@ import {
type SwapTake,
} from "@/lib/catalog/swap-studio";
import { applyEdit, cleanSettings, EditError, shotBusy, type SwapEdit } from "@/lib/catalog/swap-studio-edit";
-import { frozenTakePlan } from "@/lib/catalog/swap-studio-plan";
+import { frozenTakePlan, planMask } from "@/lib/catalog/swap-studio-plan";
// Character Swap Studio's edits (Akatz Labs' rules) and a queued take's frozen plan: pure, no server.
@@ -85,6 +85,9 @@ describe("project edits", () => {
let p = edit(projectOf(), { type: "detected", clipId: "clip-1", cuts: [120, 0, 600, 120, 300] });
expect(p.clips[0].detected).toEqual([120, 300]);
expect(p.clips[0].shots).toHaveLength(1);
+ // Dismissed: nothing waits; "no edits found" is an empty list.
+ expect(edit(p, { type: "detected", clipId: "clip-1", cuts: [], dismiss: true }).clips[0].detected).toBeNull();
+ expect(edit(p, { type: "detected", clipId: "clip-1", cuts: [] }).clips[0].detected).toEqual([]);
p = edit(p, { type: "cuts", clipId: "clip-1", cuts: [300, 120], modes: ["generate", "preserve", "generate"] });
expect(p.clips[0]).toMatchObject({ cuts: [120, 300], detected: null, cutsReviewed: true });
expect(p.clips[0].shots.map((s) => [s.start, s.end, s.mode])).toEqual([
@@ -251,6 +254,18 @@ describe("queued takes", () => {
});
});
+describe("cloud mask updates", () => {
+ it("Update frame cuts half a second from the frame (within the shot); its piece is that one frame", () => {
+ const p = projectOf([clipOf()], "cloud");
+ const shot = { ...shotOf(p), start: 24, end: 120 };
+ const [cut, mask] = planMask({ engine: "cloud", clip: p.clips[0], shot, kind: "frame", frame: 90, points: [{ x: 5, y: 5 }], who: shot.who, base: null });
+ expect(cut.request.params).toEqual({ startTime: 114 / 24, endTime: 120 / 24 });
+ expect(mask.request.params).toMatchObject({ duration: 6 / 24, points: [{ x: 5, y: 5 }] });
+ const [mid] = planMask({ engine: "cloud", clip: p.clips[0], shot, kind: "frame", frame: 10, points: [{ x: 5, y: 5 }], who: shot.who, base: null });
+ expect(mid.request.params).toEqual({ startTime: 34 / 24, endTime: 46 / 24 });
+ });
+});
+
describe("job state", () => {
const g = (status: GenSummary["status"], over: Partial<GenSummary> = {}): GenSummary => ({ status, progress: null, message: null, error: null, costUsd: 0, demo: true, ...over });