summaryrefslogtreecommitdiff
path: root/makima/src/server/state.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-27 01:22:11 +0000
committerGitHub <noreply@github.com>2026-01-27 01:22:11 +0000
commitb28345d15730ffbefe81244d06c06fe13c30b0ea (patch)
treeba27ab3a84d2504427e92aa2486e464090100f62 /makima/src/server/state.rs
parent6cd5b20670d7ecd3d48539ff898e021988f2a503 (diff)
downloadsoryu-b28345d15730ffbefe81244d06c06fe13c30b0ea.tar.gz
soryu-b28345d15730ffbefe81244d06c06fe13c30b0ea.zip
Fix supervisor merge and PR commands (#36)
* Task completion checkpoint * Task completion checkpoint * Task completion checkpoint * Fix supervisor merge for completed tasks and make PR command synchronous ## Issue 1: makima supervisor merge doesn't work for completed tasks When a task completes, the daemon removes it from in-memory task tracking. This caused merge operations to fail with "Task not found". Fixed by updating handle_merge_task_to_target() to use get_task_worktree_path() which scans the worktrees directory as a fallback when the task is not in memory. Also updated handle_create_pr() with the same pattern for consistency. ## Issue 2: makima supervisor pr returns immediately without result The create_pr handler was asynchronous - it sent the CreatePR command to the daemon and immediately returned without waiting for the result. Fixed by: 1. Adding PrResultNotification struct and pr_results broadcast channel to AppState 2. Updating mesh_daemon.rs to broadcast PRCreated results to the channel 3. Updating create_pr() handler to subscribe to pr_results and wait for the result with a 60-second timeout (matching the merge command pattern) Now the PR command returns the actual pr_url and pr_number from the daemon. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/server/state.rs')
-rw-r--r--makima/src/server/state.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs
index c579f0f..02a2328 100644
--- a/makima/src/server/state.rs
+++ b/makima/src/server/state.rs
@@ -118,6 +118,21 @@ pub struct MergeResultNotification {
pub conflicts: Option<Vec<String>>,
}
+/// Notification for PR creation results.
+#[derive(Debug, Clone)]
+pub struct PrResultNotification {
+ /// ID of the task for which PR was created
+ pub task_id: Uuid,
+ /// Whether the PR creation succeeded
+ pub success: bool,
+ /// Message describing the result
+ pub message: String,
+ /// PR URL if creation succeeded
+ pub pr_url: Option<String>,
+ /// PR number if creation succeeded
+ pub pr_number: Option<i32>,
+}
+
/// Notification for supervisor questions requiring user feedback.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -527,6 +542,8 @@ pub struct AppState {
pub supervisor_questions: broadcast::Sender<SupervisorQuestionNotification>,
/// Broadcast channel for merge result notifications
pub merge_results: broadcast::Sender<MergeResultNotification>,
+ /// Broadcast channel for PR creation result notifications
+ pub pr_results: broadcast::Sender<PrResultNotification>,
/// Pending supervisor questions awaiting user response (keyed by question_id)
pub pending_questions: DashMap<Uuid, PendingSupervisorQuestion>,
/// Responses to supervisor questions (keyed by question_id)
@@ -560,6 +577,7 @@ impl AppState {
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
+ let (pr_results, _) = broadcast::channel(256); // For PR creation results
// Initialize JWT verifier from environment (optional)
// Requires SUPABASE_URL and either SUPABASE_JWT_PUBLIC_KEY (RS256) or SUPABASE_JWT_SECRET (HS256)
@@ -603,6 +621,7 @@ impl AppState {
task_completions,
supervisor_questions,
merge_results,
+ pr_results,
pending_questions: DashMap::new(),
question_responses: DashMap::new(),
daemon_connections: DashMap::new(),
@@ -699,6 +718,13 @@ impl AppState {
let _ = self.merge_results.send(notification);
}
+ /// Broadcast a PR creation result notification to all subscribers.
+ ///
+ /// Used to notify waiting handlers when a PR creation operation completes.
+ pub fn broadcast_pr_result(&self, notification: PrResultNotification) {
+ let _ = self.pr_results.send(notification);
+ }
+
/// Add a pending supervisor question and broadcast it.
pub fn add_supervisor_question(
&self,