Clear deleted stills from the stage and library detail pane.
The file and catalog row were already removed, but the selected object stayed on screen so its prompt could still be applied. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+222
-73
@@ -238,7 +238,7 @@
|
||||
@click="libraryOpen=true"
|
||||
>Library<span v-if="familyStillCount" class="stage-library-count">{{ familyStillCount }}</span></button>
|
||||
<div
|
||||
v-if="selected && selected.kind!=='track' && (selected.kind==='clip' || showSelectedStill)"
|
||||
v-if="selectedClipLive || showSelectedStill"
|
||||
class="stage-actions"
|
||||
aria-label="Selected still actions"
|
||||
>
|
||||
@@ -283,7 +283,7 @@
|
||||
<button type="button" class="stage-action-danger" @click="deleteOutput">Delete</button>
|
||||
</div>
|
||||
<button
|
||||
v-if="selected && (selected.kind==='clip' || selected.kind==='track' || showSelectedStill)"
|
||||
v-if="selectedClipLive || selectedTrackLive || showSelectedStill"
|
||||
type="button"
|
||||
class="eye-viewer"
|
||||
:aria-pressed="eyeOpen"
|
||||
@@ -304,15 +304,15 @@
|
||||
>‹</button>
|
||||
<div class="viewer-frame">
|
||||
<p
|
||||
v-show="selected && isHidden(selected)"
|
||||
v-show="(selectedClipLive || selectedTrackLive || showSelectedStill) && isHidden(selected)"
|
||||
class="placeholder-still viewer-veil-label"
|
||||
>{{ selected?.kind==='track' ? 'Track loaded · preview hidden' : 'Output hidden' }}</p>
|
||||
<template v-if="selected?.kind==='track'">
|
||||
<template v-if="selectedTrackLive">
|
||||
<div v-show="!isHidden(selected)" class="w-full max-w-xl px-6 py-4">
|
||||
<AudioPlayer :key="selected.id" :src="`/api/library/tracks/${selected.id}/audio`" :download-name="`${selected.name || 'track'}.${selected.ext || 'wav'}`" :label="selected.name || 'Track'" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="selected?.kind==='clip'">
|
||||
<template v-else-if="selectedClipLive">
|
||||
<video
|
||||
v-show="!isHidden(selected)"
|
||||
ref="viewerVideo"
|
||||
@@ -323,7 +323,7 @@
|
||||
@loadedmetadata="onVideoTime"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="selected && showSelectedStill">
|
||||
<template v-else-if="showSelectedStill">
|
||||
<img
|
||||
v-show="!isHidden(selected)"
|
||||
:key="selected.id+'-'+stagePreviewNonce"
|
||||
@@ -721,9 +721,13 @@ function restoreBenchDraft(){
|
||||
if(draft.lockFace!=null)form.lockFace=!!draft.lockFace
|
||||
if(draft.lockOutfit!=null)form.lockOutfit=!!draft.lockOutfit
|
||||
if(draft.promptSections)form.promptSections=sectionsFrom(draft.promptSections)
|
||||
if(Array.isArray(draft.photos))form.photos=draft.photos
|
||||
.filter((p:any)=>p && typeof p.stillId==='string' && p.stillId)
|
||||
.map((p:any)=>({stillId:String(p.stillId),role:String(p.role||'change')}))
|
||||
if(Array.isArray(draft.photos)){
|
||||
const known=libraryLoadedAt?new Set((library.value.stills||[]).map((s:any)=>s.id)):null
|
||||
form.photos=draft.photos
|
||||
.filter((p:any)=>p && typeof p.stillId==='string' && p.stillId)
|
||||
.map((p:any)=>({stillId:String(p.stillId),role:String(p.role||'change')}))
|
||||
.filter((p:any)=>!removedStillIds.has(p.stillId) && (!known || known.has(p.stillId)))
|
||||
}
|
||||
if(draft.imageStyles)form.imageStyles={
|
||||
positive:Array.isArray(draft.imageStyles.positive)?draft.imageStyles.positive.map((s:any)=>String(s||'')).filter(Boolean):[],
|
||||
negative:Array.isArray(draft.imageStyles.negative)?draft.imageStyles.negative.map((s:any)=>String(s||'')).filter(Boolean):[]
|
||||
@@ -753,12 +757,51 @@ function restoreBenchDraft(){
|
||||
if(draft.music.name!=null)music.name=String(draft.music.name)
|
||||
}
|
||||
syncPhotosBindings()
|
||||
if(libraryLoadedAt) restoreDraftSelection()
|
||||
}catch{
|
||||
clearDraftStores()
|
||||
}finally{
|
||||
restoringDraft=false
|
||||
}
|
||||
}
|
||||
function restoreDraftSelection(){
|
||||
const raw=readDraftRaw()
|
||||
let draft:any=null
|
||||
try{draft=raw?JSON.parse(raw):null}catch{return}
|
||||
const stillsNow=library.value.stills||[]
|
||||
const stillIds=new Set(stillsNow.map((s:any)=>s.id))
|
||||
const liveStill=(id:string)=>!!id && !removedStillIds.has(id) && stillIds.has(id)
|
||||
if(form.imageAId && !liveStill(form.imageAId)) form.imageAId=''
|
||||
if(form.identityStillId && !liveStill(form.identityStillId)){
|
||||
form.identityStillId=''
|
||||
try{localStorage.removeItem(`studio2-hero:${form.folderId}`)}catch{/* ignore */}
|
||||
}
|
||||
form.photos=(form.photos||[]).filter((p:any)=>liveStill(p?.stillId))
|
||||
syncPhotosBindings()
|
||||
const selectedId=String(draft?.selectedId||'')
|
||||
if(!selectedId){
|
||||
if(selected.value?.id && !assetInLibrary(selected.value)){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
}
|
||||
return
|
||||
}
|
||||
if(removedStillIds.has(selectedId)){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
return
|
||||
}
|
||||
const still=stillsNow.find((s:any)=>s.id===selectedId)
|
||||
const clip=(library.value.clips||[]).find((c:any)=>c.id===selectedId)
|
||||
const track=(library.value.tracks||[]).find((t:any)=>t.id===selectedId)
|
||||
if(still) selected.value={...still,kind:'still'}
|
||||
else if(clip) selected.value={...clip,kind:'clip'}
|
||||
else if(track) selected.value={...track,kind:'track'}
|
||||
else {
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
}
|
||||
}
|
||||
|
||||
const xaigen=isXaigenStudio(useRuntimeConfig().public)
|
||||
const instanceName=String(useRuntimeConfig().public.instanceName || 'AIGen')
|
||||
@@ -770,7 +813,9 @@ const picker=ref('')
|
||||
const pickerRevealAll=ref(false)
|
||||
const uploading=ref(false),uploadMessage=ref('')
|
||||
const revealed=ref<Set<string>>(new Set())
|
||||
const measured=reactive<Record<string,{width:number;height:number}>>({}),seenOutputs=new Set<string>()
|
||||
const measured=reactive<Record<string,{width:number;height:number}>>({}),seenOutputs=new Set<string>(),removedStillIds=new Set<string>(),watchedJobIds=new Set<string>()
|
||||
let holdEmptyStage=false
|
||||
let libraryLoadedAt=0
|
||||
const loraNames=ref<any>({image:[],video:[]}),now=ref(Date.now()),healthState=ref<any>(null),upscales=ref<any[]>([])
|
||||
const library=ref<any>({folders:[],stills:[],clips:[],tracks:[]}),jobs=ref<any[]>([]),selected=ref<any>(null)
|
||||
const studioQueue=ref<any[]>([])
|
||||
@@ -916,7 +961,10 @@ watch(()=>form.folderId,(id,prev)=>{
|
||||
form.startClipId=''
|
||||
}
|
||||
loadRevealed(id)
|
||||
if(import.meta.client && form.engine!=='qwen21')form.identityStillId=localStorage.getItem(`studio2-hero:${id}`)||''
|
||||
if(import.meta.client && form.engine!=='qwen21'){
|
||||
const hero=localStorage.getItem(`studio2-hero:${id}`)||''
|
||||
form.identityStillId=hero && !removedStillIds.has(hero)?hero:''
|
||||
}
|
||||
void loadLibraryOnce().catch(()=>null)
|
||||
},{flush:'sync'})
|
||||
watch(()=>form.identityStillId,id=>{if(import.meta.client&&form.folderId&&form.engine!=='qwen21')localStorage.setItem(`studio2-hero:${form.folderId}`,id)})
|
||||
@@ -973,20 +1021,53 @@ 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'}))
|
||||
if(picker.value==='startClipId')return clips.value.filter((a:any)=>!forget.has(a.id)&&!removedStillIds.has(a.id)).map((a:any)=>({...a,kind:'clip'}))
|
||||
return stills.value.filter((a:any)=>!forget.has(a.id)&&!removedStillIds.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)&&!removedStillIds.has(s.id)))
|
||||
const family=computed(()=>{
|
||||
const folder=(library.value.folders||[]).find((f:any)=>f.id===form.folderId)
|
||||
const emptyImages=!!folder && typeof folder.imageCount==='number' && folder.imageCount===0
|
||||
return folderAssets(library.value,jobs.value,form.folderId).filter((asset:any)=>{
|
||||
if(!asset?.id || forgottenStillIds.value.has(asset.id) || removedStillIds.has(asset.id)) return false
|
||||
if(emptyImages && asset.kind==='still') return false
|
||||
return true
|
||||
})
|
||||
})
|
||||
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(()=>folderImageCount(
|
||||
(library.value.folders||[]).find((f:any)=>f.id===form.folderId),
|
||||
family.value.filter((a:any)=>a.kind==='still').length
|
||||
))
|
||||
function assetInLibrary(item:any){
|
||||
if(!item?.id || forgottenStillIds.value.has(item.id) || removedStillIds.has(item.id)) return false
|
||||
if(item.kind==='clip') return (library.value.clips||[]).some((row:any)=>row.id===item.id)
|
||||
if(item.kind==='track') return (library.value.tracks||[]).some((row:any)=>row.id===item.id)
|
||||
return (library.value.stills||[]).some((row:any)=>row.id===item.id)
|
||||
}
|
||||
const selectedClipLive=computed(()=>selected.value?.kind==='clip' && assetInLibrary(selected.value))
|
||||
const selectedTrackLive=computed(()=>selected.value?.kind==='track' && assetInLibrary(selected.value))
|
||||
const showSelectedStill=computed(()=>{
|
||||
const item=selected.value
|
||||
if(!item?.id || item.kind==='clip' || item.kind==='track') return false
|
||||
if(forgottenStillIds.value.has(item.id)) return false
|
||||
return (library.value.stills||[]).some((s:any)=>s.id===item.id)
|
||||
if(forgottenStillIds.value.has(item.id) || removedStillIds.has(item.id)) return false
|
||||
const row=(library.value.stills||[]).find((s:any)=>s.id===item.id)
|
||||
if(!row) return false
|
||||
const folder=(library.value.folders||[]).find((f:any)=>f.id===(row.folderId||item.folderId||form.folderId))
|
||||
if(folder && typeof folder.imageCount==='number' && folder.imageCount===0) return false
|
||||
return row.id===item.id
|
||||
})
|
||||
watch(()=>[selected.value?.id, selected.value?.kind, showSelectedStill.value, selectedClipLive.value, selectedTrackLive.value], ()=>{
|
||||
const item=selected.value
|
||||
if(!item?.id) return
|
||||
if(item.kind==='clip'){
|
||||
if(!selectedClipLive.value){selected.value=null;selectionPinned.value=false}
|
||||
return
|
||||
}
|
||||
if(item.kind==='track'){
|
||||
if(!selectedTrackLive.value){selected.value=null;selectionPinned.value=false}
|
||||
return
|
||||
}
|
||||
if(!showSelectedStill.value){selected.value=null;selectionPinned.value=false}
|
||||
})
|
||||
const sourceAsset=computed(()=>form.startClipId?clips.value.find((c:any)=>c.id===form.startClipId):stills.value.find((s:any)=>s.id===(form.imageAId||form.identityStillId||form.photos?.[0]?.stillId)))
|
||||
const sourceSize=computed(()=>measured[sourceAsset.value?.id] || sourceAsset.value)
|
||||
@@ -1111,7 +1192,7 @@ function addNegative(){
|
||||
negativeDraft.value=''
|
||||
}
|
||||
function stillById(id:string){
|
||||
if(!id||forgottenStillIds.value.has(id))return null
|
||||
if(!id||forgottenStillIds.value.has(id)||removedStillIds.has(id))return null
|
||||
return stills.value.find((s:any)=>s.id===id)
|
||||
|| (library.value.stills||[]).find((s:any)=>s.id===id)
|
||||
|| null
|
||||
@@ -1122,7 +1203,10 @@ function clearFormSlots(ids:string[]){
|
||||
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.identityStillId)){
|
||||
form.identityStillId=''
|
||||
try{localStorage.removeItem(`studio2-hero:${form.folderId}`)}catch{/* ignore */}
|
||||
}
|
||||
if(gone.has(form.maskId))form.maskId=''
|
||||
if(gone.has(form.endStillId))form.endStillId=''
|
||||
if(gone.has(form.startClipId))form.startClipId=''
|
||||
@@ -1152,7 +1236,7 @@ function clearRefsMissingFromLibrary(){
|
||||
const sel=selected.value
|
||||
if(sel?.id){
|
||||
const ok=sel.kind==='clip'?clipIds.has(sel.id):sel.kind==='track'?trackIds.has(sel.id):ids.has(sel.id)
|
||||
if(!ok){
|
||||
if(!ok || removedStillIds.has(sel.id)){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
}
|
||||
@@ -1280,8 +1364,13 @@ function sourceStillIdsOf(item:any){
|
||||
}
|
||||
function resolveActionAsset(item?:any){
|
||||
// Stage @click handlers pass a MouseEvent as the first arg — never treat events as library assets.
|
||||
if(item && typeof item.id==='string' && item.id) return item
|
||||
return selected.value
|
||||
if(item && typeof item.id==='string' && item.id){
|
||||
if(forgottenStillIds.value.has(item.id) || !assetInLibrary(item)) return null
|
||||
return item
|
||||
}
|
||||
if(showSelectedStill.value) return selected.value
|
||||
if(selectedClipLive.value || selectedTrackLive.value) return selected.value
|
||||
return null
|
||||
}
|
||||
function useImageRole(){
|
||||
const plan=photosPlanState.value
|
||||
@@ -1511,20 +1600,34 @@ async function deleteOutput(explicit?:any){
|
||||
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/'
|
||||
holdEmptyStage=true
|
||||
if(String(selected.value?.id||'')===id){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
}
|
||||
try{
|
||||
await $fetch('/api/library/'+kind+id,{method:'DELETE'})
|
||||
}catch(e:any){
|
||||
const status=Number(e?.statusCode||e?.status||e?.response?.status||0)
|
||||
if(status!==404){
|
||||
error.value=e?.data?.statusMessage||e?.message
|
||||
holdEmptyStage=false
|
||||
libraryRefreshKey.value+=1
|
||||
return
|
||||
}
|
||||
}
|
||||
seenOutputs.add(id)
|
||||
removedStillIds.add(id)
|
||||
forgottenStillIds.value=new Set([...forgottenStillIds.value,id])
|
||||
clearFormSlots([id])
|
||||
const countKey=kind==='clips/'?'clipCount':kind==='tracks/'?'trackCount':'imageCount'
|
||||
library.value={
|
||||
...library.value,
|
||||
folders:(library.value.folders||[]).map((folder:any)=>{
|
||||
if(String(folder?.id||'')!==String(target.folderId||form.folderId||'')) return folder
|
||||
if(typeof folder[countKey]!=='number') return folder
|
||||
return {...folder,[countKey]:Math.max(0,folder[countKey]-1)}
|
||||
}),
|
||||
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)
|
||||
@@ -1550,29 +1653,45 @@ function runStageMenu(fn:()=>void|Promise<void>){
|
||||
stageMenu.value=''
|
||||
void fn()
|
||||
}
|
||||
function libraryActionItem(item:any){
|
||||
if(!item?.id || forgottenStillIds.value.has(item.id) || removedStillIds.has(item.id)) return null
|
||||
return item
|
||||
}
|
||||
function onLibraryUseImage(item:any){
|
||||
if(item)selectOutput(item)
|
||||
applyUseImage(item)
|
||||
const asset=libraryActionItem(item)
|
||||
if(!asset) return
|
||||
selectOutput(asset)
|
||||
applyUseImage(asset)
|
||||
}
|
||||
function onLibraryUsePrompt(item:any){
|
||||
if(item)selectOutput(item)
|
||||
applyUsePrompt(item)
|
||||
const asset=libraryActionItem(item)
|
||||
if(!asset) return
|
||||
selectOutput(asset)
|
||||
applyUsePrompt(asset)
|
||||
}
|
||||
function onLibraryCopyPrompt(item:any){
|
||||
if(item)selectOutput(item)
|
||||
void copySelectedPrompt(item)
|
||||
const asset=libraryActionItem(item)
|
||||
if(!asset) return
|
||||
selectOutput(asset)
|
||||
void copySelectedPrompt(asset)
|
||||
}
|
||||
function onLibraryCopyRawPrompt(item:any){
|
||||
if(item)selectOutput(item)
|
||||
void copySelectedRawPrompt(item)
|
||||
const asset=libraryActionItem(item)
|
||||
if(!asset) return
|
||||
selectOutput(asset)
|
||||
void copySelectedRawPrompt(asset)
|
||||
}
|
||||
function onLibraryLoadInput(item:any){
|
||||
if(item)selectOutput(item)
|
||||
loadInputUsed(item)
|
||||
const asset=libraryActionItem(item)
|
||||
if(!asset) return
|
||||
selectOutput(asset)
|
||||
loadInputUsed(asset)
|
||||
}
|
||||
function onLibraryLoadInputRaw(item:any){
|
||||
if(item)selectOutput(item)
|
||||
loadInputRaw(item)
|
||||
const asset=libraryActionItem(item)
|
||||
if(!asset) return
|
||||
selectOutput(asset)
|
||||
loadInputRaw(asset)
|
||||
}
|
||||
function onLibraryDelete(item:any){
|
||||
void deleteOutput(item)
|
||||
@@ -1585,7 +1704,8 @@ function onLibraryWiped(result:any){
|
||||
...(library.value.clips||[]).filter((s:any)=>String(s.folderId||'')===folderId).map((s:any)=>s.id),
|
||||
...(library.value.tracks||[]).filter((s:any)=>String(s.folderId||'')===folderId).map((s:any)=>s.id)
|
||||
]
|
||||
for(const id of deleted) seenOutputs.add(id)
|
||||
for(const id of deleted){seenOutputs.add(id);removedStillIds.add(id)}
|
||||
holdEmptyStage=true
|
||||
const next=libraryAfterWipe({
|
||||
folders:library.value.folders,
|
||||
stills:library.value.stills,
|
||||
@@ -1781,15 +1901,25 @@ function onTaskSelect(event:Event){chooseTask((event.target as HTMLSelectElement
|
||||
function chooseClip(id:string){if(!id){form.startClipId='';return}const clip=clips.value.find((c:any)=>c.id===id);if(clip){try{Object.assign(form,bindClip(form,clip,xaigen,loraMemory))}catch(e:any){error.value=e?.message||'Could not copy clip settings.';form.startClipId=clip.id;form.mode='extend';form.engine=xaigen && form.engine==='ltx'?'ltx':'minimax'}}}
|
||||
function selectOutput(item:any){
|
||||
stageMenu.value=''
|
||||
if(item?.id && !forgottenStillIds.value.has(item.id)){
|
||||
const kind=item.kind==='clip'?'clips':item.kind==='track'?'tracks':'stills'
|
||||
const list=library.value[kind]||[]
|
||||
if(!list.some((row:any)=>row.id===item.id)){
|
||||
library.value={...library.value,[kind]:[...list,{...item,folderId:item.folderId||form.folderId}]}
|
||||
}
|
||||
if(!item?.id || forgottenStillIds.value.has(item.id) || removedStillIds.has(item.id)){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
return
|
||||
}
|
||||
holdEmptyStage=false
|
||||
const kind=item.kind==='clip'?'clips':item.kind==='track'?'tracks':'stills'
|
||||
const list=library.value[kind]||[]
|
||||
if(!list.some((row:any)=>row.id===item.id)){
|
||||
const folderId=item.folderId||form.folderId
|
||||
const folders=kind==='clips'
|
||||
? bumpFolderCount(library.value.folders,folderId,'clipCount')
|
||||
: kind==='stills'
|
||||
? bumpFolderCount(library.value.folders,folderId,'imageCount')
|
||||
: library.value.folders
|
||||
library.value={...library.value,[kind]:[...list,{...item,folderId}],folders}
|
||||
}
|
||||
selected.value=item
|
||||
selectionPinned.value=!!item
|
||||
selectionPinned.value=true
|
||||
if(form.mode==='extend' && item?.kind==='clip')chooseClip(item.id)
|
||||
}
|
||||
function restore(item:any){Object.assign(form,restoreAll(form,item,xaigen,loraMemory));form.guides=form.guides||[];batchText.value=''}
|
||||
@@ -1830,17 +1960,42 @@ async function refreshJobs(){
|
||||
liveCaption.value=nextCaption
|
||||
ingestNewOutputs(nextJobs)
|
||||
}
|
||||
/** Merge freshly completed outputs into the local catalog — never refetch the whole library. */
|
||||
function bumpFolderCount(folders:any[]|undefined, folderId:string, key:'imageCount'|'clipCount'){
|
||||
return (folders||[]).map((folder:any)=>{
|
||||
if(folder?.id!==folderId || typeof folder[key]!=='number') return folder
|
||||
return {...folder,[key]:folder[key]+1}
|
||||
})
|
||||
}
|
||||
/** Merge a job output only when it is already in the catalog or it finished after this page loaded. */
|
||||
function ingestNewOutputs(nextJobs:any[]){
|
||||
const catalogIds=new Set<string>([
|
||||
...(library.value.stills||[]).map((s:any)=>s.id),
|
||||
...(library.value.clips||[]).map((c:any)=>c.id),
|
||||
...(library.value.tracks||[]).map((t:any)=>t.id)
|
||||
])
|
||||
const fresh=newestOutput(nextJobs,seenOutputs,form.folderId)
|
||||
for(const job of nextJobs){
|
||||
const live=['waiting','waking','enhancing','submitting','rendering','saving'].includes(job.state)
|
||||
if(live && job.id) watchedJobIds.add(job.id)
|
||||
for(const output of job.outputs||[]){
|
||||
if(seenOutputs.has(output.id) || forgottenStillIds.value.has(output.id)){
|
||||
if(!output?.id) continue
|
||||
if(seenOutputs.has(output.id) || forgottenStillIds.value.has(output.id) || removedStillIds.has(output.id)){
|
||||
seenOutputs.add(output.id)
|
||||
continue
|
||||
}
|
||||
const meta=output.studio2||{}
|
||||
const savedAt=Number(meta.savedAt||0)
|
||||
const bornHere=libraryLoadedAt>0 && savedAt>=libraryLoadedAt-2000
|
||||
const watched=!!(job.id && watchedJobIds.has(job.id))
|
||||
if(!catalogIds.has(output.id) && !watched && !bornHere){
|
||||
seenOutputs.add(output.id)
|
||||
continue
|
||||
}
|
||||
if(catalogIds.has(output.id)){
|
||||
seenOutputs.add(output.id)
|
||||
continue
|
||||
}
|
||||
seenOutputs.add(output.id)
|
||||
const meta=output.studio2||{}
|
||||
const folderId=job.request?.folderId||form.folderId
|
||||
if(output.kind==='clip'){
|
||||
if(!(library.value.clips||[]).some((c:any)=>c.id===output.id)){
|
||||
@@ -1848,7 +2003,7 @@ function ingestNewOutputs(nextJobs:any[]){
|
||||
id:output.id,folderId,createdAt:meta.savedAt||Date.now(),
|
||||
name:meta.name||output.id.slice(0,8),hasThumbnail:true,hasVideo:true,
|
||||
width:meta.outputWidth,height:meta.outputHeight,studio2:meta
|
||||
}]}
|
||||
}],folders:bumpFolderCount(library.value.folders,folderId,'clipCount')}
|
||||
}
|
||||
}else if(output.kind!=='track'){
|
||||
if(!(library.value.stills||[]).some((s:any)=>s.id===output.id)){
|
||||
@@ -1857,37 +2012,27 @@ function ingestNewOutputs(nextJobs:any[]){
|
||||
name:meta.name||output.id.slice(0,8),role:'output',
|
||||
width:meta.outputWidth,height:meta.outputHeight,
|
||||
prompt:meta.prompt,promptRaw:meta.promptRaw,studio2:meta
|
||||
}]}
|
||||
}],folders:bumpFolderCount(library.value.folders,folderId,'imageCount')}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(fresh && !forgottenStillIds.value.has(fresh.id)){
|
||||
// Merge into catalog above; only auto-select when the user has not pinned a pick.
|
||||
if(!selectionPinned.value){
|
||||
const existingFresh=family.value.find(a=>a.id===fresh.id)
|
||||
const freshLive=fresh?.id && !forgottenStillIds.value.has(fresh.id) && !removedStillIds.has(fresh.id) && family.value.some((a:any)=>a.id===fresh.id)
|
||||
if(freshLive){
|
||||
if(!selectionPinned.value && !holdEmptyStage){
|
||||
const existingFresh=family.value.find((a:any)=>a.id===fresh.id)
|
||||
if(existingFresh) selected.value=existingFresh
|
||||
else{
|
||||
const kind=fresh.kind==='clip'?'clip':'still'
|
||||
selected.value={...fresh,kind,folderId:form.folderId,studio2:fresh.studio2}
|
||||
}
|
||||
}
|
||||
}else if(selected.value && forgottenStillIds.value.has(selected.value.id)){
|
||||
}else if(selected.value && (forgottenStillIds.value.has(selected.value.id) || removedStillIds.has(selected.value.id) || !family.value.some((a:any)=>a.id===selected.value.id))){
|
||||
selected.value=null
|
||||
selectionPinned.value=false
|
||||
}else if(selected.value){
|
||||
const next=reconcileSelection(selected.value,family.value)
|
||||
if(form.mode!=='music' && next?.kind==='track'){
|
||||
const nonTrack=family.value.find((a:any)=>a.kind!=='track') || null
|
||||
if(nonTrack && !selectionPinned.value) selected.value=nonTrack
|
||||
else if(next?.id===selected.value.id) selected.value=next
|
||||
}else if(next) selected.value=next
|
||||
else { selected.value=null; selectionPinned.value=false }
|
||||
}else{
|
||||
selected.value=reconcileSelection(null,family.value.filter((a:any)=>!forgottenStillIds.value.has(a.id)))
|
||||
}else if(!selected.value && !holdEmptyStage){
|
||||
const next=reconcileSelection(null,family.value)
|
||||
if(next?.id && !removedStillIds.has(next.id)) selected.value=next
|
||||
else selected.value=null
|
||||
}
|
||||
const newestTrack=(library.value.tracks||[]).filter((t:any)=>t.folderId===form.folderId).sort((a:any,b:any)=>(b.createdAt||0)-(a.createdAt||0))[0]
|
||||
if(form.mode==='music' && newestTrack && !seenOutputs.has(newestTrack.id)){
|
||||
if(form.mode==='music' && newestTrack && !seenOutputs.has(newestTrack.id) && !removedStillIds.has(newestTrack.id)){
|
||||
seenOutputs.add(newestTrack.id)
|
||||
selected.value={...newestTrack,kind:'track'}
|
||||
}
|
||||
@@ -2061,13 +2206,13 @@ async function loadLibraryOnce(deletedIds?: string[]){
|
||||
qs.set('_',String(Date.now()))
|
||||
const page=await $fetch<any>(`/api/library?${qs.toString()}`)
|
||||
if(gen!==libraryLoadGen) return
|
||||
const pageStills=(page.stills||[]).filter((s:any)=>s?.id&&!gone.has(s.id))
|
||||
const pageStills=(page.stills||[]).filter((s:any)=>s?.id&&!gone.has(s.id)&&!removedStillIds.has(s.id))
|
||||
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((id:string)=>id&&!forget.has(id)&&!gone.has(id)) as string[]
|
||||
].filter((id:string)=>id&&!forget.has(id)&&!gone.has(id)&&!removedStillIds.has(id)) as string[]
|
||||
let kept=replacing?[]:(library.value.stills||[]).filter((s:any)=>keepIds.includes(s.id)&&!pageStills.some((p:any)=>p.id===s.id)&&!forget.has(s.id)&&!gone.has(s.id))
|
||||
const stillMissing=keepIds.filter(id=>!pageStills.some((s:any)=>s.id===id)&&!kept.some((s:any)=>s.id===id))
|
||||
let epoch=page.catalogEpoch
|
||||
@@ -2078,16 +2223,16 @@ async function loadLibraryOnce(deletedIds?: string[]){
|
||||
const full=await $fetch<any>(`/api/library?light=1&_=${Date.now()}`)
|
||||
if(gen!==libraryLoadGen) return
|
||||
if(typeof full?.catalogEpoch==='number') epoch=full.catalogEpoch
|
||||
const recovered=(full.stills||[]).filter((s:any)=>stillMissing.includes(s.id)&&!forget.has(s.id)&&!gone.has(s.id))
|
||||
const recovered=(full.stills||[]).filter((s:any)=>stillMissing.includes(s.id)&&!forget.has(s.id)&&!gone.has(s.id)&&!removedStillIds.has(s.id))
|
||||
kept=[...kept,...recovered.filter((s:any)=>!kept.some((k:any)=>k.id===s.id))]
|
||||
}catch{if(replacing) kept=[]}
|
||||
}
|
||||
if(gen!==libraryLoadGen) return
|
||||
library.value={
|
||||
folders:page.folders||library.value.folders||[],
|
||||
stills:[...pageStills,...kept].filter((s:any)=>s?.id&&!forget.has(s.id)&&!gone.has(s.id)),
|
||||
clips:(page.clips||[]).filter((c:any)=>c?.id&&!forget.has(c.id)&&!gone.has(c.id)),
|
||||
tracks:(page.tracks||[]).filter((t:any)=>t?.id&&!forget.has(t.id)&&!gone.has(t.id)),
|
||||
stills:[...pageStills,...kept].filter((s:any)=>s?.id&&!forget.has(s.id)&&!gone.has(s.id)&&!removedStillIds.has(s.id)),
|
||||
clips:(page.clips||[]).filter((c:any)=>c?.id&&!forget.has(c.id)&&!gone.has(c.id)&&!removedStillIds.has(c.id)),
|
||||
tracks:(page.tracks||[]).filter((t:any)=>t?.id&&!forget.has(t.id)&&!gone.has(t.id)&&!removedStillIds.has(t.id)),
|
||||
drafts:page.drafts||library.value.drafts||[],
|
||||
loraAliases:page.loraAliases||library.value.loraAliases||{},
|
||||
loraTriggers:page.loraTriggers||library.value.loraTriggers||{},
|
||||
@@ -2095,6 +2240,7 @@ async function loadLibraryOnce(deletedIds?: string[]){
|
||||
catalogEpoch:typeof epoch==='number'?epoch:(library.value.catalogEpoch??0)
|
||||
}
|
||||
clearRefsMissingFromLibrary()
|
||||
libraryLoadedAt=Date.now()
|
||||
}
|
||||
|
||||
async function fetchHealth(){
|
||||
@@ -2136,6 +2282,7 @@ onMounted(()=>{
|
||||
// Folder page in background — never blocks Generate / prompt
|
||||
void loadLibraryOnce().then(()=>{
|
||||
restoreBenchDraft()
|
||||
restoreDraftSelection()
|
||||
clearRefsMissingFromLibrary()
|
||||
if(!form.folderId)form.folderId=library.value.folders[0]?.id||''
|
||||
loadRevealed(form.folderId)
|
||||
@@ -2201,6 +2348,8 @@ const mobileCtx=computed(()=>({
|
||||
clipThumbUrl,
|
||||
clipVideoUrl,
|
||||
showSelectedStill:showSelectedStill.value,
|
||||
selectedClipLive:selectedClipLive.value,
|
||||
selectedTrackLive:selectedTrackLive.value,
|
||||
libraryOpen:libraryOpen.value,
|
||||
eyeOpen:eyeOpen.value,
|
||||
hideInputs:hideInputs.value,
|
||||
|
||||
Reference in New Issue
Block a user