Restore box-and-arrow run diagrams without viewport list fallback

This commit is contained in:
2026-10-10 00:43:52 +01:00
parent f8ffde92f7
commit 977af96e23
3 changed files with 23 additions and 65 deletions
+1 -47
View File
@@ -5,7 +5,6 @@ import (
"strings"
"git.a-wan.net/alan/pipelines/internal/protocol"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
)
@@ -126,15 +125,6 @@ func (m Model) runGraphFollow() (int, int) {
return 0, 0
}
rows := max(1, (m.height-4)/2-5)
lines, compact := m.fittedRunGraph(max(1, m.width-4), rows)
if compact {
for i, line := range lines {
if strings.HasPrefix(ansi.Strip(line), "▸ ") {
return max(0, i-rows/2), 0
}
}
return 0, 0
}
layout := layoutGraphAppearance(graph, appearance)
for _, node := range layout.nodes {
if node.key == selected {
@@ -144,42 +134,9 @@ func (m Model) runGraphFollow() (int, int) {
return 0, 0
}
func (m Model) fittedRunGraph(width, rows int) ([]string, bool) {
lines := m.runGraphLines(width)
widest := 0
for _, line := range lines {
widest = max(widest, ansi.StringWidth(line))
}
if widest <= width && len(lines) <= rows {
return lines, false
}
graph, selected, appearance := m.runGraphState()
if appearance == nil {
return lines, false
}
// Dense overview preserves every declared branch, rather than hiding nodes
// or scaling terminal text into unreadable glyphs.
lines = nil
for _, stage := range graph.Stages {
prefix := " "
if stage.Key == selected {
prefix = "▸ "
}
line := prefix + appearance.title(stage.Key, appearance.label(stage.Key), stage.Key == selected, graph)
for _, outcome := range outcomes(stage) {
target := protocol.ResolveTarget(outcome, stage.Edges[outcome])
color, bold := appearance.edgeStyle(graphEdge{source: stage.Key, outcome: outcome, target: target})
line += " " + lipgloss.NewStyle().Foreground(color).Bold(bold).Render(outcome+" → "+nodeLabel(target))
}
lines = append(lines, strings.Split(ansi.Wrap(line, max(1, width), ""), "\n")...)
}
lines = append(lines, appearance.title(protocol.SuccessEnd, "SUCCESS", false, graph)+" "+appearance.title(protocol.FailureEnd, "FAILURE", false, graph))
return lines, true
}
func (m Model) runGraphPanel(height, top, pan int) string {
width, rows := max(1, m.width-4), max(0, height-5)
lines, compact := m.fittedRunGraph(width, rows)
lines := m.runGraphLines(width)
widest := 0
for _, line := range lines {
widest = max(widest, ansi.StringWidth(line))
@@ -192,9 +149,6 @@ func (m Model) runGraphPanel(height, top, pan int) string {
body = append(body, strings.Repeat(" ", leftPad)+ansi.Cut(line, pan, pan+width-leftPad))
}
label := m.runGraphTitle()
if compact {
label += " · compact"
}
footer := "Tab pane · n/p stage · dim = not executed"
if widest > width || len(lines) > rows {
footer = "h/j/k/l pan · c center · Tab pane · n/p stage"