Add prompt ID to interrupt API call (#4393)

This commit is contained in:
Deep Roy
2025-07-10 20:24:21 -04:00
committed by GitHub
parent ab43b5e421
commit 7cf5d1e86b
3 changed files with 14 additions and 6 deletions

View File

@@ -689,7 +689,8 @@ export class ComfyApi extends EventTarget {
Running: data.queue_running.map((prompt: Record<number, any>) => ({
taskType: 'Running',
prompt,
remove: { name: 'Cancel', cb: () => api.interrupt() }
// prompt[1] is the prompt id
remove: { name: 'Cancel', cb: () => api.interrupt(prompt[1]) }
})),
Pending: data.queue_pending.map((prompt: Record<number, any>) => ({
taskType: 'Pending',
@@ -770,10 +771,15 @@ export class ComfyApi extends EventTarget {
}
/**
* Interrupts the execution of the running prompt
* Interrupts the execution of the running prompt. If runningPromptId is provided,
* it is included in the payload as a helpful hint to the backend.
* @param {string | null} [runningPromptId] Optional Running Prompt ID to interrupt
*/
async interrupt() {
await this.#postItem('interrupt', null)
async interrupt(runningPromptId: string | null) {
await this.#postItem(
'interrupt',
runningPromptId ? { prompt_id: runningPromptId } : undefined
)
}
/**