diff options
Diffstat (limited to 'makima/src/db')
| -rw-r--r-- | makima/src/db/models.rs | 3 | ||||
| -rw-r--r-- | makima/src/db/repository.rs | 15 |
2 files changed, 13 insertions, 5 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index d5f2814..9e624c9 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -665,6 +665,9 @@ pub struct CreateTaskRequest { pub branched_from_task_id: Option<Uuid>, /// Conversation history to initialize the task with (JSON array of messages) pub conversation_history: Option<serde_json::Value>, + /// Task ID whose worktree this task shares. When set, this task reuses the supervisor's + /// worktree instead of creating its own, and should NOT have its worktree deleted during cleanup. + pub supervisor_worktree_task_id: Option<Uuid>, } /// Request payload for updating a task diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index 7c9154f..b947cdd 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -691,9 +691,9 @@ pub async fn create_task(pool: &PgPool, req: CreateTaskRequest) -> Result<Task, contract_id, parent_task_id, depth, name, description, plan, priority, is_supervisor, is_red_team, repository_url, base_branch, target_branch, merge_mode, target_repo_path, completion_action, continue_from_task_id, copy_files, - branched_from_task_id, conversation_state + branched_from_task_id, conversation_state, supervisor_worktree_task_id ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20) RETURNING * "#, ) @@ -716,6 +716,7 @@ pub async fn create_task(pool: &PgPool, req: CreateTaskRequest) -> Result<Task, .bind(©_files_json) .bind(&req.branched_from_task_id) .bind(&req.conversation_history) + .bind(&req.supervisor_worktree_task_id) .fetch_one(pool) .await } @@ -1105,9 +1106,9 @@ pub async fn create_task_for_owner( owner_id, contract_id, parent_task_id, depth, name, description, plan, priority, is_supervisor, is_red_team, repository_url, base_branch, target_branch, merge_mode, target_repo_path, completion_action, continue_from_task_id, copy_files, - branched_from_task_id, conversation_state + branched_from_task_id, conversation_state, supervisor_worktree_task_id ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21) RETURNING * "#, ) @@ -1131,6 +1132,7 @@ pub async fn create_task_for_owner( .bind(©_files_json) .bind(&req.branched_from_task_id) .bind(&req.conversation_history) + .bind(&req.supervisor_worktree_task_id) .fetch_one(pool) .await } @@ -2745,6 +2747,9 @@ pub struct TaskWorktreeInfo { pub id: Uuid, pub daemon_id: Option<Uuid>, pub overlay_path: Option<String>, + /// If set, this task shares the worktree of the specified supervisor task. + /// Should NOT have its worktree deleted during cleanup. + pub supervisor_worktree_task_id: Option<Uuid>, } /// List tasks in a contract with their daemon/worktree info. @@ -2755,7 +2760,7 @@ pub async fn list_contract_tasks_with_worktree_info( ) -> Result<Vec<TaskWorktreeInfo>, sqlx::Error> { sqlx::query_as::<_, TaskWorktreeInfo>( r#" - SELECT id, daemon_id, overlay_path + SELECT id, daemon_id, overlay_path, supervisor_worktree_task_id FROM tasks WHERE contract_id = $1 AND (daemon_id IS NOT NULL OR overlay_path IS NOT NULL) "#, |
