summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-27 01:14:17 +0000
committersoryu <soryu@soryu.co>2026-01-27 01:14:17 +0000
commit448c5a8cc0c6e39909a90999a009565fa4b1c639 (patch)
tree29df2496035a2292320c83811112160245c734b2 /makima/src/server/handlers
parentf6b4d06a0158fb7803a2d7a861cf891cb3b202b4 (diff)
downloadsoryu-makima/task-task-59202404-59202404.tar.gz
soryu-makima/task-task-59202404-59202404.zip
[WIP] Heartbeat checkpoint - 2026-01-27 01:14:17 UTCmakima/task-task-59202404-59202404
Diffstat (limited to 'makima/src/server/handlers')
-rw-r--r--makima/src/server/handlers/mesh_daemon.rs12
-rw-r--r--makima/src/server/handlers/mesh_supervisor.rs64
2 files changed, 65 insertions, 11 deletions
diff --git a/makima/src/server/handlers/mesh_daemon.rs b/makima/src/server/handlers/mesh_daemon.rs
index 0aea40e..f7fe49f 100644
--- a/makima/src/server/handlers/mesh_daemon.rs
+++ b/makima/src/server/handlers/mesh_daemon.rs
@@ -1734,15 +1734,25 @@ async fn handle_daemon_connection(socket: WebSocket, state: SharedState, auth_re
success,
message,
pr_url,
- pr_number: _,
+ pr_number,
}) => {
tracing::info!(
task_id = %task_id,
success = success,
pr_url = ?pr_url,
+ pr_number = ?pr_number,
"PR created result received"
);
+ // Broadcast the PR result for waiting handlers
+ state.broadcast_pr_result(crate::server::state::PrResultNotification {
+ task_id,
+ success,
+ message: message.clone(),
+ pr_url: pr_url.clone(),
+ pr_number,
+ });
+
// On successful PR creation, notify supervisor of next steps
if success {
if let Some(pool) = state.db_pool.as_ref() {
diff --git a/makima/src/server/handlers/mesh_supervisor.rs b/makima/src/server/handlers/mesh_supervisor.rs
index a654a05..f0cb69e 100644
--- a/makima/src/server/handlers/mesh_supervisor.rs
+++ b/makima/src/server/handlers/mesh_supervisor.rs
@@ -1476,6 +1476,9 @@ pub async fn create_pr(
).into_response();
};
+ // Subscribe to PR results BEFORE sending the command
+ let mut rx = state.pr_results.subscribe();
+
// Send CreatePR command to daemon
let cmd = DaemonCommand::CreatePR {
task_id: request.task_id,
@@ -1492,16 +1495,57 @@ pub async fn create_pr(
).into_response();
}
- (
- StatusCode::CREATED,
- Json(CreatePRResponse {
- task_id: request.task_id,
- success: true,
- message: "PR creation command sent".to_string(),
- pr_url: None,
- pr_number: None,
- }),
- ).into_response()
+ // Wait for the PR result with a timeout (60 seconds should be plenty for PR creation)
+ let timeout = tokio::time::Duration::from_secs(60);
+ let result = tokio::time::timeout(timeout, async {
+ loop {
+ match rx.recv().await {
+ Ok(notification) => {
+ if notification.task_id == request.task_id {
+ return Some(notification);
+ }
+ // Not our task, keep waiting
+ }
+ Err(_) => {
+ // Channel closed or lagged
+ return None;
+ }
+ }
+ }
+ }).await;
+
+ match result {
+ Ok(Some(notification)) => {
+ let status = if notification.success {
+ StatusCode::CREATED
+ } else {
+ StatusCode::INTERNAL_SERVER_ERROR
+ };
+ (
+ status,
+ Json(CreatePRResponse {
+ task_id: request.task_id,
+ success: notification.success,
+ message: notification.message,
+ pr_url: notification.pr_url,
+ pr_number: notification.pr_number,
+ }),
+ ).into_response()
+ }
+ Ok(None) | Err(_) => {
+ // Timeout or channel error - return error status
+ (
+ StatusCode::GATEWAY_TIMEOUT,
+ Json(CreatePRResponse {
+ task_id: request.task_id,
+ success: false,
+ message: "PR creation timed out waiting for daemon response".to_string(),
+ pr_url: None,
+ pr_number: None,
+ }),
+ ).into_response()
+ }
+ }
}
/// Get the diff for a task's changes.