From bc1ce8013bc36a1585be05b928f2386ab56529c2 Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 26 Jan 2026 21:24:04 +0000 Subject: Make merges synchronous --- makima/src/server/state.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'makima/src/server/state.rs') diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs index b954efe..988f657 100644 --- a/makima/src/server/state.rs +++ b/makima/src/server/state.rs @@ -103,6 +103,21 @@ pub struct TaskCompletionNotification { pub error_message: Option, } +/// Notification for merge operation results. +#[derive(Debug, Clone)] +pub struct MergeResultNotification { + /// ID of the task that was merged + pub task_id: Uuid, + /// Whether the merge succeeded + pub success: bool, + /// Message describing the result + pub message: String, + /// Commit SHA if merge succeeded + pub commit_sha: Option, + /// List of conflicting files if merge failed due to conflicts + pub conflicts: Option>, +} + /// Notification for supervisor questions requiring user feedback. #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] @@ -507,6 +522,8 @@ pub struct AppState { pub task_completions: broadcast::Sender, /// Broadcast channel for supervisor question notifications pub supervisor_questions: broadcast::Sender, + /// Broadcast channel for merge result notifications + pub merge_results: broadcast::Sender, /// Pending supervisor questions awaiting user response (keyed by question_id) pub pending_questions: DashMap, /// Responses to supervisor questions (keyed by question_id) @@ -539,6 +556,7 @@ impl AppState { let (task_output, _) = broadcast::channel(1024); // Larger buffer for output streaming let (task_completions, _) = broadcast::channel(256); // For supervisor task monitoring let (supervisor_questions, _) = broadcast::channel(256); // For supervisor questions to users + let (merge_results, _) = broadcast::channel(256); // For merge operation results // Initialize JWT verifier from environment (optional) // Requires SUPABASE_URL and either SUPABASE_JWT_PUBLIC_KEY (RS256) or SUPABASE_JWT_SECRET (HS256) @@ -581,6 +599,7 @@ impl AppState { task_output, task_completions, supervisor_questions, + merge_results, pending_questions: DashMap::new(), question_responses: DashMap::new(), daemon_connections: DashMap::new(), @@ -670,6 +689,13 @@ impl AppState { let _ = self.supervisor_questions.send(notification); } + /// Broadcast a merge result notification to all subscribers. + /// + /// Used to notify waiting handlers when a merge operation completes. + pub fn broadcast_merge_result(&self, notification: MergeResultNotification) { + let _ = self.merge_results.send(notification); + } + /// Add a pending supervisor question and broadcast it. pub fn add_supervisor_question( &self, -- cgit v1.2.3