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.

Place chip: checked GPU place, named cloud model, quieter phone row

Adarshb90161d9ba9d
diff --git a/src/components/ads/multiplier.tsx b/src/components/ads/multiplier.tsx
index 04e404df..3a2f6bb2 100644
--- a/src/components/ads/multiplier.tsx
+++ b/src/components/ads/multiplier.tsx
@@ -278,7 +278,7 @@ export function AdMultiplier({ models, examples }: { models: Record<string, Mode
// Where the new versions are made and their price (the studios' words); a guest or an account is told it isn't
// available here (its run would be refused), with no price.
const priced = est.data && !est.data.blocker ? est.data : undefined;
- const place = useRunPlace({ engine, models: priced?.steps.map((s) => s.modelName), model: mainModel(priced?.steps), costUsd: priced?.costUsd, demo: priced?.demo, ownerOnly: "Ad Multiplier" });
+ const place = useRunPlace({ engine, models: priced?.steps.map((s) => s.modelName), model: mainModel(priced?.steps) ?? model?.name, costUsd: priced?.costUsd, demo: priced?.demo, ownerOnly: "Ad Multiplier" });
const runLabel = versions > 1 ? `Generate ${versions} versions` : "Generate";
const mention = (n: number) => {
diff --git a/src/components/ads/new-ads.tsx b/src/components/ads/new-ads.tsx
index 4625f7c4..6b3f738e 100644
--- a/src/components/ads/new-ads.tsx
+++ b/src/components/ads/new-ads.tsx
@@ -100,9 +100,9 @@ export function NewAds({
onError: (e) => toastError(e),
});
};
- // Where the ads are made and their price, as the studios say it.
+ // Where the ads are made and their price, as the studios say it (the picked picture model until the run is priced).
const priced = est.data && !est.data.blocker ? est.data : undefined;
- const place = useRunPlace({ engine, models: priced ? [priced.modelName] : undefined, costUsd: priced?.costUsd, demo: priced?.demo, ownerOnly: "Ads Studio" });
+ const place = useRunPlace({ engine, models: priced ? [priced.modelName] : undefined, model: priced?.modelName ?? visual?.name, costUsd: priced?.costUsd, demo: priced?.demo, ownerOnly: "Ads Studio" });
return (
<div className="space-y-6">
<section className="rounded-2xl border bg-background p-4 sm:p-5">
@@ -216,7 +216,7 @@ export function NewAds({
</div>
<div className="flex items-center gap-3">
<RunPlaceChip place={place} engine={engine} onEngine={onEngine} pending={est.isFetching && !est.data} className="bg-background" />
- <Button size="lg" onClick={create} disabled={createBatch.isPending || !!est.data?.blocker} title={place?.send ? `Create ${total} ads · ${place.send}` : undefined}>
+ <Button size="lg" onClick={create} disabled={createBatch.isPending || !!est.data?.blocker} title={est.data?.blocker ?? (place?.send ? `Create ${total} ads · ${place.send}` : undefined)}>
{createBatch.isPending ? <Loader2 className="animate-spin" /> : <Sparkles />} Create {total} ads
</Button>
</div>
diff --git a/src/components/any-angle/any-angle-tool.tsx b/src/components/any-angle/any-angle-tool.tsx
index aaffbe3c..4c783f47 100644
--- a/src/components/any-angle/any-angle-tool.tsx
+++ b/src/components/any-angle/any-angle-tool.tsx
@@ -537,8 +537,9 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {
const shots = useMemo(() => (ref ? (results.data ?? []).filter((g) => photoOf(g) === ref) : []), [results.data, ref]);
const cloudOnly = mode === "cloud";
- // Where the angles are made and their price, as the studios say it (the 3D view, then one picture per angle).
- const place = useOpenRunPlace([getModel(ANY_ANGLE.buildModel)?.name, getModel(ANY_ANGLE.shotModel)?.name].filter((x): x is string => !!x), null);
+ // Where the angles are made and their price, as the studios say it (the 3D view, then one picture per angle). The 3D
+ // view is built on the viewer's own GPU only (this studio's GPUs refuse it), so an account connects its own.
+ const place = useOpenRunPlace([getModel(ANY_ANGLE.buildModel)?.name, getModel(ANY_ANGLE.shotModel)?.name].filter((x): x is string => !!x), null, { ownGpuOnly: true });
const ready = !!view && !!ref;
// A build that failed takes the angles waiting for it with it.
const waiting = build?.status === "failed" || build?.status === "canceled" ? null : asked;
@@ -688,6 +689,7 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {
? (build?.error ?? "The 3D view didn't finish. Try again.")
: "First we build a 3D view of your photo. It takes about two minutes, once per photo."}
</p>
+ {!building && !noSubject && <RunPlaceChip place={place} className="shrink-0 self-start sm:self-center" />}
{!building &&
(noSubject ? (
<Button size="lg" className="shrink-0 rounded-full" onClick={() => take({ ref: "", preview: "" })}>
@@ -698,6 +700,7 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {
size="lg"
className="shrink-0 rounded-full"
disabled={!ref || create.isPending}
+ title={place?.send ? `${failedBuild ? "Try again" : "Build 3D view"} · ${place.send}` : undefined}
onClick={() => {
if (failedBuild) setBuildId(null);
setWaiting(null);
diff --git a/src/components/marketing/click-to-ad.tsx b/src/components/marketing/click-to-ad.tsx
index 7dc3ef64..9f3d4719 100644
--- a/src/components/marketing/click-to-ad.tsx
+++ b/src/components/marketing/click-to-ad.tsx
@@ -16,7 +16,7 @@ import { StarterSection } from "@/components/starters/starter-section";
import { useCoverPlayback } from "@/components/template-cover";
import type { SlotValue } from "@/components/studio/media-slot";
import { uploadFile, useLikelyVisitor } from "@/lib/api";
-import { AD_STYLES, END_CARD, KIT_LABELS, type AdStyle, type BrandKit, type MarketingRun, type Product, type RunEstimate } from "@/lib/catalog/marketing";
+import { AD_STYLES, END_CARD, KIT_LABELS, UGC_MODELS, type AdStyle, type BrandKit, type MarketingRun, type Product, type RunEstimate } from "@/lib/catalog/marketing";
import { RunPlaceChip, useRunPlace } from "@/components/studio/run-place-chip";
import { IN_BROWSER, mainModel } from "@/lib/run-place";
import type { StarterCardData } from "@/lib/starters/types";
@@ -284,7 +284,9 @@ export function ClickToAd({ models, starters = [] }: { models: Record<string, Mo
: est.data?.blocker;
// Where the video is made and its price (the studios' words); a guest or an account is told it isn't available here.
const priced = est.data && !est.data.blocker ? est.data : undefined;
- const place = useRunPlace({ engine, models: priced?.steps.map((s) => s.modelName), model: mainModel(priced?.steps), costUsd: priced?.costUsd, demo: priced?.demo, ownerOnly: "Click to Ad" });
+ // Before the run is priced (no product yet, or a key to add), the chip names the clip's model, never a bare "Cloud".
+ const clipModel = models[withPresenter ? UGC_MODELS[engine].talk : UGC_MODELS[engine].clip]?.name;
+ const place = useRunPlace({ engine, models: priced?.steps.map((s) => s.modelName), model: mainModel(priced?.steps) ?? clipModel, costUsd: priced?.costUsd, demo: priced?.demo, ownerOnly: "Click to Ad" });
const writeScript = async () => {
if (!productId) return;
diff --git a/src/components/marketing/marketing-studio.tsx b/src/components/marketing/marketing-studio.tsx
index 0b7e7d0f..9836d8b2 100644
--- a/src/components/marketing/marketing-studio.tsx
+++ b/src/components/marketing/marketing-studio.tsx
@@ -581,7 +581,7 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri
{f.brandKit && <BrandChip value={brandId} onChange={pickBrand} />}
<SettingsPanel draft={draft} set={set} models={models} engine={engine} />
</div>
- <RunPlaceChip place={place} steps={priced?.steps} engine={engine} onEngine={setEngine} pending={est.isFetching && !est.data} className="max-sm:max-w-[11rem]" />
+ <RunPlaceChip place={place} steps={priced?.steps} engine={engine} onEngine={setEngine} pending={est.isFetching && !est.data} compact className="max-sm:shrink-0 sm:max-w-[16rem]" />
<Tooltip>
<TooltipTrigger asChild>
<button
diff --git a/src/components/studio/responsive-panel.tsx b/src/components/studio/responsive-panel.tsx
index 5dc089f7..bf69f55a 100644
--- a/src/components/studio/responsive-panel.tsx
+++ b/src/components/studio/responsive-panel.tsx
@@ -18,6 +18,7 @@ export function ResponsivePanel({
className,
sheetClassName,
align = "start",
+ focusSelf,
}: {
open: boolean;
onOpenChange: (o: boolean) => void;
@@ -29,9 +30,11 @@ export function ResponsivePanel({
className?: string;
sheetClassName?: string;
align?: "start" | "center" | "end";
+ /** Desktop too: the popover itself takes focus on open, not its first control (whose tooltip would cover the panel). */
+ focusSelf?: boolean;
}) {
const mobile = useIsMobile();
- // On phones the sheet itself takes focus, so the keyboard doesn't jump up over the list.
+ // On phones the sheet itself takes focus, so the keyboard doesn't jump up over the list (and the popover, with focusSelf).
const focusSheet = (e: Event) => {
e.preventDefault();
(e.currentTarget as HTMLElement | null)?.focus();
@@ -62,7 +65,7 @@ export function ResponsivePanel({
return (
<Popover open={open} onOpenChange={onOpenChange}>
{withTip(<PopoverTrigger asChild>{inner}</PopoverTrigger>)}
- <PopoverContent align={align} side="top" collisionPadding={12} aria-label={title} className={cn("max-h-[min(var(--radix-popover-content-available-height),640px)] w-[min(92vw,420px)] overflow-y-auto p-3", className)}>
+ <PopoverContent align={align} side="top" collisionPadding={12} aria-label={title} onOpenAutoFocus={focusSelf ? focusSheet : undefined} className={cn("max-h-[min(var(--radix-popover-content-available-height),640px)] w-[min(92vw,420px)] overflow-y-auto p-3", focusSelf && "outline-none", className)}>
{children}
</PopoverContent>
</Popover>
diff --git a/src/components/studio/run-place-chip.tsx b/src/components/studio/run-place-chip.tsx
index 4e4106ed..a89951b8 100644
--- a/src/components/studio/run-place-chip.tsx
+++ b/src/components/studio/run-place-chip.tsx
@@ -11,7 +11,7 @@ import type { Engine, GenerationRequest } from "@/lib/catalog/types";
import { CONNECT_GPU_EVENT, signInHref, useHydrated, useStatus, useViewer } from "@/lib/api";
import { formatCost } from "@/lib/format";
import { quoteBody, useHostedQuote, useSettled } from "@/lib/hosted";
-import { runPlace, type RunAudience, type RunPlace, type RunPlaceInput } from "@/lib/run-place";
+import { checkedPool, runPlace, type RunAudience, type RunPlace, type RunPlaceInput } from "@/lib/run-place";
import { cn } from "@/lib/utils";
import { chipBase, chipIdle } from "./chip";
import { EngineSwitch } from "./engine-switch";
@@ -42,18 +42,20 @@ export function useRunPlace(input: Omit<RunPlaceInput, "audience" | "format" | "
/**
* The place and price of an open-model run sent through the studios' generations (an app's own tool): your GPU, free;
- * with hosted runs on, an account with no GPU of its own runs on this studio's GPUs at the price the server quotes for
- * `request` (null: not quoted yet). `count`: runs one press starts (the quote is for one, said "each"). `ownGpuOnly`: a
- * tool that asks an account to connect its GPU instead (Relight), so it is never sent to this studio's GPUs.
+ * with hosted runs on, a guest or an account with no GPU of its own runs on this studio's GPUs once the server's price
+ * check for `request` says the run goes there, at its price (null: nothing to check yet, said as your GPU). `count`: runs
+ * one press starts (the quote is for one, said "each"). `ownGpuOnly`: a tool that asks an account to connect its GPU
+ * instead (Relight, Any Angle), so it is never sent to this studio's GPUs.
*/
export function useOpenRunPlace(models: readonly string[], request: GenerationRequest | null, o: { count?: number; ownGpuOnly?: boolean } = {}): RunPlace | null {
const viewer = useRunViewer();
- const who = viewer && o.ownGpuOnly ? { ...viewer, hosted: false } : viewer;
- const onPool = !!who && who.audience === "account" && who.hosted && !who.gpu;
- const quote = useHostedQuote(useSettled(onPool ? quoteBody(request, "pool") : null)).data?.quote;
- if (!who) return null;
- const pool = quote ? { text: (o.count ?? 1) > 1 && quote.text ? `${quote.text} each` : quote.text, sub: quote.sub } : undefined;
- return runPlace({ engine: "open", models, ...who, pool, format: formatCost });
+ const mayPool = !!viewer && !o.ownGpuOnly && viewer.audience !== "owner" && viewer.hosted && !viewer.gpu;
+ const checked = useHostedQuote(useSettled(mayPool ? quoteBody(request, "pool") : null)).data;
+ if (!viewer) return null;
+ // This studio's GPUs only on the server's word (as the studio composer asks it): a model it doesn't offer there, or
+ // no complete run to check yet, is your GPU (connect it, or sign up).
+ const pool = mayPool ? checkedPool(checked, o.count) : undefined;
+ return runPlace({ engine: "open", models, ...viewer, hosted: !!pool, pool, format: formatCost });
}
/**
@@ -67,6 +69,7 @@ export function RunPlaceChip({
engine,
onEngine,
pending,
+ compact,
className,
}: {
place: RunPlace | null;
@@ -77,6 +80,8 @@ export function RunPlaceChip({
onEngine?: (e: Engine) => void;
/** The price is being worked out. */
pending?: boolean;
+ /** On phones, the icon and the price only (the icon alone when there is no price); the panel says the rest. */
+ compact?: boolean;
className?: string;
}) {
const [open, setOpen] = useState(false);
@@ -88,6 +93,8 @@ export function RunPlaceChip({
const price = pending && !place.price ? "…" : place.price;
const canSwitch = !!(engine && onEngine && (place.where === "cloud" || place.where === "gpu" || place.where === "pool"));
const many = (steps?.length ?? 0) > 1;
+ // A compact chip on a phone: the label goes (the price stays), so the composer's other controls keep their room.
+ const iconOnly = compact && !price;
return (
<ResponsivePanel
open={open}
@@ -95,18 +102,20 @@ export function RunPlaceChip({
title={place.title}
description={place.tip}
align="end"
+ focusSelf
trigger={
<button
type="button"
data-run-place={place.where}
- aria-label={`${place.title}${place.where === "cloud" ? ` on ${place.label}` : ""}${place.price ? `, ${place.price}` : ""}. ${canSwitch ? "Details and engine" : "Details"}`}
- className={cn(chipBase, chipIdle, "max-w-full min-w-0", className)}
+ aria-label={`${place.title}${place.model ? ` on ${place.model}` : ""}${place.price ? `, ${place.price}` : ""}. ${canSwitch ? "Details and engine" : "Details"}`}
+ title={compact ? [place.label, place.price].filter(Boolean).join(" · ") : undefined}
+ className={cn(chipBase, chipIdle, "max-w-full min-w-0", iconOnly && "max-sm:px-2.5", className)}
>
<Icon className="size-3.5 shrink-0" />
- <span className="min-w-0 truncate max-sm:max-w-[9rem]">{place.label}</span>
+ <span className={cn("min-w-0 truncate max-sm:max-w-[9rem]", compact && "max-sm:hidden")}>{place.label}</span>
{price && (
<>
- <span aria-hidden className="opacity-50">
+ <span aria-hidden className={cn("opacity-50", compact && "max-sm:hidden")}>
·
</span>
<span className="shrink-0 tabular-nums">{price}</span>
diff --git a/src/lib/run-place.ts b/src/lib/run-place.ts
index ce8281e8..1bffab85 100644
--- a/src/lib/run-place.ts
+++ b/src/lib/run-place.ts
@@ -53,6 +53,8 @@ export interface RunPlace {
send: string;
/** What this viewer does before the run can start: create an account, connect a GPU, or add a key. */
needs?: "signup" | "gpu" | "key";
+ /** The cloud model the chip names, when known (the label is "Cloud" without one). */
+ model?: string;
}
const list = (names: readonly string[]) => (names.length < 2 ? (names[0] ?? "") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`);
@@ -150,8 +152,10 @@ export function runPlace(input: RunPlaceInput): RunPlace {
price,
title: "Runs in the cloud",
tip,
- send: input.demo ? price : [price, who].filter(Boolean).join(" · "),
+ // Not priced yet: the button says what this viewer does first, else nothing (never a bare "cloud").
+ send: input.demo ? price : price ? `${price} · ${who}` : needs ? who : "",
...(needs && { needs }),
+ ...(model && { model }),
};
}
@@ -167,3 +171,15 @@ export function mainModel(steps: readonly { modelName: string; costUsd: number |
/** Drawn in this browser (a Kinetic template, Click to Ad's end card): the same place and price whoever looks. */
export const IN_BROWSER: RunPlace = runPlace({ audience: "guest", engine: "browser", format: String });
+
+/**
+ * The price check's answer for a run on this studio's GPUs (`?preview=1` with `place: "pool"`), as the chip's `pool`:
+ * only when the server says the run goes there (`place: "pool"` with a quote). Undefined otherwise (not checked yet, a
+ * model the studio doesn't offer there, its own GPU or key): the chip then says your GPU, never this studio's.
+ * `count`: runs one press starts (the quote is for one, said "each").
+ */
+export function checkedPool(check: { place?: "pool"; quote?: { text: string; sub?: string } } | null | undefined, count = 1): { text: string; sub?: string } | undefined {
+ if (check?.place !== "pool" || !check.quote) return undefined;
+ const { text, sub } = check.quote;
+ return { text: count > 1 && text ? `${text} each` : text, ...(sub && { sub }) };
+}
diff --git a/tests/e2e/where-it-runs.mjs b/tests/e2e/where-it-runs.mjs
index e29ee779..5e79a713 100644
--- a/tests/e2e/where-it-runs.mjs
+++ b/tests/e2e/where-it-runs.mjs
@@ -161,9 +161,22 @@ try {
if (who === "owner") {
check(chip.where === "gpu" || chip.where === "cloud", `${tag}: on your GPU or in the cloud (${chip.where}: "${chip.text}")`);
check(chip.where !== "gpu" || /Your GPU/.test(chip.text), `${tag}: the GPU chip says Your GPU`);
+ // A cloud chip names its model (never a bare "Cloud"), and the screen reader never hears "on Cloud".
+ check(chip.where !== "cloud" || !/^Cloud\b/.test(chip.text), `${tag}: the cloud chip names its model ("${chip.text}")`);
+ check(!/on Cloud\b/.test(chip.aria), `${tag}: the chip's label names no bare cloud ("${chip.aria}")`);
+ if (size === "390" && id === "marketing") {
+ // A phone's Marketing chip is its icon and price: the format chip keeps its room.
+ const label = chip.el.locator("span").first();
+ check(!(await label.isVisible().catch(() => true)), `${tag}: the phone chip leaves its label to the panel`);
+ }
await chip.el.click();
const panel = page.getByText(chip.where === "gpu" ? "Runs on your GPU" : "Runs in the cloud").first();
check(await panel.isVisible({ timeout: 10_000 }).catch(() => false), `${tag}: the chip opens where it runs`);
+ if (size === "1440") {
+ await page.waitForTimeout(900);
+ // The popover takes focus itself: no control's tooltip covers its words.
+ check(!(await page.locator('[role="tooltip"]').first().isVisible().catch(() => false)), `${tag}: no tooltip covers the panel`);
+ }
await page.screenshot({ path: path.join(shots, `${who}-${size}-${id}-panel.png`) });
const sw = page.getByRole("radiogroup").or(page.locator('[role="dialog"] button, [data-radix-popper-content-wrapper] button').filter({ hasText: /Cloud|Open source/ }));
check((await sw.count()) > 0, `${tag}: the engine switch is in the panel`);
diff --git a/tests/run-place.test.ts b/tests/run-place.test.ts
index a1ee94e7..dd11e72e 100644
--- a/tests/run-place.test.ts
+++ b/tests/run-place.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { IN_BROWSER, mainModel, placePrice, runPlace, type RunPlaceInput } from "@/lib/run-place";
+import { checkedPool, IN_BROWSER, mainModel, placePrice, runPlace, type RunPlaceInput } from "@/lib/run-place";
/** Where a run happens and what it costs, for each audience and engine (the composers' place chip and send button). */
const fmt = (usd: number) => `$${usd.toFixed(2)}`;
@@ -35,7 +35,12 @@ describe("the owner", () => {
expect(p.tip).toBe("Runs in the cloud with GPT-5 mini and Nano Banana Pro. Estimated cost, billed by the provider to your key.");
});
it("names the cloud before the run is priced, and the first model when no main one is given", () => {
- expect(at({ audience: "owner", engine: "cloud" })).toMatchObject({ label: "Cloud", price: "", send: "cloud" });
+ // Not priced and no model known: "Cloud" on the chip, nothing after the button's name, no model for the screen reader.
+ const bare = at({ audience: "owner", engine: "cloud" });
+ expect(bare).toMatchObject({ label: "Cloud", price: "", send: "" });
+ expect(bare.model).toBeUndefined();
+ expect(at({ audience: "owner", engine: "cloud", model: "Seedance 2.5" })).toMatchObject({ label: "Seedance 2.5", model: "Seedance 2.5", send: "" });
+ expect(at({ audience: "account", engine: "cloud", model: "Seedance 2.5" })).toMatchObject({ needs: "key", send: "add your key" });
expect(at({ audience: "owner", engine: "cloud", models: ["Kling 2.5"] }).label).toBe("Kling 2.5");
});
it("says placeholder results are free stand-ins", () => {
@@ -179,3 +184,22 @@ describe("the main model of a pipeline", () => {
expect(mainModel(undefined)).toBeUndefined();
});
});
+
+describe("checkedPool", () => {
+ it("is this studio's GPUs only when the price check says the run goes there", () => {
+ expect(checkedPool({ place: "pool", quote: { text: "$0.02", sub: "Billed to your balance" } })).toEqual({ text: "$0.02", sub: "Billed to your balance" });
+ expect(checkedPool({ place: "pool", quote: { text: "$0.02" } }, 3)).toEqual({ text: "$0.02 each" });
+ expect(checkedPool({ place: "pool", quote: { text: "" } }, 3)).toEqual({ text: "" });
+ });
+ it("is nothing before the check, for a model not offered there, or for a run on the viewer's own GPU or key", () => {
+ expect(checkedPool(undefined)).toBeUndefined();
+ expect(checkedPool(null)).toBeUndefined();
+ expect(checkedPool({})).toBeUndefined();
+ expect(checkedPool({ place: "pool" })).toBeUndefined();
+ });
+ it("leaves an account with no GPU on your GPU (connect it) when the check finds no place there", () => {
+ const pool = checkedPool({});
+ const p = runPlace({ audience: "account", engine: "open", hosted: !!pool, gpu: false, pool, format: (n) => `$${n.toFixed(2)}` });
+ expect(p).toMatchObject({ where: "gpu", label: "Your GPU", needs: "gpu" });
+ });
+});