Purge identity refs from desktop Comfy and keep them in the server stills library.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -293,6 +293,7 @@ async function purgeOnDesktop(opts: {
|
||||
video?: { filename: string; subfolder: string; type: string }
|
||||
imageName?: string
|
||||
imageSubfolder?: string
|
||||
extraImageNames?: string[]
|
||||
}) {
|
||||
const config = useRuntimeConfig()
|
||||
const controlUrl = String(config.comfyControlUrl || process.env.COMFY_CONTROL_URL || '').replace(/\/$/, '')
|
||||
@@ -309,6 +310,7 @@ async function purgeOnDesktop(opts: {
|
||||
body: JSON.stringify({
|
||||
imageName: opts.imageName || '',
|
||||
imageSubfolder: opts.imageSubfolder || '',
|
||||
imageNames: (opts.extraImageNames || []).filter(Boolean),
|
||||
video: opts.video || null
|
||||
}),
|
||||
signal: AbortSignal.timeout(8000)
|
||||
@@ -322,6 +324,7 @@ export async function purgeComfyArtifacts(opts: {
|
||||
video?: { filename: string; subfolder: string; type: string }
|
||||
imageName?: string
|
||||
imageSubfolder?: string
|
||||
extraImageNames?: string[]
|
||||
promptId?: string
|
||||
}) {
|
||||
if (!purgeComfyEnabled()) return
|
||||
@@ -329,6 +332,10 @@ export async function purgeComfyArtifacts(opts: {
|
||||
const files: { filename: string; subfolder: string; type: string }[] = []
|
||||
if (opts.video?.filename) files.push(opts.video)
|
||||
if (opts.imageName) files.push({ filename: opts.imageName, subfolder: opts.imageSubfolder || '', type: 'input' })
|
||||
for (const name of opts.extraImageNames || []) {
|
||||
if (!name || name === opts.imageName) continue
|
||||
files.push({ filename: name, subfolder: opts.imageSubfolder || '', type: 'input' })
|
||||
}
|
||||
for (const file of files) {
|
||||
try {
|
||||
await comfyFetch('/aigen/purge', {
|
||||
|
||||
@@ -66,6 +66,7 @@ export interface Job {
|
||||
imageSubfolder?: string
|
||||
stillId?: string
|
||||
stillFilename?: string
|
||||
referenceImageNames?: string[]
|
||||
duration?: number
|
||||
sound?: boolean
|
||||
draftId?: string
|
||||
|
||||
@@ -27,6 +27,7 @@ export interface PendingJob {
|
||||
chainIndex?: number
|
||||
stillId?: string
|
||||
sound?: boolean
|
||||
referenceImageNames?: string[]
|
||||
}
|
||||
|
||||
function pendingRoot() {
|
||||
@@ -148,7 +149,13 @@ export async function completePendingIfReady(pending: PendingJob) {
|
||||
stillId: pending.stillId,
|
||||
sound: pending.sound
|
||||
})
|
||||
await purgeComfyArtifacts({ video, imageName: pending.imageName, imageSubfolder: pending.imageSubfolder, promptId: pending.promptId })
|
||||
await purgeComfyArtifacts({
|
||||
video,
|
||||
imageName: pending.imageName,
|
||||
imageSubfolder: pending.imageSubfolder,
|
||||
extraImageNames: pending.referenceImageNames,
|
||||
promptId: pending.promptId
|
||||
})
|
||||
deletePendingJob(pending.jobId)
|
||||
return {
|
||||
type: 'complete' as const,
|
||||
|
||||
@@ -132,6 +132,11 @@ export function watchComfyJob(job: Job, options: { persist?: boolean } = {}): Pr
|
||||
emitChainJob(job, { type: 'error', error: job.error, message: job.error })
|
||||
if (job.id) deletePendingJob(job.id)
|
||||
removeExtendTemp(job.library?.extendTmpDir)
|
||||
await purgeComfyArtifacts({
|
||||
imageName: job.library?.imageName,
|
||||
imageSubfolder: job.library?.imageSubfolder,
|
||||
extraImageNames: job.library?.referenceImageNames
|
||||
})
|
||||
resolve()
|
||||
}
|
||||
|
||||
@@ -209,6 +214,7 @@ export function watchComfyJob(job: Job, options: { persist?: boolean } = {}): Pr
|
||||
video,
|
||||
imageName: job.library.imageName,
|
||||
imageSubfolder: job.library.imageSubfolder,
|
||||
extraImageNames: job.library.referenceImageNames,
|
||||
promptId: job.promptId
|
||||
})
|
||||
if (!persist) {
|
||||
@@ -405,6 +411,7 @@ export function ensurePendingWatch(pending: {
|
||||
chainIndex?: number
|
||||
stillId?: string
|
||||
sound?: boolean
|
||||
referenceImageNames?: string[]
|
||||
}) {
|
||||
const existing = getJob(pending.jobId)
|
||||
if (existing) return existing
|
||||
@@ -435,7 +442,8 @@ export function ensurePendingWatch(pending: {
|
||||
parentClipId: pending.parentClipId,
|
||||
chainIndex: pending.chainIndex,
|
||||
stillId: pending.stillId,
|
||||
sound: pending.sound
|
||||
sound: pending.sound,
|
||||
referenceImageNames: pending.referenceImageNames
|
||||
}
|
||||
})
|
||||
if (!pendingWatches.has(job.id)) {
|
||||
|
||||
Reference in New Issue
Block a user