Keep library deletes when a still file is locked, and match LoRAs by engine folder.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -362,6 +362,8 @@
|
||||
:folder-id="form.folderId"
|
||||
:preview-hidden="!eyeOpen"
|
||||
:is-hidden="isHidden"
|
||||
:refresh-key="libraryRefreshKey"
|
||||
:hidden-ids="[...forgottenStillIds]"
|
||||
@close="libraryOpen=false"
|
||||
@select="selectOutput"
|
||||
@use-image="onLibraryUseImage"
|
||||
@@ -962,8 +964,14 @@ const gpuChipLabel=computed(()=>{
|
||||
return gpu.value.label || 'GPU ?'
|
||||
})
|
||||
const sourceSlot=computed(()=>{const clip=clips.value.find((a:any)=>a.id===form.startClipId);return form.mode==='extend'?(clip?{...clip,kind:'clip'}:null):inputStill.value})
|
||||
const pickerAssets=computed(()=>picker.value==='startClipId'?clips.value.map((a:any)=>({...a,kind:'clip'})):stills.value.map((a:any)=>({...a,kind:'still'})))
|
||||
const inputStill=computed(()=>stills.value.find((s:any)=>s.id===form.imageAId))
|
||||
const forgottenStillIds=ref(new Set<string>())
|
||||
const libraryRefreshKey=ref(0)
|
||||
const pickerAssets=computed(()=>{
|
||||
const forget=forgottenStillIds.value
|
||||
if(picker.value==='startClipId')return clips.value.filter((a:any)=>!forget.has(a.id)).map((a:any)=>({...a,kind:'clip'}))
|
||||
return stills.value.filter((a:any)=>!forget.has(a.id)).map((a:any)=>({...a,kind:'still'}))
|
||||
})
|
||||
const inputStill=computed(()=>stills.value.find((s:any)=>s.id===form.imageAId&&!forgottenStillIds.value.has(s.id)))
|
||||
const family=computed(()=>folderAssets(library.value,jobs.value,form.folderId))
|
||||
const familyStillCount=computed(()=>{
|
||||
const folder=(library.value.folders||[]).find((f:any)=>f.id===form.folderId)
|
||||
@@ -1094,11 +1102,29 @@ function addNegative(){
|
||||
negativeDraft.value=''
|
||||
}
|
||||
function stillById(id:string){
|
||||
if(!id)return null
|
||||
if(!id||forgottenStillIds.value.has(id))return null
|
||||
return stills.value.find((s:any)=>s.id===id)
|
||||
|| (library.value.stills||[]).find((s:any)=>s.id===id)
|
||||
|| null
|
||||
}
|
||||
function clearFormSlots(ids:string[]){
|
||||
const gone=new Set(ids.filter(Boolean))
|
||||
if(!gone.size)return
|
||||
const touched=gone.has(form.imageAId)||gone.has(form.imageBId)||gone.has(form.identityStillId)||(form.photos||[]).some((p:any)=>gone.has(p?.stillId))
|
||||
if(gone.has(form.imageAId))form.imageAId=''
|
||||
if(gone.has(form.imageBId))form.imageBId=''
|
||||
if(gone.has(form.identityStillId))form.identityStillId=''
|
||||
if(gone.has(form.maskId))form.maskId=''
|
||||
if(gone.has(form.endStillId))form.endStillId=''
|
||||
if(gone.has(form.startClipId))form.startClipId=''
|
||||
form.photos=(form.photos||[]).filter((p:any)=>!gone.has(p?.stillId))
|
||||
form.guides=(form.guides||[]).map((g:any)=>gone.has(g?.stillId)?{...g,stillId:''}:g)
|
||||
if(touched)syncPhotosBindings()
|
||||
if(selected.value&&gone.has(selected.value.id)){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
}
|
||||
}
|
||||
/** Photos array is source of truth — never resurrect cards from leftover imageAId. */
|
||||
function syncPhotosBindings(){
|
||||
const filled=(form.photos||[]).filter((p:any)=>p?.stillId)
|
||||
@@ -1445,23 +1471,34 @@ function slotHidden(_id:string){
|
||||
function toggleReveal(_id?:string){
|
||||
eyeOpen.value=!eyeOpen.value
|
||||
}
|
||||
async function deleteOutput(){
|
||||
if(!selected.value)return
|
||||
const label=assetLabel(selected.value)
|
||||
async function deleteOutput(explicit?:any){
|
||||
const target=explicit||selected.value
|
||||
if(!target?.id)return
|
||||
const label=assetLabel(target)
|
||||
if(import.meta.client && !window.confirm(`Delete ${label}?`))return
|
||||
const id=String(target.id)
|
||||
const kind=target.kind==='clip'?'clips/':target.kind==='track'?'tracks/':'stills/'
|
||||
try{
|
||||
const kind=selected.value.kind==='clip'?'clips/':selected.value.kind==='track'?'tracks/':'stills/'
|
||||
const id=selected.value.id
|
||||
await $fetch('/api/library/'+kind+id,{method:'DELETE'})
|
||||
library.value={
|
||||
...library.value,
|
||||
stills:(library.value.stills||[]).filter((s:any)=>s.id!==id),
|
||||
clips:(library.value.clips||[]).filter((c:any)=>c.id!==id),
|
||||
tracks:(library.value.tracks||[]).filter((t:any)=>t.id!==id)
|
||||
}catch(e:any){
|
||||
const status=Number(e?.statusCode||e?.status||e?.response?.status||0)
|
||||
if(status!==404){
|
||||
error.value=e?.data?.statusMessage||e?.message
|
||||
return
|
||||
}
|
||||
selected.value=null
|
||||
await refreshJobs()
|
||||
}catch(e:any){error.value=e.data?.statusMessage||e.message}
|
||||
}
|
||||
forgottenStillIds.value=new Set([...forgottenStillIds.value,id])
|
||||
clearFormSlots([id])
|
||||
library.value={
|
||||
...library.value,
|
||||
stills:(library.value.stills||[]).filter((s:any)=>s.id!==id),
|
||||
clips:(library.value.clips||[]).filter((c:any)=>c.id!==id),
|
||||
tracks:(library.value.tracks||[]).filter((t:any)=>t.id!==id)
|
||||
}
|
||||
if(selected.value?.id===id)selected.value=null
|
||||
libraryRefreshKey.value+=1
|
||||
try{await loadLibraryOnce()}catch{/* catalog write already landed */}
|
||||
await refreshJobs()
|
||||
}
|
||||
function stepFamily(delta:number){
|
||||
const list=family.value
|
||||
@@ -1500,8 +1537,7 @@ function onLibraryLoadInputRaw(item:any){
|
||||
loadInputRaw(item)
|
||||
}
|
||||
function onLibraryDelete(item:any){
|
||||
if(item)selectOutput(item)
|
||||
void deleteOutput()
|
||||
void deleteOutput(item)
|
||||
}
|
||||
function onStageHotkey(e:KeyboardEvent){
|
||||
if(e.metaKey||e.ctrlKey||e.altKey)return
|
||||
@@ -1929,28 +1965,30 @@ async function loadLibraryOnce(){
|
||||
// Current folder page only — never the yearly Inbox JSON on /
|
||||
const qs=new URLSearchParams({limit:'50'})
|
||||
if(form.folderId) qs.set('folderId',form.folderId)
|
||||
qs.set('_',String(Date.now()))
|
||||
const page=await $fetch<any>(`/api/library?${qs.toString()}`)
|
||||
const pageStills=page.stills||[]
|
||||
const forget=forgottenStillIds.value
|
||||
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) 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))
|
||||
].filter((id:string)=>id&&!forget.has(id)) as string[]
|
||||
let kept=(library.value.stills||[]).filter((s:any)=>keepIds.includes(s.id)&&!pageStills.some((p:any)=>p.id===s.id)&&!forget.has(s.id))
|
||||
const stillMissing=keepIds.filter(id=>!forget.has(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))
|
||||
const full=await $fetch<any>(`/api/library?light=1&_=${Date.now()}`)
|
||||
const recovered=(full.stills||[]).filter((s:any)=>stillMissing.includes(s.id)&&!forget.has(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],
|
||||
clips:page.clips||[],
|
||||
tracks:page.tracks||[],
|
||||
stills:[...pageStills,...kept].filter((s:any)=>!forget.has(s.id)),
|
||||
clips:(page.clips||[]).filter((c:any)=>!forget.has(c.id)),
|
||||
tracks:(page.tracks||[]).filter((t:any)=>!forget.has(t.id)),
|
||||
drafts:page.drafts||library.value.drafts||[],
|
||||
loraAliases:page.loraAliases||library.value.loraAliases||{},
|
||||
loraTriggers:page.loraTriggers||library.value.loraTriggers||{},
|
||||
@@ -2061,6 +2099,8 @@ const mobileCtx=computed(()=>({
|
||||
focusedJobId:focusedJobId.value,
|
||||
canClearFinished:canClearFinished.value,
|
||||
selected:selected.value,
|
||||
forgottenStillIds:[...forgottenStillIds.value],
|
||||
libraryRefreshKey:libraryRefreshKey.value,
|
||||
family:family.value,
|
||||
familyStillCount:familyStillCount.value,
|
||||
libraryOpen:libraryOpen.value,
|
||||
|
||||
Reference in New Issue
Block a user