From 6fdf04d6a09e586e86d91e0db6a44c46bb7d4c7e Mon Sep 17 00:00:00 2001 From: mika kuns Date: Thu, 4 Jun 2026 15:32:18 +0200 Subject: [PATCH] feat(children): generalize CreateChildAsync for any parent + CreatedBy stamp --- src/ClaudeDo.Data/Repositories/TaskRepository.cs | 5 ++--- src/ClaudeDo.Worker/Planning/PlanningMcpService.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ClaudeDo.Data/Repositories/TaskRepository.cs b/src/ClaudeDo.Data/Repositories/TaskRepository.cs index aeaf6f8..a5e1ba0 100644 --- a/src/ClaudeDo.Data/Repositories/TaskRepository.cs +++ b/src/ClaudeDo.Data/Repositories/TaskRepository.cs @@ -196,6 +196,7 @@ public sealed class TaskRepository string title, string? description, string? commitType, + string? createdBy = null, CancellationToken ct = default) { // AsNoTracking: SetPlanningStartedAsync mutates via ExecuteUpdate which @@ -204,9 +205,6 @@ public sealed class TaskRepository .FirstOrDefaultAsync(t => t.Id == parentId, ct); if (parent is null) throw new InvalidOperationException($"Parent task {parentId} not found."); - if (parent.PlanningPhase == PlanningPhase.None) - throw new InvalidOperationException( - $"Parent task {parentId} is not in a planning phase; cannot attach children."); var maxSort = await _context.Tasks .Where(t => t.ListId == parent.ListId) @@ -224,6 +222,7 @@ public sealed class TaskRepository CommitType = string.IsNullOrEmpty(commitType) ? parent.CommitType : commitType, ParentTaskId = parentId, SortOrder = (maxSort ?? -1) + 1, + CreatedBy = createdBy, }; _context.Tasks.Add(child); await _context.SaveChangesAsync(ct); diff --git a/src/ClaudeDo.Worker/Planning/PlanningMcpService.cs b/src/ClaudeDo.Worker/Planning/PlanningMcpService.cs index 6bf9ffb..7d57df8 100644 --- a/src/ClaudeDo.Worker/Planning/PlanningMcpService.cs +++ b/src/ClaudeDo.Worker/Planning/PlanningMcpService.cs @@ -45,7 +45,7 @@ public sealed class PlanningMcpService CancellationToken cancellationToken) { var ctx = _contextAccessor.Current; - var child = await _tasks.CreateChildAsync(ctx.ParentTaskId, title, description, commitType, cancellationToken); + var child = await _tasks.CreateChildAsync(ctx.ParentTaskId, title, description, commitType, createdBy: null, cancellationToken); await BroadcastTaskUpdatedAsync(child.Id, cancellationToken); await BroadcastTaskUpdatedAsync(ctx.ParentTaskId, cancellationToken); return new CreatedChildDto(child.Id, child.Status.ToString());