summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/server/handlers')
-rw-r--r--makima/src/server/handlers/contract_chat.rs4
-rw-r--r--makima/src/server/handlers/contracts.rs13
-rw-r--r--makima/src/server/handlers/mesh.rs4
-rw-r--r--makima/src/server/handlers/mesh_chat.rs1
-rw-r--r--makima/src/server/handlers/mesh_supervisor.rs5
-rw-r--r--makima/src/server/handlers/transcript_analysis.rs2
6 files changed, 29 insertions, 0 deletions
diff --git a/makima/src/server/handlers/contract_chat.rs b/makima/src/server/handlers/contract_chat.rs
index 98787be..c1ca3ed 100644
--- a/makima/src/server/handlers/contract_chat.rs
+++ b/makima/src/server/handlers/contract_chat.rs
@@ -1366,6 +1366,7 @@ async fn handle_contract_request(
checkpoint_sha: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
match repository::create_task_for_owner(pool, owner_id, create_req).await {
@@ -1463,6 +1464,7 @@ async fn handle_contract_request(
checkpoint_sha: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
match repository::create_task_for_owner(pool, owner_id, create_req).await {
@@ -2197,6 +2199,7 @@ async fn handle_contract_request(
checkpoint_sha: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
match repository::create_task_for_owner(pool, owner_id, create_req).await {
@@ -2717,6 +2720,7 @@ async fn handle_contract_request(
checkpoint_sha: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
if repository::create_task_for_owner(pool, owner_id, task_req).await.is_ok() {
diff --git a/makima/src/server/handlers/contracts.rs b/makima/src/server/handlers/contracts.rs
index 3ad38da..7ed84e3 100644
--- a/makima/src/server/handlers/contracts.rs
+++ b/makima/src/server/handlers/contracts.rs
@@ -301,6 +301,7 @@ pub async fn create_contract(
merge_mode: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Supervisor uses its own worktree
};
match repository::create_task_for_owner(pool, auth.owner_id, supervisor_req).await {
@@ -1673,7 +1674,19 @@ async fn cleanup_contract_worktrees(
);
// Send cleanup command to each task's daemon
+ // Skip tasks that share a supervisor's worktree (they don't own the worktree)
for task in tasks {
+ // Skip tasks that reuse the supervisor's worktree - the supervisor owns it
+ if task.supervisor_worktree_task_id.is_some() {
+ tracing::debug!(
+ task_id = %task.id,
+ supervisor_worktree_task_id = ?task.supervisor_worktree_task_id,
+ contract_id = %contract_id,
+ "Task shares supervisor worktree, skipping worktree cleanup"
+ );
+ continue;
+ }
+
if let Some(daemon_id) = task.daemon_id {
let cmd = crate::server::state::DaemonCommand::CleanupWorktree {
task_id: task.id,
diff --git a/makima/src/server/handlers/mesh.rs b/makima/src/server/handlers/mesh.rs
index 0dcab91..9ef6248 100644
--- a/makima/src/server/handlers/mesh.rs
+++ b/makima/src/server/handlers/mesh.rs
@@ -2623,6 +2623,7 @@ pub async fn reassign_task(
checkpoint_sha: task.last_checkpoint_sha.clone(),
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
let new_task = match repository::create_task_for_owner(pool, auth.owner_id, create_req).await {
@@ -3397,6 +3398,7 @@ pub async fn fork_task(
checkpoint_sha: Some(checkpoint.commit_sha.clone()),
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
let new_task = match repository::create_task_for_owner(pool, auth.owner_id, create_req).await {
@@ -3555,6 +3557,7 @@ pub async fn resume_from_checkpoint(
checkpoint_sha: Some(checkpoint.commit_sha.clone()),
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
let new_task = match repository::create_task_for_owner(pool, auth.owner_id, create_req).await {
@@ -3891,6 +3894,7 @@ pub async fn branch_task(
checkpoint_sha: None,
branched_from_task_id: Some(source_task_id),
conversation_history,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
let task = match repository::create_task_for_owner(pool, auth.owner_id, create_req).await {
diff --git a/makima/src/server/handlers/mesh_chat.rs b/makima/src/server/handlers/mesh_chat.rs
index a74eb4f..623e66d 100644
--- a/makima/src/server/handlers/mesh_chat.rs
+++ b/makima/src/server/handlers/mesh_chat.rs
@@ -1021,6 +1021,7 @@ async fn handle_mesh_request(
checkpoint_sha: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
match repository::create_task_for_owner(pool, owner_id, create_req).await {
diff --git a/makima/src/server/handlers/mesh_supervisor.rs b/makima/src/server/handlers/mesh_supervisor.rs
index a0a3a96..6f17103 100644
--- a/makima/src/server/handlers/mesh_supervisor.rs
+++ b/makima/src/server/handlers/mesh_supervisor.rs
@@ -608,6 +608,9 @@ pub async fn spawn_task(
}
// Create task request
+ // Share supervisor's worktree by default; separate worktree only when explicitly requested
+ let supervisor_worktree_task_id = if request.use_own_worktree { None } else { Some(supervisor_id) };
+
let create_req = CreateTaskRequest {
name: request.name.clone(),
description: None,
@@ -628,6 +631,7 @@ pub async fn spawn_task(
copy_files: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id,
};
// Create task in DB
@@ -2650,6 +2654,7 @@ pub async fn spawn_red_team_task(
checkpoint_sha: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Red team uses its own working area
};
// Create task in DB
diff --git a/makima/src/server/handlers/transcript_analysis.rs b/makima/src/server/handlers/transcript_analysis.rs
index 3c283da..0a6ac7f 100644
--- a/makima/src/server/handlers/transcript_analysis.rs
+++ b/makima/src/server/handlers/transcript_analysis.rs
@@ -370,6 +370,7 @@ pub async fn create_contract_from_analysis(
merge_mode: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
if let Ok(t) = repository::create_task_for_owner(pool, auth.owner_id, task_req).await {
@@ -540,6 +541,7 @@ pub async fn update_contract_from_analysis(
merge_mode: None,
branched_from_task_id: None,
conversation_history: None,
+ supervisor_worktree_task_id: None, // Not spawned by supervisor
};
if let Ok(t) = repository::create_task_for_owner(pool, auth.owner_id, task_req).await {