Show teams in the workflow mermaid graph

This commit is contained in:
Ian Gulliver
2026-10-21 12:09:33 -07:00
parent 36d6636220
commit 9ab1c0d079
3 changed files with 80 additions and 25 deletions
+8 -1
View File
@@ -15,12 +15,19 @@ private let stateColors: [RunStage.StatePayload: NodeColors] = [
.discarded: NodeColors(fill: Palette.dangerTint, stroke: Palette.danger, text: Palette.text),
]
private func stageSteps(_ steps: [WorkflowStep]) -> [WorkflowStep] {
steps.flatMap { s in s.order.map(stageSteps) ?? s.parallel.map(stageSteps) ?? [s] }
}
private func stageGraph(_ run: WorkflowRun) -> Flowchart {
var chart = Flowchart(direction: .td)
let steps = Dictionary(stageSteps(run.definition.steps).map { ($0.stage ?? "", $0) }, uniquingKeysWith: { a, _ in a })
for (i, s) in run.stages.enumerated() {
let id = "s\(i)"
let colors = stateColors[s.state]!
chart.node(id, label: s.name, shape: .box)
chart.nodes[id]!.style = stateColors[s.state]!
chart.nodes[id]!.style = colors
chart.nodes[id]!.members = teamNodes(id, steps[s.name]?.agents, stroke: colors.stroke)
}
let ids = Dictionary(run.stages.enumerated().map { ($0.element.name, "s\($0.offset)") }, uniquingKeysWith: { a, _ in a })
for s in run.stages {