From 30e7536b63f383e4f29f5f50b3bea5c41bde9446 Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Tue, 23 Dec 2025 00:11:48 +0100 Subject: [PATCH] fix(task): stop running process when task status changes away from in_progress When a user drags a running task back to Planning (or any other column), the process was not being stopped, leaving a "ghost" process that prevented deletion with "Cannot delete a running task" error. Now the task process is automatically killed when status changes away from in_progress, ensuring the process state stays in sync with the UI. --- .../src/main/ipc-handlers/task/execution-handlers.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/frontend/src/main/ipc-handlers/task/execution-handlers.ts b/apps/frontend/src/main/ipc-handlers/task/execution-handlers.ts index 398b0b94..9f304c4b 100644 --- a/apps/frontend/src/main/ipc-handlers/task/execution-handlers.ts +++ b/apps/frontend/src/main/ipc-handlers/task/execution-handlers.ts @@ -412,6 +412,13 @@ export function registerTaskExecutionHandlers( writeFileSync(planPath, JSON.stringify(plan, null, 2)); } + // Auto-stop task when status changes AWAY from 'in_progress' and process IS running + // This handles the case where user drags a running task back to Planning/backlog + if (status !== 'in_progress' && agentManager.isRunning(taskId)) { + console.warn('[TASK_UPDATE_STATUS] Stopping task due to status change away from in_progress:', taskId); + agentManager.killTask(taskId); + } + // Auto-start task when status changes to 'in_progress' and no process is running if (status === 'in_progress' && !agentManager.isRunning(taskId)) { const mainWindow = getMainWindow();