-
Notifications
You must be signed in to change notification settings - Fork 433
Fix cloud queue cancel to target specific jobs #7176
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,7 @@ import { useQueueProgress } from '@/composables/queue/useQueueProgress' | |
| import { useResultGallery } from '@/composables/queue/useResultGallery' | ||
| import { useErrorHandling } from '@/composables/useErrorHandling' | ||
| import { useAssetSelectionStore } from '@/platform/assets/composables/useAssetSelectionStore' | ||
| import { isCloud } from '@/platform/distribution/types' | ||
| import { api } from '@/scripts/api' | ||
| import { useAssetsStore } from '@/stores/assetsStore' | ||
| import { useCommandStore } from '@/stores/commandStore' | ||
|
|
@@ -263,11 +264,21 @@ const cancelQueuedWorkflows = wrapWithErrorHandlingAsync(async () => { | |
|
|
||
| const interruptAll = wrapWithErrorHandlingAsync(async () => { | ||
| const tasks = queueStore.runningTasks | ||
| await Promise.all( | ||
| tasks | ||
| .filter((task) => task.promptId != null) | ||
| .map((task) => api.interrupt(task.promptId)) | ||
| ) | ||
| const promptIds = tasks | ||
| .map((task) => task.promptId) | ||
| .filter((id): id is string => typeof id === 'string' && id.length > 0) | ||
|
|
||
| if (!promptIds.length) return | ||
|
|
||
| // Cloud backend supports cancelling specific jobs via /queue delete, | ||
| // while /interrupt always targets the "first" job. Use the targeted API | ||
| // on cloud to ensure we cancel the workflow the user clicked. | ||
| if (isCloud) { | ||
| await Promise.all(promptIds.map((id) => api.deleteItem('queue', id))) | ||
| return | ||
| } | ||
|
|
||
| await Promise.all(promptIds.map((id) => api.interrupt(id))) | ||
| }) | ||
|
Comment on lines
265
to
282
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial interruptAll now safely filters promptIds; consider deduping IDs as a minor improvement The updated logic correctly:
As a minor optimization (especially if const interruptAll = wrapWithErrorHandlingAsync(async () => {
const tasks = queueStore.runningTasks
const promptIds = tasks
.map((task) => task.promptId)
.filter((id): id is string => typeof id === 'string' && id.length > 0)
if (!promptIds.length) return
+ const uniquePromptIds = [...new Set(promptIds)]
+
// Cloud backend supports cancelling specific jobs via /queue delete,
// while /interrupt always targets the "first" job. Use the targeted API
// on cloud to ensure we cancel the workflow the user clicked.
if (isCloud) {
- await Promise.all(promptIds.map((id) => api.deleteItem('queue', id)))
+ await Promise.all(uniquePromptIds.map((id) => api.deleteItem('queue', id)))
return
}
- await Promise.all(promptIds.map((id) => api.interrupt(id)))
+ await Promise.all(uniquePromptIds.map((id) => api.interrupt(id)))
})This keeps behavior the same in the common case while avoiding redundant calls if duplicates ever appear. 🤖 Prompt for AI Agents |
||
|
|
||
| const showClearHistoryDialog = () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.