From 151e9d87e117b7980e6aad522ac8f3633eeca87a Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 2 Feb 2026 02:34:50 +0000 Subject: Make makima more opinionated and structured --- makima/src/server/handlers/mesh_daemon.rs | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'makima/src/server/handlers/mesh_daemon.rs') diff --git a/makima/src/server/handlers/mesh_daemon.rs b/makima/src/server/handlers/mesh_daemon.rs index 34e2cc3..cb929ea 100644 --- a/makima/src/server/handlers/mesh_daemon.rs +++ b/makima/src/server/handlers/mesh_daemon.rs @@ -1870,6 +1870,68 @@ async fn handle_daemon_connection(socket: WebSocket, state: SharedState, auth_re } } } + } else if let (Some(patch_b64), Some(base_sha)) = (&patch_data, &patch_base_sha) { + // Ephemeral patch-only checkpoint (no git commit) + // Store patch directly in checkpoint_patches without a task_checkpoint + if let Some(pool) = state.db_pool.as_ref() { + match base64::engine::general_purpose::STANDARD.decode(patch_b64) { + Ok(patch_bytes) => { + let files_count = patch_files_count.unwrap_or(0); + // Default TTL: 7 days (168 hours) + let ttl_hours = 168i64; + match repository::create_checkpoint_patch( + pool, + task_id, + None, // No checkpoint_id for ephemeral patches + base_sha, + &patch_bytes, + files_count, + ttl_hours, + ).await { + Ok(patch) => { + tracing::info!( + task_id = %task_id, + patch_id = %patch.id, + patch_size = patch_bytes.len(), + files_count = files_count, + "Ephemeral patch stored for recovery" + ); + + state.broadcast_task_output(TaskOutputNotification { + task_id, + owner_id: Some(owner_id), + message_type: "system".to_string(), + content: format!( + "✓ Patch saved: {} ({} files)", + message, + files_count + ), + tool_name: None, + tool_input: None, + is_error: Some(false), + cost_usd: None, + duration_ms: None, + is_partial: false, + }); + } + Err(e) => { + tracing::warn!( + task_id = %task_id, + error = %e, + "Failed to store ephemeral patch" + ); + } + } + } + Err(e) => { + tracing::warn!( + task_id = %task_id, + error = %e, + "Failed to decode ephemeral patch base64 data" + ); + } + } + } } } else { // Broadcast failure -- cgit v1.2.3