tui

package
v0.1.156 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorPrimary   = lipgloss.Color("#7C3AED")
	ColorSecondary = lipgloss.Color("#06B6D4")
	ColorSuccess   = lipgloss.Color("#10B981")
	ColorWarning   = lipgloss.Color("#F59E0B")
	ColorError     = lipgloss.Color("#EF4444")
	ColorMuted     = lipgloss.Color("#6B7280")
	ColorText      = lipgloss.Color("#E5E7EB")
	ColorSubtle    = lipgloss.Color("#374151")
	ColorBg        = lipgloss.Color("#111827")
)

Functions

func DefaultInput

func DefaultInput(def bool) string

DefaultInput returns "(Y/n)" or "(y/N)" based on the default value.

func NewLogChannel

func NewLogChannel() <-chan agents.ChannelLog

NewLogChannel creates a buffered channel and registers a processor so agent logs flow into the channel. Call this before starting agents.

func RenderDebug

func RenderDebug(text string) string

RenderDebug renders text in the debug style.

func RenderError

func RenderError(text string) string

RenderError renders text in the error style with an icon.

func RenderErrorDetail

func RenderErrorDetail(text string) string

RenderErrorDetail renders text in the error style without an icon.

func RenderFocus

func RenderFocus(text string) string

RenderFocus renders text with a rounded border for emphasis.

func RenderHeader

func RenderHeader(level int, text string) string

RenderHeader renders text as a level-1 or level-2 header.

func RenderInfo

func RenderInfo(text string) string

RenderInfo renders text in the info style.

func RenderMarkdown

func RenderMarkdown(content string, style string) (string, error)

RenderMarkdown renders markdown content with the given glamour style (e.g. "dark", "light", "auto").

func RenderTrace

func RenderTrace(text string) string

RenderTrace renders text in the trace style.

func RenderWarning

func RenderWarning(text string) string

RenderWarning renders text in the warning style with an icon.

func RenderWithMargin

func RenderWithMargin(text string) string

RenderWithMargin renders text with a standard display margin.

func RunPaginate

func RunPaginate(text string) error

RunPaginate shows text in a paginated view. Blocks until dismissed.

func RunServiceTUI

func RunServiceTUI(service string, logCh <-chan agents.ChannelLog, startFn func(t *ServiceTUI)) error

RunServiceTUI creates and runs an inline TUI for a service. startFn is called in a goroutine to start the service flow; it should call tui.SendReady/SendError when the flow reaches steady state. The TUI blocks until Ctrl+C or SendDone. Returns after the TUI exits. Output remains visible in the terminal after exit for debugging.

func ServiceFocusRenderer

func ServiceFocusRenderer(unique string) func(string) string

ServiceFocusRenderer returns a render function like ServiceRenderer but with a rounded border added, for focus-level log messages.

func ServiceRenderer

func ServiceRenderer(unique string) func(string) string

ServiceRenderer returns a render function that applies a deterministic color to text based on the service's unique identifier. Results are cached.

func Styles

func Styles() *struct {
	Header     lipgloss.Style
	StatusBar  lipgloss.Style
	LogInfo    lipgloss.Style
	LogWarn    lipgloss.Style
	LogError   lipgloss.Style
	LogDebug   lipgloss.Style
	LogForward lipgloss.Style
	LogTrace   lipgloss.Style
	Service    lipgloss.Style
	Spinner    lipgloss.Style
	Muted      lipgloss.Style
	Bold       lipgloss.Style
	Viewport   lipgloss.Style
}

Styles returns the shared style set.

Types

type ChoiceResult

type ChoiceResult struct {
	Entry   *Entry
	Stopped bool
}

ChoiceResult holds the outcome of a choice prompt.

func RunChoice

func RunChoice(message string, entries []*Entry) (ChoiceResult, error)

RunChoice runs an interactive choice prompt. Returns the selected entry and whether the user cancelled (Ctrl+C).

type ConfirmResult

type ConfirmResult struct {
	Confirmed bool
	Stopped   bool
}

ConfirmResult holds the outcome of a confirm prompt.

func RunConfirm

func RunConfirm(message string, defaultValue bool) (ConfirmResult, error)

RunConfirm runs an interactive yes/no prompt.

type Entry

type Entry struct {
	Identifier  string
	Current     bool
	Description string
}

Entry represents a selectable item in a choice/select prompt.

func (*Entry) String

func (e *Entry) String() string

type FlowDoneMsg

type FlowDoneMsg struct {
	Err error
}

FlowDoneMsg signals that the flow has completed (playbook returned).

type InputResult

type InputResult struct {
	Value   string
	Stopped bool
}

InputResult holds the outcome of an input prompt.

func RunInput

func RunInput(message string, defaultValue string) (InputResult, error)

RunInput runs an interactive text input prompt.

type LogView

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

LogView is a scrollable log panel that renders styled log entries.

func NewLogView

func NewLogView() LogView

NewLogView creates a LogView with a sensible default size.

func (*LogView) AppendText

func (l *LogView) AppendText(text string)

AppendText adds a raw styled line to the log viewport.

func (*LogView) Init

func (l *LogView) Init() tea.Cmd

func (*LogView) SetSize

func (l *LogView) SetSize(width, height int)

func (*LogView) Update

func (l *LogView) Update(msg tea.Msg) tea.Cmd

func (*LogView) View

func (l *LogView) View() string

type SelectResult

type SelectResult struct {
	Entry   *Entry
	Stopped bool
}

SelectResult holds the outcome of a select prompt.

func RunSelect

func RunSelect(message string, entries []*Entry) (SelectResult, error)

RunSelect runs an interactive selection prompt.

type ServiceErrorMsg

type ServiceErrorMsg struct {
	Err error
}

ServiceErrorMsg is sent on a fatal error from the flow.

type ServiceLogMsg

type ServiceLogMsg struct {
	Level   wool.Loglevel
	Source  string
	Message string
}

ServiceLogMsg carries a log entry from an agent or service binary.

type ServiceReadyMsg

type ServiceReadyMsg struct {
	Service string
	Port    int
}

ServiceReadyMsg is sent when the service has started successfully.

type ServiceRunnerModel

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

ServiceRunnerModel is a Bubbletea model for running a Codefly service.

func (ServiceRunnerModel) Init

func (m ServiceRunnerModel) Init() tea.Cmd

func (ServiceRunnerModel) Update

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

func (ServiceRunnerModel) View

func (m ServiceRunnerModel) View() string

type ServiceState

type ServiceState int

ServiceState enumerates the phases of a service lifecycle.

const (
	StateLoading ServiceState = iota
	StateInitializing
	StateStarting
	StateRunning
	StateTesting
	StateStopping
	StateStopped
	StateFailed
)

func (ServiceState) String

func (s ServiceState) String() string

type ServiceStateMsg

type ServiceStateMsg struct {
	State   ServiceState
	Service string
}

ServiceStateMsg reports a lifecycle state change.

type ServiceTUI

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

ServiceTUI controls a running service TUI. Callers use Send* methods to push events without knowing about Bubbletea.

func (*ServiceTUI) PumpLogs

func (t *ServiceTUI) PumpLogs(logCh <-chan agents.ChannelLog)

PumpLogs reads from logCh and forwards entries to the TUI. Blocks until the channel is closed; run in a goroutine.

func (*ServiceTUI) SendDone

func (t *ServiceTUI) SendDone(err error)

SendDone signals the flow has completed.

func (*ServiceTUI) SendError

func (t *ServiceTUI) SendError(err error)

SendError reports a fatal error.

func (*ServiceTUI) SendLog

func (t *ServiceTUI) SendLog(level wool.Loglevel, source, message string)

SendLog pushes a log entry into the TUI viewport.

func (*ServiceTUI) SendReady

func (t *ServiceTUI) SendReady(service string, port int)

SendReady marks the service as running.

func (*ServiceTUI) SendState

func (t *ServiceTUI) SendState(service string, state ServiceState)

SendState reports a lifecycle state change.

type StatusBar

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

StatusBar renders a bottom bar with service name, state, and elapsed time.

func NewStatusBar

func NewStatusBar(service string) StatusBar

func (*StatusBar) SetState

func (b *StatusBar) SetState(state ServiceState)

func (*StatusBar) SetWidth

func (b *StatusBar) SetWidth(w int)

func (*StatusBar) Update

func (b *StatusBar) Update(msg tea.Msg) tea.Cmd

func (*StatusBar) View

func (b *StatusBar) View() string

Jump to

Keyboard shortcuts

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