From 43a593c1e1c77b2218f3cd46dbcccb80698f5e94 Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Wed, 17 Dec 2025 17:21:55 +0100 Subject: [PATCH] Bug fix: dont let tasks slip by human review if the task was set as done. --- .../ipc-handlers/task/execution-handlers.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/auto-claude-ui/src/main/ipc-handlers/task/execution-handlers.ts b/auto-claude-ui/src/main/ipc-handlers/task/execution-handlers.ts index fe242db5..cb98c302 100644 --- a/auto-claude-ui/src/main/ipc-handlers/task/execution-handlers.ts +++ b/auto-claude-ui/src/main/ipc-handlers/task/execution-handlers.ts @@ -216,6 +216,16 @@ export function registerTaskExecutionHandlers( taskId: string, status: TaskStatus ): Promise => { + // Validate status transition - 'done' can only be set through merge handler + // This prevents AI agents from bypassing the human review workflow + if (status === 'done') { + console.warn(`[TASK_UPDATE_STATUS] Blocked attempt to set status 'done' directly for task ${taskId}. Use merge workflow instead.`); + return { + success: false, + error: "Cannot set status to 'done' directly. Complete the human review and merge the worktree changes instead." + }; + } + // Find task and project const { task, project } = findTaskAndProject(taskId); @@ -242,8 +252,8 @@ export function registerTaskExecutionHandlers( // Store the exact UI status - project-store.ts will map it back plan.status = status; // Also store mapped version for Python compatibility - plan.planStatus = status === 'done' ? 'completed' - : status === 'in_progress' ? 'in_progress' + // Note: 'done' is blocked at the start of this handler - only set via merge workflow + plan.planStatus = status === 'in_progress' ? 'in_progress' : status === 'ai_review' ? 'review' : status === 'human_review' ? 'review' : 'pending'; @@ -252,14 +262,14 @@ export function registerTaskExecutionHandlers( writeFileSync(planPath, JSON.stringify(plan, null, 2)); } else { // If no implementation plan exists yet, create a basic one + // Note: 'done' status is blocked at the start of this handler const plan = { feature: task.title, description: task.description || '', created_at: task.createdAt.toISOString(), updated_at: new Date().toISOString(), status: status, // Store exact UI status for persistence - planStatus: status === 'done' ? 'completed' - : status === 'in_progress' ? 'in_progress' + planStatus: status === 'in_progress' ? 'in_progress' : status === 'ai_review' ? 'review' : status === 'human_review' ? 'review' : 'pending',