From a4593613769a5454e7eabeccb03e9e7ead6808ab Mon Sep 17 00:00:00 2001 From: Daniel Abrao Date: Fri, 12 Apr 2024 08:04:46 -0300 Subject: [PATCH] Modify the processing to consider the active queue length instead of in_progress only --- .../socketio/socketQueueItemStatusChanged.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts index 4b91ff3a2e..c633dbf63b 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts @@ -8,13 +8,17 @@ const log = logger('socketio'); const updatePageTitle = (itemStatus: string) => { const baseString: string = document.title.replace('(1) ', ''); document.title = itemStatus === 'in_progress' ? `(1) ${baseString}` : baseString; +const updatePageTitle = (activeQueueLength: number) => { + const baseString: string = document.title.replace(/\(\d+\)/ , ''); + document.title = activeQueueLength > 0 ? `(${activeQueueLength}) ${baseString}` : baseString; }; const updatePageFavicon = (itemStatus: string) => { +const updatePageFavicon = (activeQueueLength: number) => { const InvokeLogoSVG: string = 'assets/images/invoke-favicon.svg'; const InvokeAlertLogoSVG: string = 'assets/images/invoke-alert-favicon.svg'; const faviconEl: HTMLLinkElement = document.getElementById('invoke-favicon') as HTMLLinkElement; - faviconEl.href = itemStatus === 'in_progress' ? InvokeAlertLogoSVG : InvokeLogoSVG; + faviconEl.href = activeQueueLength > 0 ? InvokeAlertLogoSVG : InvokeLogoSVG; }; export const addSocketQueueItemStatusChangedEventListener = (startAppListening: AppStartListening) => { @@ -24,6 +28,9 @@ export const addSocketQueueItemStatusChangedEventListener = (startAppListening: // we've got new status for the queue item, batch and queue const { queue_item, batch_status, queue_status } = action.payload.data; + // Keep track of the active queue length by summing up pending and in_progress count + const activeQueueLength: number = (queue_status.pending + queue_status.in_progress) || 0; + log.debug(action.payload, `Queue item ${queue_item.item_id} status updated: ${queue_item.status}`); // Update this specific queue item in the list of queue items (this is the queue item DTO, without the session) @@ -67,8 +74,8 @@ export const addSocketQueueItemStatusChangedEventListener = (startAppListening: queueApi.util.invalidateTags(['CurrentSessionQueueItem', 'NextSessionQueueItem', 'InvocationCacheStatus']) ); - updatePageTitle(queue_item.status); - updatePageFavicon(queue_item.status); + updatePageTitle(activeQueueLength); + updatePageFavicon(activeQueueLength); }, }); };