* 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.