Files
pipelines/internal/tui/context_footer.go
T
alan a6aff47117 Add a human decision stage that pauses a run for an operator's choice
A new registered stage type `human` (internal/stage/human.go) has no model,
agent, tools or configs: its required `prompt` block carries the operator
instructions and its non-error edges are the selectable options. It parses,
validates, renders, exports and imports like every other type (no parser
special-case, no config keys).

At runtime the runner parks the run instead of executing: the step and the run
persist `waiting` with self-contained {prompt, options} evidence, and the run
returns without starting later stages, capturing file diffs, scanning artifacts,
holding a goroutine/timer or applying a stage timeout. The wait is durable: a
restart leaves the waiting rows untouched (RecoverRuns excludes them) and a
rebuilt runtime over the same database still accepts the decision.

`pipelines decide <run-id> [stage] --option KEY [--feedback TEXT] [--json]` and
the TUI `c` picker resolve the decision from the pinned graph in one store
transaction, record the choice and feedback as the step's evidence and resume
along edges[KEY]. An unknown option is refused with the valid list, a stage that
is not waiting is refused, and a repeated decision for an already-decided visit
does not double-apply. Cancel and retry keep working while waiting and after a
decision; a human stage is never killed by a stage timeout or max_visits, and a
`notify` policy can fire an `on=waiting` event.

Docs: the authoring skill references (format.md, operations.md), docs/cli.md and
README describe the stage, the command and the TUI picker. Tests cover stage
validation, the parsing round-trip, the store transitions, a websocket wait/decide
integration, cancel/retry, waiting notifications and a persistence-layer rebuild
(second Open + newRunner over one database, no process restart).
2026-10-16 16:47:28 +01:00

111 lines
3.9 KiB
Go

package tui
import (
"strings"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
)
// Modal controls replace, rather than inherit, the obscured page's shortcuts.
func (m Model) activeFooter() string {
text := ""
switch {
case m.editorChecking:
text = "Refreshing published state · draft retained"
case m.decisionOpen:
text = "↑/↓ choose · Tab feedback · Enter decide · Esc cancel"
case m.actionConfirm != nil || m.mutationCommand != nil:
text = "y confirm · n/Esc cancel · j/k read"
case m.draftDeletingPath != "":
text = "y delete · n/Esc keep · j/k read"
case m.statusOpen:
text = "j/k scroll · r refresh · Esc back"
case m.editorOpen:
text = "Type to filter · ↑/↓ choose · Enter open · Esc cancel"
case m.confirmOpen && m.templateConfirm:
text = "Enter create pipeline · edit name · Esc keep draft"
if m.pendingDraft != nil && m.pendingDraft.path == "" {
text = "Enter create pipeline · edit name · Esc back"
}
case m.confirmOpen && m.pendingDraft != nil && strings.TrimSpace(m.pendingDraft.name) == "":
text = "Enter save name · Esc keep draft"
case m.confirmOpen:
text = "s " + m.publicationAction() + " · e edit · Esc keep draft"
case m.versionsOpen:
text = "↑/↓ choose · Enter view version · Esc back"
case m.paletteOpen && m.searchOpen:
text = "Type to search · ↑/↓ choose · Enter open · Esc cancel"
case m.paletteOpen:
text = "Type a command · ↑/↓ choose · Enter execute · Esc cancel"
case m.logOpen:
text = "j/k line · ←/→ pan · Esc back"
case m.runPicker:
text = "Type to filter · ↑/↓ choose · Enter select · Esc cancel"
case m.runForm != 0:
text = "Ctrl+S run · Enter newline · Esc cancel"
case m.templateOpen && len(m.templates) == 0:
text = ": commands · Esc back"
case m.templateOpen:
text = "s create pipeline · Tab graph · n/p template · j/k read · Esc back"
if m.templateGraphFocus {
text = "s create pipeline · Tab description · n/p template · hjkl pan · Esc back"
}
case m.runSearchOpen:
text = "Type to filter · Enter results · Esc clear"
}
if text == "" {
return ""
}
if m.width < 65 {
switch {
case m.editorChecking:
text = "Refreshing · draft retained"
case m.decisionOpen:
text = "Esc cancel · Enter decide · ↑↓ select"
case m.actionConfirm != nil || m.mutationCommand != nil:
text = "Esc cancel · y confirm · j/k read"
case m.draftDeletingPath != "":
text = "Esc keep · y delete · j/k read"
case m.statusOpen:
text = "Esc back · r refresh · j/k read"
case m.editorOpen || m.runPicker:
text = "Esc back · Enter open · ↑↓ select"
case m.confirmOpen && m.templateConfirm:
text = "Esc keep · Enter create pipeline"
if m.pendingDraft != nil && m.pendingDraft.path == "" {
text = "Esc back · Enter create pipeline"
}
case m.confirmOpen && m.pendingDraft != nil && strings.TrimSpace(m.pendingDraft.name) == "":
text = "Esc keep · Enter save name"
case m.confirmOpen:
text = "Esc keep · s " + m.publicationAction()
case m.versionsOpen:
text = "Esc back · Enter view · ↑↓ select"
case m.paletteOpen && m.searchOpen:
text = "Esc back · Enter open · ↑↓ select"
case m.paletteOpen:
text = "Esc back · Enter run · ↑↓ select"
case m.logOpen:
text = "Esc back · j/k read · ←→ pan"
case m.runForm != 0:
text = "Esc cancel · Ctrl+S run"
case m.templateOpen:
text = "Esc · s create · Tab graph · n/p"
if m.templateGraphFocus {
text = "Esc · Tab description · hjkl pan · n/p"
}
case m.runSearchOpen:
text = "Esc clear · Enter results"
}
}
return lipgloss.NewStyle().Foreground(themeMuted).Render(ansi.Truncate(text, max(1, m.width), "…"))
}
func (m Model) publicationAction() string {
if m.pendingDraft != nil && !m.pendingDraft.createOnly && m.pendingDraft.baseVersion > 0 {
return "update pipeline"
}
return "create pipeline"
}