Notify from the installed web app when a generation finishes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5743,6 +5743,7 @@ async function generateExtension() {
|
||||
statusMessage.value = 'Extracting last frame & stitching extension...'
|
||||
startTimer('video')
|
||||
try {
|
||||
await ensureGenerationNotifyPermission()
|
||||
const started = await $fetch<{ jobId: string; steps: number; hideThumbnail?: boolean; folderLocked?: boolean }>('/api/extend', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
@@ -6463,6 +6464,7 @@ async function editImage() {
|
||||
const extraPasses = editPassQueue.value.map(item => ({ prompt: item.prompt.trim() }))
|
||||
const hideOut = hideThumbnail.value
|
||||
try {
|
||||
await ensureGenerationNotifyPermission()
|
||||
const body = new FormData()
|
||||
body.append('image', file.value)
|
||||
if (editRefFile.value) body.append('image2', editRefFile.value)
|
||||
@@ -6679,6 +6681,7 @@ async function editImageV2() {
|
||||
const extraPasses = v2PassChaining.value ? editPassQueue.value.map(item => ({ prompt: item.prompt.trim() })) : []
|
||||
const hideOut = hideThumbnail.value
|
||||
try {
|
||||
await ensureGenerationNotifyPermission()
|
||||
const body = new FormData()
|
||||
body.append('mode', v2Mode.value)
|
||||
body.append('task', v2Mode.value === 'generate' ? 't2i' : v2Mode.value === 'refine' ? 'refine' : v2Mode.value === 'compose' ? v2Task.value : 'scene')
|
||||
@@ -6900,6 +6903,7 @@ async function generate() {
|
||||
const hideOut = hideThumbnail.value
|
||||
const folderLockedPref = false
|
||||
try {
|
||||
await ensureGenerationNotifyPermission()
|
||||
const body = new FormData()
|
||||
if (file.value) body.append('image', file.value)
|
||||
if (inputStillId.value) body.append('stillId', inputStillId.value)
|
||||
@@ -7132,6 +7136,7 @@ function applyEditEvent(payload: Record<string, any>, hidden: boolean, folderLoc
|
||||
scheduleLibraryRefresh()
|
||||
void pollComfyHealth()
|
||||
void refreshStudioQueue()
|
||||
void notifyGenerationComplete('image')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7246,6 +7251,7 @@ function applyVideoEvent(payload: Record<string, any>, hidden: boolean, folderLo
|
||||
toast(locked
|
||||
? 'Saved to the locked folder. Unlock it to view.'
|
||||
: 'New clip saved to the library')
|
||||
void notifyGenerationComplete('video')
|
||||
return
|
||||
}
|
||||
if (locked) {
|
||||
@@ -7277,6 +7283,7 @@ function applyVideoEvent(payload: Record<string, any>, hidden: boolean, folderLo
|
||||
scheduleLibraryRefresh()
|
||||
void pollComfyHealth()
|
||||
void refreshStudioQueue()
|
||||
void notifyGenerationComplete('video')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -727,11 +727,14 @@ function listen(queue: Queue) {
|
||||
sources.set(queue.id, source)
|
||||
source.onmessage = (event) => {
|
||||
try {
|
||||
const payload = JSON.parse(event.data) as { message?: string; type?: string }
|
||||
const payload = JSON.parse(event.data) as { message?: string; type?: string; queuedRemaining?: number }
|
||||
if (payload.message) liveMessage.value = { ...liveMessage.value, [queue.id]: payload.message }
|
||||
if (payload.type === 'checkpoint' || payload.type === 'complete' || payload.type === 'error') {
|
||||
void loadQueues()
|
||||
}
|
||||
if (payload.type === 'complete' && !(Number(payload.queuedRemaining) > 0)) {
|
||||
void notifyGenerationComplete('video')
|
||||
}
|
||||
if (payload.type === 'complete' || payload.type === 'error') {
|
||||
source.close()
|
||||
sources.delete(queue.id)
|
||||
@@ -759,11 +762,14 @@ function listenJob(job: StudioJobRow) {
|
||||
sources.set(job.id, source)
|
||||
source.onmessage = (event) => {
|
||||
try {
|
||||
const payload = JSON.parse(event.data) as { message?: string; type?: string }
|
||||
const payload = JSON.parse(event.data) as { message?: string; type?: string; queuedRemaining?: number; stillId?: string }
|
||||
if (payload.message) liveMessage.value = { ...liveMessage.value, [job.id]: payload.message }
|
||||
if (payload.type === 'checkpoint' || payload.type === 'complete' || payload.type === 'error') {
|
||||
void loadQueues()
|
||||
}
|
||||
if (payload.type === 'complete' && !(Number(payload.queuedRemaining) > 0)) {
|
||||
void notifyGenerationComplete(job.kind === 'edit' || payload.stillId ? 'image' : 'video')
|
||||
}
|
||||
if (payload.type === 'complete' || payload.type === 'error') {
|
||||
source.close()
|
||||
sources.delete(job.id)
|
||||
|
||||
Reference in New Issue
Block a user