* Derive a phase's sidebar status from the actual record + the agents grouped under it. * * The actual record comes from `phase_started`/`phase_done` events. Scripts that follow the * ultracode canonical pipeline pattern pass `opts.phase` directly to `agent()` inside * `pipeline()`/`parallel()`
(
actual: { status: 'running' | 'done' } | undefined,
inPhase: AgentProgress[],
)
| 30 | * (`running` if `phase()` was called and is still active, else pending). |
| 31 | */ |
| 32 | function derivePhaseStatus( |
| 33 | actual: { status: 'running' | 'done' } | undefined, |
| 34 | inPhase: AgentProgress[], |
| 35 | ): PhaseStatus { |
| 36 | if (actual?.status === 'done') return 'done' |
| 37 | if (inPhase.length > 0) { |
| 38 | return inPhase.every(a => a.status === 'done') ? 'done' : 'running' |
| 39 | } |
| 40 | return actual?.status === 'running' ? 'running' : 'pending' |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Merge declaredPhases (declared by meta), run.phases (actually running/done), |