runner: keep export handoffs nonterminal through recovery

This commit is contained in:
2026-10-20 21:19:26 +01:00
parent ca78b24f47
commit ec3eda9e05
28 changed files with 370 additions and 82 deletions
+4 -1
View File
@@ -27,6 +27,9 @@ func lastWaitingStep(r *protocol.RunDetail) (protocol.RunStep, bool) {
// waiting step and falls back to the pinned graph's edges when a step recorded
// no options.
func (m Model) waitingStage() (string, []string, string) {
if m.runDetail != nil && m.runDetail.ExportPendingSequence > 0 {
return m.runDetail.CurrentStage, nil, ""
}
if m.runDetail == nil {
return "", nil, ""
}
@@ -43,7 +46,7 @@ func (m Model) waitingStage() (string, []string, string) {
}
func (m Model) openDecision() (tea.Model, tea.Cmd) {
if m.runDetail == nil || m.runDetail.Status != protocol.RunStatusWaiting {
if m.runDetail == nil || m.runDetail.Status != protocol.RunStatusWaiting || m.runDetail.ExportPendingSequence > 0 {
m.runError = "This run is not waiting for a decision."
return m, nil
}
+25
View File
@@ -0,0 +1,25 @@
package tui
import (
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
func TestExportWaitRendersRecoveryNotHumanDecision(t *testing.T) {
run := &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 7, Status: "waiting", ExportPendingSequence: 2, CurrentStage: "worker"}, Graph: protocol.Graph{Stages: []protocol.Stage{{Key: "worker", Type: "model", Edges: map[string]string{"success": "next", "error": "#failure"}}}}}
frame := strings.Join(waitingLines(run), "\n")
if !strings.Contains(frame, "Waiting for session export") || strings.Contains(frame, "person") || strings.Contains(frame, "Decide:") {
t.Fatalf("export wait offered a human choice:\n%s", frame)
}
m := Model{runDetail: run}
_, options, _ := m.waitingStage()
if len(options) != 0 {
t.Fatal("model-stage edges exposed as human options")
}
updated, _ := m.openDecision()
if updated.(Model).decisionOpen {
t.Fatal("opened decision for export wait")
}
}
+6
View File
@@ -18,6 +18,9 @@ func resultLabel(r protocol.RunSummary) string {
}
return "Finished · no result recorded"
}
if r.Status == protocol.RunStatusWaiting && r.ExportPendingSequence > 0 {
return "Waiting for session export · stage " + r.CurrentStage
}
if r.Diagnostic != "" {
return "Stopped: " + ansi.Strip(r.Diagnostic)
}
@@ -111,6 +114,9 @@ func waitingLines(r *protocol.RunDetail) []string {
if r.Status != protocol.RunStatusWaiting {
return nil
}
if r.ExportPendingSequence > 0 {
return []string{fmt.Sprintf("⏸ Waiting for session export · stage %s · visit %d", r.CurrentStage, r.ExportPendingSequence), "Computed output retained; automatic export-only recovery pending."}
}
lines := []string{"⏸ Waiting for a person · stage " + r.CurrentStage}
if step, ok := lastWaitingStep(r); ok {
if prompt := strings.TrimSpace(protocol.WaitingPrompt(step.Output)); prompt != "" {
+2 -2
View File
@@ -657,7 +657,7 @@ func (m Model) runActions() string {
if m.runDetail != nil {
text += " · a evidence · A artifacts"
}
if m.runDetail != nil && m.runDetail.Status == protocol.RunStatusWaiting {
if m.runDetail != nil && m.runDetail.Status == protocol.RunStatusWaiting && m.runDetail.ExportPendingSequence == 0 {
text += " · c decide"
}
if m.selectedFailedRun() > 0 {
@@ -740,7 +740,7 @@ func (m Model) runsDetailsView(height int) string {
page := max(0, innerHeight-5)
top := max(0, min(m.runTop, max(0, len(lines)-page)))
footerHint := "o result · d diff · s progress · i input · t evidence · m details · A artifacts"
if r.Status == protocol.RunStatusWaiting {
if r.Status == protocol.RunStatusWaiting && r.ExportPendingSequence == 0 {
footerHint += " · c decide"
}
footer := bar(footerHint, fmt.Sprintf("%d–%d / %d", min(top+1, len(lines)), min(top+page, len(lines)), len(lines)), max(1, m.width-4), false)