Skip to content

Commit 7cf5d1e

Browse files
authored
Add prompt ID to interrupt API call (#4393)
1 parent ab43b5e commit 7cf5d1e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/components/sidebar/tabs/QueueSidebarTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const toggleExpanded = () => {
159159
160160
const removeTask = async (task: TaskItemImpl) => {
161161
if (task.isRunning) {
162-
await api.interrupt()
162+
await api.interrupt(task.promptId)
163163
}
164164
await queueStore.delete(task)
165165
}

src/composables/useCoreCommands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useDialogService } from '@/services/dialogService'
1919
import { useLitegraphService } from '@/services/litegraphService'
2020
import { useWorkflowService } from '@/services/workflowService'
2121
import type { ComfyCommand } from '@/stores/commandStore'
22+
import { useExecutionStore } from '@/stores/executionStore'
2223
import { useCanvasStore, useTitleEditorStore } from '@/stores/graphStore'
2324
import { useQueueSettingsStore, useQueueStore } from '@/stores/queueStore'
2425
import { useSettingStore } from '@/stores/settingStore'
@@ -39,6 +40,7 @@ export function useCoreCommands(): ComfyCommand[] {
3940
const firebaseAuthActions = useFirebaseAuthActions()
4041
const toastStore = useToastStore()
4142
const canvasStore = useCanvasStore()
43+
const executionStore = useExecutionStore()
4244
const getTracker = () => workflowStore.activeWorkflow?.changeTracker
4345

4446
const getSelectedNodes = (): LGraphNode[] => {
@@ -203,7 +205,7 @@ export function useCoreCommands(): ComfyCommand[] {
203205
icon: 'pi pi-stop',
204206
label: 'Interrupt',
205207
function: async () => {
206-
await api.interrupt()
208+
await api.interrupt(executionStore.activePromptId)
207209
toastStore.add({
208210
severity: 'info',
209211
summary: t('g.interrupted'),

src/scripts/api.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ export class ComfyApi extends EventTarget {
689689
Running: data.queue_running.map((prompt: Record<number, any>) => ({
690690
taskType: 'Running',
691691
prompt,
692-
remove: { name: 'Cancel', cb: () => api.interrupt() }
692+
// prompt[1] is the prompt id
693+
remove: { name: 'Cancel', cb: () => api.interrupt(prompt[1]) }
693694
})),
694695
Pending: data.queue_pending.map((prompt: Record<number, any>) => ({
695696
taskType: 'Pending',
@@ -770,10 +771,15 @@ export class ComfyApi extends EventTarget {
770771
}
771772

772773
/**
773-
* Interrupts the execution of the running prompt
774+
* Interrupts the execution of the running prompt. If runningPromptId is provided,
775+
* it is included in the payload as a helpful hint to the backend.
776+
* @param {string | null} [runningPromptId] Optional Running Prompt ID to interrupt
774777
*/
775-
async interrupt() {
776-
await this.#postItem('interrupt', null)
778+
async interrupt(runningPromptId: string | null) {
779+
await this.#postItem(
780+
'interrupt',
781+
runningPromptId ? { prompt_id: runningPromptId } : undefined
782+
)
777783
}
778784

779785
/**

0 commit comments

Comments
 (0)