* All implementation steps are complete. Here's a summary of what was implemented: Implemented auto-linking of subtasks when creating tasks with 6 changes: 1. **`crates/db/src/models/task_attempt.rs`** - Added `find_by_branch()` query to look up task attempts by branch name within a project 2. **`crates/db/src/models/task.rs`** - Added: - `Clone` derive to `CreateTask` struct - `with_parent_from_branch()` helper method on `CreateTask` for fluent branch-based parent resolution - `update_parent_task_attempt()` method on `Task` to update parent linkage for existing tasks 3. **`crates/server/src/routes/tasks.rs`** - Updated `create_task_and_start()` to use `with_parent_from_branch()` helper before creating the task 4. **`crates/server/src/routes/task_attempts.rs`** - Updated `create_task_attempt()` to link existing tasks to parent attempts when `base_branch` matches an existing attempt's branch 5. **`crates/server/src/mcp/task_server.rs`** - Updated MCP `create_task` to automatically set `parent_task_attempt` from the current context's `attempt_id` 6. **`crates/db/.sqlx/`** - Updated SQLx query cache with the new queries * Cleanup script changes for task attempt 3bcb8f0d-6655-4b34-9cd2-c3c731795b78 * All implementation steps are complete. Here's a summary of what was implemented: ## Summary Auto-linking of subtasks when creating tasks is now implemented for all three scenarios: 1. **MCP create_task** (`task_server.rs:404-432`): When an AI agent creates a task via MCP while working in a worktree, the new task automatically becomes a subtask of the current attempt (uses `McpContext.attempt_id`) 2. **Branch-based targeting**: - `create_task_and_start` (`tasks.rs`): Uses `with_parent_from_branch` helper to auto-link when `base_branch` matches an existing attempt - `create_task_attempt` (`task_attempts.rs`): Updates existing task's parent when creating an attempt with a matching `base_branch` 3. **Rebase** (`task_attempts.rs:1249-1257`): When rebasing a task attempt onto another attempt's branch, the task's `parent_task_attempt` is updated to point to that attempt ### Files modified: - `crates/db/src/models/task_attempt.rs` - Added `find_by_branch` query - `crates/db/src/models/task.rs` - Added `Clone` derive, `with_parent_from_branch` helper, `update_parent_task_attempt` method - `crates/server/src/routes/tasks.rs` - Updated `create_task_and_start` - `crates/server/src/routes/task_attempts.rs` - Updated `create_task_attempt` and `rebase_task_attempt` - `crates/server/src/mcp/task_server.rs` - Updated MCP `create_task` * Cleanup script changes for task attempt 3bcb8f0d-6655-4b34-9cd2-c3c731795b78 * All 8 steps are now complete. Here's a summary of the implementation: ## Summary Added auto-linking of subtasks in the `change_target_branch` endpoint (`task_attempts.rs:1047-1055`). When a user changes a task attempt's target branch to match another attempt's branch, the task automatically becomes a subtask of that attempt. The full implementation now covers all 4 scenarios: 1. **MCP create_task** - Links via `McpContext.attempt_id` 2. **Branch-based targeting** - Links in `create_task_and_start` and `create_task_attempt` via `with_parent_from_branch` 3. **Rebase** - Links in `rebase_task_attempt` after successful git rebase 4. **Change target branch** - Links in `change_target_branch` after updating target_branch (newly added) * Done. Removed `from_title_description` helper from `task.rs` and updated `task_server.rs` to construct `CreateTask` directly with all fields set correctly. All checks pass.
75 lines
2.0 KiB
JSON
75 lines
2.0 KiB
JSON
{
|
|
"db_name": "SQLite",
|
|
"query": "SELECT ta.id as \"id!: Uuid\", ta.task_id as \"task_id!: Uuid\",\n ta.container_ref, ta.branch, ta.target_branch,\n ta.executor as \"executor!\", ta.worktree_deleted as \"worktree_deleted!: bool\",\n ta.setup_completed_at as \"setup_completed_at: DateTime<Utc>\",\n ta.created_at as \"created_at!: DateTime<Utc>\",\n ta.updated_at as \"updated_at!: DateTime<Utc>\"\n FROM task_attempts ta\n JOIN tasks t ON ta.task_id = t.id\n WHERE t.project_id = ? AND ta.branch = ?\n ORDER BY ta.created_at DESC\n LIMIT 1",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"name": "id!: Uuid",
|
|
"ordinal": 0,
|
|
"type_info": "Blob"
|
|
},
|
|
{
|
|
"name": "task_id!: Uuid",
|
|
"ordinal": 1,
|
|
"type_info": "Blob"
|
|
},
|
|
{
|
|
"name": "container_ref",
|
|
"ordinal": 2,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "branch",
|
|
"ordinal": 3,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "target_branch",
|
|
"ordinal": 4,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "executor!",
|
|
"ordinal": 5,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "worktree_deleted!: bool",
|
|
"ordinal": 6,
|
|
"type_info": "Bool"
|
|
},
|
|
{
|
|
"name": "setup_completed_at: DateTime<Utc>",
|
|
"ordinal": 7,
|
|
"type_info": "Datetime"
|
|
},
|
|
{
|
|
"name": "created_at!: DateTime<Utc>",
|
|
"ordinal": 8,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "updated_at!: DateTime<Utc>",
|
|
"ordinal": 9,
|
|
"type_info": "Text"
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Right": 2
|
|
},
|
|
"nullable": [
|
|
true,
|
|
false,
|
|
true,
|
|
false,
|
|
false,
|
|
true,
|
|
false,
|
|
true,
|
|
false,
|
|
false
|
|
]
|
|
},
|
|
"hash": "3893e8aa7f30ac45d817eb19bbea6c4afc9ab8ad001039593350b658ea970f3f"
|
|
}
|