fix(worker): advance parent when the last non-terminal child is deleted
DeleteTask never re-evaluated a WaitingForChildren parent, so deleting the last non-terminal child left it stuck (the BlockedByTaskId SET NULL FK only repairs the blocked chain, not parent status). Expose TaskStateService.TryAdvanceParentAsync on the interface and call it from ExternalMcpService.DeleteTask after a child delete.
This commit is contained in:
@@ -104,7 +104,8 @@ public sealed class ExternalMcpServiceTests : IDisposable
|
||||
return id;
|
||||
}
|
||||
|
||||
private async Task<TaskEntity> SeedTaskAsync(string listId, string title = "t", TaskStatus status = TaskStatus.Idle)
|
||||
private async Task<TaskEntity> SeedTaskAsync(
|
||||
string listId, string title = "t", TaskStatus status = TaskStatus.Idle, string? parentId = null)
|
||||
{
|
||||
var task = new TaskEntity
|
||||
{
|
||||
@@ -112,6 +113,7 @@ public sealed class ExternalMcpServiceTests : IDisposable
|
||||
ListId = listId,
|
||||
Title = title,
|
||||
Status = status,
|
||||
ParentTaskId = parentId,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CommitType = "chore",
|
||||
};
|
||||
@@ -284,6 +286,21 @@ public sealed class ExternalMcpServiceTests : IDisposable
|
||||
sut.DeleteTask("does-not-exist", CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteTask_LastNonTerminalChild_AdvancesParentToWaitingForReview()
|
||||
{
|
||||
var listId = await SeedListAsync();
|
||||
var parent = await SeedTaskAsync(listId, status: TaskStatus.WaitingForChildren);
|
||||
await SeedTaskAsync(listId, status: TaskStatus.Done, parentId: parent.Id);
|
||||
var lastChild = await SeedTaskAsync(listId, status: TaskStatus.Idle, parentId: parent.Id);
|
||||
var sut = BuildSut(CreateQueue());
|
||||
|
||||
await sut.DeleteTask(lastChild.Id, CancellationToken.None);
|
||||
|
||||
var reloadedParent = await _tasks.GetByIdAsync(parent.Id);
|
||||
Assert.Equal(TaskStatus.WaitingForReview, reloadedParent!.Status);
|
||||
}
|
||||
|
||||
private ExternalMcpService NewService() => BuildSut(CreateQueue());
|
||||
|
||||
private async Task<string> SeedIdleTask(string title = "t")
|
||||
|
||||
Reference in New Issue
Block a user