feat: add back navigation, review step, and error retry to TUI
Implements three UX improvements (TODO #1–#3): - Back navigation: Esc returns to the previous input step. The Model keeps a history stack of input steps (advance/goBack helpers); action/wait steps are excluded via isInputStep so back never re-enters a side-effecting step. Form values are preserved. - Review step (StepReview): shows all collected config for confirmation before any file is written; Enter installs, Esc edits. - Retry vs. fix: transient failures (image pull, container run) offer "r: tentar novamente" instead of quitting; validation failures route back to the relevant form to correct the value. Adds nav_test.go for the history/navigation logic and updates README/CLAUDE/docs (incl. docs/TODO.md tracking the remaining ideas). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
type Model struct {
|
||||
currentStep step
|
||||
history []step // stack of input steps visited, for back navigation
|
||||
cursor int
|
||||
width int
|
||||
height int
|
||||
@@ -263,3 +264,31 @@ func InitialModel() Model {
|
||||
func (m Model) Init() tea.Cmd {
|
||||
return tea.Batch(CheckDockerCmd(), TickCmd(), m.spinner.Tick)
|
||||
}
|
||||
|
||||
// advance moves to the next step, recording the current step on the history stack when
|
||||
// it is an input step so that Esc can return to it. Consecutive duplicates are skipped.
|
||||
func (m *Model) advance(next step) {
|
||||
if isInputStep(m.currentStep) {
|
||||
if n := len(m.history); n == 0 || m.history[n-1] != m.currentStep {
|
||||
m.history = append(m.history, m.currentStep)
|
||||
}
|
||||
}
|
||||
m.currentStep = next
|
||||
}
|
||||
|
||||
// goBack returns to the previous input step on the history stack, if any. It reports
|
||||
// whether the step changed.
|
||||
func (m *Model) goBack() bool {
|
||||
if len(m.history) == 0 {
|
||||
return false
|
||||
}
|
||||
last := m.history[len(m.history)-1]
|
||||
m.history = m.history[:len(m.history)-1]
|
||||
m.currentStep = last
|
||||
return true
|
||||
}
|
||||
|
||||
// canGoBack reports whether Esc would return to a previous step from the current one.
|
||||
func (m Model) canGoBack() bool {
|
||||
return isInputStep(m.currentStep) && len(m.history) > 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user