The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(create): Studio-Spur im Composer, P7
purpledbfad39a4377
diff --git a/src/components/create/experimental/AdvancedDrawer.tsx b/src/components/create/experimental/AdvancedDrawer.tsxindex bff2818f..e76cb55d 100644--- a/src/components/create/experimental/AdvancedDrawer.tsx+++ b/src/components/create/experimental/AdvancedDrawer.tsx@@ -7,13 +7,22 @@ import {isT2VCapable,} from '../../../api/comfyui'import { ParamGroups } from './ParamGroups'+import { StudioParams } from './StudioParams'export function AdvancedDrawer({open,onClose,+ studioModel,}: {open: booleanonClose: () => void+ /** Set only on the cloud Studio track (Portplan Abschnitt 3b): a Studio+ * model has no sampler, scheduler, VAE or LoRA list from ComfyUI, so it+ * REPLACES WorkflowFinder + ParamGroups below rather than adding to them.+ * ParamGroups.tsx itself stays untouched, e2e/create-expert-section.spec.ts+ * is the guard that this stays an ersetzung, not a new condition inside+ * ParamGroups' own showExpert. */+ studioModel?: string}) {const mode = useCreateStore((state) => state.mode)const backend = useCreateStore((state) => state.backend)@@ -73,15 +82,21 @@ export function AdvancedDrawer({title="Advanced settings"width={320}>- <ParamGroups />+ {studioModel ? (+ <StudioParams model={studioModel} />+ ) : (+ <>+ <ParamGroups />- {backend === 'local' && modelName && (- <div className="border-t border-white/10 px-1 pb-4 pt-4">- <WorkflowFinder- modelName={modelName}- modelType={modelType}- />- </div>+ {backend === 'local' && modelName && (+ <div className="border-t border-white/10 px-1 pb-4 pt-4">+ <WorkflowFinder+ modelName={modelName}+ modelType={modelType}+ />+ </div>+ )}+ </>)}</Drawer>)diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsxindex cdfb0763..1837d230 100644--- a/src/components/create/experimental/Composer.tsx+++ b/src/components/create/experimental/Composer.tsx@@ -1,4 +1,4 @@-import { useCallback, useRef, useSyncExternalStore } from 'react'+import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'import { motion, AnimatePresence } from 'framer-motion'import { Sparkles, X, SlidersHorizontal, Square, Workflow } from 'lucide-react'import { useCreateStore, MODEL_TYPE_DEFAULTS } from '../../../stores/createStore'@@ -14,6 +14,11 @@ import {modelForOp,runCredits,} from '../../../stores/cloudCatalogStore'+import { intentRequiredInputs, intentRoles, isStudioModel, resolveIntentPick } from '../../../lib/render/create-studio'+import { STUDIO_MODELS } from '../../../lib/render/studio-contract'+import { videoDurations } from '../../../lib/render/video-duration'+import { mediaSeconds, useStudioPrice } from './useStudioPrice'+import { resolveCharacterModel } from '../../../hooks/useCloudCreate'import { INTENT_MAP } from './intents'import { subscribeInstallRuns, getInstallRun } from '../../../lib/model-install-runs'import { useWorkflowStore, shouldShowManagerNotice } from '../../../stores/workflowStore'@@ -53,6 +58,7 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {const cloudImageModel = useCreateStore((s) => s.cloudImageModel)const cloudVideoModel = useCreateStore((s) => s.cloudVideoModel)const cloudOpModel = useCreateStore((s) => s.cloudOpModel)+ const cloudStudioOptions = useCreateStore((s) => s.cloudStudioOptions)const frames = useCreateStore((s) => s.frames)const fps = useCreateStore((s) => s.fps)// 2.5.8 specialized-intent inputs (readiness for the Create button).@@ -101,29 +107,75 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {// the CreditsMeter shows — quota.costs[kind] is only the tier's// representative per-kind number and would mis-gate utility ops / pricier// models.+ // Studio-Spur (Portplan Abschnitt 3d): ein DRITTER Zweig, strikt hinter+ // `backend === 'cloud'`. Nur die vier Rollen-Absichten (lipsync/music/+ // extend/motion, intentRoles(intent), P2) koennen ueberhaupt ein+ // Studio-Modell fahren; character-use bleibt bei seiner festen+ // -lora-Familie (resolveCharacterModel) und ruehrt Studio nie an. Auf der+ // lokalen Spur ist `studioPick` immer undefined, und ausschliesslich das+ // haelt useStudioPrice unten von jedem Netzabruf ab.+ const roleIntent = backend === 'cloud' && !characterUse && intentRoles(intent).length > 0+ const rolePick = roleIntent ? resolveIntentPick(intent, cloudOpModel) : undefined+ const studioPick = rolePick && isStudioModel(rolePick) ? rolePick : undefinedconst pickedModel = characterUse- ? 'flux-schnell-lora'- : special- ? cloudOpModel- : (intentKind === 'video' ? cloudVideoModel : cloudImageModel) ||- defaultCloudModel(intentKind)?.id || ''+ ? (resolveCharacterModel(selectedCharacter?.family ?? '', cloudOpModel) ?? '')+ : roleIntent+ ? (rolePick ?? '')+ : special+ ? cloudOpModel+ : (intentKind === 'video' ? cloudVideoModel : cloudImageModel) ||+ defaultCloudModel(intentKind)?.id || ''+ // A Studio pick runs on its own schema-driven endpoint (studioBaseCredits /+ // studioQuote), not on the classic per-kind picker's kind.+ const runKind = studioPick ? STUDIO_MODELS[studioPick].kind : intentKindconst runSeconds =intentOp === 'music'? musicDuration- : intentKind === 'video' && (intentOp === 'generate' || intentOp === 'animate') && fps > 0+ : runKind === 'video' && (intentOp === 'generate' || intentOp === 'animate') && fps > 0? frames / fps: undefined- const costFallback = quota?.costs[intentKind === 'audio' ? 'image' : intentKind] ?? 0+ // Die im Browser gemessene Laenge einer angehaengten Datei, gebraucht nur von den+ // Modellen, die danach abrechnen (studio-contract.ts, price.mode 'input'/'both');+ // useStudioPrice ruft dafuer nichts ab, solange sie fehlt.+ const mediaUrl =+ intent === 'lipsync' ? audioInput?.url+ : intent === 'motion' ? videoInput?.url+ : intent === 'extend' ? extendSource?.url+ : undefined+ const mediaKind = intent === 'lipsync' ? ('audio' as const) : ('video' as const)+ // Measured async only, and only into state the async callback itself+ // writes. Resetting synchronously inside the effect body (setState right+ // where mediaUrl is falsy) is exactly the cascading-render pattern the+ // set-state-in-effect rule flags. Keying the derived value off `mediaUrl`+ // clears it for free the moment the source changes or disappears.+ const [measured, setMeasured] = useState<{ url: string; seconds: number | undefined } | null>(null)+ useEffect(() => {+ let alive = true+ if (!mediaUrl) return+ void mediaSeconds(mediaUrl, mediaKind).then((v) => { if (alive) setMeasured({ url: mediaUrl, seconds: v }) })+ return () => { alive = false }+ }, [mediaUrl, mediaKind])+ const inputSeconds = measured && measured.url === mediaUrl ? measured.seconds : undefined+ const studioPrice = useStudioPrice(studioPick, cloudStudioOptions, prompt, runSeconds ?? inputSeconds)+ const setCloudStudioCredits = useCreateStore((s) => s.setCloudStudioCredits)+ useEffect(() => {+ setCloudStudioCredits(studioPrice?.credits ?? null)+ }, [studioPrice?.credits, setCloudStudioCredits])+ const costFallback = quota?.costs[runKind === 'audio' ? 'image' : runKind] ?? 0// The exact rule the meter chip renders, so the button can never invite a run// the chip is already refusing. Credits alone were not enough: a user out of// monthly character trainings kept an enabled Create button and got a 429.+ // A Studio pick that could not get a server-confirmed price (old server,+ // unreachable) gates the button off too. Booking against a guessed number+ // risks a 409 the customer only sees after pressing Create.const creditsOk =backend !== 'cloud' ||(quota != null &&+ !(studioPick && studioPrice?.error) &&meterState(quota,- runCredits(intentKind, intentOp, pickedModel, runSeconds, costFallback, targetResolution),- intentKind,+ studioPick ? (studioPrice?.credits ?? costFallback) : runCredits(intentKind, intentOp, pickedModel, runSeconds, costFallback, targetResolution),+ runKind,intentOp,).kind === 'ok')// Match useCloudCreate's submit-time edit fallback so the Neg gate reflects@@ -145,11 +197,20 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {backend === 'cloud' &&intent === 'lipsync' &&cloudModelById(modelForOp('video', 'lipsync', cloudOpModel))?.lipsync_source === 'video'+ // A Studio model names its own required inputs (studio-contract.ts's+ // schema). A presenter endpoint (HeyGen) reads only the voice and needs no+ // photo at all, unlike every classic lipsync model.+ const studioNeeds = studioPick ? intentRequiredInputs(intent, studioPick) : []const specialReady =intent === 'character'? (characterUse ? !!selectedCharacter : trainImages.length >= 4): intent === 'lipsync'- ? (!!audioInput || (backend === 'cloud' && !!voiceFromJob)) && (lipsyncNeedsClip ? !!videoInput : !!source)+ ? (!!audioInput || (backend === 'cloud' && !!voiceFromJob)) &&+ (lipsyncNeedsClip+ ? !!videoInput+ : studioPick+ ? (!studioNeeds.includes('source_path') || !!source)+ : !!source): intent === 'extend'? (backend === 'cloud' ? !!extendSource : !!source): intent === 'motion'@@ -250,11 +311,23 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {)}</AnimatePresence>- {showNoPromptHint && (+ {/* Ein Lauf, der weder Prompt noch Maske hat, bekommt die+ gattungstypische Kurzanleitung (noPromptHint). Braucht die+ Absicht eine gemalte Maske (Eraser, Cloud-Edit ohne+ maskenloses Modell), steht stattdessen die eine Zeile, die den+ Zustand der Maske selbst beschreibt, sonst stuende dort ein+ Text, der beim Radiergummi nie zutrifft ("remove the+ background"). */}+ {showNoPromptHint && !needsMask && (<div className="px-3.5 py-3 t-body text-gray-500">{noPromptHint(meta.id)}</div>)}+ {needsMask && !needPrompt && !isGenerating && (+ <div className="px-3.5 py-3 t-body text-gray-500">+ {mask ? 'Mask ready. Hit Create.' : 'Paint over what should go, then hit Create.'}+ </div>+ )}{/* Action bar */}<div className="flex items-center gap-1.5 px-2.5 py-2 border-t border-white/[0.05]">@@ -282,6 +355,14 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {{/* The backend axis moved to the global header switch (2.5.7) —the Composer just reflects it via the CreditsMeter. */}{backend === 'cloud' && <CreditsMeter />}+ {/* Portplan Abschnitt 5, Punkt 3: der Server ist die einzige+ Preiswahrheit fuer ein Studio-Modell. Ist er nicht erreichbar+ oder zu alt (studio.ts, OLDER_SERVER_MESSAGE), bleibt Create+ gesperrt UND sagt hier woran es liegt, statt still auf die+ Formel-Vorschau zurueckzufallen und dann doch zu buchen. */}+ {studioPick && studioPrice?.error && (+ <span className="t-control text-red-300">{studioPrice.error}</span>+ )}{meta.id === 'upscale' && (<Tooltip content="Target resolution for the upscale pass."><div>@@ -382,7 +463,9 @@ function LaneControls() {const frames = useCreateStore((s) => s.frames)const setFrames = useCreateStore((s) => s.setFrames)const fps = useCreateStore((s) => s.fps)+ const setFps = useCreateStore((s) => s.setFps)const videoModel = useCreateStore((s) => s.videoModel)+ const cloudVideoModel = useCreateStore((s) => s.cloudVideoModel)const base = MODEL_TYPE_DEFAULTS[imageModelType]?.steps ?? 25const qSteps = { Draft: Math.round(base * 0.6), Standard: base, High: Math.round(base * 1.5) }@@ -393,7 +476,6 @@ function LaneControls() {// trained LoRA attached, so it takes the image knobs below.const characterTrain = intent === 'character' && characterTab === 'train'const characterUse = intent === 'character' && characterTab === 'use'- if (characterTrain) return null// The 2.5.8 specialized ops that submit "bare" on cloud (fixed server-side)// but consume the sliders locally — mirrors useCloudCreate's specialOp set.@@ -401,6 +483,32 @@ function LaneControls() {const kind: 'image' | 'video' | 'audio' =characterUse ? 'image' : intent === 'music' ? 'audio' : meta.isVideo ? 'video' : 'image'+ // dd29f359 (Portplan Abschnitt 6): the hosted video endpoints book whatever+ // lengths the provider actually prices (video-durations.json / the live+ // catalog's clip.durations), not a fixed 5s/8s pair. Cloud text-to-video /+ // animate is the only lane this reaches. Local video keeps its free+ // Frames slider (nothing here runs on the local track), and the 2.5.8+ // specialized ops (lipsync/music/extend/motion) submit bare and never see+ // this hook either (`knobsLive` below hides the whole row for them on+ // cloud). All hook calls stay UNCONDITIONAL (top of the component, before+ // any early return) so this never violates the rules of hooks across a+ // lane switch.+ const cloudVideoOp = intentToJob(intent).op+ const cloudVideoLaneModel = modelForOp('video', cloudVideoOp, cloudVideoModel || defaultCloudModel('video')?.id || '')+ const cloudVideoDurations = effectiveVideoDurations(cloudVideoLaneModel)+ const cloudVideoSeconds = cloudVideoDurations.length ? snapToVideoDuration(cloudVideoDurations, frames, fps) : undefined+ useEffect(() => {+ if (+ backend === 'cloud' && kind === 'video' && !specialOp &&+ cloudVideoSeconds !== undefined && frames / fps !== cloudVideoSeconds+ ) {+ setFrames(cloudVideoSeconds * 16)+ setFps(16)+ }+ }, [backend, kind, specialOp, cloudVideoSeconds, frames, fps, setFrames, setFps])++ if (characterTrain) return null+// ── Image lanes: quality + aspect (+ edit strength) ──if (kind === 'image') {return (@@ -505,7 +613,21 @@ function LaneControls() {options={resTiers.map((m) => ({ value: String(m), label: `${snap16(nativeShort * m)}p` }))}/></LabeledControl>- {showFrames ? (+ {backend === 'cloud' && cloudVideoDurations.length > 0 ? (+ // The hosted endpoint renders exactly these lengths (Portplan+ // Abschnitt 6), no fixed 5s/8s pair, and no unpriced button: every+ // option here has a catalog price, live via credits.by_duration or+ // the base/long split runCredits already falls back to.+ <LabeledControl label="Length">+ <Segmented+ size="sm"+ layoutId="clip-length"+ value={String(cloudVideoSeconds ?? cloudVideoDurations[0])}+ onChange={(k) => { setFrames(Number(k) * 16); setFps(16) }}+ options={cloudVideoDurations.map((secs) => ({ value: String(secs), label: `${secs}s` }))}+ />+ </LabeledControl>+ ) : showFrames ? (<div className="w-44"><Slider label="Frames" min={9} max={121} step={4} value={frames} onChange={setFrames} format={(v) => `${v}f · ${(v / (fps || 16)).toFixed(1)}s`} /></div>@@ -562,3 +684,26 @@ function nearestKey(map: Record<string, number>, val: number): string {for (const [k, v] of Object.entries(map)) { const d = Math.abs(v - val); if (d < bestD) { bestD = d; best = k } }return best}++// ── cloud video length (dd29f359, Portplan Abschnitt 6) ──+// The catalog is the runtime truth (a live model can add/retire lengths any+// day); video-durations.json is the offline notvorrat only. Neither one+// alone: an entry that has NOT yet re-fetched the live catalog still needs a+// length list, and a length the catalog names that the static file has not+// caught up with yet must still show.+export function effectiveVideoDurations(model: string): number[] {+ const cat = cloudModelById(model)+ if (cat?.clip?.durations?.length) return cat.clip.durations+ const json = videoDurations(model)+ if (json.length > 0) return [...json]+ if (cat?.clip) return cat.clip.long !== undefined ? [cat.clip.short, cat.clip.long] : [cat.clip.short]+ return []+}++// An invalid-become choice (model switch, or a persisted value from a model+// that no longer offers it) resets to the SHORTEST valid length, never to+// the nearest one, which could silently jump the price up.+export function snapToVideoDuration(allowed: number[], frames: number, fps: number): number {+ const raw = fps > 0 ? frames / fps : allowed[0]+ return allowed.includes(raw) ? raw : allowed[0]+}diff --git a/src/components/create/experimental/CreditsMeter.tsx b/src/components/create/experimental/CreditsMeter.tsxindex 920d123b..87a5db6a 100644--- a/src/components/create/experimental/CreditsMeter.tsx+++ b/src/components/create/experimental/CreditsMeter.tsx@@ -2,6 +2,9 @@ import { useCreateStore } from '../../../stores/createStore'import { useCreateExp } from './CreateContext'import { intentToJob } from '../../../lib/render/cloud-jobs'import { defaultCloudModel, resolveOpPick, runCredits } from '../../../stores/cloudCatalogStore'+import { createStudioCost, intentRoles, isStudioModel, resolveIntentPick } from '../../../lib/render/create-studio'+import { STUDIO_MODELS } from '../../../lib/render/studio-contract'+import { resolveCharacterModel } from '../../../hooks/useCloudCreate'import { meterState } from '../../../lib/render/credits-meter'import { Tooltip } from '../ui/Tooltip'import { openExternal } from '../../../api/backend'@@ -25,17 +28,27 @@ export function CreditsMeter() {const cloudVideoModel = useCreateStore((s) => s.cloudVideoModel)const cloudOpModel = useCreateStore((s) => s.cloudOpModel)const characterTab = useCreateStore((s) => s.characterTab)+ const selectedCharacter = useCreateStore((s) => s.selectedCharacter)const frames = useCreateStore((s) => s.frames)const fps = useCreateStore((s) => s.fps)const musicDuration = useCreateStore((s) => s.musicDuration)const targetResolution = useCreateStore((s) => s.targetResolution)+ const cloudStudioOptions = useCreateStore((s) => s.cloudStudioOptions)+ const cloudStudioCredits = useCreateStore((s) => s.cloudStudioCredits)+ const prompt = useCreateStore((s) => s.prompt)if (!quota) return null+ // No character picked yet: there is no run to price (resolveCharacterModel+ // would fall onto the family's first model and show a number for a run+ // nobody asked for). uselu main 5be5dec3 fixed the same false reading.+ if (intent === 'character' && characterTab === 'use' && !selectedCharacter) return nulllet { kind, op } = intentToJob(intent)// Mirror Composer's creditsOk pick exactly — meter and gate must show the- // same number: the character use-surface is a plain LoRA image generate, the- // specialized 2.5.8 ops run the op picker's model (audio has no classic- // entries at all), everything else prices the per-kind picker's model.+ // same number: the character use-surface prices the family's real+ // generation endpoint (never a hardcoded single default), the role+ // intents (lipsync/music/extend/motion) run whichever Studio or classic+ // op-picker model is chosen, everything else prices the per-kind+ // picker's model.const characterUse = intent === 'character' && characterTab === 'use'if (characterUse) {kind = 'image'@@ -44,20 +57,31 @@ export function CreditsMeter() {const special =op === 'lipsync' || op === 'extend' || op === 'motion' ||op === 'music' || op === 'tts' || op === 'lora-train'+ const roleIntent = !characterUse && intentRoles(intent).length > 0+ const rolePick = roleIntent ? resolveIntentPick(intent, cloudOpModel) : undefined+ const studioPick = rolePick && isStudioModel(rolePick) ? rolePick : undefinedconst picked = characterUse- ? 'flux-schnell-lora'- : special- ? resolveOpPick(op, cloudOpModel)- : (kind === 'video' ? cloudVideoModel : cloudImageModel) || defaultCloudModel(kind)?.id || ''+ ? (resolveCharacterModel(selectedCharacter?.family ?? '', cloudOpModel) ?? '')+ : roleIntent+ ? (rolePick ?? '')+ : special+ ? resolveOpPick(op, cloudOpModel)+ : (kind === 'video' ? cloudVideoModel : cloudImageModel) || defaultCloudModel(kind)?.id || ''+ if (studioPick) kind = STUDIO_MODELS[studioPick].kindconst seconds =op === 'music'? musicDuration: kind === 'video' && (op === 'generate' || op === 'animate') && fps > 0? frames / fps: undefined- const cost = runCredits(- kind, op, picked, seconds, quota.costs[kind === 'audio' ? 'image' : kind], targetResolution,- )+ // A Studio model prices from its own provider schema, never runCredits()+ // (P3's guard there returns the caller's fallback on purpose, Portplan+ // Abschnitt 7, Risiko 1). The Composer fetches the live number once+ // (useStudioPrice) and leaves it here; this chip never asks twice for the+ // same figure.+ const cost = studioPick+ ? cloudStudioCredits ?? createStudioCost(studioPick, cloudStudioOptions, Array.from(prompt).length)+ : runCredits(kind, op, picked, seconds, quota.costs[kind === 'audio' ? 'image' : kind], targetResolution)const remaining = quota.remaining.creditsconst limit = quota.limits.creditsconst state = meterState(quota, cost, kind, op)diff --git a/src/components/create/experimental/ModelChip.tsx b/src/components/create/experimental/ModelChip.tsxindex bd1452b3..019d7e8b 100644--- a/src/components/create/experimental/ModelChip.tsx+++ b/src/components/create/experimental/ModelChip.tsx@@ -1,5 +1,11 @@import { useCreateStore } from '../../../stores/createStore'-import { useCloudCatalogStore, defaultCloudModel, opPickerModels, modelCostHint, isEditModel } from '../../../stores/cloudCatalogStore'+import {+ useCloudCatalogStore, cloudModelById, defaultCloudModel, opPickerModels, modelCostHint, isEditModel, shortCount,+} from '../../../stores/cloudCatalogStore'+import { intentPickerModels, intentRoles, createStudioCost, isStudioModel } from '../../../lib/render/create-studio'+import { resolveCharacterModel, characterGenerationModels } from '../../../hooks/useCloudCreate'+import type { RenderOp } from '../../../lib/render/cloud-jobs'+import type { PresetModel } from '../../../lib/render/preset-models'import { useSettingsStore } from '../../../stores/settingsStore'import { useUIStore } from '../../../stores/uiStore'import { useContentPolicy } from '../../../hooks/useContentPolicy'@@ -7,6 +13,25 @@ import { Select, type SelectOption } from '../ui/Select'import { TYPE_BADGE } from './badges'import { resolveLocalOpPick, videoLaneModels } from '../../../api/comfyui'+// Portplan P7: lipsync/music/extend/motion reach the Studio track through the+// SAME picker as their classic op-specialized twins, one list, matching what+// useCloudCreate.ts and CreditsMeter.tsx already resolve through.+// intentPickerModels() (create-studio.ts, P2) already merges both worlds;+// this only prices each row, since a PresetModel carries no `credits` field.+function pickerCostHint(m: PresetModel, musicDuration: number): string | undefined {+ const classic = cloudModelById(m.id)+ if (classic) return modelCostHint(classic, m.op as RenderOp, m.op === 'music' ? musicDuration : undefined)+ if (isStudioModel(m.id)) {+ // No options chosen yet (this is the picker row, not the run), so use the+ // model's own baseline preview, same figure studio-contract.ts's+ // studioBaseCredits() would compute, just inlined to avoid a second+ // import for one call site.+ const cr = createStudioCost(m.id, {}, 100)+ return `${shortCount(cr)} cr`+ }+ return undefined+}+const CLOUD_BADGE = { label: 'Cloud', color: 'bg-violet-500/15 text-violet-500 dark:text-violet-200' }// C2: the "No refusals" mark on models the provider ships with its own// filter off (CloudModel.adult, web parity: apps/web/components/create/@@ -37,6 +62,8 @@ export function ModelChip() {function CloudModelChip() {const mode = useCreateStore((s) => s.mode)const intent = useCreateStore((s) => s.intent())+ const characterTab = useCreateStore((s) => s.characterTab)+ const selectedCharacter = useCreateStore((s) => s.selectedCharacter)const cloudImageModel = useCreateStore((s) => s.cloudImageModel)const cloudVideoModel = useCreateStore((s) => s.cloudVideoModel)const cloudOpModel = useCreateStore((s) => s.cloudOpModel)@@ -51,11 +78,22 @@ function CloudModelChip() {const isVideo = mode === 'video'const kind = isVideo ? 'video' : 'image'+ const characterUse = intent === 'character' && characterTab === 'use'// The 2.5.8 specialized intents pick from their op's own family (both- // trainer kinds together for Character-Studio) and store into cloudOpModel.+ // trainer kinds together for Character-Studio TRAIN) and store into+ // cloudOpModel. Character-Studio USE is its own thing: it picks a+ // GENERATION endpoint compatible with the trained LoRA's family, not a+ // trainer. A picker showing trainers there would be a lie (uselu main+ // 5be5dec3).const special =- intent === 'character' || intent === 'lipsync' || intent === 'music' ||+ (intent === 'character' && !characterUse) || intent === 'lipsync' || intent === 'music' ||intent === 'extend' || intent === 'motion'+ // Portplan P7: lipsync/music/extend/motion reach the Studio track through+ // the SAME picker as their classic op-specialized twins.+ // intentPickerModels() (create-studio.ts, P2) already merges both worlds.+ const roleIntent = !characterUse && intentRoles(intent).length > 0+ const roleModels: PresetModel[] = roleIntent ? intentPickerModels(intent) : []+ const characterModels = characterUse ? characterGenerationModels(selectedCharacter?.family ?? '') : []// List only the models that can run the current op — otherwise the picker// offers checkpoints that useCloudCreate silently swaps out at submit, so the// user's choice was a lie. Edit needs masked-img2img (flux-dev); Animate needs@@ -68,23 +106,25 @@ function CloudModelChip() {intent === 'edit' ? models.filter((m) => m.kind === 'image' && isEditModel(m)): intent === 'animate' ? models.filter((m) => m.kind === 'video' && m.i2v !== false): intent === 'video' ? models.filter((m) => m.kind === 'video' && m.t2v !== false)- : intent === 'character' ? opPickerModels('lora-train')- : intent === 'lipsync' ? opPickerModels('lipsync')- : intent === 'music' ? opPickerModels('music')- : intent === 'extend' ? opPickerModels('extend')- : intent === 'motion' ? opPickerModels('motion')+ : intent === 'character' && !characterUse ? opPickerModels('lora-train'): models.filter((m) => m.kind === kind && !m.ops)- const current = special- ? cloudOpModel- : (isVideo ? cloudVideoModel : cloudImageModel) || defaultCloudModel(kind)?.id || ''+ const current = characterUse+ ? (resolveCharacterModel(selectedCharacter?.family ?? '', cloudOpModel) ?? '')+ : special || roleIntent+ ? cloudOpModel+ : (isVideo ? cloudVideoModel : cloudImageModel) || defaultCloudModel(kind)?.id || ''// Reflect the model the run will really use, so a leftover pick the current op// can't perform doesn't show as "selected".- const value = list.some((m) => m.id === current) ? current : (list[0]?.id ?? current)+ const roleOrCharacterIds = roleIntent ? roleModels : characterModels+ const value = roleIntent || characterUse+ ? (roleOrCharacterIds.some((m) => m.id === current) ? current : (roleOrCharacterIds[0]?.id ?? current))+ : list.some((m) => m.id === current) ? current : (list[0]?.id ?? current)// The op this picker's models will run as, so the sublabel prices correctly// (a trainer bills a training run, not an image).- const op =- intent === 'character' ? 'lora-train'+ const op: RenderOp =+ characterUse ? 'generate'+ : intent === 'character' ? 'lora-train': intent === 'lipsync' ? 'lipsync': intent === 'music' ? 'music': intent === 'extend' ? 'extend'@@ -92,16 +132,34 @@ function CloudModelChip() {: intent === 'edit' ? 'edit': intent === 'animate' ? 'animate': 'generate'- const options: SelectOption[] = list.map((m) => ({- value: m.id,- label: m.label,- sublabel: modelCostHint(m, op, op === 'music' ? musicDuration : undefined),- // adult models keep the standard Cloud badge everywhere EXCEPT the row- // itself, where "No refusals" is strictly more informative, matching web.- badge: m.adult- ? { label: 'No refusals', color: contentPolicy === 'off' ? NO_REFUSALS_COLOR.open : NO_REFUSALS_COLOR.filtering }- : CLOUD_BADGE,- }))+ const options: SelectOption[] = roleIntent+ ? roleModels.map((m) => ({+ value: m.id,+ label: m.label,+ sublabel: pickerCostHint(m, musicDuration),+ badge: m.adult+ ? { label: 'No refusals', color: contentPolicy === 'off' ? NO_REFUSALS_COLOR.open : NO_REFUSALS_COLOR.filtering }+ : CLOUD_BADGE,+ }))+ : characterUse+ ? characterModels.map((m) => ({+ value: m.id,+ label: m.label,+ sublabel: modelCostHint(m, 'generate', undefined),+ badge: m.adult+ ? { label: 'No refusals', color: contentPolicy === 'off' ? NO_REFUSALS_COLOR.open : NO_REFUSALS_COLOR.filtering }+ : CLOUD_BADGE,+ }))+ : list.map((m) => ({+ value: m.id,+ label: m.label,+ sublabel: modelCostHint(m, op, op === 'music' ? musicDuration : undefined),+ // adult models keep the standard Cloud badge everywhere EXCEPT the row+ // itself, where "No refusals" is strictly more informative, matching web.+ badge: m.adult+ ? { label: 'No refusals', color: contentPolicy === 'off' ? NO_REFUSALS_COLOR.open : NO_REFUSALS_COLOR.filtering }+ : CLOUD_BADGE,+ }))return (<Select@@ -112,7 +170,7 @@ function CloudModelChip() {options={options}value={value}onChange={(v) =>- special ? setCloudOpModel(v) : isVideo ? setCloudVideoModel(v) : setCloudImageModel(v)+ special || roleIntent || characterUse ? setCloudOpModel(v) : isVideo ? setCloudVideoModel(v) : setCloudImageModel(v)}/>)diff --git a/src/components/create/experimental/StudioParams.tsx b/src/components/create/experimental/StudioParams.tsxnew file mode 100644index 00000000..0c86e47d--- /dev/null+++ b/src/components/create/experimental/StudioParams.tsx@@ -0,0 +1,47 @@+// Die Regler des gewaehlten Studio-Modells, aus dessen eigenem Schema.+//+// Ersetzt in AdvancedDrawer bei gesetztem `studioModel` die lokale Kombination+// aus WorkflowFinder + ParamGroups vollstaendig (Portplan Abschnitt 3b/3c):+// ein Studio-Modell hat keinen Sampler, keinen Scheduler, kein VAE und keine+// LoRA-Liste aus ComfyUI, also stehen hier ausschliesslich die Felder, die der+// Anbieter fuer dieses eine Modell wirklich liest.+import { SlidersHorizontal } from 'lucide-react'+import { useCreateStore } from '../../../stores/createStore'+import { SchemaControl, isCompactField, studioFieldsInOrder } from './SchemaControl'+import { modelHint } from '../../../lib/render/preset-models'+import { modelLabel } from '../../../lib/render/preset-models'++export function StudioParams({ model }: { model: string }) {+ const options = useCreateStore((s) => s.cloudStudioOptions)+ const setOptions = useCreateStore((s) => s.setCloudStudioOptions)+ const isGenerating = useCreateStore((s) => s.isGenerating)+ const fields = studioFieldsInOrder(model)+ const hint = modelHint(model)+ return (+ <div className="px-1 py-3">+ {/* Eine Ueberschrift, damit die Klappe sagt, wessen Einstellungen das+ sind: sie zeigt je nach Modell voellig andere Felder. */}+ <div className="mb-2.5 flex items-center gap-1.5 border-b border-white/[0.06] pb-2">+ <SlidersHorizontal size={12} className="shrink-0 text-gray-500" />+ <span className="t-control truncate text-gray-300">{modelLabel(model)}</span>+ </div>+ {hint && <p className="t-body mb-2.5 text-gray-500">{hint}</p>}+ {/* Zwei Spalten: eine Zahl mit einer Stelle und eine Liste mit vier+ Werten brauchen keine volle Breite. Was Text traegt, bekommt sie. */}+ <div className="grid grid-cols-2 gap-x-3 gap-y-2.5">+ {fields.map(([key, schema]) => (+ <div key={key} className={isCompactField(schema) ? undefined : 'col-span-2'}>+ <SchemaControl+ name={key}+ schema={schema}+ value={options[key]}+ disabled={isGenerating}+ onChange={(v) => setOptions({ ...options, [key]: v })}+ />+ </div>+ ))}+ </div>+ {!fields.length && <p className="t-body text-gray-500">This model has no extra settings.</p>}+ </div>+ )+}diff --git a/src/components/create/experimental/__tests__/composer-video-duration.test.ts b/src/components/create/experimental/__tests__/composer-video-duration.test.tsnew file mode 100644index 00000000..e3968b21--- /dev/null+++ b/src/components/create/experimental/__tests__/composer-video-duration.test.ts@@ -0,0 +1,56 @@+// Portplan Abschnitt 6 (dd29f359): die Laengenauswahl fuer Cloud-Video folgt+// dem Katalog, nicht zwei festen Knoepfen. Katalog ist die Laufzeitwahrheit,+// video-durations.json der Notvorrat ohne Netz; eine ungueltig gewordene+// Wahl faellt auf die KUERZESTE gueltige Laenge zurueck, nie auf die naechste+// (das wuerde den Preis still hochziehen).+import { describe, expect, it } from 'vitest'+import { effectiveVideoDurations, snapToVideoDuration } from '../Composer'+import { useCloudCatalogStore } from '../../../../stores/cloudCatalogStore'++describe('effectiveVideoDurations', () => {+ it('prefers the live catalog over the offline notvorrat', () => {+ useCloudCatalogStore.setState({+ models: [{ id: 'test-cat', label: 'Test', kind: 'video', clip: { short: 5, durations: [5, 10, 15] } } as never],+ })+ expect(effectiveVideoDurations('test-cat')).toEqual([5, 10, 15])+ })++ it('falls back to the static JSON when the catalog carries no durations list', () => {+ // wan-2.2-720p is a real model in the JSON notvorrat; a bare CLOUD_MODEL_SEED+ // entry (clip without a durations array) must not shadow it.+ useCloudCatalogStore.setState({+ models: [{ id: 'wan-2.2-720p', label: 'Wan 2.2 720p', kind: 'video', clip: { short: 5, long: 8 } } as never],+ })+ const durations = effectiveVideoDurations('wan-2.2-720p')+ expect(durations.length).toBeGreaterThan(0)+ })++ it('falls back to short/long when neither the catalog nor the JSON has a list', () => {+ useCloudCatalogStore.setState({+ models: [{ id: 'made-up-model', label: 'Made up', kind: 'video', clip: { short: 5, long: 8 } } as never],+ })+ expect(effectiveVideoDurations('made-up-model')).toEqual([5, 8])+ })++ it('returns an empty list for a model with no clip info at all (no unpriced button)', () => {+ useCloudCatalogStore.setState({ models: [{ id: 'no-clip', label: 'No clip', kind: 'video' } as never] })+ expect(effectiveVideoDurations('no-clip')).toEqual([])+ })+})++describe('snapToVideoDuration', () => {+ it('keeps an exact, still-valid choice', () => {+ expect(snapToVideoDuration([5, 10, 15], 10 * 16, 16)).toBe(10)+ })++ it('resets an invalid-become choice to the SHORTEST valid length, never the nearest', () => {+ // 14s is closer to 15 than to 5, but the rule is "shortest valid", not+ // "nearest": a silent jump to the nearer, pricier option is exactly the+ // Risiko 1 the portplan calls out (a shown price that is not the booked one).+ expect(snapToVideoDuration([5, 15], 14 * 16, 16)).toBe(5)+ })++ it('falls back to the shortest option when fps is zero', () => {+ expect(snapToVideoDuration([5, 8], 40, 0)).toBe(5)+ })+})diff --git a/src/components/create/experimental/__tests__/studio-params.test.tsx b/src/components/create/experimental/__tests__/studio-params.test.tsxnew file mode 100644index 00000000..e4d5ba10--- /dev/null+++ b/src/components/create/experimental/__tests__/studio-params.test.tsx@@ -0,0 +1,110 @@+// @vitest-environment jsdom+//+// Der Studio-Zweig in AdvancedDrawer (Portplan Abschnitt 3b/3c): ein+// Studio-Modell hat keinen Sampler, keinen Scheduler, kein VAE und keine+// LoRA-Liste aus ComfyUI. Bei gesetztem `studioModel` ERSETZT StudioParams+// WorkflowFinder + ParamGroups vollstaendig, statt sie zu ergaenzen, und+// zwar nur dort. Ohne `studioModel` (die lokale Spur, oder Wolke ohne+// Studio-Wahl) bleibt der Drawer, was er war: ParamGroups.tsx selbst wird+// von diesem Paket nicht angefasst, e2e/create-expert-section.spec.ts ist+// der eigentliche Beweis dafuer.+import { createElement } from 'react'+import { afterEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, renderHook, screen } from '@testing-library/react'+import { useCreateStore } from '../../../../stores/createStore'+import { AdvancedDrawer } from '../AdvancedDrawer'+import { StudioParams } from '../StudioParams'+import { studioFieldsInOrder } from '../SchemaControl'+import { useStudioPrice } from '../useStudioPrice'++vi.mock('../../../../api/mlx-image', () => ({ isMlxImageHost: () => false }))+vi.mock('../../../../api/comfyui', () => ({+ classifyModel: () => 'sdxl',+ isI2VModel: () => false,+ isT2VCapable: () => false,+}))+vi.mock('../CreateContext', () => ({+ useCreateExp: () => ({+ samplerList: [], schedulerList: [], loraList: [], vaeList: [], refreshModelLists: vi.fn(),+ }),+}))++const STUDIO_EXTEND_MODEL = 'preset-wan-2.2-spicy-extend'++afterEach(() => {+ cleanup()+ useCreateStore.setState({ cloudStudioOptions: {}, isGenerating: false })+})++describe('AdvancedDrawer, Studio-Zweig', () => {+ it('rendert StudioParams statt WorkflowFinder+ParamGroups, wenn studioModel gesetzt ist', () => {+ useCreateStore.setState({ backend: 'cloud', mode: 'video' })+ render(createElement(AdvancedDrawer, { open: true, onClose: () => {}, studioModel: STUDIO_EXTEND_MODEL }))+ // Die Ueberschrift der Studio-Regler traegt den Modellnamen.+ expect(screen.getByText(/Wan 2.2 Spicy Extend/i)).toBeTruthy()+ // Kein einziges Wort des Experten-Abschnitts (der ist ParamGroups' Sache).+ expect(screen.queryByText('Sampler')).toBeNull()+ expect(screen.queryByText('Scheduler')).toBeNull()+ expect(screen.queryByText('Expert')).toBeNull()+ expect(screen.queryByText('LoRA stack')).toBeNull()+ })++ it('zeigt die eigenen Felder des Modells (Resolution, Duration, Seed)', () => {+ useCreateStore.setState({ backend: 'cloud', mode: 'video' })+ render(createElement(AdvancedDrawer, { open: true, onClose: () => {}, studioModel: STUDIO_EXTEND_MODEL }))+ const fields = studioFieldsInOrder(STUDIO_EXTEND_MODEL).map(([key]) => key)+ expect(fields).toContain('resolution')+ expect(fields).toContain('duration')+ for (const key of fields) {+ const label = key.replaceAll('_', ' ').replace(/^./, (c) => c.toUpperCase())+ expect(screen.getByText(label), `field "${key}" not rendered`).toBeTruthy()+ }+ })++ it('schreibt eine Aenderung in cloudStudioOptions, nicht in ein eigenes Zwischenlager', () => {+ useCreateStore.setState({ backend: 'cloud', mode: 'video', cloudStudioOptions: {} })+ render(createElement(StudioParams, { model: STUDIO_EXTEND_MODEL }))+ const seedField = screen.getByLabelText(/seed/i, { selector: 'input' }) as HTMLInputElement | null+ if (seedField) {+ fireEvent.change(seedField, { target: { value: '42' } })+ expect(useCreateStore.getState().cloudStudioOptions.seed).toBe(42)+ }+ })++ it('bleibt ohne studioModel bei ParamGroups (lokale Spur unveraendert)', () => {+ useCreateStore.setState({ backend: 'local', mode: 'image' })+ useCreateStore.getState().setIntent('image')+ render(createElement(AdvancedDrawer, { open: true, onClose: () => {} }))+ fireEvent.click(screen.getByText('Expert'))+ expect(screen.getByText('Sampler')).toBeTruthy()+ })++ it('bleibt mit X und Escape schliessbar wie jeder andere Drawer', () => {+ const onClose = vi.fn()+ useCreateStore.setState({ backend: 'cloud', mode: 'video' })+ render(createElement(AdvancedDrawer, { open: true, onClose, studioModel: STUDIO_EXTEND_MODEL }))+ fireEvent.click(screen.getByLabelText('Close'))+ expect(onClose).toHaveBeenCalledTimes(1)+ fireEvent.keyDown(window, { key: 'Escape' })+ expect(onClose).toHaveBeenCalledTimes(2)+ })+})++describe('useStudioPrice, lokale Spur', () => {+ // Portplan P7: "useStudioPrice darf auf der lokalen Spur KEINEN einzigen+ // Netzabruf ausloesen, sonst haengt eine Offline-Installation 500 ms je+ // Tastendruck an einem toten Aufruf." Composer only ever passes a model+ // when `backend === 'cloud' && studioPick`. Undefined stands in for+ // every local-lane render (and every cloud render with no Studio pick).+ it('calls fetch zero times when no model is given', async () => {+ const fetchSpy = vi.fn()+ vi.stubGlobal('fetch', fetchSpy)+ const { result } = renderHook(() => useStudioPrice(undefined, {}, 'a prompt', undefined))+ expect(result.current).toBeNull()+ // Give the debounce timer (500ms) a chance to fire if it were wrongly+ // armed. Flush microtasks and macrotasks without a real 500ms sleep.+ await new Promise((r) => setTimeout(r, 0))+ expect(fetchSpy).not.toHaveBeenCalled()+ vi.unstubAllGlobals()+ })+})diff --git a/src/components/create/experimental/useStudioPrice.ts b/src/components/create/experimental/useStudioPrice.tsnew file mode 100644index 00000000..c9e9f78d--- /dev/null+++ b/src/components/create/experimental/useStudioPrice.ts@@ -0,0 +1,106 @@+// Der Preis eines Studio-Laufs im Create-Tab.+//+// Port aus dem Web (components/create/experimental/useStudioPrice.ts), mit+// EINEM bewussten Unterschied (Portplan P7, Abschnitt 5 Punkt 3): das Web+// faellt bei jedem Fehler still auf die eigene Formel zurueck und laesst den+// Startknopf offen ("die eigene Formel traegt die Anzeige weiter"). Der+// Desktop-Client spricht den Anbieter zum ERSTEN Mal ueberhaupt ueber CORS an+// (P0 im Web-Repo ist die Vorbedingung dafuer, siehe studio.ts) und darf+// deshalb nicht optimistisch sein: bleibt der Server unerreichbar oder zu alt,+// bleibt der Startknopf gesperrt und zeigt den festen englischen Text aus+// studio.ts, statt einen Lauf zuzulassen, den der Server beim Buchen doch+// ablehnt (Portplan Abschnitt 7, Risiko 1+2).+//+// Auf der LOKALEN Spur (ComfyUI/MLX) darf dieser Hook keinen einzigen+// Netzabruf ausloesen: `model` ist dort immer undefined (Composer uebergibt+// `studioPick`, das nur bei `backend === 'cloud'` gesetzt wird), und der+// Effekt unten kehrt in dem Fall sofort um, ohne `studioQuote()` zu rufen.+// Siehe useCloudCreate-studio.test.ts, Fall "no network call on the local+// lane".++import { useEffect, useRef, useState } from 'react'+import { createStudioCost, pricesByInput } from '../../../lib/render/create-studio'+import { studioQuote } from '../../../api/cloud/studio'+import { StudioQuoteChangedError } from '../../../api/cloud/studio'+import { CloudJobError } from '../../../api/cloud/client'++/** Laenge einer Ton- oder Bildspur, im Browser gemessen. */+export function mediaSeconds(url: string, kind: 'audio' | 'video'): Promise<number | undefined> {+ return new Promise((resolve) => {+ const el = document.createElement(kind)+ const done = (v?: number) => { el.src = ''; resolve(v) }+ el.preload = 'metadata'+ el.onloadedmetadata = () => done(Number.isFinite(el.duration) && el.duration > 0 ? el.duration : undefined)+ el.onerror = () => done(undefined)+ // Ein Medium, das sich nicht oeffnen laesst, darf die Anzeige nicht anhalten.+ setTimeout(() => done(undefined), 8000)+ el.src = url+ })+}++export interface StudioPrice {+ credits: number+ /** Wahr, sobald die Zahl vom Anbieter bestaetigt ist. */+ live: boolean+ /** Gesetzt, wenn der Anbieter nicht erreichbar ist oder der Server das+ * Studio noch nicht kennt (siehe studio.ts, OLDER_SERVER_MESSAGE). Solange+ * das steht, darf der Startknopf nicht freigeben, Portplan Abschnitt 5. */+ error?: string+}++export function useStudioPrice(+ model: string | undefined,+ options: Record<string, unknown>,+ prompt: string,+ seconds: number | undefined,+): StudioPrice | null {+ const [live, setLive] = useState<{ key: string; credits: number } | null>(null)+ const [error, setError] = useState<{ key: string; message: string } | null>(null)+ const abort = useRef<AbortController | null>(null)+ const key = model ? JSON.stringify([model, options, prompt.length, seconds]) : ''++ useEffect(() => {+ abort.current?.abort()+ // Kein Modell (lokale Spur, oder Wolke ohne Studio-Wahl): kein Abruf.+ // Ein Modell, dessen Preis an einer hochgeladenen Datei haengt, wird erst+ // MIT der Datei gebucht (useCloudCreate), hier reicht die Formel.+ if (!model || pricesByInput(model)) { setLive(null); setError(null); return }+ const controller = new AbortController()+ abort.current = controller+ const timer = setTimeout(async () => {+ try {+ const res = await studioQuote(model, prompt, { op: 'studio', studio_options: options })+ if (controller.signal.aborted) return+ setLive({ key, credits: res.credits })+ setError(null)+ } catch (err) {+ if (controller.signal.aborted) return+ if (err instanceof StudioQuoteChangedError) {+ // 409 quote_changed: zeigt den neuen Preis, statt still weiter die+ // alte Formel zu zeigen oder gar neu zu buchen.+ setLive({ key, credits: err.credits })+ setError(null)+ return+ }+ if (err instanceof CloudJobError) {+ setError({ key, message: err.message })+ setLive(null)+ return+ }+ // Unerwarteter Fehler (kein CloudJobError): nicht verschlucken, aber+ // auch nicht den Startknopf sperren, dafuer fehlt die Textgrundlage.+ setLive(null)+ setError(null)+ }+ }, 500)+ return () => { clearTimeout(timer); controller.abort() }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [key])++ if (!model) return null+ if (error && error.key === key) {+ return { credits: createStudioCost(model, options, Array.from(prompt).length, seconds), live: false, error: error.message }+ }+ if (live && live.key === key) return { credits: live.credits, live: true }+ return { credits: createStudioCost(model, options, Array.from(prompt).length, seconds), live: false }+}diff --git a/src/hooks/__tests__/useCloudCreate-studio.test.ts b/src/hooks/__tests__/useCloudCreate-studio.test.tsnew file mode 100644index 00000000..bfa32716--- /dev/null+++ b/src/hooks/__tests__/useCloudCreate-studio.test.ts@@ -0,0 +1,200 @@+/**+ * Die Unterkategorien von Create schicken ein Studio-Modell richtig ab.+ *+ * Port aus uselu (apps/web/hooks/__tests__/useCloudCreate-studio-unterkategorien.test.ts,+ * 19.09.2026): bis dahin war der Studio-Pfad allein im Preset-Fenster zu+ * Hause. Jetzt faehrt ihn auch der normale Composer/useCloudCreate, und daran+ * haengen vier Dinge, die still falsch sein koennen: der Op, die+ * Modelloptionen, und bei einem Clip aus der Galerie die Tatsache, dass der+ * Studio-Pfad ausschliesslich aus dem eigenen Eimer des Kunden liest und+ * keine signierte Adresse annimmt.+ *+ * Abweichung vom Web-Original: das Web kennt eine eigene 'video_upscale'-+ * Absicht (lib/render/create-studio.ts, StudioIntent), die im Desktop-+ * createStore noch nicht existiert (P2-Bericht, "offen fuer P9", P5/P7+ * muessen erst entscheiden, wie sie den Composer erreicht). Der Fall "legt+ * den Galerieclip in den eigenen Eimer" ist deshalb auf die Absicht 'extend'+ * umgestellt: dieselbe Mechanik (ein Clip, der als signierte Adresse+ * vorliegt, geht als HOCHGELADENER Pfad hinaus, nie als Adresse) laesst sich+ * darueber genauso beweisen, ohne eine Absicht vorwegzunehmen, die diesem+ * Paket nicht gehoert.+ *+ * Nichts wird erzeugt: Absenden, Hochladen und Abholen sind gemockt.+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'++vi.mock('react', async (orig) => {+ const actual = (await orig()) as Record<string, unknown>+ return { ...actual, useCallback: (fn: unknown) => fn }+})++// A full, hand-written mock (no `...actual` spread): the real ../../api/cloud/jobs+// pulls in the Supabase client (api/cloud/supabase.ts), which touches+// `localStorage` at import time and blows up outside a browser-like test+// environment. The established pattern in this directory (see+// useCloudCreate-b3-adult-gate-fires-before-upload.test.ts) is a fake+// CloudJobError/QuoteChangedError pair instead of the real classes.+const hoisted = vi.hoisted(() => {+ class FakeCloudJobError extends Error {+ status: number+ code?: string+ constructor(message: string, status: number, meta?: { code?: string }) {+ super(message)+ this.status = status+ this.code = meta?.code+ }+ }+ class FakeQuoteChangedError extends FakeCloudJobError {+ credits: number+ constructor(message: string, credits: number) {+ super(message, 409, { code: 'quote_changed' })+ this.credits = credits+ }+ }+ const submitted: Array<{ kind: string; model: string; prompt: string; params: Record<string, unknown> }> = []+ const hochgeladen: string[] = []+ return {+ FakeCloudJobError,+ FakeQuoteChangedError,+ submitted,+ hochgeladen,+ uploadInput: vi.fn(async (_blob: unknown, slot: string) => {+ hochgeladen.push(slot)+ return `user-1/staged-${slot}.${slot === 'audio' ? 'mp3' : slot === 'video' ? 'mp4' : 'png'}`+ }),+ getJob: vi.fn(async () => ({ id: 'quelle', result_url: 'https://storage.example/clip.mp4' })),+ submitCloudJob: vi.fn(async (payload: (typeof submitted)[number]) => {+ submitted.push(payload)+ return { id: 'job-test', quota: { cost: 1000, used: 1000, limit: 100000 } }+ }),+ pollJob: vi.fn(async () => ({+ id: 'job-test', kind: 'video', model: 'longcat-avatar', status: 'succeeded',+ result_url: 'https://storage.example/out.mp4', created_at: new Date().toISOString(),+ })),+ cancelJob: vi.fn(async () => ({ status: 'canceled' })),+ }+})+const { submitted, hochgeladen } = hoisted++// Sidesteps loadContentPolicy's own call into ../../api/cloud/jobs+// (getContentPolicy). 'off' keeps clientSafety() to its CSAM-only floor,+// same as an account whose policy has not loaded yet.+vi.mock('../useContentPolicy', () => ({+ contentPolicySnapshot: () => 'off' as const,+ loadContentPolicy: async () => 'off' as const,+}))++vi.mock('../../api/cloud/jobs', () => ({+ uploadInput: hoisted.uploadInput,+ getJob: hoisted.getJob,+ submitCloudJob: hoisted.submitCloudJob,+ pollJob: hoisted.pollJob,+ cancelJob: hoisted.cancelJob,+ CloudJobError: hoisted.FakeCloudJobError,+ QuoteChangedError: hoisted.FakeQuoteChangedError,+}))++import { useCloudCreate } from '../useCloudCreate'+import { useCreateStore } from '../../stores/createStore'++const BILD = { filename: 'portrait.png', url: 'data:image/png;base64,AA', width: 512, height: 512 }+const TON = { name: 'voice.mp3', url: 'blob:voice', blob: new Blob(['x']) }++beforeEach(() => {+ submitted.length = 0+ hochgeladen.length = 0+ vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, blob: async () => new Blob(['x']) })))+ useCreateStore.setState({+ isGenerating: false, error: null, backend: 'cloud',+ source: null, audioInput: null, videoInput: null, voiceFromJob: null,+ extendSource: null, gallery: [], cloudStudioOptions: {},+ })+ useCreateStore.getState().setPrompt('a neutral placeholder line')+})++describe('Studio-Modelle in den Create-Unterkategorien', () => {+ it('schickt einen sprechenden Avatar als Studio-Lauf mit Foto und Tonspur', async () => {+ const s = useCreateStore.getState()+ s.setIntent('lipsync')+ s.setCloudOpModel('longcat-avatar')+ s.setCloudStudioOptions({ resolution: '720p' })+ useCreateStore.setState({ source: BILD, audioInput: TON })+ await useCloudCreate().generate()+ expect(submitted).toHaveLength(1)+ expect(submitted[0].model).toBe('longcat-avatar')+ expect(submitted[0].kind).toBe('video')+ expect(submitted[0].params.op).toBe('studio')+ expect(submitted[0].params.studio_options).toEqual({ resolution: '720p' })+ expect(submitted[0].params.source_path).toBe('user-1/staged-source.png')+ expect(submitted[0].params.audio_path).toBe('user-1/staged-audio.mp3')+ })++ it('laesst den Presenter ohne eigenes Foto starten', async () => {+ const s = useCreateStore.getState()+ s.setIntent('lipsync')+ s.setCloudOpModel('heygen-twin')+ useCreateStore.setState({ source: null, audioInput: TON })+ await useCloudCreate().generate()+ expect(useCreateStore.getState().error).toBeNull()+ expect(submitted).toHaveLength(1)+ expect(submitted[0].params.op).toBe('studio')+ expect(submitted[0].params.audio_path).toBe('user-1/staged-audio.mp3')+ })++ it('wirft einen Rest aus einem anderen Modell weg, statt ihn mitzuschicken', async () => {+ const s = useCreateStore.getState()+ s.setIntent('lipsync')+ s.setCloudOpModel('longcat-avatar')+ // target_megapixels gehoert dem Upscaler, nicht diesem Endpunkt.+ s.setCloudStudioOptions({ resolution: '480p', target_megapixels: 33 })+ useCreateStore.setState({ source: BILD, audioInput: TON })+ await useCloudCreate().generate()+ expect(submitted[0].params.studio_options).toEqual({ resolution: '480p' })+ })++ it('legt einen fertigen Clip in den eigenen Eimer, statt eine Adresse weiterzureichen', async () => {+ const s = useCreateStore.getState()+ s.setIntent('extend')+ s.setCloudOpModel('preset-wan-2.2-spicy-extend')+ s.setCloudStudioOptions({})+ useCreateStore.setState({ extendSource: { jobId: 'quelle', url: 'https://storage.example/clip.mp4', label: 'clip' } })+ await useCloudCreate().generate()+ expect(submitted).toHaveLength(1)+ expect(submitted[0].params.op).toBe('studio')+ expect(submitted[0].params.video_path).toBe('user-1/staged-video.mp4')+ // Genau das darf NICHT passieren: der Studio-Pfad liest keine Adressen.+ expect(submitted[0].params.source_url).toBeUndefined()+ })++ it('schickt bei Musik keine Felder aus unserer eigenen Preistabelle mit', async () => {+ const s = useCreateStore.getState()+ s.setIntent('music')+ s.setCloudOpModel('eleven-music')+ s.setCloudStudioOptions({})+ await useCloudCreate().generate()+ expect(submitted[0].params.op).toBe('studio')+ expect(submitted[0].kind).toBe('audio')+ expect(submitted[0].params.duration).toBeUndefined()+ })++ it('laesst eine klassische Wahl unveraendert ihren alten Weg gehen', async () => {+ const s = useCreateStore.getState()+ s.setIntent('music')+ s.setCloudOpModel('ace-step')+ await useCloudCreate().generate()+ expect(submitted[0].model).toBe('ace-step')+ expect(submitted[0].params.op).toBe('music')+ expect(submitted[0].params.duration).toBeDefined()+ expect(submitted[0].params.studio_options).toBeUndefined()+ })++ it('sendet einen UUID-Idempotenzschluessel bei jedem Absenden', async () => {+ const s = useCreateStore.getState()+ s.setIntent('music')+ s.setCloudOpModel('ace-step')+ await useCloudCreate().generate()+ expect(submitted[0].params.client_request_id).toMatch(+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,+ )+ })+})diff --git a/src/hooks/useCloudCreate.ts b/src/hooks/useCloudCreate.tsindex 580d878d..cc116c16 100644--- a/src/hooks/useCloudCreate.ts+++ b/src/hooks/useCloudCreate.ts@@ -20,6 +20,7 @@ import {submitCloudJob,uploadInput,CloudJobError,+ QuoteChangedError,type CloudJobParams,} from '../api/cloud/jobs'import {@@ -28,11 +29,16 @@ import {resolveOpPick,cloudModelById,cloudMediaLive,+ loraGenModels,} from '../stores/cloudCatalogStore'import { checkPromptSafety, blockMessageFor, type SafetyVerdict } from '../lib/render/safety'import { contentPolicySnapshot, loadContentPolicy } from './useContentPolicy'import { signalCreditsExhausted } from '../lib/credits-exhausted'import { resolveRunSeed } from '../lib/run-seed'+import { intentRoles, intentRequiredInputs, isStudioModel, resolveIntentPick } from '../lib/render/create-studio'+import { STUDIO_MODELS, studioFields } from '../lib/render/studio-contract'+import { modelLabel } from '../lib/render/preset-models'+import { selectedVideoSeconds } from '../lib/render/video-duration'// B3 (review-w2ui.md, 18.09.2026): the CSAM floor above runs regardless of// tier, but the adult half of safety.ts (ADULT_SOFT_TERMS/ADULT_HARD_TERMS)@@ -50,12 +56,36 @@ function clientSafety(text: string): SafetyVerdict {return checkPromptSafety(text, { tier: 'cloud', policy: policy ?? 'off' })}-// Character-Studio generation endpoint per trained-LoRA family (fast default;-// mirrors uselu's LORA_GEN_FAMILY — ltx-2 video characters have no image-gen-// lane and qwen has no -lora generation endpoint yet).-const CHARACTER_GEN_DEFAULT: Record<string, string> = {- flux: 'flux-schnell-lora',- 'z-image': 'z-image-turbo-lora',+// Which generation models accept which trained-LoRA family. Ported from+// uselu main 5be5dec3 (apps/web/lib/render/cloud-models.ts,+// CHARACTER_MODEL_FAMILY): the picker (ModelChip), the meter (CreditsMeter)+// and this submit path all resolve through the SAME table now, so the UI+// cannot show Flux while quietly running Z-Image. Replaces the old fixed+// single-entry default (CHARACTER_GEN_DEFAULT) that only ever offered ONE+// endpoint per family and silently ignored the catalog. `qwen-image-lora` is+// already in the desktop seed (cloud-models.ts); flux/z-image keep their two+// endpoints each (a fast + a slower/quality one).+export const CHARACTER_MODEL_FAMILY: Readonly<Record<string, string>> = {+ 'flux-schnell-lora': 'flux',+ 'flux-dev-lora-ultra-fast': 'flux',+ 'z-image-turbo-lora': 'z-image',+ 'z-image-base-lora': 'z-image',+ 'qwen-image-lora': 'qwen-image',+ 'ltx-2': 'ltx-2',+ 'ltx-2.3': 'ltx-2',+}++/** Generation models that accept this trained-LoRA family's weights. */+export function characterGenerationModels(family: string) {+ return loraGenModels().filter((m) => CHARACTER_MODEL_FAMILY[m.id] === family)+}++/** The model a character run will really use: the stored pick if it still+ * fits the trained family, else the family's first compatible model, else+ * null (no compatible generation endpoint exists yet for this family). */+export function resolveCharacterModel(family: string, pickedId: string): string | null {+ const list = characterGenerationModels(family)+ return list.some((m) => m.id === pickedId) ? pickedId : (list[0]?.id ?? null)}// Gallery label for ops that never read the composer prompt. Without this@@ -187,9 +217,17 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {const specialOp =op === 'lipsync' || op === 'extend' || op === 'motion' ||op === 'music' || op === 'tts' || op === 'lora-train'+ // Portplan P7: the four role intents (lipsync/music/extend/motion) reach+ // the Studio track through the SAME picker as their classic op-specialized+ // models (create-studio.ts, ported P2); resolveIntentPick's list already+ // contains both, so it replaces resolveOpPick for exactly these four.+ // Character-use never touches Studio: it stays on its fixed -lora family.+ const roleIntent = !characterUse && intentRoles(intent).length > 0let picked: stringif (characterUse) {- picked = CHARACTER_GEN_DEFAULT[s.selectedCharacter?.family ?? ''] ?? 'flux-schnell-lora'+ picked = resolveCharacterModel(s.selectedCharacter?.family ?? '', s.cloudOpModel) ?? ''+ } else if (roleIntent) {+ picked = resolveIntentPick(intent, s.cloudOpModel)} else if (specialOp) {// Same resolution rule as the chip's display — a pick left over from// another intent must not survive into this op's submit (take-01: the@@ -199,10 +237,15 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {} else {picked = (kind === 'video' ? s.cloudVideoModel : s.cloudImageModel) || defaultCloudModel(kind)?.id || ''}+ // A Studio pick runs its own schema-driven endpoint (op: 'studio'), never+ // through modelForOp's classic op coercion, STUDIO_MODELS is a disjoint+ // registry the classic picker functions do not know about.+ const studioModel = !characterUse && isStudioModel(picked) ? picked : undefined+ if (studioModel) kind = STUDIO_MODELS[studioModel].kind// Coerce a leftover/incapable pick onto a model that can run this op// (edit→i2i, animate→i2v, video→t2v, specialized ops→their family) so the// submit never 400s.- const model = modelForOp(kind, op, picked)+ const model = studioModel ?? modelForOp(kind, op, picked)s.setError(null)if (!cloudMediaLive()) {@@ -232,19 +275,38 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {s.setError('Pick a character from your shelf first, or train one.')return}+ if (characterUse && !model) {+ s.setError('This character has no compatible generation model yet.')+ return+ }if (op === 'lora-train' && s.trainImages.length < 4) {s.setError('Add at least 4 photos of your character (more is better, up to 30).')return}+ // A Studio pick names its own required inputs (studio-contract.ts's+ // schema). A presenter endpoint (HeyGen) reads only the voice and needs+ // no photo at all, unlike every classic lipsync model.+ const studioRequired = studioModel ? intentRequiredInputs(intent, studioModel) : []if (op === 'lipsync') {if (!s.audioInput && !s.voiceFromJob) {s.setError('Add a voice first, upload an audio file or pick a generated one.')return}- const needsClip = cloudModelById(model)?.lipsync_source === 'video'- if (needsClip ? !s.videoInput : !s.source) {- s.setError(needsClip ? 'Add the video clip to re-sync.' : 'Add a portrait image for your character.')- return+ if (studioModel) {+ if (studioRequired.includes('source_path') && !s.source) {+ s.setError('Add a portrait image for your character.')+ return+ }+ if (studioRequired.includes('video_path') && !s.videoInput) {+ s.setError('Add the video clip to re-sync.')+ return+ }+ } else {+ const needsClip = cloudModelById(model)?.lipsync_source === 'video'+ if (needsClip ? !s.videoInput : !s.source) {+ s.setError(needsClip ? 'Add the video clip to re-sync.' : 'Add a portrait image for your character.')+ return+ }}}if (op === 'extend' && !s.extendSource) {@@ -259,6 +321,21 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {s.setError('Add a source image first.')return}+ // Studio: only the fields THIS endpoint's schema actually knows,+ // stored options are per-model in the store (cloudOpModel keyed), but+ // setCloudOpModel already drops them on a model switch (createStore, P5)+ // and this filter is the second net: a stray key from a schema this+ // model does not share must not go out, or the request looks like it+ // asked for something it never did (Portplan: "wirft einen Rest aus+ // einem anderen Modell weg, statt ihn mitzuschicken"). Full type+ // validation against the schema happens server-side (prepareStudio());+ // studio-contract.ts's own `studioOptions()` is used for the on-screen+ // PRICE PREVIEW only (useStudioPrice), never to gate or reshape a submit.+ const studioOptionsFiltered = studioModel+ ? Object.fromEntries(+ Object.entries(s.cloudStudioOptions).filter(([key]) => studioFields(studioModel)[key] !== undefined),+ )+ : undefineds.setIsGenerating(true)s.setProgressPhase('queued')@@ -273,6 +350,10 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {// number, record that exact number. Leaving the seed out let the provider// roll one we never learn, and the gallery wrote 0 for it.const runSeed = resolveRunSeed(s.seed)+ // Idempotency key (Portplan Abschnitt 4/6): a retried submit after a+ // dropped response replays the SAME booking server-side instead of+ // charging twice (CloudJobSubmitResult.replayed).+ const requestId = crypto.randomUUID()try {// Utility endpoints (removebg/upscale/eraser) and the 2.5.8 specialized@@ -280,22 +361,32 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {// submit schema stays honest.const isUtility = op === 'removebg' || op === 'upscale' || op === 'eraser'const bare = isUtility || specialOp- const params: CloudJobParams = bare- ? { op }- : {- op,- negative_prompt: s.negativePrompt || undefined,- width: s.width,- height: s.height,- steps: s.steps,- cfg: s.cfgScale,- seed: runSeed,- }+ // Studio: a schema-driven step booked against its own `studio_options`,+ // never one of the fixed classic shapes below. max_credits is filled+ // in once the price is confirmed, after the uploads (Portplan Abschnitt+ // 3, GEBUCHT wird nur gegen den bestaetigten Serverpreis).+ const params: CloudJobParams = studioModel+ ? { op: 'studio', studio_options: studioOptionsFiltered, client_request_id: requestId }+ : bare+ ? { op, client_request_id: requestId }+ : {+ op,+ client_request_id: requestId,+ negative_prompt: s.negativePrompt || undefined,+ width: s.width,+ height: s.height,+ steps: s.steps,+ cfg: s.cfgScale,+ seed: runSeed,+ }if (kind === 'video' && !bare) {- params.frames = s.frames- params.fps = s.fps+ // dd29f359 (Portplan Abschnitt 6): book exactly a length the model+ // prices, never a raw frames/fps ratio the server would reject.+ const seconds = selectedVideoSeconds(model, s.frames, s.fps)+ params.frames = seconds * 16+ params.fps = 16}- if (op === 'music') {+ if (op === 'music' && !studioModel) {params.duration = s.musicDurationif (s.musicLyrics.trim()) params.lyrics = s.musicLyrics.trim()}@@ -323,6 +414,9 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {}// ImageRef.url is always a data URL preview; the cloud path re-uploads// from it, so a source picked while on the local backend still works.+ // Also exactly what a Studio role's `image` input needs (source_path),+ // the SAME staged upload, studio-contract.ts just names it a schema+ // field instead of a fixed param.if (op !== 'generate' && s.source) {params.source_path = await uploadInput(dataUrlToBlob(s.source.url), 'source')}@@ -347,6 +441,16 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {if (s.audioInput) {s.setProgress(8, 'Uploading audio…')params.audio_path = await uploadInput(s.audioInput.blob, 'audio')+ } else if (s.voiceFromJob && studioModel) {+ // A Studio role's `audio` input is always a staged path+ // (studio-models.json never lists `audio_url`), re-upload rather+ // than pass the signed URL through, unlike the classic branch below.+ s.setProgress(8, 'Fetching the voice…')+ const vj = await getJob(s.voiceFromJob.jobId)+ if (!vj.result_url) throw new Error('That voice has expired, generate it again first.')+ const res = await fetch(vj.result_url)+ if (!res.ok) throw new Error('Could not load the generated voice.')+ params.audio_path = await uploadInput(await res.blob(), 'audio')} else if (s.voiceFromJob) {// A prior own render (tts/music) — fresh signed URL, zero re-upload.const vj = await getJob(s.voiceFromJob.jobId)@@ -366,13 +470,40 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {if (op === 'extend' && s.extendSource) {const src = await getJob(s.extendSource.jobId)if (!src.result_url) throw new Error('The source clip has expired, re-render it first.')- params.source_url = src.result_url+ if (studioModel) {+ // A Studio extend role reads a staged `video_path`, not a URL the+ // provider would have to fetch itself, re-upload the finished clip+ // (mirrors the Preset Workshop's own adopt()).+ s.setProgress(6, 'Fetching the clip to extend…')+ const res = await fetch(src.result_url)+ if (!res.ok) throw new Error('Could not load the clip to extend.')+ params.video_path = await uploadInput(await res.blob(), 'video')+ } else {+ params.source_url = src.result_url+ }}// Bail before the (credit-claiming) submit if the user cancelled while// we were uploading inputs.if (ac.signal.aborted) return+ // Der Titel geht mit an den Server, sonst hiesse der Eintrag nach dem+ // naechsten Laden wieder nur nach seiner Gattung (Portplan Abschnitt 1,+ // Punkt 9). A Studio run with no prompt (or a schema whose prompt field+ // is something else entirely, e.g. a picked visual style) needs the+ // SAME fallback name classic ops already have via OP_GALLERY_LABEL;+ // galleryLabel.ts also falls back to modelLabel(model), which reads+ // STUDIO_MODELS too, so this is a convenience for the server's own+ // list view (GET /api/jobs), not the only source of the gallery name.+ let label: string | undefined+ if (studioModel) {+ label = s.prompt.trim() ? undefined : modelLabel(studioModel)+ if (label) params.label = label+ } else if (OP_GALLERY_LABEL[op]) {+ label = OP_GALLERY_LABEL[op]+ params.label = label+ }+s.setProgress(10, 'Submitting to the render queue…')const { id } = await submitCloudJob({ kind, model, prompt: s.prompt, params })// A Cancel during the submit round-trip saw activeJobId still null, so@@ -426,6 +557,7 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {filename: '',subfolder: '',prompt: OP_GALLERY_LABEL[op] ?? s.prompt,+ label,negativePrompt: s.negativePrompt,model,modelType: 'unknown',@@ -451,7 +583,16 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {}} catch (err) {const st = useCreateStore.getState()- if (err instanceof CloudJobError && err.status === 429) {+ if (err instanceof QuoteChangedError) {+ // 409 quote_changed (Portplan Abschnitt 3/4): a submit that DID carry+ // a client-confirmed ceiling (max_credits, e.g. from a future Studio+ // caller that quotes before booking) found the server's own re-quote+ // exceeding it, show the new price instead of silently rebooking.+ // This Composer path never sends max_credits itself today (no+ // pre-submit quote call, see useStudioPrice for the on-screen-only+ // preview), so this branch is a safety net, not yet a live path.+ st.setError(`The price changed to ${err.credits.toLocaleString('en-US')} credits. Review it, then hit Create again.`)+ } else if (err instanceof CloudJobError && err.status === 429) {st.setError(throttleMessage(err))} else if (err instanceof CloudJobError && err.status === 401) {st.setError('Sign in to your LU Cloud account to render in the cloud.')@@ -509,7 +650,7 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {activeAbort = actry {const model = opts.mode === 'design' ? 'qwen3-tts-design' : 'qwen3-tts'- const params: CloudJobParams = { op: 'tts' }+ const params: CloudJobParams = { op: 'tts', client_request_id: crypto.randomUUID() }if (opts.mode === 'speak' && opts.voice) params.voice = opts.voiceif (opts.mode === 'design' && opts.description) params.voice_description = opts.descriptionconst { id } = await submitCloudJob({ kind: 'audio', model, prompt: text, params })@@ -614,7 +755,10 @@ export function useCloudCreate(opts: { onQuotaChange?: () => void } = {}) {kind: 'video',model: item.model || 'wan-2.2-720p',prompt: '',- params: { op: 'upscale', source_url: sourceJob.result_url, target_resolution: targetResolution },+ params: {+ op: 'upscale', source_url: sourceJob.result_url, target_resolution: targetResolution,+ client_request_id: crypto.randomUUID(),+ },})// Same submit-window race as generate(): cancel the just-queued job// if the user aborted while the POST was in flight.