Let clips move between folders, save busy jobs, and fail dropped Comfy runs.

Held jobs restore the form after a 3-minute wait, hidden stills stay blurred in the picker, and reloading Comfy no longer leaves xaigen spinning.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-25 21:46:24 -05:00
co-authored by Cursor
parent ba7a483aac
commit a7a810a7b3
22 changed files with 775 additions and 97 deletions
+31 -6
View File
@@ -3,7 +3,7 @@ import net from 'node:net'
import { execFile, spawn } from 'node:child_process'
import { promisify } from 'node:util'
import { readdirSync, existsSync, rmSync } from 'node:fs'
import { basename, join } from 'node:path'
import { basename, join, resolve, relative, isAbsolute } from 'node:path'
const execFileAsync = promisify(execFile)
const port = Number(process.env.COMFY_CONTROL_PORT || 8199)
@@ -123,11 +123,28 @@ function sharedRoots() {
}
}
function inputRoots() {
const local = process.env.LOCALAPPDATA || ''
const roots = [
process.env.COMFY_INPUT_DIR || join(local, 'Comfy-Desktop', 'ComfyUI-Shared', 'input')
]
const installs = join(local, 'Comfy-Desktop', 'ComfyUI-Installs')
try {
for (const dir of readdirSync(installs, { withFileTypes: true })) {
if (!dir.isDirectory()) continue
roots.push(join(installs, dir.name, 'ComfyUI', 'input'))
}
} catch { /* ignore */ }
return roots
}
function safeFile(root, subfolder, filename) {
const name = basename(String(filename || ''))
if (!name || name === '.' || name === '..') return null
const target = join(root, String(subfolder || '').replace(/\.\./g, ''), name)
if (!target.startsWith(root)) return null
const rootAbs = resolve(root)
const target = resolve(rootAbs, String(subfolder || '').replace(/\.\./g, ''), name)
const rel = relative(rootAbs, target)
if (!rel || rel.startsWith('..') || isAbsolute(rel)) return null
return target
}
@@ -156,9 +173,17 @@ function purgeDesktopFiles(body) {
const roots = sharedRoots()
const deleted = []
const imageName = String(body?.imageName || body?.filename || '')
const imageSub = String(body?.imageSubfolder || '')
if (imageName) {
const inputPath = safeFile(roots.input, '', imageName)
if (removeFile(inputPath)) deleted.push(inputPath)
for (const root of inputRoots()) {
if (!existsSync(root)) continue
const nested = safeFile(root, imageSub, imageName)
if (removeFile(nested)) deleted.push(nested)
if (imageSub) {
const flat = safeFile(root, '', imageName)
if (removeFile(flat)) deleted.push(flat)
}
}
}
const video = body?.video || null
const videoName = String(video?.filename || '')
@@ -166,7 +191,7 @@ function purgeDesktopFiles(body) {
const outputPath = safeFile(roots.output, video.subfolder || 'video', videoName)
if (removeFile(outputPath)) deleted.push(outputPath)
}
console.log(JSON.stringify({ src: 'comfy-host-agent', event: 'purge', deleted: deleted.length, files: deleted.map((path) => basename(path)) }))
console.log(JSON.stringify({ src: 'comfy-host-agent', event: 'purge', deleted: deleted.length, files: deleted.map((path) => basename(path)), imageName }))
return { ok: true, deleted }
}