From 3679ceb3325033faa2f889ef3dfee5668ef7aeea Mon Sep 17 00:00:00 2001 From: soryu Date: Tue, 10 Mar 2026 17:33:23 +0000 Subject: feat: soryu-co/soryu - makima: Fix build errors in daemon protocol and task manager (#89) --- makima/src/daemon/task/manager.rs | 33 +++++++++++++++++++++++++++++++ makima/src/daemon/ws/protocol.rs | 9 +++++++++ makima/src/server/handlers/mesh_daemon.rs | 17 ++++++++++++++++ makima/src/server/state.rs | 3 +++ 4 files changed, 62 insertions(+) diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs index acdf4ad..ca97453 100644 --- a/makima/src/daemon/task/manager.rs +++ b/makima/src/daemon/task/manager.rs @@ -3672,6 +3672,39 @@ impl TaskManager { Ok(()) } + /// Resolve the best diff base reference for a given base branch. + /// Tries origin/{base} first, then falls back to local {base} branch. + async fn resolve_diff_base(path: &std::path::PathBuf, base: &str) -> Option { + // Try origin/{base} first + let origin_ref = format!("origin/{}", base); + let check_origin = tokio::process::Command::new("git") + .current_dir(path) + .args(["rev-parse", "--verify", &origin_ref]) + .output() + .await; + + if let Ok(output) = check_origin { + if output.status.success() { + return Some(format!("origin/{}...HEAD", base)); + } + } + + // Fall back to local branch + let check_local = tokio::process::Command::new("git") + .current_dir(path) + .args(["rev-parse", "--verify", base]) + .output() + .await; + + if let Ok(output) = check_local { + if output.status.success() { + return Some(format!("{}...HEAD", base)); + } + } + + None + } + /// Handle GetWorktreeDiff command - get git diff for a task's worktree. async fn handle_get_worktree_diff( &self, diff --git a/makima/src/daemon/ws/protocol.rs b/makima/src/daemon/ws/protocol.rs index 0583783..ced653b 100644 --- a/makima/src/daemon/ws/protocol.rs +++ b/makima/src/daemon/ws/protocol.rs @@ -348,6 +348,15 @@ pub enum DaemonMessage { error: Option, }, + /// Response to GetWorktreeDiff command. + WorktreeDiffResult { + #[serde(rename = "taskId")] + task_id: Uuid, + success: bool, + diff: Option, + error: Option, + }, + /// Response to CreateCheckpoint command. CheckpointCreated { #[serde(rename = "taskId")] diff --git a/makima/src/server/handlers/mesh_daemon.rs b/makima/src/server/handlers/mesh_daemon.rs index 139db70..e5f0a81 100644 --- a/makima/src/server/handlers/mesh_daemon.rs +++ b/makima/src/server/handlers/mesh_daemon.rs @@ -2488,6 +2488,23 @@ async fn handle_daemon_connection(socket: WebSocket, state: SharedState, auth_re } } } + Ok(DaemonMessage::WorktreeDiffResult { task_id, success, diff, error }) => { + tracing::debug!( + task_id = %task_id, + success = success, + "Worktree diff result received" + ); + + // Fulfill pending worktree diff request if any + if let Some((_, tx)) = state.pending_worktree_diff.remove(&task_id) { + let _ = tx.send(crate::server::state::WorktreeDiffResponse { + task_id, + success, + diff: diff.unwrap_or_default(), + error, + }); + } + } Err(e) => { tracing::warn!("Failed to parse daemon message: {}", e); } diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs index 83ac2e8..1f7b264 100644 --- a/makima/src/server/state.rs +++ b/makima/src/server/state.rs @@ -675,6 +675,8 @@ pub struct AppState { pub pending_worktree_info: DashMap>, /// Pending task diff requests awaiting daemon response (keyed by task_id) pub pending_task_diff: DashMap>, + /// Pending worktree diff requests awaiting daemon response (keyed by task_id) + pub pending_worktree_diff: DashMap>, /// Pending worktree commit requests awaiting daemon response (keyed by task_id) pub pending_worktree_commit: DashMap>, /// Lazily-loaded TTS engine (initialized on first Speak connection) @@ -759,6 +761,7 @@ impl AppState { jwt_verifier, pending_worktree_info: DashMap::new(), pending_task_diff: DashMap::new(), + pending_worktree_diff: DashMap::new(), pending_worktree_commit: DashMap::new(), tts_engine: OnceCell::new(), daemon_reauth_status: DashMap::new(), -- cgit v1.2.3