From f93489a52409af63cea69fd1ce8661f74d0361b8 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 20 Feb 2026 19:07:23 +0000 Subject: feat: auto-remove merged steps, fix UI overflow, and improve worktree handling (#74) * feat: soryu-co/soryu - makima: Fix contracts page overflow - constrain layout to viewport height * feat: soryu-co/soryu - makima: Add git fetch to create_worktree and improve completion prompt merge conflict handling * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: Add pending question notification badge to directive sidebar and nav * feat: soryu-co/soryu - makima: Fix reconcile:on blocking - make phaseguard poll indefinitely instead of returning immediately * feat: soryu-co/soryu - makima: Auto-remove merged steps before planning runs --- makima/src/server/handlers/directives.rs | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'makima/src/server') diff --git a/makima/src/server/handlers/directives.rs b/makima/src/server/handlers/directives.rs index 56278a8..992affe 100644 --- a/makima/src/server/handlers/directives.rs +++ b/makima/src/server/handlers/directives.rs @@ -931,6 +931,19 @@ pub async fn cleanup_directive( .into_response(); } + // Auto-remove completed steps that were already included in a merged PR + if directive.pr_url.is_some() || directive.pr_branch.is_some() { + match crate::orchestration::directive::remove_already_merged_steps(pool, id).await { + Ok(count) if count > 0 => { + tracing::info!("Auto-removed {} completed steps already in PR for directive {} during cleanup", count, id); + } + Err(e) => { + tracing::warn!("Failed to auto-remove merged steps during cleanup for directive {}: {}", id, e); + } + _ => {} + } + } + // Get completed step tasks for branch name computation let step_tasks = match repository::get_completed_step_tasks(pool, id).await { Ok(tasks) => tasks, @@ -1155,7 +1168,7 @@ pub async fn pick_up_orders( }; // Verify directive ownership and get directive with steps - let (directive, steps) = + let (directive, mut steps) = match repository::get_directive_with_steps_for_owner(pool, auth.owner_id, id).await { Ok(Some((d, s))) => (d, s), Ok(None) => { @@ -1175,6 +1188,30 @@ pub async fn pick_up_orders( } }; + // Auto-remove completed steps that were already included in a PR + if directive.pr_url.is_some() || directive.pr_branch.is_some() { + match crate::orchestration::directive::remove_already_merged_steps(pool, id).await { + Ok(count) if count > 0 => { + tracing::info!("Auto-removed {} completed steps already in PR for directive {}", count, id); + // Re-fetch steps since some were removed + steps = match repository::list_directive_steps(pool, id).await { + Ok(s) => s, + Err(e) => { + tracing::error!("Failed to re-fetch steps after cleanup: {}", e); + return ( + StatusCode::INTERNAL_SERVER_ERROR, + Json(ApiError::new("REFETCH_STEPS_FAILED", &e.to_string())), + ).into_response(); + } + }; + } + Err(e) => { + tracing::warn!("Failed to auto-remove merged steps for directive {}: {}", id, e); + } + _ => {} + } + } + // Reconcile existing orders: mark done if step completed, under_review if step in progress match repository::reconcile_directive_orders(pool, auth.owner_id, id).await { Ok(count) => { -- cgit v1.2.3