feat(planning): consolidate finalize+chain via TaskStateService, fix queue pickup
Slice 4 of the worker state consolidation refactor. Eliminates the "queue never picks up planning tasks" bug structurally by routing both the manager and MCP finalize paths through TaskStateService and PlanningChainCoordinator.SetupChainAsync, where the auto-wake on enqueue guarantees the queue picker claims the first child immediately. - Delete TaskRepository.FinalizePlanningAsync; PlanningSessionManager now orchestrates via _state.FinalizePlanningAsync + _chain.SetupChainAsync. - Rename QueueSubtasksSequentiallyAsync to SetupChainAsync (internal); layout is now Status=Queued + BlockedByTaskId, with auto-attached agent tag. - OnChildFinishedAsync looks up the successor by BlockedByTaskId, drops the legacy Waiting status lookup. - PlanningMcpService.Finalize routes through state+chain; EditableStatuses drops Waiting and adds Idle; gate uses PlanningPhase==Active. - TaskStateService.FinalizePlanningAsync clears the planning session token. - UI: TaskRowViewModel adds BlockedByTaskId; IsQueued/IsWaiting reflect the new layout; TasksIslandViewModel.RemoveFromQueueAsync clears BlockedByTaskId on dequeue. - New regression test PlanningEndToEndTests.FinalizeAsync_FirstChildIs ClaimedByPicker_WithinDeadline asserts the picker claims the first child within 200ms with no manual WakeQueue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -495,18 +495,27 @@ public sealed partial class TasksIslandViewModel : ViewModelBase
|
||||
|
||||
// For a planning parent the dequeue button targets queued/waiting children,
|
||||
// not the parent itself (whose Status is Planning/Planned).
|
||||
if (entity.Status == TaskStatus.Planning || entity.Status == TaskStatus.Planned)
|
||||
if (entity.Status == TaskStatus.Planning || entity.Status == TaskStatus.Planned
|
||||
|| entity.PlanningPhase != PlanningPhase.None)
|
||||
{
|
||||
var children = await db.Tasks
|
||||
.Where(t => t.ParentTaskId == row.Id
|
||||
&& (t.Status == TaskStatus.Queued || t.Status == TaskStatus.Waiting))
|
||||
.ToListAsync();
|
||||
foreach (var c in children) c.Status = TaskStatus.Manual;
|
||||
foreach (var c in children)
|
||||
{
|
||||
c.Status = TaskStatus.Manual;
|
||||
c.BlockedByTaskId = null;
|
||||
}
|
||||
await db.SaveChangesAsync();
|
||||
foreach (var c in children)
|
||||
{
|
||||
var childRow = Items.FirstOrDefault(r => r.Id == c.Id);
|
||||
if (childRow is not null) childRow.Status = TaskStatus.Manual;
|
||||
if (childRow is not null)
|
||||
{
|
||||
childRow.Status = TaskStatus.Manual;
|
||||
childRow.BlockedByTaskId = null;
|
||||
}
|
||||
}
|
||||
row.HasQueuedSubtasks = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user