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.

Models & licences: studios with their own model menus leave switched-off models out

Claude5c05921a2304
diff --git a/src/components/ads/multiplier.tsx b/src/components/ads/multiplier.tsx
index 0abf2437..cf377bb8 100644
--- a/src/components/ads/multiplier.tsx
+++ b/src/components/ads/multiplier.tsx
@@ -15,6 +15,8 @@ import { VideoTrimmer } from "@/components/studio/video-trimmer";
import { initialClip, mentionedImages, MULTIPLIER, MULTIPLIER_MODELS, multiplierResolution, type ClipRange as Range, type MarketingRun, type RunEstimate } from "@/lib/catalog/marketing";
import { formatCost } from "@/lib/format";
import { probeBlob, probeUrl } from "@/lib/media-probe";
+import { useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { addRuns, send, useEstimate, useStatusFlags } from "@/components/marketing/hooks";
import type { ModelInfo } from "@/components/marketing/model-info";
@@ -172,6 +174,7 @@ function MentionImages({ value, onChange, onMention, max }: { value: string[]; o
export function AdMultiplier({ models }: { models: Record<string, ModelInfo> }) {
const qc = useQueryClient();
const { engine, setEngine } = useMarketingEngine();
+ const access = useModelAccess();
const { higgsfield } = useStatusFlags();
const [video, setVideo] = useState<SlotValue | null>(null);
const [duration, setDuration] = useState<number | null>(null);
@@ -190,8 +193,9 @@ export function AdMultiplier({ models }: { models: Record<string, ModelInfo> })
const resultsRef = useRef<HTMLDivElement>(null);
const sections = hookOn || ctaOn;
- const choices = MULTIPLIER_MODELS[engine];
- const fallback = engine === "cloud" && !higgsfield ? "kling-o3" : choices[0].id;
+ // Models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
+ const choices = useMemo(() => keepOffered(MULTIPLIER_MODELS[engine], (c) => offered(access, c.id, engine)), [access, engine]);
+ const fallback = engine === "cloud" && !higgsfield && choices.some((c) => c.id === "kling-o3") ? "kling-o3" : choices[0].id;
const modelId = picked && choices.some((c) => c.id === picked) ? picked : fallback;
const model = models[modelId];
const maxImages = engine === "open" ? 1 : (model?.maxImages ?? 0);
diff --git a/src/components/dub/dub-studio.tsx b/src/components/dub/dub-studio.tsx
index c8406267..7e167f07 100644
--- a/src/components/dub/dub-studio.tsx
+++ b/src/components/dub/dub-studio.tsx
@@ -15,7 +15,8 @@ import { SourceLanguageSelect, TargetLanguages } from "@/components/av/language-
import { MediaDrop } from "@/components/av/media-drop";
import { StepList, type StepRow } from "@/components/av/step-list";
import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";
-import { useEngine } from "@/lib/api";
+import { useEngine, useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import { cueProblems } from "@/lib/av/cue-edit";
import { BACKGROUND_DB, crowdedLines, dubResult, languageStage, ONE_SHOT_MODELS, priceLine, reviewCues, takeLines, translateKey, voiceOnly, type DubPrice, type DubSessionView, type DubStage, type OneShotModel } from "@/lib/av/dub";
import { languageByCode, supportsTarget, type DubRoute } from "@/lib/av/languages";
@@ -93,7 +94,11 @@ function NewDub({ onStarted }: { onStarted: (id: string) => void }) {
const [video, setVideo] = useState<SlotValue | null>(null);
const [duration, setDuration] = useState<number | undefined>(undefined);
const [mode, setMode] = useState<"steps" | "oneshot">("steps");
- const [model, setModel] = useState<OneShotModel>("heygen-translate");
+ const [picked, setModel] = useState<OneShotModel>("heygen-translate");
+ // One-shot dubbing models switched off in Settings → Models & licences leave the menu; the pick falls back to one that is on.
+ const access = useModelAccess();
+ const oneShotModels = keepOffered(ONE_SHOT_MODELS, (m) => offered(access, m, "cloud"));
+ const model: OneShotModel = oneShotModels.includes(picked) ? picked : oneShotModels[0];
const [source, setSource] = useState("auto");
const [targets, setTargets] = useState<string[]>(["es"]);
const oneShot = mode === "oneshot" && engine === "cloud";
@@ -158,7 +163,7 @@ function NewDub({ onStarted }: { onStarted: (id: string) => void }) {
<SelectValue />
</SelectTrigger>
<SelectContent>
- {ONE_SHOT_MODELS.map((m) => (
+ {oneShotModels.map((m) => (
<SelectItem key={m} value={m}>
{ONE_SHOT[m].name}
</SelectItem>
diff --git a/src/components/faceless/settings-form.tsx b/src/components/faceless/settings-form.tsx
index 25d9b872..c436e155 100644
--- a/src/components/faceless/settings-form.tsx
+++ b/src/components/faceless/settings-form.tsx
@@ -6,7 +6,8 @@ import { useEffect, useState } from "react";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
import { fileToList, SlotPreview, type SlotValue } from "@/components/studio/media-slot";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
-import { useElements } from "@/lib/api";
+import { useElements, useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import {
ANIMATION_MODES,
DEFAULT_RESOLUTION,
@@ -130,7 +131,14 @@ export function EpisodeSettingsForm({
// Frame by frame moves a camera over each picture (Ken Burns, no video model); Fully animated picks a video model.
const frames = value.animation === "frames";
const camera = picker.cameraMoves?.[value.engine];
- const videos = frames ? [] : picker.videoModels.filter((m) => m.engine === value.engine);
+ // Video models switched off in Settings → Models & licences leave the list; the default falls back to one that is on.
+ const access = useModelAccess();
+ const videos = frames ? [] : keepOffered(picker.videoModels.filter((m) => m.engine === value.engine), (m) => offered(access, m.id, value.engine));
+ // A video model picked before it was switched off counts as no pick (the next one that is on runs).
+ const offPick = !!value.videoModel && videos.length > 0 && !videos.some((m) => m.id === value.videoModel);
+ useEffect(() => {
+ if (offPick) onChange({ videoModel: undefined, resolution: undefined });
+ }, [offPick, onChange]);
const video = frames ? (camera && { ...camera, engine: value.engine }) : (videos.find((m) => m.id === value.videoModel) ?? videos.find((m) => m.id === ENGINE_MODELS[value.engine].video) ?? videos[0]);
const resolution = value.resolution && video?.resolutions.includes(value.resolution) ? value.resolution : (DEFAULT_RESOLUTION[video?.id ?? ""]?.[value.animation] ?? video?.resolutions[0]);
return (
diff --git a/src/components/fashion/fashion-view.tsx b/src/components/fashion/fashion-view.tsx
index 452d0476..154fbf7b 100644
--- a/src/components/fashion/fashion-view.tsx
+++ b/src/components/fashion/fashion-view.tsx
@@ -14,7 +14,8 @@ import { useRun, useRunPreview } from "@/components/photodump/hooks";
import { RunLine, Steps } from "@/components/photodump/steps";
import { CharacterPicker } from "@/components/photodump/subject";
import { UploadBox } from "@/components/photodump/upload-box";
-import { useEngine, useGenerations } from "@/lib/api";
+import { useEngine, useGenerations, useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import { FASHION, FASHION_START, FASHION_STEPS, fashionBlocker, fashionReducer, getTemplate, type FashionState } from "@/lib/catalog/packs";
import type { Generation } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
@@ -63,7 +64,11 @@ export function FashionView() {
const [s, dispatch] = useStoredReducer<FashionState, Parameters<typeof fashionReducer>[1]>("fuobe.fashion", fashionReducer, FASHION_START);
const [engine, setEngine] = useEngine();
const [garment, setGarment] = useState<SlotValue | null>(null);
- const [outfitModel, setOutfitModel] = useState<string>("fashn-tryon");
+ const [pickedOutfit, setOutfitModel] = useState<string>("fashn-tryon");
+ // Outfit models switched off in Settings → Models & licences leave the choice; the pick falls back to one that is on.
+ const access = useModelAccess();
+ const outfitModels = keepOffered(OUTFIT_MODELS, ([id]) => offered(access, id, "cloud"));
+ const outfitModel = outfitModels.some(([id]) => id === pickedOutfit) ? pickedOutfit : outfitModels[0][0];
const [bannerSeen, hideBanner] = useBannerSeen();
const { data } = useGenerations({ features: ["fashion"], limit: 200 });
const base = useRun<Record<string, unknown>>("/api/photodump/fashion");
@@ -238,7 +243,7 @@ export function FashionView() {
</div>
{engine === "cloud" && (
<div role="radiogroup" aria-label="Outfit model" onKeyDown={radioKeys} className="flex flex-wrap gap-1">
- {OUTFIT_MODELS.map(([id, label]) => (
+ {outfitModels.map(([id, label]) => (
<button key={id} role="radio" aria-checked={outfitModel === id} tabIndex={radioTab(outfitModel === id)} onClick={() => setOutfitModel(id)} className={cn("h-8 rounded-full border px-2.5 text-[12.5px] font-medium transition-colors", outfitModel === id ? "border-primary bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}>
{label}
</button>
diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsx
index 29e73fff..1ba05df8 100644
--- a/src/components/genjutsu/genjutsu-studio.tsx
+++ b/src/components/genjutsu/genjutsu-studio.tsx
@@ -21,7 +21,7 @@ import { fileToList, MediaSlot, type SlotValue } from "@/components/studio/media
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { SketchEditor, type Stroke } from "@/components/studio/sketch-editor";
import { VideoTrimmer, type TrimRange, type VideoTrimmerHandle } from "@/components/studio/video-trimmer";
-import { useEngine, useGenerations, useStatus } from "@/lib/api";
+import { useEngine, useGenerations, useModelAccess, useStatus } from "@/lib/api";
import {
chooseMaker,
decodeSetup,
@@ -45,6 +45,7 @@ import {
import { chainState } from "@/lib/catalog/shorts";
import type { PixelPoint } from "@/lib/catalog/types";
import { downloadHref, downloadName } from "@/lib/library";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { useGenjutsuEstimate, useGenjutsuRun, type GenjutsuBody } from "./hooks";
import { LookPicker, type LookSource } from "./look-picker";
@@ -81,6 +82,7 @@ const ready = (xs: SlotValue[]) => xs.filter((x) => !x.uploading).map((x) => x.r
*/
export function GenjutsuStudio() {
const [engine, setEngine, engineMode] = useEngine();
+ const access = useModelAccess();
const status = useStatus().data;
const higgsfield = !!status?.providers.higgsfield?.configured;
const [mode, setModeState] = useState<GenjutsuMode>("motion");
@@ -139,9 +141,11 @@ export function GenjutsuStudio() {
: undefined;
const lookKind = mode === "restyle" ? (lookSource === "higgsfield" ? "higgsfield" : "fuobe") : "";
const choiceKey = `${engine}:${mode}:${target ?? ""}:${lookKind}`;
- const choice = chooseMaker({ engine, mode, target, tier, look: effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined), modelId: picked[choiceKey], higgsfield });
+ // Models switched off in Settings → Models & licences leave the list, and the pick falls back to one that is on.
+ const isOn = (id: string) => offered(access, id, engine);
+ const choice = chooseMaker({ engine, mode, target, tier, look: effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined), modelId: picked[choiceKey], higgsfield, offered: isOn });
const maker: Maker | null = "maker" in choice ? choice.maker : null;
- const options = makersFor(engine, mode, target, effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined));
+ const options = keepOffered(makersFor(engine, mode, target, effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined)), (m) => isOn(m.id));
const references = mode === "restyle" && lookSource !== "higgsfield" ? [] : ready(refs);
const showRefs = mode !== "restyle" || lookSource === "higgsfield";
const needsFrame = (mode === "swap" && (target === "click" || target === "paint")) || (mode === "insert" && target === "paint");
diff --git a/src/components/influencer/influencer-builder.tsx b/src/components/influencer/influencer-builder.tsx
index b71b8110..52d47e0b 100644
--- a/src/components/influencer/influencer-builder.tsx
+++ b/src/components/influencer/influencer-builder.tsx
@@ -15,7 +15,8 @@ import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
-import { useEngine, useGenerations } from "@/lib/api";
+import { useEngine, useGenerations, useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import {
categoriesFor,
CREATURE_TYPES,
@@ -123,10 +124,14 @@ export function InfluencerBuilder() {
const [photo, setPhoto] = useState<SlotValue | null>(null);
const [clothing, setClothing] = useState<SlotValue[]>([]);
const [direction, setDirection] = useState("");
- const [modelId, setModelId] = useState(CLOUD_MODELS[0].id);
+ const [picked, setModelId] = useState(CLOUD_MODELS[0].id);
const [ids, setIds] = useState<string[]>([]);
const clothingInput = useRef<HTMLInputElement>(null);
- const model = CLOUD_MODELS.find((m) => m.id === modelId) ?? CLOUD_MODELS[0];
+ // Models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
+ const access = useModelAccess();
+ const cloudModels = useMemo(() => keepOffered(CLOUD_MODELS, (m) => offered(access, m.id, "cloud")), [access]);
+ const model = cloudModels.find((m) => m.id === picked) ?? cloudModels[0];
+ const modelId = model.id;
const categories = useMemo(() => categoriesFor(state.tier), [state.tier]);
const category = categories.find((c) => c.id === active);
@@ -376,7 +381,7 @@ export function InfluencerBuilder() {
<SelectValue />
</SelectTrigger>
<SelectContent>
- {CLOUD_MODELS.map((m) => (
+ {cloudModels.map((m) => (
<SelectItem key={m.id} value={m.id}>
{m.label}
</SelectItem>
diff --git a/src/components/katana/katana-studio.tsx b/src/components/katana/katana-studio.tsx
index b485a203..f226c828 100644
--- a/src/components/katana/katana-studio.tsx
+++ b/src/components/katana/katana-studio.tsx
@@ -18,9 +18,10 @@ import { frameDiff, openVideo, releaseVideo, sampleFrames } from "@/components/a
import { MediaDrop } from "@/components/av/media-drop";
import { StepList, type StepRow } from "@/components/av/step-list";
import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";
-import { useEngine } from "@/lib/api";
+import { useEngine, useModelAccess } from "@/lib/api";
import { formatCueTime } from "@/lib/av/cue-edit";
import { detectCutIndices, KATANA_LIMITS, katanaProgress, katanaStage, motionModel, MOTION_MODELS, nearestAspect, planSegments, refineCut, refineTimes, type KatanaJobView, type Segment } from "@/lib/av/katana";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { useKatanaActions, useKatanaJobs, useKatanaPreview, type KatanaBody } from "./hooks";
@@ -71,7 +72,10 @@ export function KatanaStudio() {
const [scanning, setScanning] = useState<number | null>(null);
const [modelId, setModelId] = useState<string | undefined>(undefined);
const [keepAudio, setKeepAudio] = useState(true);
- const m = motionModel(engine, modelId);
+ // Motion models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
+ const access = useModelAccess();
+ const motionModels = keepOffered(MOTION_MODELS[engine], (x) => offered(access, x.id, engine));
+ const m = motionModel(engine, modelId && motionModels.some((x) => x.id === modelId) ? modelId : motionModels[0].id);
const len = Math.min(m.max, Math.max(m.min, length ?? m.max));
const segments = useMemo<Segment[] | null>(() => {
@@ -253,7 +257,7 @@ export function KatanaStudio() {
<SelectValue />
</SelectTrigger>
<SelectContent>
- {MOTION_MODELS[engine].map((x) => (
+ {motionModels.map((x) => (
<SelectItem key={x.id} value={x.id}>
{x.label} · {x.min}–{x.max} s
</SelectItem>
diff --git a/src/components/layers/editor-context.tsx b/src/components/layers/editor-context.tsx
index dee4ca4a..4a6bc5ce 100644
--- a/src/components/layers/editor-context.tsx
+++ b/src/components/layers/editor-context.tsx
@@ -45,6 +45,11 @@ export interface EditorCtx {
select: (id: string | null) => void;
engine: Engine;
models: Record<string, LayerModelInfo>;
+ /**
+ * A tool's model ids as Settings → Models & licences offers them: the ones switched off leave its menu and its
+ * default (all of them stay when none is on, and a run names the switch).
+ */
+ offeredIds: (ids: readonly string[]) => string[];
isDemo: (m: LayerModelInfo | undefined) => boolean;
jobs: LayerJob[];
/** The job still working on a layer (queued, running, or finished but not laid out yet). */
diff --git a/src/components/layers/layers-editor.tsx b/src/components/layers/layers-editor.tsx
index 8faec3d3..eeef8a28 100644
--- a/src/components/layers/layers-editor.tsx
+++ b/src/components/layers/layers-editor.tsx
@@ -9,7 +9,8 @@ import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { CompareSlider } from "@/components/studio/compare-slider";
import { useIsMobile } from "@/hooks/use-mobile";
-import { useEngine, useStatus } from "@/lib/api";
+import { useEngine, useModelAccess, useStatus } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import {
APPLIES_TO_DOC,
decomposeCost,
@@ -574,6 +575,8 @@ function Editor({ view, refetch, models }: { view: LayerProjectView; refetch: ()
};
}, [compare, doc]);
+ const access = useModelAccess();
+ const offeredIds = useCallback((ids: readonly string[]) => keepOffered(ids, (x) => offered(access, x, engine)), [access, engine]);
const isDemo = useCallback(
(m: LayerModelInfo | undefined) => {
if (!m || !status) return false;
@@ -608,6 +611,7 @@ function Editor({ view, refetch, models }: { view: LayerProjectView; refetch: ()
select,
engine,
models,
+ offeredIds,
isDemo,
jobs: view.jobs,
busyJob,
@@ -637,7 +641,7 @@ function Editor({ view, refetch, models }: { view: LayerProjectView; refetch: ()
};
if (isMobile) {
- const modelId = TOOL_MODELS.decompose[engine][0];
+ const modelId = offeredIds(TOOL_MODELS.decompose[engine])[0];
const model = models[modelId];
return (
<MobileView
diff --git a/src/components/layers/layers-panel.tsx b/src/components/layers/layers-panel.tsx
index f8c356de..57e3e8a0 100644
--- a/src/components/layers/layers-panel.tsx
+++ b/src/components/layers/layers-panel.tsx
@@ -109,14 +109,14 @@ async function layerFromImage(url: string, name: string, doc: { width: number; h
}
function AddLayer() {
- const { doc, commit, select, run, engine, models, isDemo } = useEditor();
+ const { doc, commit, select, run, engine, models, offeredIds, isDemo } = useEditor();
const file = useRef<HTMLInputElement>(null);
const [picking, setPicking] = useState(false);
const [generating, setGenerating] = useState(false);
const [prompt, setPrompt] = useState("");
const [ref, setRef] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
- const options = modelsFor(models, TOOL_MODELS["generate-layer"][engine]);
+ const options = modelsFor(models, offeredIds(TOOL_MODELS["generate-layer"][engine]));
const [modelId, setModelId] = useState<string | undefined>();
const model = options.find((m) => m.id === modelId) ?? options[0];
@@ -491,10 +491,10 @@ function LayerRow({
/** Per-layer AI: “Layer edit prompt” + reference → Generate / Regenerate, and the layer's revisions. */
function SelectedLayer({ node }: { node: LayerNode }) {
- const { doc, commit, run, engine, models, isDemo, endJob, busyJob, failedJob, showJob, tool } = useEditor();
+ const { doc, commit, run, engine, models, offeredIds, isDemo, endJob, busyJob, failedJob, showJob, tool } = useEditor();
const [prompt, setPrompt] = useState(node.prompt ?? "");
const [ref, setRef] = useState<string | null>(node.refSrc ?? null);
- const options = modelsFor(models, TOOL_MODELS.regenerate[engine]);
+ const options = modelsFor(models, offeredIds(TOOL_MODELS.regenerate[engine]));
const [modelId, setModelId] = useState<string | undefined>();
const model = options.find((m) => m.id === modelId) ?? options[0];
// Layers cut out of a picture keep their transparency; full pictures (the bottom layer, a whole-image result) don't.
diff --git a/src/components/layers/tools.tsx b/src/components/layers/tools.tsx
index b93f9da8..a7bfb5ea 100644
--- a/src/components/layers/tools.tsx
+++ b/src/components/layers/tools.tsx
@@ -125,8 +125,8 @@ function Scope({ node }: { node?: LayerNode }) {
}
function ModelSelect({ tool, ids, value, onChange, label = "Model" }: { tool: LayerTool; ids?: string[]; value?: string; onChange: (id: string) => void; label?: string }) {
- const { engine, models } = useEditor();
- const options = modelsFor(models, ids ?? TOOL_MODELS[tool][engine]);
+ const { engine, models, offeredIds } = useEditor();
+ const options = modelsFor(models, offeredIds(ids ?? TOOL_MODELS[tool][engine]));
if (options.length < 2) return options[0] ? <p className="text-[12px] text-muted-foreground">{label} · {options[0].name}</p> : null;
return (
<Field label={label}>
@@ -148,9 +148,9 @@ function ModelSelect({ tool, ids, value, onChange, label = "Model" }: { tool: La
/** The model the tool will run (picked, or the engine's default); `picked` is what the user chose, if anything. */
function useToolModel(tool: LayerTool, ids?: string[]) {
- const { engine, models } = useEditor();
+ const { engine, models, offeredIds } = useEditor();
const [picked, setPicked] = useState<string | undefined>();
- const options = ids ?? TOOL_MODELS[tool][engine];
+ const options = offeredIds(ids ?? TOOL_MODELS[tool][engine]);
const chosen = picked && options.includes(picked) ? picked : undefined;
const id = chosen ?? options[0];
return { modelId: id, model: id ? models[id] : undefined, setModelId: setPicked, picked: chosen };
diff --git a/src/components/marketing/marketing-studio.tsx b/src/components/marketing/marketing-studio.tsx
index 98d80808..7c42dcc3 100644
--- a/src/components/marketing/marketing-studio.tsx
+++ b/src/components/marketing/marketing-studio.tsx
@@ -13,6 +13,8 @@ import { BrandChip } from "@/components/brand/brand-dialog";
import { inputCls } from "@/components/brand/fields";
import { FORMATS, formatModels, looksLikeWebsite, MAX_PROMPT, openingAspect, TEMPLATE_INDEX, type FormatId, type MarketingCategory, type MarketingTemplate, type RunEstimate } from "@/lib/catalog/marketing";
import { formatCost } from "@/lib/format";
+import { useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { addRuns, send, useBrands, useEstimate, useStatusFlags } from "./hooks";
import type { MarketingRun } from "@/lib/catalog/marketing";
@@ -100,7 +102,9 @@ function withTemplate(d: Draft, t: MarketingTemplate | null, format?: FormatId):
function SettingsPanel({ draft, set, models, higgsfield, engine }: { draft: Draft; set: (p: Partial<Draft>) => void; models: Record<string, ModelInfo>; higgsfield: boolean; engine: "cloud" | "open" }) {
const [open, setOpen] = useState(false);
const f = FORMATS[draft.format];
- const choices = formatModels(f, engine, { product: !!draft.product, avatar: !!draft.avatar, higgsfield });
+ // Models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
+ const access = useModelAccess();
+ const choices = keepOffered(formatModels(f, engine, { product: !!draft.product, avatar: !!draft.avatar, higgsfield }), (c) => offered(access, c.id, engine));
const model = choices.find((c) => c.id === draft.modelId) ?? choices[0];
const summary = [draft.aspectRatio, f.durations && `${draft.duration}s`, draft.batch > 1 && `×${draft.batch}`].filter(Boolean).join(" · ");
const seg = (active: boolean) => cn("h-7 rounded-full px-2.5 text-[12px] font-medium text-muted-foreground", active && "bg-background text-foreground shadow-soft");
diff --git a/src/components/mixed-media/mixed-studio.tsx b/src/components/mixed-media/mixed-studio.tsx
index 5133d707..03df21b7 100644
--- a/src/components/mixed-media/mixed-studio.tsx
+++ b/src/components/mixed-media/mixed-studio.tsx
@@ -12,7 +12,8 @@ import { LookCard } from "@/components/shorts/preset-card";
import { useSubmitGuard } from "@/components/shorts/hooks";
import { ClipBar, ClipDrop, costText, Field, Segmented, tabKeys } from "@/components/shorts/ui";
import { clipDuration, useSourceClip } from "@/components/shorts/use-source-clip";
-import { uploadFile, useEngine } from "@/lib/api";
+import { uploadFile, useEngine, useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import {
clampFps,
defaultValues,
@@ -283,10 +284,12 @@ function Editor({
const [mode, setMode] = useState<MixedMode>("frames");
const cloud = engine === "cloud";
const frameMode = cloud && mode === "frames";
- const models = frameMode ? frameModels : restyleModels;
+ // Models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
+ const access = useModelAccess();
+ const models = keepOffered(frameMode ? frameModels : restyleModels, (m) => offered(access, m.id, engine));
const slot = frameMode ? "frames" : engine;
const [pickedModel, setModel] = useState<Record<Engine | "frames", string>>({ cloud: "", open: "", frames: "" });
- const modelId = pickedModel[slot] || models[0]?.id;
+ const modelId = (models.some((m) => m.id === pickedModel[slot]) && pickedModel[slot]) || models[0]?.id;
const model = models.find((m) => m.id === modelId);
const [previewId, setPreviewId] = useState<string | null>(null);
// Every main step of the latest render (cut → frames or restyle → sound), so a failed step shows its own error.
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index f445d3e0..36eb6781 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -15,7 +15,7 @@ import { FailedTile, PendingTile } from "@/components/studio/feed";
import { MediaSlot, type SlotValue } from "@/components/studio/media-slot";
import { MediaDrop } from "@/components/av/media-drop";
import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";
-import { useCreateGeneration, useEngine, useGenerations } from "@/lib/api";
+import { useCreateGeneration, useEngine, useGenerations, useModelAccess } from "@/lib/api";
import {
MAX_3D_PROMPT,
MODEL3D_FEATURE,
@@ -34,6 +34,7 @@ import {
type ViewSide,
} from "@/lib/av/model3d";
import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { priceLine, useRunPreview } from "./hooks";
import { ModelCard } from "./model-card";
@@ -122,6 +123,7 @@ function ModePicker({ mode, onChange }: { mode: Model3dMode; onChange: (m: Model
/** Image to 3D: a photo, several photos, words, an object in a photo or a splat → a model to spin, download, rig and animate. */
export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const [engine, setEngine, engineMode] = useEngine();
+ const access = useModelAccess();
const create = useCreateGeneration();
const results = useGenerations({ features: [MODEL3D_FEATURE, "app:app-image-to-3d"], limit: 24 });
const [mode, setMode] = useState<Model3dMode>("image");
@@ -140,8 +142,10 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
},
[setEngine],
);
- const choices = MODELS_3D[mode][engine];
- const modelId = model3dFor(mode, engine, picked[`${mode}:${engine}`]);
+ // Models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
+ const choices = keepOffered(MODELS_3D[mode][engine], (m) => offered(access, m.id, engine));
+ const wanted = picked[`${mode}:${engine}`];
+ const modelId = model3dFor(mode, engine, wanted && choices.some((m) => m.id === wanted) ? wanted : choices[0]?.id);
const sides = Object.fromEntries(VIEW_SIDES.flatMap((s) => (views[s] ? [[s, views[s]!.ref]] : []))) as Partial<Record<ViewSide, string>>;
const input: Model3dInput = { engine, mode, modelId: modelId ?? undefined, photo: photo?.ref, views: sides, prompt: mode === "text" ? text : mode === "objects" ? object : undefined };
const uploading = !!photo?.uploading || VIEW_SIDES.some((s) => views[s]?.uploading);
diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsx
index 1a28c497..1486243e 100644
--- a/src/components/photodump/photodump-view.tsx
+++ b/src/components/photodump/photodump-view.tsx
@@ -11,7 +11,8 @@ import { Input } from "@/components/ui/input";
import { EngineSwitch } from "@/components/studio/engine-switch";
import { fileToList, type SlotValue } from "@/components/studio/media-slot";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
-import { useElements, useEngine, useGenerations } from "@/lib/api";
+import { useElements, useEngine, useGenerations, useModelAccess } from "@/lib/api";
+import { keepOffered, offered } from "@/lib/model-access";
import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, type Pack } from "@/lib/catalog/packs";
import type { Generation } from "@/lib/catalog/types";
import { timeAgo } from "@/lib/format";
@@ -179,7 +180,9 @@ export function PhotodumpView() {
// The Model choice follows the engine: a pick the other engine had counts as Auto (one radio is always checked).
const elements = useElements();
const character = subjectMode === "character" ? elements.data?.find((e) => e.id === elementId) : undefined;
- const choices: (string | undefined)[] = [undefined, ...PHOTODUMP_MODELS[engine]];
+ // Models switched off in Settings → Models & licences leave the choices (Auto picks among the ones on).
+ const access = useModelAccess();
+ const choices: (string | undefined)[] = [undefined, ...keepOffered(PHOTODUMP_MODELS[engine], (m) => offered(access, m, engine))];
const unavailable = (m?: string): string | null => {
if (m !== "oss-z-image-turbo") return null;
if (pack?.custom) return "Your own packs recreate each reference photo with Qwen-Image-Edit";
diff --git a/src/components/remove-object/remove-object-tool.tsx b/src/components/remove-object/remove-object-tool.tsx
index 9cea1874..f1a66f39 100644
--- a/src/components/remove-object/remove-object-tool.tsx
+++ b/src/components/remove-object/remove-object-tool.tsx
@@ -17,7 +17,7 @@ import { Feed } from "@/components/studio/feed";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { SketchEditor, type Stroke } from "@/components/studio/sketch-editor";
import { VideoTrimmer, type TrimRange, type VideoTrimmerHandle } from "@/components/studio/video-trimmer";
-import { useEngine, useGenerations } from "@/lib/api";
+import { useEngine, useGenerations, useModelAccess } from "@/lib/api";
import {
CLICK_OPEN_PROBLEM,
chooseEraser,
@@ -31,6 +31,7 @@ import {
import { chainState } from "@/lib/catalog/shorts";
import type { Generation, PixelPoint } from "@/lib/catalog/types";
import { downloadHref, downloadName } from "@/lib/library";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { FrameStage, frameFromBlob, type Frame } from "./frame-stage";
import { useRemovalActions, useRemovalEstimate, type RemovalBody } from "./hooks";
@@ -69,6 +70,7 @@ interface Run {
*/
export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {
const [engine, setEngine, engineMode] = useEngine();
+ const access = useModelAccess();
const source = useSourceClip(REMOVE.maxBytes);
const clip = source.clip;
const trimmer = useRef<VideoTrimmerHandle>(null);
@@ -94,9 +96,14 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {
const duration = clipDuration(clip);
const size = clipSize(clip);
const choiceKey = `${engine}:${mode}`;
- const choice = chooseEraser({ engine, mode, effects: mode === "type" && effects, modelId: picked[choiceKey] });
+ // Erasers switched off in Settings → Models & licences leave the list, and the pick falls back to one that is on.
+ const isOn = (id: string) => offered(access, id, engine);
+ const choice = chooseEraser({ engine, mode, effects: mode === "type" && effects, modelId: picked[choiceKey], offered: isOn });
const eraser: Eraser | null = "eraser" in choice ? choice.eraser : null;
- const options = erasersFor(engine, mode).filter((e) => !e.effects);
+ const options = keepOffered(
+ erasersFor(engine, mode).filter((e) => !e.effects),
+ (e) => isOn(e.id),
+ );
const everyone = !!eraser?.everyone;
// The selection's first frame, grabbed by the browser: what points and paint are made on.
diff --git a/src/components/shorts/shorts-studio.tsx b/src/components/shorts/shorts-studio.tsx
index 216eebd6..0dc2c1be 100644
--- a/src/components/shorts/shorts-studio.tsx
+++ b/src/components/shorts/shorts-studio.tsx
@@ -8,7 +8,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { SidebarTrigger } from "@/components/ui/sidebar";
import { EngineSwitch } from "@/components/studio/engine-switch";
import { VideoTrimmer } from "@/components/studio/video-trimmer";
-import { useEngine } from "@/lib/api";
+import { useEngine, useModelAccess } from "@/lib/api";
import {
clipShapeProblem,
rangeProblem,
@@ -24,6 +24,7 @@ import {
import type { RestyleModelInfo } from "@/lib/catalog/shorts-models";
import type { Engine } from "@/lib/catalog/types";
import type { TrimRange } from "@/lib/trim-range";
+import { keepOffered, offered } from "@/lib/model-access";
import { cn } from "@/lib/utils";
import { CustomPresetDialog } from "./custom-preset-dialog";
import { useShortsActions, useShortsEstimate, useShortsPresets, useSubmitGuard, type ShortsBody } from "./hooks";
@@ -41,6 +42,9 @@ const CUSTOM = "Created by you";
export function ShortsStudio({ models }: { models: Record<Engine, ModelChoice[]> }) {
const [tab, setTab] = useState<"presets" | "history">("presets");
const [engine, setEngine] = useEngine();
+ // Restyle models switched off in Settings → Models & licences leave the menu (the default is the first one on).
+ const access = useModelAccess();
+ const engineModels = keepOffered(models[engine], (m) => offered(access, m.id, engine));
const [presetId, setPresetId] = useState<string | null>(null);
const source = useSourceClip(SHORTS.maxBytes);
const { clip } = source;
@@ -107,7 +111,7 @@ export function ShortsStudio({ models }: { models: Record<Engine, ModelChoice[]>
</div>
<Workspace
engine={engine}
- models={models[engine]}
+ models={engineModels}
presetId={presetId}
setPresetId={setPresetId}
source={source}
@@ -313,7 +317,9 @@ function SetupPanel({
// A custom preset is its reference images: on cloud, start on the first model that reads them
// (Kling O3 4K Edit, then Happy Horse) unless a model was picked.
const refModel = models.find((m) => m.refs > 0)?.id;
- const modelId = pickedModel[engine] || (customRefs > 0 && engine === "cloud" && refModel ? refModel : models[0]?.id);
+ // A pick that has since been switched off in Settings → Models & licences counts as no pick.
+ const pickedOn = models.some((m) => m.id === pickedModel[engine]) ? pickedModel[engine] : "";
+ const modelId = pickedOn || (customRefs > 0 && engine === "cloud" && refModel ? refModel : models[0]?.id);
const model = models.find((m) => m.id === modelId);
const duration = clipDuration(clip);
const actions = useShortsActions();
diff --git a/src/lib/catalog/genjutsu.ts b/src/lib/catalog/genjutsu.ts
index 45157ac0..aa6029d7 100644
--- a/src/lib/catalog/genjutsu.ts
+++ b/src/lib/catalog/genjutsu.ts
@@ -13,6 +13,7 @@
* the shareable setup code), shared by the page, the server (src/server/genjutsu.ts) and the tests.
* Research: docs/research/higgsfield-delta-4.md §4.2, paid-model-apis-4.md §4, comfyui-oss-4.md §c.
*/
+import { keepOffered } from "@/lib/model-access";
import {
joinWithSound,
MASK_TRACKER,
@@ -389,10 +390,17 @@ export function chooseMaker(o: {
modelId?: string;
/** A Higgsfield key is set. */
higgsfield: boolean;
+ /**
+ * Whether Settings → Models & licences offers a model: one switched off isn't picked while another is on (with
+ * all of them off the pick stays, and its run names the switch).
+ */
+ offered?: (id: string) => boolean;
}): { maker: Maker } | { problem: string } {
const target = MODE_TARGETS[o.mode].length ? (o.target ?? MODE_TARGETS[o.mode][0]) : undefined;
if (target && !MODE_TARGETS[o.mode].includes(target)) return { problem: `${getMode(o.mode).label} doesn't take ${target === "click" ? "clicks" : "that"} — pick another way` };
- const options = makersFor(o.engine, o.mode, target, o.look);
+ const on = o.offered;
+ const all = makersFor(o.engine, o.mode, target, o.look);
+ const options = on ? keepOffered(all, (m) => on(m.id)) : all;
if (!options.length) {
if (o.engine === "open" && o.mode === "restyle" && o.look?.kind === "higgsfield") return { problem: OPEN_LOOK_PROBLEM };
return { problem: (o.engine === "open" && OPEN_TARGET_PROBLEM[o.mode]) || "Nothing on this engine does that yet" };
diff --git a/src/lib/catalog/remove-object.ts b/src/lib/catalog/remove-object.ts
index bd104acd..86a8b05c 100644
--- a/src/lib/catalog/remove-object.ts
+++ b/src/lib/catalog/remove-object.ts
@@ -226,15 +226,22 @@ export function erasersFor(engine: Engine, mode: RemoveMode): Eraser[] {
return ERASERS.filter((e) => e.engine === engine && e.modes.includes(mode));
}
-/** The eraser a request runs on, or why there is none. */
-export function chooseEraser(o: { engine: Engine; mode: RemoveMode; effects?: boolean; modelId?: string }): { eraser: Eraser } | { problem: string } {
+/**
+ * The eraser a request runs on, or why there is none. `offered` (Settings → Models & licences) passes over an
+ * eraser switched off for the next one that does the job and is on; with none on, the default stays and its run
+ * names the switch.
+ */
+export function chooseEraser(o: { engine: Engine; mode: RemoveMode; effects?: boolean; modelId?: string; offered?: (id: string) => boolean }): { eraser: Eraser } | { problem: string } {
if (o.engine === "open" && o.mode === "click") return { problem: CLICK_OPEN_PROBLEM };
if (o.effects && o.mode !== "type") return { problem: "Shadows and reflections go too when you type what to remove — switch to Type it" };
+ const on = o.offered ?? (() => true);
+ const fits = (e: Eraser | undefined): e is Eraser => !!e && e.engine === o.engine && e.modes.includes(o.mode) && (!o.effects || !!e.effects);
const picked = getEraser(o.modelId);
- if (picked && picked.engine === o.engine && picked.modes.includes(o.mode) && (!o.effects || picked.effects)) return { eraser: picked };
+ if (fits(picked) && on(picked.id)) return { eraser: picked };
const id = DEFAULT_ERASER[o.engine][o.effects ? "effects" : o.mode];
const eraser = getEraser(id);
- return eraser ? { eraser } : { problem: "Nothing on this engine removes objects that way yet" };
+ if (!eraser) return { problem: "Nothing on this engine removes objects that way yet" };
+ return { eraser: [eraser, ...erasersFor(o.engine, o.mode)].find((e) => fits(e) && on(e.id)) ?? eraser };
}
// ---------------------------------------------------------------------------
diff --git a/src/server/assist/studio-routes.ts b/src/server/assist/studio-routes.ts
index 26e960bc..0fbddacf 100644
--- a/src/server/assist/studio-routes.ts
+++ b/src/server/assist/studio-routes.ts
@@ -20,6 +20,7 @@ import { createDubSession, previewDub, videoLength, type CreateDubInput } from "
import { createChannel, createEpisode, estimateEpisode, listChannels } from "../faceless";
import { chooseRoute } from "../generations";
import { createProject, deleteProject, FileUrl, jobSteps, startJob } from "../layers";
+import { firstOn } from "../model-access";
import { engineMode } from "../settings";
import { createSession, estimateWith, sourceInfo, type ShortsBody, type SourceInfo } from "../shorts";
import { absolutePath, getAsset } from "../storage";
@@ -111,7 +112,7 @@ function layersJob(i: LayersToolInput, ctx: ToolContext): Checked<{ input: Layer
if (!size) return { problem: "Layers couldn't read that image's size (PNG, JPEG, WebP, GIF or SVG)" };
const models = TOOL_MODELS.decompose[engine];
if (i.model_id && !models.includes(i.model_id)) return { problem: `${getModel(i.model_id)?.name ?? i.model_id} isn't one of Layers' decomposition models on this engine` };
- const modelId = i.model_id ?? models[0];
+ const modelId = i.model_id ?? firstOn(models, engine)!;
const layers = clampLayers(modelId, i.layers ?? defaultLayers("decompose", modelId));
return {
width: size.width,
@@ -210,7 +211,7 @@ const shortsRoute: StudioRoute<RestyleToolInput> = {
plan: (i, ctx) => {
const { body, info, notes } = ok(shortsJob(i, ctx));
const est = estimateWith(body, info);
- const modelId = body.modelId ?? SHORTS_MODELS[body.engine][0];
+ const modelId = body.modelId ?? firstOn(SHORTS_MODELS[body.engine], body.engine)!;
const job: PlannedJob = {
tool: "restyle_footage",
modelId,
diff --git a/src/server/assist/studio-tools.ts b/src/server/assist/studio-tools.ts
index 1cc821e7..4d850d9d 100644
--- a/src/server/assist/studio-tools.ts
+++ b/src/server/assist/studio-tools.ts
@@ -60,7 +60,7 @@ const LayersInput = z.object({
.string()
.optional()
.describe(
- `Layers' decomposition models: ${TOOL_MODELS.decompose.cloud.join(", ")} (cloud), ${TOOL_MODELS.decompose.open.join(", ")} (open source); default: the engine's first. Another model runs outside Layers, as a plain job in the Library.`,
+ `Layers' decomposition models: ${TOOL_MODELS.decompose.cloud.join(", ")} (cloud), ${TOOL_MODELS.decompose.open.join(", ")} (open source); default: the engine's first one switched on in Settings → Models & licences. Another model runs outside Layers, as a plain job in the Library.`,
),
});
const RestyleInput = z.object({
@@ -71,7 +71,7 @@ const RestyleInput = z.object({
.string()
.optional()
.describe(
- `Shorts Studio's restyle models: ${SHORTS_MODELS.cloud.join(", ")} (cloud), ${SHORTS_MODELS.open.join(", ")} (open source); default: the engine's first. Another video-to-video model runs outside Shorts Studio, as a single job in the Library.`,
+ `Shorts Studio's restyle models: ${SHORTS_MODELS.cloud.join(", ")} (cloud), ${SHORTS_MODELS.open.join(", ")} (open source); default: the engine's first one switched on in Settings → Models & licences. Another video-to-video model runs outside Shorts Studio, as a single job in the Library.`,
),
});
const DubInput = z.object({
diff --git a/src/server/faceless.ts b/src/server/faceless.ts
index c06942fd..6826abcb 100644
--- a/src/server/faceless.ts
+++ b/src/server/faceless.ts
@@ -86,7 +86,7 @@ import { llmBackends, probeOllama } from "./providers/llm";
import { fetchRemote } from "./remote-fetch";
import { engineMode, getSetting } from "./settings";
import { fileUrl, saveFile } from "./storage";
-import { offeredModel } from "./model-access";
+import { firstOn, offeredModel } from "./model-access";
/**
* Faceless Studio and the Explainer on the server: channels (genre, saved style, narrator, aspect,
@@ -715,9 +715,21 @@ function runsAsDemo(modelId: string, op: GenerationRequest["op"]): boolean {
}
}
+/**
+ * An episode's settings with the video model Settings → Models & licences offers: without a pick, a default that is
+ * switched off gives way to the next video choice that is on (a pick that is off stays, and its run names the switch).
+ */
+export function withOfferedVideo(s: EpisodeSettings): EpisodeSettings {
+ if (s.animation === "frames") return s;
+ const m = ENGINE_MODELS[s.engine];
+ if (s.videoModel && m.videoChoices.includes(s.videoModel)) return s;
+ const id = firstOn([m.video, ...m.videoChoices], s.engine);
+ return !id || id === m.video ? s : { ...s, videoModel: id };
+}
+
function graphInput(ep: FacelessEpisode, blocks = ep.script.blocks, stillEdits?: StillEdits): GraphInput {
const genre = genreInfo(ep.channelId ? getChannel(ep.channelId)?.genre : "education");
- const s = ep.settings;
+ const s = withOfferedVideo(ep.settings);
const narration = ENGINE_MODELS[s.engine].narration;
let fallbackVoice: string | undefined;
if (s.engine === "open" && s.voice?.kind !== "sample") {
@@ -828,7 +840,7 @@ function narrationCues(ep: FacelessEpisode): TimedText[] | null {
function advance(ep: FacelessEpisode): FacelessEpisode {
const plan = ep.plan!;
const blocks = ep.script.blocks;
- const video = getModel(resolveModels(ep.settings, narrationText(blocks).length, getModel).video);
+ const video = getModel(resolveModels(withOfferedVideo(ep.settings), narrationText(blocks).length, getModel).video);
const cues = narrationCues(ep);
const spoken = cues ? spokenTimes(blocks, cues) : null;
const timing = spoken ? sceneTiming(blocks, spoken, video, plan.timing) : (plan.timing ?? plannedTiming(blocks, video));
@@ -1202,7 +1214,7 @@ function graphInputSafe(ep: FacelessEpisode): GraphInput {
try {
return graphInput(ep);
} catch {
- return { feature: ep.kind, title: ep.title, genre: genreInfo(ep.channelId ? getChannel(ep.channelId)?.genre : "education"), settings: ep.settings, blocks: ep.script.blocks, fallbackVoice: "/api/files/placeholder.wav" };
+ return { feature: ep.kind, title: ep.title, genre: genreInfo(ep.channelId ? getChannel(ep.channelId)?.genre : "education"), settings: withOfferedVideo(ep.settings), blocks: ep.script.blocks, fallbackVoice: "/api/files/placeholder.wav" };
}
}
@@ -1314,7 +1326,7 @@ export function estimateEpisode(input: { kind: "faceless" | "explainer"; setting
/** What the render will do differently from what was asked (nothing that stops it). */
function notesFor(settings: EpisodeSettings, seconds: number): { notes?: string[] } {
const notes: string[] = [];
- const m = resolveModels(settings, 0, getModel);
+ const m = resolveModels(withOfferedVideo(settings), 0, getModel);
const limit = styleRefLimit(settings.engine, getModel);
if (settings.styleRefs.length > limit) notes.push(`The open-source picture model follows the first ${limit} style references.`);
if (settings.engine === "open" && settings.styleRefs.length && settings.sourceImages?.length) notes.push("Your style references set the look; the attached images aren't used for the open-source pictures.");
diff --git a/src/server/genjutsu.ts b/src/server/genjutsu.ts
index cf6e4f2c..cb985c4b 100644
--- a/src/server/genjutsu.ts
+++ b/src/server/genjutsu.ts
@@ -26,6 +26,7 @@ import { planSegments, type PlanStep } from "@/lib/catalog/shorts";
import type { Engine, Generation, PixelPoint, ProviderId } from "@/lib/catalog/types";
import { createPipeline } from "./chains";
import { previewChained } from "./generations";
+import { isOffered } from "./model-access";
import { provider } from "./providers";
import { pointsFromPaint } from "./remove-object";
import { engineMode } from "./settings";
@@ -127,7 +128,16 @@ interface Planned {
async function planInput(body: GenjutsuBody, opts: { probe: boolean }): Promise<Planned> {
mustMatchMode(body.engine);
- const picked = chooseMaker({ engine: body.engine, mode: body.mode, target: body.target, tier: body.tier, look: body.look, modelId: body.modelId, higgsfield: higgsfieldReady() });
+ const picked = chooseMaker({
+ engine: body.engine,
+ mode: body.mode,
+ target: body.target,
+ tier: body.tier,
+ look: body.look,
+ modelId: body.modelId,
+ higgsfield: higgsfieldReady(),
+ offered: (id) => isOffered(id, body.engine),
+ });
if ("problem" in picked) throw new ShortsError(picked.problem, 422);
const maker = picked.maker;
// The header's facts win over what the browser read (the estimate runs before the upload is read).
@@ -277,7 +287,7 @@ function mixProblem(modes: StepMode[], cannot: boolean, input: GenjutsuPlanInput
/** Another model for the same job that doesn't need Higgsfield (the way around a missing Higgsfield key). */
function otherModel(input: GenjutsuPlanInput): string | undefined {
- const other = makersFor(input.engine, input.mode, input.target, input.look).find((x) => x.id !== input.maker.id && !x.higgsfield);
+ const other = makersFor(input.engine, input.mode, input.target, input.look).find((x) => x.id !== input.maker.id && !x.higgsfield && isOffered(x.id, input.engine));
return other ? `pick ${other.label}` : undefined;
}
diff --git a/src/server/katana.ts b/src/server/katana.ts
index a4ecd719..499b2a63 100644
--- a/src/server/katana.ts
+++ b/src/server/katana.ts
@@ -9,6 +9,7 @@ import { probeMedia } from "@/lib/media-probe";
import { createPipeline } from "./chains";
import { db } from "./db";
import { cancelGeneration, createGenerations, getGeneration, previewChained } from "./generations";
+import { firstOn } from "./model-access";
import { engineMode } from "./settings";
import fs from "node:fs";
import { absolutePath } from "./storage";
@@ -175,7 +176,8 @@ export function planKatana(body: KatanaRequest): { input: KatanaInput; engine: E
const engine: Engine = mode === "both" ? body.engine : mode;
const duration = Math.min(referenceLength(body.reference, body.duration), KATANA_LIMITS.maxReference);
if (duration < KATANA_LIMITS.minReference) throw new Error("The reference is too short");
- const m = motionModel(engine, body.motionModel);
+ // Without one asked for: the first motion model switched on in Settings → Models & licences.
+ const m = motionModel(engine, body.motionModel ?? firstOn(MOTION_MODELS[engine].map((x) => x.id), engine));
if (body.motionModel && m.id !== body.motionModel) throw new Error(`${getModel(body.motionModel)?.name ?? body.motionModel} isn't a ${engine === "open" ? "open-source" : "cloud"} motion model for Katana`);
const segments = body.segments?.length ? validSegments(body.segments, duration) : planSegments({ duration, mode: "fixed", length: body.length ?? m.max, min: m.min, max: m.max });
const title = body.title?.trim().slice(0, 120) || "Katana edit";
diff --git a/src/server/layers.ts b/src/server/layers.ts
index 0d06a9d6..28577f19 100644
--- a/src/server/layers.ts
+++ b/src/server/layers.ts
@@ -35,6 +35,7 @@ import {
import { createPipeline, type PipelineStep } from "./chains";
import { db } from "./db";
import { cancelGeneration, getGeneration, previewGeneration } from "./generations";
+import { firstOn } from "./model-access";
import { getAsset } from "./storage";
/**
@@ -176,13 +177,14 @@ export const JobInputSchema = z.object({
});
// ---------------------------------------------------------------------------
-// Jobs → generation requests (pure: no database)
+// Jobs → generation requests (no database, but for the switches a default model reads)
/** The tool's model on this engine: the one asked for (when the tool offers it) or its default. */
export function toolModel(tool: LayerTool, engine: Engine, modelId?: string, list: string[] = TOOL_MODELS[tool][engine]): ModelDef {
if (!list.length) throw new LayersError(`${TOOL_LABELS[tool]} has no ${engine === "open" ? "open-source" : "cloud"} model yet`);
if (modelId && !list.includes(modelId)) throw new LayersError("That model can't run this tool", 400);
- const m = getModel(modelId ?? list[0]);
+ // Without one asked for: the tool's first model switched on in Settings → Models & licences.
+ const m = getModel(modelId ?? firstOn(list, engine)!);
if (!m) throw new LayersError("That model isn't in the catalog", 400);
return m;
}
diff --git a/src/server/marketing.ts b/src/server/marketing.ts
index ede3e225..6a9d0f9e 100644
--- a/src/server/marketing.ts
+++ b/src/server/marketing.ts
@@ -50,6 +50,8 @@ import { createPipeline, type PipelineStep } from "./chains";
import { db } from "./db";
import { llmText } from "./enhance";
import { createGenerations, getGeneration, listGenerations, previewChained, recordLocalGeneration } from "./generations";
+import { isOffered } from "./model-access";
+import { keepOffered } from "@/lib/model-access";
import { provider } from "./providers";
import { engineMode } from "./settings";
import { encodePng } from "./png";
@@ -240,7 +242,8 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlan
throw new PlanError(f.id === "product-with-model" ? "Attach reference or product" : f.id === "poster" ? "Add a prompt or a product" : "Add a prompt, a product or a website");
}
}
- const choices = formatModels(f, input.engine, { product: hasProduct, avatar: !!input.avatar, higgsfield: ctx.higgsfield });
+ // Models switched off in Settings → Models & licences aren't picked while another choice is on.
+ const choices = keepOffered(formatModels(f, input.engine, { product: hasProduct, avatar: !!input.avatar, higgsfield: ctx.higgsfield }), (c) => isOffered(c.id, input.engine));
const name = tpl?.name ?? f.name;
const title = [name, product?.name ?? brand?.name].filter(Boolean).join(" · ");
const meta: MarketingRunMeta = { format: f.id, templateId: tpl?.id, productId: product?.id ?? null, brandId: brand?.id ?? null };
@@ -788,8 +791,8 @@ function planAd(input: ClickToAdInput, ctx: { product: Product; brand?: BrandKit
// Ad Multiplier: a reference ad (4–30 s) → new versions (whole ad, or a new hook / CTA around it)
export function multiplierModel(input: Pick<MultiplierInput, "engine" | "modelId">, higgsfield: boolean): ModelDef {
- const choices = MULTIPLIER_MODELS[input.engine];
- const fallback = input.engine === "cloud" && !higgsfield ? "kling-o3" : choices[0].id;
+ const choices = keepOffered(MULTIPLIER_MODELS[input.engine], (c) => isOffered(c.id, input.engine));
+ const fallback = input.engine === "cloud" && !higgsfield && choices.some((c) => c.id === "kling-o3") ? "kling-o3" : choices[0].id;
const id = input.modelId && choices.some((c) => c.id === input.modelId) ? input.modelId : fallback;
return need(id);
}
diff --git a/src/server/remove-object.ts b/src/server/remove-object.ts
index ce8a3686..74a600df 100644
--- a/src/server/remove-object.ts
+++ b/src/server/remove-object.ts
@@ -25,6 +25,7 @@ import type { PlanStep } from "@/lib/catalog/shorts";
import type { Engine, GenParams, Generation, PixelPoint } from "@/lib/catalog/types";
import { createPipeline } from "./chains";
import { previewChained } from "./generations";
+import { isOffered } from "./model-access";
import { decodePng } from "./png";
import { engineMode } from "./settings";
import { probeSource, ShortsError } from "./shorts";
@@ -145,7 +146,7 @@ interface Planned {
async function planInput(body: RemovalBody, opts: { probe: boolean; preview?: boolean }): Promise<Planned> {
mustMatchMode(body.engine);
- const picked = chooseEraser({ engine: body.engine, mode: body.mode, effects: body.effects, modelId: body.modelId });
+ const picked = chooseEraser({ engine: body.engine, mode: body.mode, effects: body.effects, modelId: body.modelId, offered: (id) => isOffered(id, body.engine) });
if ("problem" in picked) throw new ShortsError(picked.problem, 422);
const eraser = picked.eraser;
// The header's facts win over what the browser read (the estimate runs before the upload is read).
diff --git a/src/server/shorts.ts b/src/server/shorts.ts
index 95b79246..4d761f01 100644
--- a/src/server/shorts.ts
+++ b/src/server/shorts.ts
@@ -34,6 +34,7 @@ import { createPipeline } from "./chains";
import { db } from "./db";
import { getGeneration, previewChained } from "./generations";
import { trashGenerations } from "./library";
+import { firstOn } from "./model-access";
import { engineMode } from "./settings";
import { readRef } from "./storage";
import { mediaFacts, type SourceInfo } from "./media-facts";
@@ -235,7 +236,8 @@ async function planInput(body: ShortsBody, opts: { probe: boolean }): Promise<{
/** planInput with the clip's header already read (`{}`: the browser's numbers only). */
function planWith(body: ShortsBody, info: SourceInfo): { input: ShortsPlanInput; info: SourceInfo } {
checkEngine(body.engine);
- const modelId = body.modelId && SHORTS_MODELS[body.engine].includes(body.modelId) ? body.modelId : SHORTS_MODELS[body.engine][0];
+ // Without one asked for: the engine's first restyle model switched on in Settings → Models & licences.
+ const modelId = body.modelId && SHORTS_MODELS[body.engine].includes(body.modelId) ? body.modelId : firstOn(SHORTS_MODELS[body.engine], body.engine)!;
const look = body.look ?? lookFor(body.presetId);
const duration = info.duration ?? body.source.duration;
const problem = rangeProblem(body.range, duration) ?? clipShapeProblem(info.width ?? body.source.width, info.height ?? body.source.height);
diff --git a/tests/model-access-studios.test.ts b/tests/model-access-studios.test.ts
new file mode 100644
index 00000000..bffce7a4
--- /dev/null
+++ b/tests/model-access-studios.test.ts
@@ -0,0 +1,98 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeEach, describe, expect, it } from "vitest";
+import { chooseMaker, makersFor } from "@/lib/catalog/genjutsu";
+import { MOTION_MODELS } from "@/lib/av/katana";
+import { chooseEraser, erasersFor } from "@/lib/catalog/remove-object";
+import { SHORTS_MODELS } from "@/lib/catalog/shorts";
+import { TOOL_MODELS } from "@/lib/layers";
+import { keepOffered, offered } from "@/lib/model-access";
+
+/**
+ * Settings → Models & licences in the studios with their own model menus (Genjutsu, Remove object, Shorts, Layers,
+ * Katana, Marketing's Ad Multiplier, Faceless): a model switched off leaves the menu, and a default that is off
+ * gives way to the next one that is on, in the browser (keepOffered + offered) as on the server (firstOn, isOffered).
+ */
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-access-studios-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9";
+const { changeAccess, firstOn, isOffered } = await import("@/server/model-access");
+const { toolModel } = await import("@/server/layers");
+const { planKatana } = await import("@/server/katana");
+const { multiplierModel } = await import("@/server/marketing");
+const { withOfferedVideo } = await import("@/server/faceless");
+const { setSetting } = await import("@/server/settings");
+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
+
+beforeEach(() => {
+ changeAccess([{ kind: "reset" }]);
+ setSetting("engineMode", "both");
+ setSetting("demoMode", "on");
+});
+
+describe("a studio's own model menu", () => {
+ it("keeps the choices that are on, and all of them when none is (a run then names the switch)", () => {
+ const summary = { off: ["a", "b"] };
+ expect(keepOffered(["a", "b", "c"], (id) => offered(summary, id))).toEqual(["c"]);
+ expect(keepOffered(["a", "b"], (id) => offered(summary, id))).toEqual(["a", "b"]);
+ expect(keepOffered(["a"], (id) => offered(undefined, id))).toEqual(["a"]);
+ });
+
+ it("Genjutsu and Remove object pick past a model that is off", () => {
+ const motion = makersFor("cloud", "motion");
+ expect(motion.length).toBeGreaterThan(1);
+ const first = chooseMaker({ engine: "cloud", mode: "motion", higgsfield: false });
+ expect("maker" in first).toBe(true);
+ const firstId = "maker" in first ? first.maker.id : "";
+ const next = chooseMaker({ engine: "cloud", mode: "motion", higgsfield: false, offered: (id) => id !== firstId });
+ expect("maker" in next && next.maker.id).not.toBe(firstId);
+ // An explicit pick that is off isn't kept while another is on.
+ expect(chooseMaker({ engine: "cloud", mode: "motion", higgsfield: false, modelId: firstId, offered: (id) => id !== firstId })).toMatchObject({ maker: { id: expect.not.stringMatching(firstId) } });
+ // With every one off, the default stays: its run names the switch.
+ expect(chooseMaker({ engine: "cloud", mode: "motion", higgsfield: false, offered: () => false })).toMatchObject({ maker: { id: firstId } });
+
+ const eraser = chooseEraser({ engine: "cloud", mode: "type" });
+ const eraserId = "eraser" in eraser ? eraser.eraser.id : "";
+ expect(erasersFor("cloud", "type").length).toBeGreaterThan(1);
+ const other = chooseEraser({ engine: "cloud", mode: "type", offered: (id) => id !== eraserId });
+ expect("eraser" in other && other.eraser.id).not.toBe(eraserId);
+ expect(chooseEraser({ engine: "cloud", mode: "type", offered: () => false })).toMatchObject({ eraser: { id: eraserId } });
+ });
+});
+
+describe("a studio's default on the server", () => {
+ it("is the first model that is on (Shorts, Layers, Katana), else the first", () => {
+ expect(firstOn(SHORTS_MODELS.cloud, "cloud")).toBe(SHORTS_MODELS.cloud[0]);
+ changeAccess([{ kind: "model", id: SHORTS_MODELS.cloud[0], on: false }]);
+ expect(firstOn(SHORTS_MODELS.cloud, "cloud")).toBe(SHORTS_MODELS.cloud[1]);
+
+ const [seedream, flash] = TOOL_MODELS.decompose.cloud;
+ expect(toolModel("decompose", "cloud").id).toBe(seedream);
+ changeAccess([{ kind: "model", id: seedream, on: false }]);
+ expect(toolModel("decompose", "cloud").id).toBe(flash);
+ // A model asked for by name is the caller's choice: it runs (or is refused) as it is.
+ expect(toolModel("decompose", "cloud", seedream).id).toBe(seedream);
+
+ const [kling, next] = MOTION_MODELS.cloud;
+ const katana = { engine: "cloud" as const, reference: "/api/files/ref.mp4", duration: 8, photos: ["/api/files/me.png"] };
+ expect(planKatana(katana).input.motionModel).toBe(kling.id);
+ changeAccess([{ kind: "model", id: kling.id, on: false }]);
+ expect(planKatana(katana).input.motionModel).toBe(next.id);
+ expect(isOffered(kling.id, "cloud")).toBe(false);
+ });
+
+ it("Ad Multiplier and Faceless fall back past a switched-off default", () => {
+ expect(multiplierModel({ engine: "cloud" }, false).id).toBe("kling-o3");
+ changeAccess([{ kind: "model", id: "kling-o3", on: false }]);
+ expect(multiplierModel({ engine: "cloud" }, false).id).not.toBe("kling-o3");
+
+ const settings = { engine: "cloud" as const, animation: "animated" } as Parameters<typeof withOfferedVideo>[0];
+ expect(withOfferedVideo(settings)).toBe(settings);
+ changeAccess([{ kind: "model", id: "gemini-omni-flash", on: false }]);
+ expect(withOfferedVideo(settings).videoModel).toBe("seedance-2-5");
+ // A pick stays the pick.
+ expect(withOfferedVideo({ ...settings, videoModel: "gemini-omni-flash" }).videoModel).toBe("gemini-omni-flash");
+ });
+});