Delete Comfy input stills after library save, not only outputs.

Purge was skipping Beast input copies and never sending image names to the host agent, so studio temps piled up on the desktop. Also sweep stale hex-/aigen-prefixed inputs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-03 23:27:14 -05:00
co-authored by Cursor
parent 780b407b3c
commit a9c2c01b35
3 changed files with 70 additions and 11 deletions
+17 -5
View File
@@ -604,9 +604,13 @@ async function purgeOnDesktop(opts: {
const controlUrl = String(config.comfyControlUrl || process.env.COMFY_CONTROL_URL || '').replace(/\/$/, '')
const token = String(config.comfyControlToken || process.env.COMFY_CONTROL_TOKEN || '')
if (!controlUrl) return
const imageNames = [
opts.imageName,
...(Array.isArray(opts.extraImageNames) ? opts.extraImageNames : [])
].map(name => String(name || '').trim()).filter(Boolean)
try {
// Exact files only. Do not sweep other MiniMax/LTX outputs or inputs —
// those are still part of the desktop workflow and recover path.
// Exact temps only: the input still(s) we uploaded + the output we already copied
// into the library. Library on the web server is source of truth — Beast must not keep copies.
await fetch(`${controlUrl}/purge`, {
method: 'POST',
headers: {
@@ -615,6 +619,9 @@ async function purgeOnDesktop(opts: {
...(token ? { Authorization: `Bearer ${token}` } : {})
},
body: JSON.stringify({
imageName: imageNames[0] || '',
imageNames,
imageSubfolder: opts.imageSubfolder || '',
video: opts.video || null,
audio: opts.audio || null,
output: opts.output || (opts.video && /\.(png|jpe?g|webp|gif)$/i.test(opts.video.filename) ? opts.video : null),
@@ -638,13 +645,18 @@ export async function purgeComfyArtifacts(opts: {
}) {
if (!purgeComfyEnabled()) return
await purgeOnDesktop(opts)
// Only remove the output we already copied into the library.
// Leave Comfy input stills / identity refs on disk — shot chains and
// desktop recover still need them.
const files: ComfyDiskFile[] = []
if (opts.video?.filename) files.push(opts.video)
if (opts.audio?.filename) files.push(opts.audio)
if (opts.output?.filename) files.push(opts.output)
const inputSub = opts.imageSubfolder || ''
if (opts.imageName) {
files.push({ filename: opts.imageName, subfolder: inputSub, type: 'input' })
}
for (const name of opts.extraImageNames || []) {
if (!name) continue
files.push({ filename: name, subfolder: inputSub, type: 'input' })
}
for (const file of files) {
await deleteComfyHttpFile(file)
}
+22 -4
View File
@@ -376,6 +376,10 @@ async function purgeImageOnDesktop(opts: {
config.imageComfyControlToken || process.env.IMAGE_COMFY_CONTROL_TOKEN || config.comfyControlToken || process.env.COMFY_CONTROL_TOKEN || ''
)
if (!controlUrl) return
const imageNames = [
opts.inputName,
...(Array.isArray(opts.extraInputNames) ? opts.extraInputNames : [])
].map(name => String(name || '').trim()).filter(Boolean)
try {
await fetch(`${controlUrl}/purge`, {
method: 'POST',
@@ -385,13 +389,16 @@ async function purgeImageOnDesktop(opts: {
...(token ? { Authorization: `Bearer ${token}` } : {})
},
body: JSON.stringify({
imageName: imageNames[0] || '',
imageNames,
imageSubfolder: opts.inputSubfolder || '',
output: opts.output || null,
sweep: false
}),
signal: AbortSignal.timeout(8000)
})
} catch {
/* Host agent purge is optional; Comfy HTTP delete is the primary path. */
/* Host agent purge is optional; Comfy HTTP delete is the fallback. */
}
}
@@ -403,6 +410,12 @@ export async function purgeImageComfyArtifacts(opts: {
promptId?: string
}) {
if (!purgeImageEnabled()) return
await purgeImageOnDesktop({
inputName: opts.inputName,
inputSubfolder: opts.inputSubfolder,
extraInputNames: opts.extraInputNames,
output: opts.output
})
const files: { filename: string; subfolder: string; type: string }[] = []
if (opts.output?.filename) {
files.push({
@@ -411,12 +424,17 @@ export async function purgeImageComfyArtifacts(opts: {
type: opts.output.type || 'output'
})
}
const inputSub = opts.inputSubfolder || ''
if (opts.inputName) {
files.push({ filename: opts.inputName, subfolder: inputSub, type: 'input' })
}
for (const name of opts.extraInputNames || []) {
if (!name) continue
files.push({ filename: name, subfolder: inputSub, type: 'input' })
}
for (const file of files) {
await deleteSidecarFile(file)
}
await purgeImageOnDesktop({
output: opts.output
})
if (opts.promptId) {
try {
await imageComfyFetch('/history', {