From d569985bbf8dbe07f05a76a198a6dd76ef3304e2 Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 26 Jan 2026 14:26:06 +0000 Subject: Fix branching to restore from checkpoint --- makima/src/server/handlers/mesh.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'makima/src/server') diff --git a/makima/src/server/handlers/mesh.rs b/makima/src/server/handlers/mesh.rs index 3d64eb4..545d1ea 100644 --- a/makima/src/server/handlers/mesh.rs +++ b/makima/src/server/handlers/mesh.rs @@ -3500,6 +3500,30 @@ pub async fn branch_task( }), ).await; + // Fetch latest checkpoint patch from source task for worktree recovery + let (patch_data, patch_base_sha) = match repository::get_latest_checkpoint_patch(pool, source_task_id).await { + Ok(Some(patch)) => { + tracing::info!( + source_task_id = %source_task_id, + new_task_id = %task.id, + patch_size = patch.patch_size_bytes, + base_sha = %patch.base_commit_sha, + files_count = patch.files_count, + "Including checkpoint patch for task branching recovery" + ); + let encoded = base64::engine::general_purpose::STANDARD.encode(&patch.patch_data); + (Some(encoded), Some(patch.base_commit_sha)) + } + Ok(None) => { + tracing::debug!(source_task_id = %source_task_id, "No checkpoint patch found for branching"); + (None, None) + } + Err(e) => { + tracing::warn!(source_task_id = %source_task_id, error = %e, "Failed to fetch checkpoint patch for branching"); + (None, None) + } + }; + // Try to find an available daemon to start the task let daemon_id = state.daemon_connections .iter() @@ -3536,8 +3560,8 @@ pub async fn branch_task( autonomous_loop: false, resume_session: message_count > 0, // Resume if we have conversation history conversation_history: updated_task.conversation_state.clone(), - patch_data: None, - patch_base_sha: None, + patch_data, + patch_base_sha, }; if let Err(e) = state.send_daemon_command(target_daemon_id, command).await { -- cgit v1.2.3