Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add prompt ID to interrupt API call
  • Loading branch information
deepanjanroy committed Jul 9, 2025
commit b4a245914947db1364527b28517dfbc316b4e4e7
2 changes: 1 addition & 1 deletion src/components/sidebar/tabs/QueueSidebarTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const toggleExpanded = () => {

const removeTask = async (task: TaskItemImpl) => {
if (task.isRunning) {
await api.interrupt()
await api.interrupt(task.promptId)
}
await queueStore.delete(task)
}
Expand Down
4 changes: 3 additions & 1 deletion src/composables/useCoreCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useDialogService } from '@/services/dialogService'
import { useLitegraphService } from '@/services/litegraphService'
import { useWorkflowService } from '@/services/workflowService'
import type { ComfyCommand } from '@/stores/commandStore'
import { useExecutionStore } from '@/stores/executionStore'
import { useCanvasStore, useTitleEditorStore } from '@/stores/graphStore'
import { useQueueSettingsStore, useQueueStore } from '@/stores/queueStore'
import { useSettingStore } from '@/stores/settingStore'
Expand All @@ -39,6 +40,7 @@ export function useCoreCommands(): ComfyCommand[] {
const firebaseAuthActions = useFirebaseAuthActions()
const toastStore = useToastStore()
const canvasStore = useCanvasStore()
const executionStore = useExecutionStore()
const getTracker = () => workflowStore.activeWorkflow?.changeTracker

const getSelectedNodes = (): LGraphNode[] => {
Expand Down Expand Up @@ -203,7 +205,7 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-stop',
label: 'Interrupt',
function: async () => {
await api.interrupt()
await api.interrupt(executionStore.activePromptId)
toastStore.add({
severity: 'info',
summary: t('g.interrupted'),
Expand Down
14 changes: 10 additions & 4 deletions src/scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prompt[1] is not the most readable, but this bit of code is only used by the legacy UI and it's somewhat complicated to have nicer types here, so I did a low-effort thing.

})),
Pending: data.queue_pending.map((prompt: Record<number, any>) => ({
taskType: 'Pending',
Expand Down Expand Up @@ -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
)
}

/**
Expand Down