ui

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package ui provides the Bubble Tea TUI layer for solo-provisioner. It replaces the default zerolog console output with a structured, human-friendly display of workflow step progress using spinners, status icons, and a summary table.

Global flags (set from root command):

VerboseLevel    – controls output detail: 0=compact, 1=verbose.
NonInteractive  – disables TUI, outputs raw zerolog for CI/pipelines.

Index

Constants

This section is empty.

Variables

View Source
var NonInteractive bool

NonInteractive disables the TUI and outputs raw zerolog lines. Set by --non-interactive. Intended for CI pipelines and machine-readable output.

View Source
var VerboseLevel int

VerboseLevel controls output verbosity. Set by the -V flag.

0 (default) — collapsed phases with progress bar + current step name
1 (-V)      — all steps (start + completion) + transient detail + version info

Functions

func CaptureOutput

func CaptureOutput() (origStdout *os.File, cleanup func())

CaptureOutput redirects file descriptors 1 (stdout) and 2 (stderr) to discard pipes at the OS level using dup2. This catches ALL output — even from third-party C/Go libraries that captured the fd at init time or write directly to fd 1/2 (e.g. Helm OCI "Pulled:", syspkg "apt manager").

Returns an *os.File backed by the original stdout fd (for the output handler to write to) and a cleanup function that restores both fds.

func IsUnformatted

func IsUnformatted() bool

IsUnformatted returns true when the TUI should be bypassed and zerolog writes directly to the console. This is the case when --non-interactive is set OR when stdout is not a terminal (CI, pipes, redirected output).

func NewTUIHandler

func NewTUIHandler(program *tea.Program) *notify.Handler

NewTUIHandler creates a notify.Handler that sends messages to the given tea.Program. At VerboseLevel >= 1, completed steps, phases, and detail lines are printed permanently above the TUI via program.Println (which guarantees ordering). The model is then updated via program.Send so View() can skip already-printed content.

func RenderSummaryTable

func RenderSummaryTable(report *automa.Report, totalDuration time.Duration, reportPath string, logPath string) string

RenderSummaryTable produces a compact summary for use after the TUI quits or in line handler mode. reportPath and logPath are included if non-empty.

func RenderVersionHeader

func RenderVersionHeader() string

RenderVersionHeader returns a styled version block for display when VerboseLevel >= 1. Returns an empty string when verbosity is too low.

func SuppressConsoleLogging

func SuppressConsoleLogging(cfg logx.LoggingConfig, program ...*tea.Program)

SuppressConsoleLogging replaces the global logx logger with a file-only writer (no ConsoleWriter) so that raw zerolog lines do not appear on stdout.

When program is non-nil a tuiLogHook is attached so that log messages are forwarded to the TUI as transient "thinking" detail text. When program is nil (called before the program exists) only the console suppression is applied.

This works around the upstream logx.Initialize() unconditionally creating a ConsoleWriter regardless of the ConsoleLogging config field.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the Bubble Tea model for the TUI display.

func NewModel

func NewModel() Model

NewModel creates a new TUI model ready for use with tea.NewProgram.

func (Model) Err

func (m Model) Err() error

Err returns any build/init error captured during workflow execution.

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the spinner tick.

func (Model) Report

func (m Model) Report() *automa.Report

Report returns the workflow report captured after completion.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles incoming messages and updates the model state.

func (Model) View

func (m Model) View() string

View renders the TUI output. The layout depends on VerboseLevel:

0 — collapsed phases with progress bar + current step
1 (-V) — all steps visible with transient detail text

type PhaseDoneMsg

type PhaseDoneMsg struct {
	ID       string
	Name     string
	Status   automa.TypeStatus
	Duration time.Duration
}

PhaseDoneMsg is sent when a major workflow phase completes.

type PhaseFailedMsg

type PhaseFailedMsg struct {
	ID     string
	Name   string
	ErrMsg string
}

PhaseFailedMsg is sent when a major workflow phase fails.

type PhaseStartedMsg

type PhaseStartedMsg struct {
	ID   string
	Name string
}

PhaseStartedMsg is sent when a major workflow phase begins. The TUI renders this as a section header with subsequent steps indented below.

type StepDetailMsg

type StepDetailMsg struct {
	Detail string
}

StepDetailMsg is a transient sub-status update shown as greyed-out text under the currently running step. Used by child steps to indicate progress without creating a new top-level entry in the TUI.

type StepDoneMsg

type StepDoneMsg struct {
	ID       string
	Name     string
	Status   automa.TypeStatus
	Duration time.Duration
}

StepDoneMsg is sent when a workflow step completes successfully or is skipped.

type StepFailedMsg

type StepFailedMsg struct {
	ID     string
	Name   string
	ErrMsg string
}

StepFailedMsg is sent when a workflow step fails.

type StepStartedMsg

type StepStartedMsg struct {
	ID   string
	Name string
}

StepStartedMsg is sent when a workflow step begins execution.

type WorkflowDoneMsg

type WorkflowDoneMsg struct {
	Report *automa.Report
	Err    error
}

WorkflowDoneMsg is sent when the entire workflow finishes execution.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL