Let image edit run while video Comfy is busy.
Split video/edit job state so the sidecar can edit concurrently, and hide v2 identity-ref thumbnails when the input still is hidden. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+419
-220
File diff suppressed because it is too large
Load Diff
@@ -72,6 +72,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
const clipName = nextClipPartName(clipTitle(source))
|
const clipName = nextClipPartName(clipTitle(source))
|
||||||
|
|
||||||
const job = createJob()
|
const job = createJob()
|
||||||
|
job.kind = 'video'
|
||||||
job.maxStep = steps
|
job.maxStep = steps
|
||||||
job.hideThumbnail = source.hideThumbnail
|
job.hideThumbnail = source.hideThumbnail
|
||||||
const tmpDir = extendTempDir(owner, job.id)
|
const tmpDir = extendTempDir(owner, job.id)
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const chainTotal = 1 + extensions.length
|
const chainTotal = 1 + extensions.length
|
||||||
const job = createJob()
|
const job = createJob()
|
||||||
|
job.kind = 'video'
|
||||||
job.maxStep = steps
|
job.maxStep = steps
|
||||||
job.hideThumbnail = hideThumbnail
|
job.hideThumbnail = hideThumbnail
|
||||||
job.library = {
|
job.library = {
|
||||||
|
|||||||
@@ -1,35 +1,59 @@
|
|||||||
|
function livePayload(job: ReturnType<typeof getJob> & {}) {
|
||||||
|
if (!job) return null
|
||||||
|
return {
|
||||||
|
jobId: job.id,
|
||||||
|
kind: job.kind || 'video',
|
||||||
|
hideThumbnail: job.hideThumbnail === true,
|
||||||
|
folderLocked: job.library?.folderLocked === true,
|
||||||
|
...jobSnapshot(job)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const owner = libraryOwnerKey(event)
|
const owner = libraryOwnerKey(event)
|
||||||
const live = listJobs()
|
const live = listJobs()
|
||||||
.filter(job => job.library?.ownerKey === owner && (job.status === 'queued' || job.status === 'uploading' || job.status === 'running'))
|
.filter(job => job.library?.ownerKey === owner && (job.status === 'queued' || job.status === 'uploading' || job.status === 'running'))
|
||||||
.sort((a, b) => b.startedAt - a.startedAt)[0]
|
.sort((a, b) => b.startedAt - a.startedAt)
|
||||||
if (live) {
|
const videoLive = live.find(job => job.kind !== 'edit')
|
||||||
return {
|
const editLive = live.find(job => job.kind === 'edit')
|
||||||
jobId: live.id,
|
|
||||||
hideThumbnail: live.hideThumbnail === true,
|
let video = videoLive ? livePayload(videoLive) : null
|
||||||
folderLocked: live.library?.folderLocked === true,
|
const edit = editLive ? livePayload(editLive) : null
|
||||||
...jobSnapshot(live)
|
|
||||||
|
if (!video) {
|
||||||
|
const pending = listPendingJobs()
|
||||||
|
.filter(job => job.ownerKey === owner)
|
||||||
|
.sort((a, b) => b.startedAt - a.startedAt)[0]
|
||||||
|
if (pending) {
|
||||||
|
const resolved = await resolvePendingJob(pending).catch(() => null)
|
||||||
|
if (resolved) {
|
||||||
|
video = {
|
||||||
|
jobId: pending.jobId,
|
||||||
|
kind: 'video' as const,
|
||||||
|
hideThumbnail: pending.hideThumbnail === true,
|
||||||
|
folderLocked: pending.folderLocked === true,
|
||||||
|
...resolved
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
video = {
|
||||||
|
jobId: pending.jobId,
|
||||||
|
kind: 'video',
|
||||||
|
type: 'snapshot',
|
||||||
|
status: 'running',
|
||||||
|
message: 'Reconnecting to ComfyUI...',
|
||||||
|
progress: Math.max(8, Math.min(90, Math.round((Date.now() - pending.startedAt) / 1000))),
|
||||||
|
promptId: pending.promptId,
|
||||||
|
elapsedMs: Date.now() - pending.startedAt,
|
||||||
|
hideThumbnail: pending.hideThumbnail === true,
|
||||||
|
folderLocked: pending.folderLocked === true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pending = listPendingJobs()
|
return {
|
||||||
.filter(job => job.ownerKey === owner)
|
jobId: video?.jobId || edit?.jobId || null,
|
||||||
.sort((a, b) => b.startedAt - a.startedAt)[0]
|
video,
|
||||||
if (pending) {
|
edit
|
||||||
const resolved = await resolvePendingJob(pending).catch(() => null)
|
|
||||||
if (resolved) return resolved
|
|
||||||
return {
|
|
||||||
jobId: pending.jobId,
|
|
||||||
type: 'snapshot',
|
|
||||||
status: 'running',
|
|
||||||
message: 'Reconnecting to ComfyUI...',
|
|
||||||
progress: Math.max(8, Math.min(90, Math.round((Date.now() - pending.startedAt) / 1000))),
|
|
||||||
promptId: pending.promptId,
|
|
||||||
elapsedMs: Date.now() - pending.startedAt,
|
|
||||||
hideThumbnail: pending.hideThumbnail === true,
|
|
||||||
folderLocked: pending.folderLocked === true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { jobId: null }
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody<{ jobId?: string }>(event).catch(() => ({}))
|
const body = await readBody<{ jobId?: string; kind?: string }>(event).catch(() => ({}))
|
||||||
const jobId = String(body?.jobId || '')
|
const jobId = String(body?.jobId || '')
|
||||||
const job = jobId ? getJob(jobId) : undefined
|
const job = jobId ? getJob(jobId) : undefined
|
||||||
if (job) {
|
if (job) {
|
||||||
@@ -8,7 +8,8 @@ export default defineEventHandler(async (event) => {
|
|||||||
removeExtendTemp(job.library?.extendTmpDir)
|
removeExtendTemp(job.library?.extendTmpDir)
|
||||||
}
|
}
|
||||||
if (jobId) deletePendingJob(jobId)
|
if (jobId) deletePendingJob(jobId)
|
||||||
const ok = job?.kind === 'edit'
|
const kind = job?.kind || (body?.kind === 'edit' ? 'edit' : 'video')
|
||||||
|
const ok = kind === 'edit'
|
||||||
? await interruptImageComfy()
|
? await interruptImageComfy()
|
||||||
: await interruptComfy()
|
: await interruptComfy()
|
||||||
if (job) {
|
if (job) {
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ export function listJobs() {
|
|||||||
export function jobSnapshot(job: Job) {
|
export function jobSnapshot(job: Job) {
|
||||||
return {
|
return {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
|
kind: job.kind || 'video',
|
||||||
type: 'snapshot' as const,
|
type: 'snapshot' as const,
|
||||||
status: job.status,
|
status: job.status,
|
||||||
message: job.message,
|
message: job.message,
|
||||||
|
|||||||
Reference in New Issue
Block a user