diff --git a/shared/studio2/input.mjs b/shared/studio2/input.mjs index 2f79385..e222397 100644 --- a/shared/studio2/input.mjs +++ b/shared/studio2/input.mjs @@ -9,15 +9,17 @@ export function resolveSize(aspect, source, fallback = {width:1344,height:768}) } export function bindClip(form, clip, xaigen = false) { if (!clip?.id) return form - const saved = clip.studio2 || clip.job || {}, settings = saved.settings || clip.settings || clip - const next = {...form, startClipId:clip.id, settings:{...form.settings}} - next.settings.aspect=['auto','16:9','9:16','1:1'].includes(settings.aspect)?settings.aspect:'auto' - for (const key of ['duration','aspect','width','height','fps','loraStack','turbo','steps','cfg']) { - if (settings[key] != null && key!=='aspect') next.settings[key] = structuredClone(settings[key]) + const saved = clip.studio2 || clip.job || {} + const settings = saved.settings || clip.settings || {} + const next = {...form, startClipId:clip.id, mode:'extend', settings:{...form.settings}} + next.settings.aspect=['auto','16:9','9:16','1:1'].includes(settings.aspect)?settings.aspect:(form.settings?.aspect || 'auto') + for (const key of ['duration','width','height','fps','loraStack','turbo','steps','cfg']) { + if (settings[key] == null) continue + try { next.settings[key] = typeof structuredClone === 'function' ? structuredClone(settings[key]) : JSON.parse(JSON.stringify(settings[key])) } + catch { next.settings[key] = settings[key] } } next.engine = xaigen && (saved.engine || clip.engine)==='ltx' ? 'ltx' : 'minimax' if (saved.identityStillId) next.identityStillId = saved.identityStillId - // Missing legacy metadata must not reset a user's current choice. for (const key of ['lockFace','lockOutfit']) if (typeof saved[key] === 'boolean') next[key] = saved[key] return next } @@ -39,9 +41,11 @@ export function restoreAsset(form, item) { return next } export function extendSelected(form, clip, xaigen = false) { - // Switching task on the already bound clip must preserve the user's overrides. - const next=clip?.id && form.startClipId !== clip.id ? bindClip(form,clip,xaigen) : form - return {...next,mode:'extend',engine:xaigen && next.engine==='ltx'?'ltx':'minimax'} + const next = { ...form, mode: 'extend', engine: xaigen && form.engine === 'ltx' ? 'ltx' : 'minimax' } + const target = clip?.id ? clip : null + if (!target?.id) return next + try { return bindClip(next, target, xaigen) } + catch { return { ...next, startClipId: target.id } } } export function changeSource(form) { return form.mode==='extend' ? form : {...form,startClipId:'',settings:{...form.settings,aspect:'auto'}}