Add stage-exclusive resource waiting
Add durable FIFO capacity-one resource leases for executable stages, including cleanup-confirmed release, conservative restart quarantine, queue state events, and CLI/TUI/Android waiting presentation. Add scheduler, cleanup, protocol, client, and Android coverage plus a proposed Android v3 resource draft. Checked packaged templates and authoring skill references: neither needs updating in this item. The per-item docs note records the shared documentation that docs-fold must update; no shared README or packaged reference was edited.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
func TestResourceWaitFrames(t *testing.T) {
|
||||
previous := lipgloss.ColorProfile()
|
||||
defer lipgloss.SetColorProfile(previous)
|
||||
for _, width := range []int{60, 120} {
|
||||
for _, plain := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("width-%d-plain-%t", width, plain), func(t *testing.T) {
|
||||
if plain {
|
||||
lipgloss.SetColorProfile(termenv.Ascii)
|
||||
} else {
|
||||
lipgloss.SetColorProfile(termenv.TrueColor)
|
||||
}
|
||||
m := decisionModel()
|
||||
m.width = width
|
||||
m.runDetail.Status = protocol.RunStatusQueued
|
||||
m.runDetail.Steps = nil
|
||||
m.runDetail.ResourceWait = &protocol.ResourceWait{Resource: "phone-X", Stage: "review", Sequence: 1, QueuedSince: "2026-10-18T10:00:00Z"}
|
||||
frame := ansi.Strip(m.runsDetailsView(24))
|
||||
if !strings.Contains(frame, "Waiting for resource phone-X") || strings.Contains(frame, "c decide") || strings.Contains(frame, "Waiting for a person") {
|
||||
t.Fatal("wrong resource wait frame:\n", frame)
|
||||
}
|
||||
for _, line := range strings.Split(frame, "\n") {
|
||||
if ansi.StringWidth(line) > width {
|
||||
t.Fatalf("overflow: %q", line)
|
||||
}
|
||||
}
|
||||
t.Log("Rendered resource wait (no phone):\n" + frame)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import (
|
||||
)
|
||||
|
||||
func resultLabel(r protocol.RunSummary) string {
|
||||
if r.ResourceWait != nil {
|
||||
return r.StatusLabel() + " · stage " + r.ResourceWait.Stage
|
||||
}
|
||||
preview := ansi.Strip(r.ResultPreview)
|
||||
if r.Status == "succeeded" {
|
||||
if preview != "" {
|
||||
@@ -55,7 +58,7 @@ func (m Model) pipelineResultLines() []string {
|
||||
if r == nil {
|
||||
return []string{"Results · This version has not run yet. No accomplishments recorded."}
|
||||
}
|
||||
lines := []string{fmt.Sprintf("Results · run #%d · %s · %s · %d completed visits · %s", r.ID, r.Label(), ansi.Strip(m.progress(r.Status)), r.CompletedSteps, runDuration(r.CreatedAt, r.FinishedAt)), resultLabel(*r)}
|
||||
lines := []string{fmt.Sprintf("Results · run #%d · %s · %s · %d completed visits · %s", r.ID, r.Label(), ansi.Strip(m.runSummaryStatus(*r)), r.CompletedSteps, runDuration(r.CreatedAt, r.FinishedAt)), resultLabel(*r)}
|
||||
if r.Status != "succeeded" && r.ResultPreview != "" && r.Diagnostic != "" {
|
||||
lines = append(lines, "Partial output: "+ansi.Strip(r.ResultPreview))
|
||||
}
|
||||
|
||||
@@ -275,6 +275,13 @@ func runStatus(status string) string {
|
||||
return lipgloss.NewStyle().Foreground(color).Render(status)
|
||||
}
|
||||
|
||||
func (m Model) runSummaryStatus(run protocol.RunSummary) string {
|
||||
if run.ResourceWait != nil {
|
||||
return run.StatusLabel()
|
||||
}
|
||||
return m.progress(run.Status)
|
||||
}
|
||||
|
||||
func runDuration(start, end string) string {
|
||||
first, err := time.Parse(time.RFC3339, start)
|
||||
if err != nil {
|
||||
@@ -687,7 +694,7 @@ func (m Model) runsDetailsView(height int) string {
|
||||
start, end := selectionWindow(len(runs), m.runIndex, max(1, (height-4-len(rows))/2))
|
||||
for i := start; i < end; i++ {
|
||||
r := runs[i]
|
||||
text := fmt.Sprintf("#%d %s · v%d · %s · %s", r.ID, r.Label(), r.Version, m.progress(r.Status), dateLabel(r.FinishedAt))
|
||||
text := fmt.Sprintf("#%d %s · v%d · %s · %s", r.ID, r.Label(), r.Version, m.runSummaryStatus(r), dateLabel(r.FinishedAt))
|
||||
rows = append(rows, menuOption(text, i == m.runIndex))
|
||||
rows = append(rows, " "+ansi.Truncate(resultLabel(r), max(1, m.width-6), "…"))
|
||||
}
|
||||
@@ -710,7 +717,8 @@ func (m Model) runsDetailsView(height int) string {
|
||||
return panel(m.width, height, []string{bar(title, fmt.Sprint(len(runs)), max(1, m.width-4), true)}, rows, footer, true)
|
||||
}
|
||||
r := m.runDetail
|
||||
header := bar(fmt.Sprintf("#%d %s · v%d", r.ID, r.Label(), r.Version), m.progress(r.Status)+" · "+runDuration(r.CreatedAt, r.FinishedAt), m.width, false)
|
||||
status := m.runSummaryStatus(r.RunSummary)
|
||||
header := bar(fmt.Sprintf("#%d %s · v%d", r.ID, r.Label(), r.Version), status+" · "+runDuration(r.CreatedAt, r.FinishedAt), m.width, false)
|
||||
if height <= 6 {
|
||||
return fitBlock([]string{header, runHighlight(m.runSelectionLabel(), m.width), m.runActions() + " · Tab pane · Esc back"}, m.width, height)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user