-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify title and favicon when item in progress (issue #2392) #6204
Modify title and favicon when item in progress (issue #2392) #6204
Conversation
Neat! And even some banana sushi!?! 👏 Is there a reason for (1) instead of the current active queue? |
I couldn't think of a better combination; as a good Brazilian, I love bananas and sushis! Keeping track of running items and clearing them upon completion is simpler. Still, the current implementation can be flawed if parallel operations are to be supported. I reviewed it, and it seems I could achieve that by doing something similar to the I'm open if you have any suggestions to improve this feature. |
@hipsterusername Thanks for your suggestion; I reviewed the code and implemented a solution similar to what I found in the Demodemo.mp4Questions
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
The implementation isn't quite right. Currently, we are imperatively updating the title and favicon in the socket handler, but the queue status can be changed by other code paths. For example, if you queue 5 items, then clear the queue, the count and icon do not reset as expected, because that query handler isn't updating the title and favicon.
The cache for useGetQueueStatusQuery
can be considered the source of truth for the queue status. The socket events and endpoints all sync to the cache. For example, in the listener you updated, you can see we update the query cache.
I'd suggest a hook that uses useEffect
to sync the title and favicon, using the data from that query cache.
- The hook would be a singleton. It's fine to just add a docstring to the hook saying to consider it a singleton, instead of programmatically enforcing it.
- Define constants as module-scoped variables outside the hook (
document.title
can be referenced for the initial value outside the hook) - Use a type guard that checks if
faviconEl
is an instance ofHTMLLinkElement
instead of casting it - Call the hook once in
App.tsx
We don't have an e2e test setup for the frontend. Don't worry about tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
Summary
Description
Two methods (
updatePageTitle
andupdatePageFavicon
) were created and executed within the WebSocket handler.When a Queue item's status changes, the methods append a
(1)
prefix and modify the favicon, respectively. I included anid
attribute to thelink
element to ensure the query wouldn't fail or collide.After Hipsterusername's suggestion, I modified the
updatePageTitle
method to display the active queue length instead of (1).Files changed:
invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts
invokeai/frontend/web/index.html
Files added
invokeai/frontend/web/public/assets/images/invoke-alert-favicon.svg
Demo
demo.mp4
(I will update the final demo video with all suggestions implemented once it's done)
Open questions
Related Issues / Discussions
Address issue #2392
QA Instructions
invoke
buttonMerge Plan
Checklist