diff options
Diffstat (limited to 'makima/src/daemon/task/manager.rs')
| -rw-r--r-- | makima/src/daemon/task/manager.rs | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs index 1e04ca1..d246ac8 100644 --- a/makima/src/daemon/task/manager.rs +++ b/makima/src/daemon/task/manager.rs @@ -997,6 +997,8 @@ pub struct ManagedTask { pub autonomous_loop: bool, /// Whether the contract is in local-only mode (skips automatic completion actions). pub local_only: bool, + /// Whether to auto-merge to target branch locally when local_only mode is enabled. + pub auto_merge_local: bool, /// If set, merge this task's changes to the supervisor's worktree on completion (cross-daemon case). pub merge_to_supervisor_task_id: Option<Uuid>, /// If set, this task shares the worktree of the specified supervisor task. @@ -1730,6 +1732,7 @@ impl TaskManager { patch_data, patch_base_sha, local_only, + auto_merge_local, supervisor_worktree_task_id, } => { tracing::info!( @@ -1758,7 +1761,7 @@ impl TaskManager { parent_task_id, depth, is_orchestrator, is_supervisor, target_repo_path, completion_action, continue_from_task_id, copy_files, contract_id, autonomous_loop, resume_session, - conversation_history, patch_data, patch_base_sha, local_only, + conversation_history, patch_data, patch_base_sha, local_only, auto_merge_local, supervisor_worktree_task_id, ).await?; } @@ -1838,6 +1841,7 @@ impl TaskManager { let completion_action = task.completion_action.clone(); let contract_id = task.contract_id; let local_only = task.local_only; + let auto_merge_local = task.auto_merge_local; // Spawn in background to not block the command handler tokio::spawn(async move { @@ -1861,6 +1865,7 @@ impl TaskManager { None, // patch_data - not available for respawn None, // patch_base_sha - not available for respawn local_only, + auto_merge_local, None, // supervisor_worktree_task_id - supervisors use their own worktree ).await { tracing::error!( @@ -2117,6 +2122,7 @@ impl TaskManager { patch_data: Option<String>, patch_base_sha: Option<String>, local_only: bool, + auto_merge_local: bool, supervisor_worktree_task_id: Option<Uuid>, ) -> TaskResult<()> { tracing::info!(task_id = %task_id, is_orchestrator = is_orchestrator, is_supervisor = is_supervisor, depth = depth, patch_available = patch_data.is_some(), "=== SPAWN_TASK START ==="); @@ -2169,6 +2175,7 @@ impl TaskManager { concurrency_key, autonomous_loop, local_only, + auto_merge_local, merge_to_supervisor_task_id: None, // Set later if cross-daemon supervisor_worktree_task_id, created_at: Instant::now(), @@ -2197,7 +2204,7 @@ impl TaskManager { task_id, task_name, plan, repo_url, base_branch, target_branch, is_orchestrator, is_supervisor, target_repo_path, completion_action, continue_from_task_id, copy_files, contract_id, autonomous_loop, resume_session, - conversation_history, patch_data, patch_base_sha, local_only, + conversation_history, patch_data, patch_base_sha, local_only, auto_merge_local, supervisor_worktree_task_id, ).await { tracing::error!(task_id = %task_id, error = %e, "Task execution failed"); @@ -4203,6 +4210,7 @@ impl TaskManagerInner { patch_data: Option<String>, patch_base_sha: Option<String>, local_only: bool, + auto_merge_local: bool, supervisor_worktree_task_id: Option<Uuid>, ) -> Result<(), DaemonError> { tracing::info!(task_id = %task_id, is_orchestrator = is_orchestrator, is_supervisor = is_supervisor, resume_session = resume_session, has_patch = patch_data.is_some(), "=== RUN_TASK START ==="); @@ -5398,14 +5406,30 @@ impl TaskManagerInner { } } - // Execute completion action if task succeeded (skip in local_only mode) + // Execute completion action if task succeeded (skip in local_only mode unless auto_merge_local is enabled) let completion_result = if success { if local_only { - tracing::info!( - task_id = %task_id, - "Skipping completion action - contract is in local_only mode" - ); - Ok(None) + if auto_merge_local { + // In local_only mode with auto_merge_local enabled, merge locally + tracing::info!( + task_id = %task_id, + "Local-only mode with auto_merge_local - executing local merge" + ); + self.execute_completion_action( + task_id, + &task_name, + &working_dir, + "merge", // Use merge action (not pr) + target_repo_path.as_deref(), + target_branch.as_deref(), + ).await + } else { + tracing::info!( + task_id = %task_id, + "Skipping completion action - contract is in local_only mode" + ); + Ok(None) + } } else if let Some(ref action) = completion_action { if action != "none" { self.execute_completion_action( |
