feat: Round-robin session queue scheduling across users#127
Open
Copilot wants to merge 9 commits into
Open
Conversation
- Add SESSION_QUEUE_MODE type and session_queue_mode config field - Modify dequeue() to support round-robin ordering when multiuser mode is active, serving each user in turn based on last-served timestamp - Add tests for FIFO and round-robin dequeue behavior Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add round-robin generation sessions across users
feat: Round-robin session queue scheduling across users
Mar 10, 2026
Three regressions from the multiuser isolation work in 33ec16d were preventing non-admin users from seeing the broader queue: 1. The "X/Y" pending badge collapsed to a single number because the backend stopped returning per-user counts and the frontend dropped the X/Y formatting. Restored user_pending/user_in_progress on SessionQueueStatus and the X/Y formatter; get_queue_status now takes an explicit is_admin flag for current-item visibility. 2. The queue list only showed the caller's own jobs because get_queue_item_ids filtered by user. Per-item field redaction already happens in list_all_queue_items / get_queue_items_by_item_ids, so the id list itself can be returned unfiltered. 3. After enqueue or status change in another user's batch, A's queue list, badge totals, and item statuses stayed stale until reload because QueueItemStatusChangedEvent and BatchEnqueuedEvent went only to user:{owner} + admin rooms. Now the full event still goes to those rooms, and a sanitized companion (user_id="redacted", identifiers and error fields stripped) is broadcast to the queue room with the owner and admin sids in skip_sid so they don't receive a clobbering duplicate. The frontend handler short-circuits the redacted variant to tag invalidation only, skipping per-session side effects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Run via `pnpm run generate-docs-data`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
lstein
added a commit
that referenced
this pull request
May 8, 2026
…ue status (invoke-ai#9087) * fix(multiuser): redact other users' current-item identifiers from queue status events QueueItemStatusChangedEvent embeds the SessionQueueStatus, which includes the currently-running item's item_id, session_id, and batch_id. The event ships to user:{owner} and admin rooms. When user A's item changed status while user B's item was the one in progress, owner A's frontend received the event with B's identifiers exposed. In _set_queue_item_status, scrub item_id/session_id/batch_id from the embedded queue_status when the in-progress item belongs to a different user than the changed item. Aggregate counts remain global (not user-sensitive). Identified out-of-scope in the security audit of #127. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(session_queue): close race condition in session queue user_id redaction --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
* feat: add image subfolder strategy setting UI * fix: address image subfolder strategy review
* translationBot(ui): update translation (Russian) Currently translated at 56.8% (1508 of 2652 strings) Co-authored-by: Dmitry Warkentin <dmitry@warkentin.ru> Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/ru/ Translation: InvokeAI/Web UI * translationBot(ui): update translation (Italian) Currently translated at 97.2% (2649 of 2724 strings) translationBot(ui): update translation (Italian) Currently translated at 97.2% (2639 of 2713 strings) translationBot(ui): update translation (Italian) Currently translated at 97.2% (2594 of 2666 strings) translationBot(ui): update translation (Italian) Currently translated at 97.1% (2577 of 2652 strings) Co-authored-by: Riccardo Giovanetti <riccardo.giovanetti@gmail.com> Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/it/ Translation: InvokeAI/Web UI * translationBot(ui): update translation files Updated by "Remove blank strings" hook in Weblate. Co-authored-by: Hosted Weblate <hosted@weblate.org> Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/ Translation: InvokeAI/Web UI * translationBot(ui): update translation (English (United Kingdom)) Currently translated at 0.1% (3 of 2729 strings) translationBot(ui): update translation (Romanian) Currently translated at 11.8% (323 of 2724 strings) translationBot(ui): update translation (Romanian) Currently translated at 0.1% (1 of 2724 strings) Co-authored-by: Filip Mînăilă <fillipgamerx414@gmail.com> Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/en_GB/ Translate-URL: https://hosted.weblate.org/projects/invokeai/web-ui/ro/ Translation: InvokeAI/Web UI --------- Co-authored-by: Dmitry Warkentin <dmitry@warkentin.ru> Co-authored-by: Riccardo Giovanetti <riccardo.giovanetti@gmail.com> Co-authored-by: Filip Mînăilă <fillipgamerx414@gmail.com>
… lost in merge The merge of main into this branch combined two conflicting refactors of get_queue_status: the branch added per-user user_pending/user_in_progress fields while main introduced acting_user_id for redaction. The merge kept the new structure plus the references in the return statement, but lost the lines that compute those variables, leaving user_counts_result populated but unused and raising NameError on every dequeue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In multiuser mode, a single user could monopolize the queue by enqueueing large batches, forcing other users to wait indefinitely. This adds a
round_robinqueue mode that interleaves jobs across users so each gets a turn before any user gets a second slot.Changes
session_queue_mode("FIFO"|"round_robin", default"round_robin"): controls dequeue ordering. Configurable viainvokeai.yaml, env var (INVOKEAI_SESSION_QUEUE_MODE), or CLI.session_queue_modeis ignored whenmultiuser=False.dequeue()SQL: uses two CTEs —user_last_servedtracksMAX(started_at)per user;user_next_itemselects each user's best pending item (priority DESC, item_id ASC). Rows are ordered byCOALESCE(last_served_at, '1970-01-01') ASCso the least-recently-served user always goes next.QA Instructions
multiuser: trueininvokeai.yaml(defaultsession_queue_mode: round_robin).session_queue_mode: FIFOand confirm strict insertion-order is restored.multiuser: false— confirm FIFO is used regardless ofsession_queue_mode.Run the new unit tests:
Checklist
What's Newcopy (if doing a release after this PR)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.