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.
This commit is contained in:
AndyMik90
2025-12-23 00:11:48 +01:00
parent 220faf0fb4
commit 30e7536b63
@@ -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();