(tasks: Task[] | undefined)
| 539 | } |
| 540 | |
| 541 | function findNextPendingTask(tasks: Task[] | undefined): Task | undefined { |
| 542 | if (!tasks) { |
| 543 | return undefined; |
| 544 | } |
| 545 | const pendingTasks = tasks.filter(t => t.status === 'pending'); |
| 546 | if (pendingTasks.length === 0) { |
| 547 | return undefined; |
| 548 | } |
| 549 | const unresolvedIds = new Set(tasks.filter(t => t.status !== 'completed').map(t => t.id)); |
| 550 | return pendingTasks.find(t => !t.blockedBy.some(id => unresolvedIds.has(id))) ?? pendingTasks[0]; |
| 551 | } |
no test coverage detected