summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-06 21:43:21 +0000
committersoryu <soryu@soryu.co>2026-02-06 21:43:21 +0000
commitcececbf326e258211ceae7afce716a5d1e46014f (patch)
treea10db0b7e26908b043fa9b9b065be5d5c94bbd67 /makima/src/server/handlers
parent1b692b8cde4a888c8a35af69231f181b57bf5619 (diff)
downloadsoryu-cececbf326e258211ceae7afce716a5d1e46014f.tar.gz
soryu-cececbf326e258211ceae7afce716a5d1e46014f.zip
Fix: Link directives and contracts
Diffstat (limited to 'makima/src/server/handlers')
-rw-r--r--makima/src/server/handlers/directives.rs68
1 files changed, 67 insertions, 1 deletions
diff --git a/makima/src/server/handlers/directives.rs b/makima/src/server/handlers/directives.rs
index 52422cd..9c65c5e 100644
--- a/makima/src/server/handlers/directives.rs
+++ b/makima/src/server/handlers/directives.rs
@@ -292,7 +292,73 @@ pub async fn start_directive(
// Start directive via orchestration engine
let engine = crate::orchestration::DirectiveEngine::new(pool.clone());
match engine.start_directive(id).await {
- Ok(()) => {
+ Ok(planning) => {
+ // Auto-start the planning task on an available daemon
+ if let Some(daemon_id) = state.find_alternative_daemon(auth.owner_id, &[]) {
+ // Update task status to "starting" and assign daemon
+ let update_req = crate::db::models::UpdateTaskRequest {
+ status: Some("starting".to_string()),
+ daemon_id: Some(daemon_id),
+ ..Default::default()
+ };
+ if let Err(e) = repository::update_task_for_owner(
+ pool,
+ planning.task_id,
+ auth.owner_id,
+ update_req,
+ )
+ .await
+ {
+ tracing::warn!("Failed to update planning task status: {}", e);
+ }
+
+ let command = crate::server::state::DaemonCommand::SpawnTask {
+ task_id: planning.task_id,
+ task_name: planning.task_name,
+ plan: planning.plan,
+ repo_url: planning.repository_url,
+ base_branch: planning.base_branch,
+ target_branch: None,
+ parent_task_id: None,
+ depth: 0,
+ is_orchestrator: false,
+ target_repo_path: None,
+ completion_action: Some("none".to_string()),
+ continue_from_task_id: None,
+ copy_files: None,
+ contract_id: Some(planning.contract_id),
+ is_supervisor: true,
+ autonomous_loop: false,
+ resume_session: false,
+ conversation_history: None,
+ patch_data: None,
+ patch_base_sha: None,
+ local_only: false,
+ auto_merge_local: false,
+ supervisor_worktree_task_id: None,
+ };
+
+ if let Err(e) = state.send_daemon_command(daemon_id, command).await {
+ tracing::warn!(
+ "Failed to auto-start planning task on daemon {}: {}",
+ daemon_id,
+ e
+ );
+ } else {
+ tracing::info!(
+ "Auto-started planning task {} on daemon {} for directive {}",
+ planning.task_id,
+ daemon_id,
+ id
+ );
+ }
+ } else {
+ tracing::warn!(
+ "No daemon available to auto-start planning task for directive {}",
+ id
+ );
+ }
+
// Return the updated directive with progress
match repository::get_directive_with_progress(pool, id, auth.owner_id).await {
Ok(Some(directive)) => Json(directive).into_response(),