Compact graph columns and branch spacing and simplify Home hints

This commit is contained in:
2026-10-10 02:00:39 +01:00
parent c05789d8a6
commit d73a021cd4
11 changed files with 146 additions and 37 deletions
+41
View File
@@ -0,0 +1,41 @@
package tui
import (
"fmt"
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/pipeline"
"git.a-wan.net/alan/pipelines/internal/protocol"
"github.com/charmbracelet/x/ansi"
)
func TestCompactGraphDimensions(t *testing.T) {
linear, err := pipeline.Parse(pipeline.Template([]string{"plan", "implement_with_a_long_stage_name", "review", "publish"}, true))
if err != nil {
t.Fatal(err)
}
for name, graph := range map[string]protocol.Graph{"linear": linear, "nested": nestedForkGraph(t)} {
layout := layoutGraph(graph)
t.Logf("%s: %d columns × %d rows", name, layout.width, layout.height)
// Measured before compaction: linear 175×15; nested forks 147×48.
if name == "linear" && (layout.width > 100 || layout.height > 15) {
t.Fatal("linear graph grew", layout.width, layout.height)
}
if name == "nested" && (layout.width > 118 || layout.height > 41) {
t.Fatal("fork graph grew", layout.width, layout.height)
}
assertForkRouteClearance(t, layout)
view := ansi.Strip(strings.Join(renderGraph(graph), "\n"))
for _, stage := range graph.Stages {
if !strings.Contains(view, stage.Key) {
t.Fatal("compaction lost stage", stage.Key)
}
}
for _, edge := range layout.edges {
if !strings.Contains(view, fmt.Sprintf("%s [%d]", edge.label, edge.id)) {
t.Fatal("compaction lost outcome", edge)
}
}
}
}