diff options
Diffstat (limited to 'makima/src/server/handlers/mesh_daemon.rs')
| -rw-r--r-- | makima/src/server/handlers/mesh_daemon.rs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/makima/src/server/handlers/mesh_daemon.rs b/makima/src/server/handlers/mesh_daemon.rs index f5a3c10..6934662 100644 --- a/makima/src/server/handlers/mesh_daemon.rs +++ b/makima/src/server/handlers/mesh_daemon.rs @@ -448,6 +448,29 @@ pub enum DaemonMessage { /// Error message if operation failed error: Option<String>, }, + /// Response to CreateExportPatch command + ExportPatchCreated { + #[serde(rename = "taskId")] + task_id: Uuid, + success: bool, + /// The uncompressed, human-readable patch content + #[serde(rename = "patchContent")] + patch_content: Option<String>, + /// Number of files changed + #[serde(rename = "filesCount")] + files_count: Option<usize>, + /// Lines added + #[serde(rename = "linesAdded")] + lines_added: Option<usize>, + /// Lines removed + #[serde(rename = "linesRemoved")] + lines_removed: Option<usize>, + /// The base commit SHA that the patch is diffed against + #[serde(rename = "baseCommitSha")] + base_commit_sha: Option<String>, + /// Error message if failed + error: Option<String>, + }, /// Response to MergeTaskToTarget command MergeToTargetResult { #[serde(rename = "taskId")] @@ -1783,6 +1806,75 @@ async fn handle_daemon_connection(socket: WebSocket, state: SharedState, auth_re ); } } + Ok(DaemonMessage::ExportPatchCreated { + task_id, + success, + patch_content, + files_count, + lines_added, + lines_removed, + base_commit_sha, + error, + }) => { + if success { + tracing::info!( + task_id = %task_id, + files_count = ?files_count, + lines_added = ?lines_added, + lines_removed = ?lines_removed, + base_commit_sha = ?base_commit_sha, + patch_len = patch_content.as_ref().map(|p| p.len()), + "Export patch created successfully" + ); + + // Broadcast as task output so UI can access the result + let output_text = format!( + "✓ Export patch created: {} files changed, +{} -{} lines (base: {})", + files_count.unwrap_or(0), + lines_added.unwrap_or(0), + lines_removed.unwrap_or(0), + base_commit_sha.as_deref().unwrap_or("unknown") + ); + state.broadcast_task_output(TaskOutputNotification { + task_id, + owner_id: Some(owner_id), + message_type: "export_patch".to_string(), + content: output_text, + tool_name: None, + tool_input: Some(serde_json::json!({ + "patchContent": patch_content, + "filesCount": files_count, + "linesAdded": lines_added, + "linesRemoved": lines_removed, + "baseCommitSha": base_commit_sha, + })), + is_error: None, + cost_usd: None, + duration_ms: None, + is_partial: false, + }); + } else { + tracing::warn!( + task_id = %task_id, + error = ?error, + "Failed to create export patch" + ); + + // Broadcast error + state.broadcast_task_output(TaskOutputNotification { + task_id, + owner_id: Some(owner_id), + message_type: "error".to_string(), + content: format!("✗ Export patch failed: {}", error.unwrap_or_else(|| "Unknown error".to_string())), + tool_name: None, + tool_input: None, + is_error: Some(true), + cost_usd: None, + duration_ms: None, + is_partial: false, + }); + } + } Err(e) => { tracing::warn!("Failed to parse daemon message: {}", e); } |
