From ea96c718182842bf5e4b8ae131a2cad5b2895896 Mon Sep 17 00:00:00 2001 From: Godwin Iheuwa Date: Tue, 30 Dec 2025 01:18:59 +0530 Subject: [PATCH] fix(queue): Cancel button now works for pending jobs (#7788) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes the cancel button on queue job items to properly handle pending (queued) jobs. ## Problem The cancel button was calling `api.interrupt()` for all jobs, but interrupt only affects running/initializing jobs. For pending jobs, it silently fails with log message: `"Prompt ... is not currently running, skipping interrupt"`. The "Cancel job" option in the context menu worked correctly because it checks the job state first. Reported in #7758. ## Changes Update `onCancelItem` in `QueueProgressOverlay.vue` to mirror the behavior of `cancelJob()` in `useJobMenu.ts`: - Check `item.state` before deciding which API to call - Call `api.interrupt(promptId)` for `running` or `initialization` states - Call `api.deleteItem('queue', promptId)` for `pending` state - Refresh queue state after cancel action with `queueStore.update()` ## Testing - All 3816 unit tests pass - Type check passes - Lint passes (prettier, oxlint, eslint) ## Steps to Reproduce (before fix) 1. Queue more than 1 job 2. Open job history 3. Click "Cancel" button on any "in queue" job 4. Observe nothing happens (job remains in queue) After this fix, clicking Cancel on a pending job will remove it from the queue. Fixes #7758 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7788-fix-queue-Cancel-button-now-works-for-pending-jobs-2d86d73d365081b3957fdf1d5d677809) by [Unito](https://www.unito.io) --------- Co-authored-by: RUiNtheExtinct --- src/components/queue/QueueProgressOverlay.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/queue/QueueProgressOverlay.vue b/src/components/queue/QueueProgressOverlay.vue index a941af55a..78efb7a78 100644 --- a/src/components/queue/QueueProgressOverlay.vue +++ b/src/components/queue/QueueProgressOverlay.vue @@ -197,7 +197,16 @@ const displayedJobGroups = computed(() => groupedJobItems.value) const onCancelItem = wrapWithErrorHandlingAsync(async (item: JobListItem) => { const promptId = item.taskRef?.promptId if (!promptId) return - await api.interrupt(promptId) + + if (item.state === 'running' || item.state === 'initialization') { + // Running/initializing jobs: interrupt execution + await api.interrupt(promptId) + await queueStore.update() + } else if (item.state === 'pending') { + // Pending jobs: remove from queue + await api.deleteItem('queue', promptId) + await queueStore.update() + } }) const onDeleteItem = wrapWithErrorHandlingAsync(async (item: JobListItem) => {