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.

Layouts everywhere: the "Words drawn by the model" switch in Marketing and Ads Studio, and Plan layout in the Layout editor

Claude3e2ff2e26fde
diff --git a/src/components/ads/new-ads.tsx b/src/components/ads/new-ads.tsx
index 11fc59c8..9c194bd4 100644
--- a/src/components/ads/new-ads.tsx
+++ b/src/components/ads/new-ads.tsx
@@ -5,8 +5,9 @@ import { useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { Switch } from "@/components/ui/switch";
import { AddFromLink, ProductCard, ProductDialog, UploadProductButton } from "@/components/brand/products";
-import { AD_VISUAL_MODELS, MAX_ADS_PER_PRODUCT, MAX_PRODUCTS_PER_RUN, type BrandKit, type Product } from "@/lib/catalog/marketing";
+import { AD_VISUAL_MODELS, DRAWN_WORDS_LABEL, DRAWN_WORDS_MODELS, MAX_ADS_PER_PRODUCT, MAX_PRODUCTS_PER_RUN, type BrandKit, type Product } from "@/lib/catalog/marketing";
import { useModelAccess } from "@/lib/api";
import { keepOffered, offered } from "@/lib/model-access";
import { formatCost } from "@/lib/format";
@@ -55,13 +56,15 @@ export function NewAds({ brand, products, engine, onCreated }: { brand: BrandKit
const [editing, setEditing] = useState<Product | null>(null);
// The picture's model: Fuobe Marketing Image first; partner models as choices (those switched off in Settings leave).
const access = useModelAccess();
- const visuals = keepOffered(AD_VISUAL_MODELS[engine], (c) => offered(access, c.id, engine));
+ // "Words drawn by the model": the whole ad drawn from a layout of its places, by a model that reads boxes.
+ const [drawn, setDrawn] = useState(false);
+ const visuals = keepOffered(drawn ? DRAWN_WORDS_MODELS[engine] : AD_VISUAL_MODELS[engine], (c) => offered(access, c.id, engine));
const [picked, setPicked] = useState<string>();
const visual = visuals.find((c) => c.id === picked) ?? visuals[0];
const items = selected.filter((id) => products.some((p) => p.id === id)).map((productId) => ({ productId, count: counts[productId] ?? 4 }));
const total = items.reduce((n, i) => n + i.count, 0);
// useEstimate keys on the body's JSON, so a fresh object each render is fine.
- const body = items.length ? { brandId: brand.id, engine, items, ...(visual && { modelId: visual.id }) } : null;
+ const body = items.length ? { brandId: brand.id, engine, items, ...(visual && { modelId: visual.id }), ...(drawn && { drawnWords: true }) } : null;
const est = useEstimate<BatchEstimate>("/api/ads/estimate", body);
const toggle = (id: string) =>
setSelected((s) => {
@@ -118,7 +121,9 @@ export function NewAds({ brand, products, engine, onCreated }: { brand: BrandKit
{items.length > 0 && (
<section className="rounded-2xl border bg-background p-4 sm:p-5">
<h3 className="text-[16px] font-semibold">How many ads to create?</h3>
- <p className="text-[13px] text-muted-foreground">Each ad comes in 1:1, 4:5 and 9:16, with a headline, copy and a call to action.</p>
+ <p className="text-[13px] text-muted-foreground">
+ {drawn ? "Each ad is drawn whole in 4:5, with its headline, copy and call to action in place." : "Each ad comes in 1:1, 4:5 and 9:16, with a headline, copy and a call to action."}
+ </p>
<ul className="mt-4 divide-y">
{items.map((i) => {
const p = products.find((x) => x.id === i.productId)!;
@@ -134,6 +139,28 @@ export function NewAds({ brand, products, engine, onCreated }: { brand: BrandKit
);
})}
</ul>
+ <div className="mt-4 flex items-start gap-3 rounded-xl bg-muted/60 p-3">
+ <div className="min-w-0 flex-1">
+ <label htmlFor="ads-drawn-words" className="block text-[13px] font-medium">
+ {DRAWN_WORDS_LABEL}
+ </label>
+ <p id="ads-drawn-words-hint" className="mt-0.5 text-[12px] leading-snug text-muted-foreground">
+ {drawn
+ ? "The model draws the headline, copy and button into the picture, in their places: its own lettering, one 4:5 format."
+ : "Off: the words are set on top in your brand fonts, letter for letter, in every format."}
+ </p>
+ </div>
+ <Switch
+ id="ads-drawn-words"
+ checked={drawn}
+ onCheckedChange={(v) => {
+ setDrawn(v);
+ setPicked(undefined);
+ }}
+ aria-describedby="ads-drawn-words-hint"
+ className="mt-0.5 shrink-0"
+ />
+ </div>
{visuals.length > 1 && visual && (
<div className="mt-4 flex flex-wrap items-center gap-x-3 gap-y-1.5">
<label htmlFor="ads-visual" className="text-[13px] font-medium">
@@ -152,7 +179,7 @@ export function NewAds({ brand, products, engine, onCreated }: { brand: BrandKit
</SelectContent>
</Select>
<p id="ads-visual-note" className="w-full text-[12px] text-muted-foreground">
- {visual.note}. Headlines, copy and your logo are set in your brand fonts on top.
+ {visual.note}.{drawn ? "" : " Headlines, copy and your logo are set in your brand fonts on top."}
</p>
</div>
)}
diff --git a/src/components/marketing/marketing-studio.tsx b/src/components/marketing/marketing-studio.tsx
index 13cd3d16..a9ffc4b5 100644
--- a/src/components/marketing/marketing-studio.tsx
+++ b/src/components/marketing/marketing-studio.tsx
@@ -12,7 +12,8 @@ import { ResponsivePanel } from "@/components/studio/responsive-panel";
import { BrandChip } from "@/components/brand/brand-dialog";
import { inputCls } from "@/components/brand/fields";
import { withoutOwnGpu } from "@/lib/catalog/engines";
-import { FORMATS, formatModels, looksLikeWebsite, pickable, MAX_PROMPT, openingAspect, TEMPLATE_INDEX, type FormatId, type MarketingCategory, type MarketingTemplate, type RunEstimate } from "@/lib/catalog/marketing";
+import { Switch } from "@/components/ui/switch";
+import { DRAWN_WORDS_HINT, DRAWN_WORDS_LABEL, FORMATS, formatModels, looksLikeWebsite, pickable, MAX_PROMPT, openingAspect, TEMPLATE_INDEX, type FormatId, type MarketingCategory, type MarketingTemplate, type RunEstimate } from "@/lib/catalog/marketing";
import { SelfHostNote } from "@/components/self-host-note";
import { formatCost } from "@/lib/format";
import { useIsOwner, useLikelyVisitor, useModelAccess } from "@/lib/api";
@@ -52,6 +53,8 @@ interface Draft {
voiceSample: SlotValue | null;
/** SaaS motion: a website or social link to make the video about. */
website: string;
+ /** "Words drawn by the model" (formats with words): the headline and button drawn in place, not set on top. */
+ drawnWords?: boolean;
}
const BLANK: Draft = { format: "product-standalone", templateId: null, product: null, avatar: null, reference: null, hookId: null, settingId: null, prompt: "", headline: "", cta: "", aspectRatio: "3:4", batch: 1, voiceSample: null, website: "" };
@@ -111,7 +114,7 @@ function SettingsPanel({ draft, set, models, engine }: { draft: Draft; set: (p:
const access = useModelAccess();
// A guest or an account: Marketing Studio runs on a self-hosted Fuobe only, so no model reads "on your GPU".
const visitor = useLikelyVisitor();
- const listed = formatModels(f, engine, { product: !!draft.product, avatar: !!draft.avatar });
+ const listed = formatModels(f, engine, { product: !!draft.product, avatar: !!draft.avatar }, !!draft.drawnWords);
// One listed only to say it runs on your GPU (the Original's Standalone shot in the cloud) is shown, never picked.
const choices = keepOffered(pickable(listed), (c) => offered(access, c.id, engine));
const elsewhere = listed.filter((c) => c.unavailable);
@@ -190,6 +193,7 @@ function SettingsPanel({ draft, set, models, engine }: { draft: Draft; set: (p:
function TextPanel({ draft, set, template }: { draft: Draft; set: (p: Partial<Draft>) => void; template?: MarketingTemplate }) {
const [open, setOpen] = useState(false);
const has = draft.headline || draft.cta;
+ const drawnId = "marketing-drawn-words";
return (
<ResponsivePanel
open={open}
@@ -212,6 +216,18 @@ function TextPanel({ draft, set, template }: { draft: Draft; set: (p: Partial<Dr
<span className="text-[12px] font-medium text-muted-foreground">Button</span>
<input value={draft.cta} onChange={(e) => set({ cta: e.target.value })} maxLength={40} placeholder={template?.cta ?? "e.g. Shop now"} className={inputCls} />
</label>
+ {/* Off by default: words set on top keep your exact fonts. On: a model that places boxes draws them in place. */}
+ <div className="flex items-start gap-3 rounded-xl bg-muted/60 p-3">
+ <div className="min-w-0 flex-1">
+ <label htmlFor={drawnId} className="block text-[13px] font-medium">
+ {DRAWN_WORDS_LABEL}
+ </label>
+ <p id={`${drawnId}-hint`} className="mt-0.5 text-[11px] leading-snug text-muted-foreground">
+ {DRAWN_WORDS_HINT}
+ </p>
+ </div>
+ <Switch id={drawnId} checked={!!draft.drawnWords} onCheckedChange={(v) => set({ drawnWords: v, modelId: undefined })} aria-describedby={`${drawnId}-hint`} className="mt-0.5 shrink-0" />
+ </div>
</div>
</ResponsivePanel>
);
@@ -327,7 +343,7 @@ export function MarketingStudio({ models }: { models: Record<string, ModelInfo>
format: draft.format,
templateId: draft.templateId ?? undefined,
// A pick that runs on your GPU only (the Original's Standalone shot) isn't sent to the cloud: its default runs.
- modelId: draft.modelId && !formatModels(f, engine, { product: true, avatar: true }).some((c) => c.unavailable && c.id === draft.modelId) ? draft.modelId : undefined,
+ modelId: draft.modelId && !formatModels(f, engine, { product: true, avatar: true }, !!draft.drawnWords).some((c) => c.unavailable && c.id === draft.modelId) ? draft.modelId : undefined,
productId: draft.product?.productId,
productImages: draft.product && !draft.product.productId ? draft.product.images : undefined,
avatar: f.avatar !== "none" ? draft.avatar?.ref : undefined,
@@ -344,6 +360,7 @@ export function MarketingStudio({ models }: { models: Record<string, ModelInfo>
voice: draft.voice,
voiceSample: draft.voiceSample?.ref,
website: f.oneOf?.includes("website") && looksLikeWebsite(draft.website) ? draft.website.trim() : undefined,
+ drawnWords: f.text && f.pipeline === "image" && draft.drawnWords ? true : undefined,
}),
[draft, engine, f, brandId],
);
diff --git a/src/components/studio/layout-editor.tsx b/src/components/studio/layout-editor.tsx
index 3282f573..c93a94c4 100644
--- a/src/components/studio/layout-editor.tsx
+++ b/src/components/studio/layout-editor.tsx
@@ -1,6 +1,6 @@
"use client";
-import { ArrowDownToLine, ClipboardCopy, FileJson, FlaskConical, Import, Plus, Trash2, Undo2, X } from "lucide-react";
+import { ArrowDownToLine, ClipboardCopy, FileJson, FlaskConical, Import, Loader2, Plus, Sparkles, Trash2, Undo2, X } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
@@ -10,6 +10,8 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSepara
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { copyWithToast } from "@/lib/clipboard";
+import { useLikelyVisitor } from "@/lib/api";
+import { responseError, toastError } from "@/lib/refusals";
import type { ModelDef } from "@/lib/catalog/types";
import { boxesAt, drawnBox, inkOn, keyResizedBox, KIND_COLOR, movedBox, newBox, nudgedBox, pickBox, resizedBox, type Handle } from "@/lib/layout-edit";
import { layoutCompilerFor, parseLayout, readsBoxes, type LayoutBox, type LayoutCanvas as CanvasType, type LayoutDraft, type LayoutItem, type LayoutLabel, type LayoutSource } from "@/lib/layout-prompt";
@@ -163,6 +165,9 @@ function LayoutBoard({
const [history, setHistory] = useState<Snapshot[]>([]);
const board = useRef<HTMLDivElement>(null);
const lastPress = useRef<{ x: number; y: number } | null>(null);
+ const [planning, setPlanning] = useState(false);
+ // Plan layout plans with the studio's own AI helper: a visitor draws the boxes by hand.
+ const visitor = useLikelyVisitor();
const size = canvasFor(aspect);
const ratio = ratioOf(aspect);
@@ -343,13 +348,56 @@ function LayoutBoard({
return true;
};
+ /** Plan layout: a first draft from the whole picture's words, on this canvas (POST /api/layout/plan); Undo takes it back. */
+ const plan = async () => {
+ const words = caption.trim();
+ if (!words) return void toast("Describe the whole picture first, then plan its layout");
+ setPlanning(true);
+ try {
+ const res = await fetch("/api/layout/plan", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ words, width: size.width, height: size.height }) });
+ const j = (await res.json().catch(() => ({}))) as { layout?: LayoutDraft; error?: string };
+ if (!res.ok || !j.layout) throw responseError(res, j.error ?? "Couldn't plan a layout. Try again, or draw the boxes");
+ remember();
+ setItems(j.layout.items);
+ if (j.layout.summary.meta.length && !tags.trim()) setTags(j.layout.summary.meta.join(", "));
+ setSelected(j.layout.items.length ? 0 : null);
+ setSheetOpen(true);
+ const n = j.layout.items.length;
+ toast(`Planned ${n} box${n === 1 ? "" : "es"}: move them, change the words, or Undo`, { id: "layout-plan" });
+ } catch (e) {
+ toastError(e);
+ } finally {
+ setPlanning(false);
+ }
+ };
+
const rows = (
<div className="space-y-3">
<div className="space-y-2 rounded-xl border p-3">
- <label htmlFor="layout-caption" className="text-[12px] font-medium">
- The whole picture
- </label>
+ <div className="flex items-center justify-between gap-2">
+ <label htmlFor="layout-caption" className="text-[12px] font-medium">
+ The whole picture
+ </label>
+ {!visitor && (
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ className="h-7 gap-1 rounded-full px-2.5 text-[12px]"
+ onClick={() => void plan()}
+ disabled={planning || !caption.trim()}
+ aria-describedby="layout-plan-hint"
+ >
+ {planning ? <Loader2 className="size-3.5 animate-spin" /> : <Sparkles className="size-3.5" />} Plan layout
+ </Button>
+ )}
+ </div>
<Textarea id="layout-caption" value={caption} onChange={(e) => setCaption(e.target.value)} rows={2} placeholder="A warm autumn sale poster for a candle shop" className="min-h-0 resize-none text-[13px]" />
+ {!visitor && (
+ <p id="layout-plan-hint" className="text-[11px] leading-snug text-muted-foreground">
+ Plan layout turns these words into boxes to start from: “a sale poster for my candle shop, 30% off”.
+ </p>
+ )}
<div className="flex flex-wrap items-center gap-2">
<span id="layout-canvas-label" className="text-[12px] text-muted-foreground">
Canvas