Show full audited run graphs and scope searchable run history

This commit is contained in:
2026-10-10 00:26:32 +01:00
parent a1c0eb4a72
commit e9a8eaf8ae
15 changed files with 438 additions and 66 deletions
+46 -14
View File
@@ -34,15 +34,51 @@ func (m Model) runVisitKey(index int) string {
}
func (m Model) runGraphLines(_ int) []string {
graph := m.runPathGraph()
graph, selected, appearance := m.runGraphState()
if len(graph.Stages) == 0 {
return []string{"Waiting for the first stage…"}
}
selected := graph.Stages[len(graph.Stages)-1].Key
if m.runStepIndex > 0 && m.runStepIndex <= len(graph.Stages) {
selected = graph.Stages[m.runStepIndex-1].Key
return renderGraphAppearance(graph, selected, appearance)
}
func (m Model) runGraphState() (protocol.Graph, string, *graphAppearance) {
if m.runDetail == nil {
return protocol.Graph{}, "", nil
}
return renderGraph(graph, selected)
r := m.runDetail
graph := r.Graph
// Older servers may omit the graph. Never substitute a different version.
if len(graph.Stages) == 0 && m.detail != nil && m.detail.ID == r.PipelineID && m.detail.Version == r.Version {
graph = m.detail.Graph
}
index := len(r.Steps) - 1
if m.runStepIndex > 0 && m.runStepIndex <= len(r.Steps) {
index = m.runStepIndex - 1
}
if len(graph.Stages) == 0 {
graph = m.runPathGraph()
selected := ""
if index >= 0 {
selected = graph.Stages[index].Key
}
return graph, selected, nil
}
appearance := &graphAppearance{nodes: map[string]bool{}, routes: map[graphRoute]bool{}}
for _, step := range r.Steps {
appearance.nodes[step.Stage] = true
if step.Target != "" && step.Outcome != "" {
target := protocol.ResolveTarget(step.Outcome, step.Target)
appearance.routes[graphRoute{step.Stage, step.Outcome, target}] = true
if protocol.IsTerminal(target) {
appearance.nodes[target] = true
}
}
}
selected := r.CurrentStage
if index >= 0 {
selected = r.Steps[index].Stage
}
return graph, selected, appearance
}
func (m Model) runsView(height int) string {
@@ -54,7 +90,7 @@ func (m Model) runsView(height int) string {
if !m.runGraphFocus {
top, pan = m.runGraphFollow()
}
graph := graphViewport(m.runGraphTitle(), m.runGraphLines(max(3, m.width-4)), m.width, graphHeight, top, pan, m.runGraphFocus, "g graph/details · arrows pan · j/k scroll · live")
graph := graphViewport(m.runGraphTitle(), m.runGraphLines(max(3, m.width-4)), m.width, graphHeight, top, pan, m.runGraphFocus, "g graph/details · arrows pan · j/k scroll · dim = not executed")
details := m.runsDetailsView(height - graphHeight)
return fitBlock(strings.Split(graph+"\n"+details, "\n"), m.width, height)
}
@@ -62,13 +98,13 @@ func (m Model) runsView(height int) string {
func (m Model) runGraphTitle() string {
r := m.runDetail
if r == nil {
return "Run path"
return "Run graph"
}
durationLabel := "elapsed"
if r.FinishedAt != "" {
durationLabel = "duration"
}
title := "Run path · " + durationLabel + " " + runDuration(r.CreatedAt, r.FinishedAt) + " · started " + dateLabel(r.CreatedAt)
title := "Run graph · " + durationLabel + " " + runDuration(r.CreatedAt, r.FinishedAt) + " · started " + dateLabel(r.CreatedAt)
if r.FinishedAt != "" {
title += " · finished " + dateLabel(r.FinishedAt)
}
@@ -76,17 +112,13 @@ func (m Model) runGraphTitle() string {
}
func (m Model) runGraphFollow() (int, int) {
graph := m.runPathGraph()
graph, selected, _ := m.runGraphState()
if len(graph.Stages) == 0 {
return 0, 0
}
index := len(graph.Stages) - 1
if m.runStepIndex > 0 {
index = min(m.runStepIndex-1, index)
}
layout := layoutGraph(graph)
for _, node := range layout.nodes {
if node.key == graph.Stages[index].Key {
if node.key == selected {
return node.y, max(0, node.x-(m.width-4-node.width)/2)
}
}