Let saved library stills queue Edit without a format rejection.
Use catalog width/height or aspect fallback in resolveRequestSize, restore GIF/BMP upload messaging, and keep Photo to change still ids across reload so Klein/Qwen Edit can bind imageAId. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1089,7 +1089,12 @@ function addNegative(){
|
||||
}
|
||||
negativeDraft.value=''
|
||||
}
|
||||
function stillById(id:string){return id?stills.value.find((s:any)=>s.id===id)||null:null}
|
||||
function stillById(id:string){
|
||||
if(!id)return null
|
||||
return stills.value.find((s:any)=>s.id===id)
|
||||
|| (library.value.stills||[]).find((s:any)=>s.id===id)
|
||||
|| null
|
||||
}
|
||||
/** Photos array is source of truth — never resurrect cards from leftover imageAId. */
|
||||
function syncPhotosBindings(){
|
||||
const filled=(form.photos||[]).filter((p:any)=>p?.stillId)
|
||||
@@ -1132,11 +1137,15 @@ function setPhotoStill(index:number,stillId:string){
|
||||
if(!Number.isInteger(index)||!form.photos[index])return
|
||||
if(!stillId){
|
||||
form.photos.splice(index,1)
|
||||
}else if(!stillById(stillId)){
|
||||
// Never fill the card with an id that is not in library.stills
|
||||
form.photos[index].stillId=''
|
||||
}else{
|
||||
form.photos[index].stillId=stillId
|
||||
// Prefer a library row; if the picker passed a still object already in library.value, stillById works.
|
||||
// Keep the id when the still is in library.stills (any folder match via merge) so Edit can bind imageAId.
|
||||
const inLibrary=(library.value.stills||[]).some((s:any)=>s.id===stillId)
|
||||
if(!inLibrary && !stillById(stillId)){
|
||||
form.photos[index].stillId=''
|
||||
}else{
|
||||
form.photos[index].stillId=stillId
|
||||
}
|
||||
}
|
||||
syncPhotosBindings()
|
||||
saveBenchDraft(true)
|
||||
@@ -1533,8 +1542,13 @@ function pickAsset(asset:any){
|
||||
else if(key==='startClipId')chooseClip(asset?.id||'')
|
||||
else if(key.startsWith('photo:')){
|
||||
const index=Number(key.slice(6))
|
||||
if(asset?.id)setPhotoStill(index,asset.id)
|
||||
else discardEmptyPhotoDraft(index)
|
||||
if(asset?.id){
|
||||
// Ensure the chosen library still stays in library.stills so the card + imageAId bind
|
||||
if(!(library.value.stills||[]).some((s:any)=>s.id===asset.id)){
|
||||
library.value={...library.value,stills:[{...asset,role:asset.role||'input'},...(library.value.stills||[])]}
|
||||
}
|
||||
setPhotoStill(index,asset.id)
|
||||
}else discardEmptyPhotoDraft(index)
|
||||
}else if(key) form[key]=asset?.id||''
|
||||
picker.value=''
|
||||
pickerRevealAll.value=false
|
||||
@@ -1913,12 +1927,21 @@ async function loadLibraryOnce(){
|
||||
if(form.folderId) qs.set('folderId',form.folderId)
|
||||
const page=await $fetch<any>(`/api/library?${qs.toString()}`)
|
||||
const pageStills=page.stills||[]
|
||||
const keepIds=new Set([
|
||||
const keepIds=[
|
||||
...(form.photos||[]).map((p:any)=>p?.stillId).filter(Boolean),
|
||||
form.imageAId,form.imageBId,form.identityStillId,form.maskId,form.endStillId,
|
||||
...(form.guides||[]).map((g:any)=>g?.stillId).filter(Boolean)
|
||||
].filter(Boolean))
|
||||
const kept=(library.value.stills||[]).filter((s:any)=>keepIds.has(s.id)&&!pageStills.some((p:any)=>p.id===s.id))
|
||||
].filter(Boolean) as string[]
|
||||
let kept=(library.value.stills||[]).filter((s:any)=>keepIds.includes(s.id)&&!pageStills.some((p:any)=>p.id===s.id))
|
||||
const stillMissing=keepIds.filter(id=>!pageStills.some((s:any)=>s.id===id)&&!kept.some((s:any)=>s.id===id))
|
||||
// Draft / upload stills must survive reload even when they fall outside the first page
|
||||
if(stillMissing.length){
|
||||
try{
|
||||
const full=await $fetch<any>('/api/library?light=1')
|
||||
const recovered=(full.stills||[]).filter((s:any)=>stillMissing.includes(s.id))
|
||||
kept=[...kept,...recovered.filter((s:any)=>!kept.some((k:any)=>k.id===s.id))]
|
||||
}catch{/* keep page + in-memory stills */}
|
||||
}
|
||||
library.value={
|
||||
folders:page.folders||library.value.folders||[],
|
||||
stills:[...pageStills,...kept],
|
||||
@@ -1929,11 +1952,13 @@ async function loadLibraryOnce(){
|
||||
loraTriggers:page.loraTriggers||library.value.loraTriggers||{},
|
||||
keepPrompts:page.keepPrompts||library.value.keepPrompts
|
||||
}
|
||||
// Drop filled photo cards whose still left the library
|
||||
const allStills=[...pageStills,...kept]
|
||||
// Drop filled photo cards only when the still is truly gone from the catalog
|
||||
for(let i=(form.photos||[]).length-1;i>=0;i-=1){
|
||||
const id=form.photos[i]?.stillId
|
||||
if(id && !stillById(id)) form.photos[i].stillId=''
|
||||
if(id && !allStills.some((s:any)=>s.id===id)) form.photos[i].stillId=''
|
||||
}
|
||||
syncPhotosBindings()
|
||||
}
|
||||
|
||||
async function fetchHealth(){
|
||||
|
||||
Reference in New Issue
Block a user