From 7af8561677cfdcfd23d099a25783c7fef51d1ba6 Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 29 Jan 2026 02:30:16 +0000 Subject: Fix worktree cleanup to not run for shared worktrees --- makima/src/db/models.rs | 3 +++ makima/src/db/repository.rs | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'makima/src/db') 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, /// Conversation history to initialize the task with (JSON array of messages) pub conversation_history: Option, + /// 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, } /// 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 Result, pub overlay_path: Option, + /// 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, } /// List tasks in a contract with their daemon/worktree info. @@ -2755,7 +2760,7 @@ pub async fn list_contract_tasks_with_worktree_info( ) -> Result, 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) "#, -- cgit v1.2.3