Notify from the installed web app when a generation finishes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+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