diff options
| author | soryu <soryu@soryu.co> | 2026-01-29 16:43:07 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-29 17:23:03 +0000 |
| commit | 4f1d67797dd56046665b772702b6b38fda9aa039 (patch) | |
| tree | 09bd946399987742c06076862daa5204b4f13245 | |
| parent | aef9c46c5608c8e455d49d31d790a4cc483706b9 (diff) | |
| download | soryu-4f1d67797dd56046665b772702b6b38fda9aa039.tar.gz soryu-4f1d67797dd56046665b772702b6b38fda9aa039.zip | |
Add autodetection of master for PR creation
| -rw-r--r-- | makima/src/daemon/task/manager.rs | 29 | ||||
| -rw-r--r-- | makima/src/daemon/ws/protocol.rs | 4 | ||||
| -rw-r--r-- | makima/src/server/handlers/mesh_supervisor.rs | 6 | ||||
| -rw-r--r-- | makima/src/server/state.rs | 4 |
4 files changed, 33 insertions, 10 deletions
diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs index 1e05978..dd133a2 100644 --- a/makima/src/daemon/task/manager.rs +++ b/makima/src/daemon/task/manager.rs @@ -2021,7 +2021,7 @@ impl TaskManager { tracing::info!( task_id = %task_id, title = %title, - base_branch = %base_branch, + base_branch = ?base_branch, branch = %branch, "Creating pull request" ); @@ -3136,7 +3136,7 @@ impl TaskManager { task_id: Uuid, title: String, body: Option<String>, - base_branch: String, + base_branch: Option<String>, branch: String, ) -> Result<(), DaemonError> { // Get worktree path - this works even for completed tasks by scanning worktrees directory @@ -3156,6 +3156,31 @@ impl TaskManager { } }; + // Detect base branch if not provided + let base_branch = match base_branch { + Some(b) => b, + None => { + match self.worktree_manager.detect_default_branch(&worktree_path).await { + Ok(detected) => { + tracing::info!(task_id = %task_id, detected_branch = %detected, "Auto-detected base branch"); + detected + } + Err(e) => { + tracing::error!(task_id = %task_id, error = %e, "Failed to detect default branch"); + let msg = DaemonMessage::PRCreated { + task_id, + success: false, + message: format!("Failed to detect default branch: {}", e), + pr_url: None, + pr_number: None, + }; + let _ = self.ws_tx.send(msg).await; + return Ok(()); + } + } + } + }; + tracing::info!( task_id = %task_id, base_branch = %base_branch, diff --git a/makima/src/daemon/ws/protocol.rs b/makima/src/daemon/ws/protocol.rs index e971798..c396961 100644 --- a/makima/src/daemon/ws/protocol.rs +++ b/makima/src/daemon/ws/protocol.rs @@ -693,9 +693,9 @@ pub enum DaemonCommand { task_id: Uuid, title: String, body: Option<String>, - /// Base branch for the PR. + /// Base branch for the PR. If None, will be auto-detected from the repo. #[serde(rename = "baseBranch")] - base_branch: String, + base_branch: Option<String>, /// Source branch name to push and create PR from. branch: String, }, diff --git a/makima/src/server/handlers/mesh_supervisor.rs b/makima/src/server/handlers/mesh_supervisor.rs index 6f17103..5e74251 100644 --- a/makima/src/server/handlers/mesh_supervisor.rs +++ b/makima/src/server/handlers/mesh_supervisor.rs @@ -1544,19 +1544,17 @@ pub async fn create_pr( ).into_response(); }; - // Use base_branch from the task's repository config, falling back to "main" - let base_branch = task.base_branch.unwrap_or_else(|| "main".to_string()); - // Subscribe to PR results BEFORE sending the command let mut rx = state.pr_results.subscribe(); // Send CreatePR command to daemon using the supervisor's task ID // (the branch is in the supervisor's worktree) + // Pass base_branch from task if available, otherwise daemon will auto-detect let cmd = DaemonCommand::CreatePR { task_id: supervisor_id, title: request.title.clone(), body: request.body.clone(), - base_branch, + base_branch: task.base_branch.clone(), branch: request.branch.clone(), }; diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs index 4650a57..8a9bb7f 100644 --- a/makima/src/server/state.rs +++ b/makima/src/server/state.rs @@ -461,9 +461,9 @@ pub enum DaemonCommand { task_id: Uuid, title: String, body: Option<String>, - /// Base branch for the PR + /// Base branch for the PR. If None, will be auto-detected from the repo. #[serde(rename = "baseBranch")] - base_branch: String, + base_branch: Option<String>, /// Source branch name to push and create PR from branch: String, }, |
