modal

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package modal provides modal dialogs for user interactions in the TUI application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStatusBar

func FormatStatusBar(runs []watcher.WatchedRun) string

FormatStatusBar returns a formatted status bar string for watched runs.

Types

type BranchItem

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

BranchItem represents a branch in the list.

func (BranchItem) Description

func (BranchItem) Description() string

Description returns the list item description (unused for branches).

func (BranchItem) FilterValue

func (i BranchItem) FilterValue() string

FilterValue returns the value used for fuzzy filtering.

func (BranchItem) Title

func (i BranchItem) Title() string

Title returns the branch name for list display.

type BranchModal

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

BranchModal presents a filterable list of branches.

func NewBranchModal

func NewBranchModal(title string, branches []string, current string) *BranchModal

NewBranchModal creates a new branch selection modal.

func NewBranchModalWithDefault

func NewBranchModalWithDefault(title string, branches []string, current, defaultBranch string) *BranchModal

NewBranchModalWithDefault creates a new branch selection modal with default branch pinning.

func (*BranchModal) IsDone

func (m *BranchModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*BranchModal) Result

func (m *BranchModal) Result() any

Result returns the selected branch.

func (*BranchModal) SetSize

func (m *BranchModal) SetSize(width, height int)

SetSize updates the modal dimensions based on terminal size.

func (*BranchModal) Update

func (m *BranchModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the branch modal.

func (*BranchModal) View

func (m *BranchModal) View() string

View renders the branch modal.

type BranchResultMsg

type BranchResultMsg struct {
	Value string
}

BranchResultMsg is sent when a branch is selected.

type ChainConfirmModal

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

ChainConfirmModal shows the chain configuration and confirms execution.

func NewChainConfirmModal

func NewChainConfirmModal(
	chainName string, chainDef *config.Chain, variables map[string]string, branch string, watch bool,
) *ChainConfirmModal

NewChainConfirmModal creates a chain confirmation modal.

func (*ChainConfirmModal) IsDone

func (m *ChainConfirmModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ChainConfirmModal) Result

func (m *ChainConfirmModal) Result() any

Result returns the confirmation result.

func (*ChainConfirmModal) SetSize added in v1.2.1

func (m *ChainConfirmModal) SetSize(width, _ int)

SetSize records the room the modal has, so a long command wraps rather than widening the modal past the terminal.

func (*ChainConfirmModal) Update

func (m *ChainConfirmModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the chain confirm modal.

func (*ChainConfirmModal) View

func (m *ChainConfirmModal) View() string

View renders the chain confirm modal.

type ChainConfirmResultMsg

type ChainConfirmResultMsg struct {
	Variables map[string]string
	ChainName string
	Branch    string
	Confirmed bool
	Watch     bool
}

ChainConfirmResultMsg is sent when chain execution is confirmed or canceled.

type ChainRerunModal

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

ChainRerunModal presents options for re-running a chain from history.

func NewChainRerunModal

func NewChainRerunModal(entry *frecency.HistoryEntry) *ChainRerunModal

NewChainRerunModal creates a chain re-run modal.

func (*ChainRerunModal) IsDone

func (m *ChainRerunModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ChainRerunModal) Result

func (m *ChainRerunModal) Result() any

Result returns the re-run selection result.

func (*ChainRerunModal) Update

func (m *ChainRerunModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the chain re-run modal.

func (*ChainRerunModal) View

func (m *ChainRerunModal) View() string

View renders the chain re-run modal.

type ChainRerunResultMsg

type ChainRerunResultMsg struct {
	HistoryEntry   *frecency.HistoryEntry
	Action         string
	ResumeFromStep int
}

ChainRerunResultMsg is sent when chain re-run options are selected.

type ChainSelectModal

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

ChainSelectModal displays available chains for selection.

func NewChainSelectModal

func NewChainSelectModal(cfg *config.WfdConfig) *ChainSelectModal

NewChainSelectModal creates a new chain selection modal.

func (*ChainSelectModal) IsDone

func (m *ChainSelectModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ChainSelectModal) Result

func (*ChainSelectModal) Result() any

Result returns nil for chain select modal.

func (*ChainSelectModal) Update

func (m *ChainSelectModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the chain select modal.

func (*ChainSelectModal) View

func (m *ChainSelectModal) View() string

View renders the chain select modal.

type ChainSelectResultMsg

type ChainSelectResultMsg struct {
	ChainName string
	Chain     config.Chain
}

ChainSelectResultMsg is sent when a chain is selected.

type ChainStatusModal

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

ChainStatusModal displays the current status of a chain execution.

func NewChainStatusModal

func NewChainStatusModal(state chain.ChainState) *ChainStatusModal

NewChainStatusModal creates a new chain status modal.

func NewChainStatusModalWithCommands

func NewChainStatusModalWithCommands(state chain.ChainState, commands []string, branch string) *ChainStatusModal

NewChainStatusModalWithCommands creates a chain status modal with command strings.

func (*ChainStatusModal) GetDetailedError

func (m *ChainStatusModal) GetDetailedError() string

GetDetailedError returns a detailed error message with context.

func (*ChainStatusModal) GetFailedStepRunURL

func (m *ChainStatusModal) GetFailedStepRunURL() string

GetFailedStepRunURL returns the URL of the failed step's run, if available.

func (*ChainStatusModal) IsDone

func (m *ChainStatusModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ChainStatusModal) Result

func (*ChainStatusModal) Result() any

Result returns nil for chain status modal.

func (*ChainStatusModal) SetCommands

func (m *ChainStatusModal) SetCommands(commands []string, branch string)

SetCommands sets the command strings for each step.

func (*ChainStatusModal) Update

func (m *ChainStatusModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the chain status modal.

func (*ChainStatusModal) UpdateState

func (m *ChainStatusModal) UpdateState(state chain.ChainState)

UpdateState updates the chain state displayed in the modal.

func (*ChainStatusModal) View

func (m *ChainStatusModal) View() string

View renders the chain status modal.

func (*ChainStatusModal) WasStopped

func (m *ChainStatusModal) WasStopped() bool

WasStopped returns true if the user requested to stop the chain.

type ChainStatusStopMsg

type ChainStatusStopMsg struct{}

ChainStatusStopMsg is sent when the user requests to stop the chain.

type ChainStatusViewLogsMsg

type ChainStatusViewLogsMsg struct {
	Branch     string
	State      chain.ChainState
	ErrorsOnly bool
}

ChainStatusViewLogsMsg is sent when the user requests to view logs.

type ChainVariableModal

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

ChainVariableModal collects variable values for chain execution.

func NewChainVariableModal

func NewChainVariableModal(chainName string, chainDef *config.Chain) *ChainVariableModal

NewChainVariableModal creates a chain variable input modal.

func (*ChainVariableModal) IsDone

func (m *ChainVariableModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ChainVariableModal) Result

func (m *ChainVariableModal) Result() any

Result returns the variable collection result.

func (*ChainVariableModal) Update

func (m *ChainVariableModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the chain variable modal.

func (*ChainVariableModal) View

func (m *ChainVariableModal) View() string

View renders the chain variable modal.

type ChainVariableResultMsg

type ChainVariableResultMsg struct {
	Variables map[string]string
	ChainName string
	Canceled  bool
}

ChainVariableResultMsg is sent when chain variable input is complete.

type ClosedMsg added in v1.0.1

type ClosedMsg struct {
	Result any
}

ClosedMsg is sent when a modal is closed.

type ConfirmModal

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

ConfirmModal presents a yes/no choice.

func NewConfirmModal

func NewConfirmModal(title, description string, current, defaultVal bool) *ConfirmModal

NewConfirmModal creates a new confirmation modal.

func (*ConfirmModal) IsDone

func (m *ConfirmModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ConfirmModal) Result

func (m *ConfirmModal) Result() any

Result returns the confirmed value.

func (*ConfirmModal) Update

func (m *ConfirmModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the confirm modal.

func (*ConfirmModal) View

func (m *ConfirmModal) View() string

View renders the confirm modal.

type ConfirmResultMsg

type ConfirmResultMsg struct {
	Value bool
}

ConfirmResultMsg is sent when confirmation is made.

type Context

type Context interface {
	Update(msg tea.Msg) (Context, tea.Cmd)
	View() string
	IsDone() bool
	Result() any
}

Context represents a modal that can be pushed onto the stack.

type ErrorModal

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

ErrorModal displays an error message with a dismiss button.

func NewErrorModal

func NewErrorModal(title, message string) *ErrorModal

NewErrorModal creates a new error modal with a title and message.

func (*ErrorModal) IsDone

func (m *ErrorModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ErrorModal) Result

func (*ErrorModal) Result() any

Result returns nil for error modal.

func (*ErrorModal) Update

func (m *ErrorModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the error modal.

func (*ErrorModal) View

func (m *ErrorModal) View() string

View renders the error modal.

type FilterModal

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

FilterModal presents a fuzzy filter input.

func NewFilterModal

func NewFilterModal(title string, items []string, currentFilter string) *FilterModal

NewFilterModal creates a new filter modal.

func (*FilterModal) IsDone

func (m *FilterModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*FilterModal) Result

func (m *FilterModal) Result() any

Result returns the filter value.

func (*FilterModal) Update

func (m *FilterModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the filter modal.

func (*FilterModal) View

func (m *FilterModal) View() string

View renders the filter modal.

type FilterResultMsg

type FilterResultMsg struct {
	Value    string
	Canceled bool
}

FilterResultMsg is sent when filter is applied or canceled.

type HelpModal

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

HelpModal displays keyboard shortcuts and help.

func NewHelpModal

func NewHelpModal() *HelpModal

NewHelpModal creates a new help modal.

func (*HelpModal) IsDone

func (m *HelpModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*HelpModal) Result

func (*HelpModal) Result() any

Result returns nil for help modal.

func (*HelpModal) SetSize added in v1.2.0

func (m *HelpModal) SetSize(_, height int)

SetSize records how many content lines the modal has room for.

func (*HelpModal) Update

func (m *HelpModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the help modal.

func (*HelpModal) View

func (m *HelpModal) View() string

View renders the help modal.

type InputModal

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

InputModal presents a text input field.

func NewInputModal

func NewInputModal(
	title, description, defaultVal, inputType, current string, options []string, rules []rule.ValidationRule,
) *InputModal

NewInputModal creates a new text input modal.

func (*InputModal) IsDone

func (m *InputModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*InputModal) Result

func (m *InputModal) Result() any

Result returns the entered value.

func (*InputModal) Update

func (m *InputModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the input modal.

func (*InputModal) View

func (m *InputModal) View() string

View renders the input modal.

type InputResultMsg

type InputResultMsg struct {
	Value string
}

InputResultMsg is sent when input is confirmed.

type LiveViewClearAllMsg

type LiveViewClearAllMsg struct{}

LiveViewClearAllMsg is sent when user wants to clear all completed runs.

type LiveViewClearMsg

type LiveViewClearMsg struct {
	RunID int64
}

LiveViewClearMsg is sent when user wants to clear a specific run.

type LiveViewModal

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

LiveViewModal displays the status of watched workflow runs.

func NewLiveViewModal

func NewLiveViewModal(runs []watcher.WatchedRun) *LiveViewModal

NewLiveViewModal creates a new live view modal.

func (*LiveViewModal) IsDone

func (m *LiveViewModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*LiveViewModal) Result

func (*LiveViewModal) Result() any

Result returns nil for live view modal.

func (*LiveViewModal) Update

func (m *LiveViewModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the live view modal.

func (*LiveViewModal) UpdateRuns

func (m *LiveViewModal) UpdateRuns(runs []watcher.WatchedRun)

UpdateRuns updates the list of watched runs.

func (*LiveViewModal) View

func (m *LiveViewModal) View() string

View renders the live view modal.

type LogsViewerModal

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

LogsViewerModal displays workflow logs in a unified view with collapsible sections.

func NewLogsViewerModal

func NewLogsViewerModal(runLogs *logs.RunLogs, width, height int) *LogsViewerModal

NewLogsViewerModal creates a new unified logs viewer modal.

func NewLogsViewerModalWithError

func NewLogsViewerModalWithError(runLogs *logs.RunLogs, width, height int) *LogsViewerModal

NewLogsViewerModalWithError creates a logs viewer pre-filtered for errors.

func (*LogsViewerModal) AppendStreamUpdate

func (m *LogsViewerModal) AppendStreamUpdate(update logs.StreamUpdate)

AppendStreamUpdate appends new log entries from streaming.

func (*LogsViewerModal) DisableStreaming

func (m *LogsViewerModal) DisableStreaming()

DisableStreaming disables streaming mode.

func (*LogsViewerModal) EnableStreaming

func (m *LogsViewerModal) EnableStreaming(runID int64, autoScroll bool)

EnableStreaming enables streaming mode for this viewer.

func (*LogsViewerModal) IsDone

func (m *LogsViewerModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*LogsViewerModal) IsStreaming

func (m *LogsViewerModal) IsStreaming() bool

IsStreaming returns whether streaming is active.

func (*LogsViewerModal) Result

func (*LogsViewerModal) Result() any

Result returns nil.

func (*LogsViewerModal) StreamRunID

func (m *LogsViewerModal) StreamRunID() int64

StreamRunID returns the run ID being streamed.

func (*LogsViewerModal) Update

func (m *LogsViewerModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the logs viewer modal.

func (*LogsViewerModal) View

func (m *LogsViewerModal) View() string

View renders the logs viewer modal.

type MatchLocation

type MatchLocation struct {
	StepIndex  int // index in filtered.Steps
	EntryIndex int // index in step.Entries
	LineNumber int // line number in viewport content (0-based)
}

MatchLocation tracks the position of a search match in the rendered viewport.

type RemapAction

type RemapAction int

RemapAction represents the action to take for a validation error.

const (
	RemapActionDrop RemapAction = iota // Drop this input
	RemapActionKeep                    // Keep with original name (ignore error)
	RemapActionMap                     // Map to a different input name
)

Remap action values.

type RemapDecision

type RemapDecision struct {
	OriginalName string
	NewName      string
	Action       RemapAction
}

RemapDecision represents a user decision for a validation error.

type RemapModal

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

RemapModal presents a wizard for remapping invalid configuration inputs.

func NewRemapModal

func NewRemapModal(
	errors []validation.ConfigValidationError, currentInputs map[string]workflow.Input,
) *RemapModal

NewRemapModal creates a new remapping wizard modal.

func (*RemapModal) IsDone

func (m *RemapModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*RemapModal) Result

func (m *RemapModal) Result() any

Result returns the remapping decisions.

func (*RemapModal) Update

func (m *RemapModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the remap modal.

func (*RemapModal) View

func (m *RemapModal) View() string

View renders the remap modal.

type RemapResultMsg

type RemapResultMsg struct {
	Decisions []RemapDecision
}

RemapResultMsg is sent when remapping is complete.

type ResetDiff

type ResetDiff struct {
	Name    string
	Current string
	Default string
}

ResetDiff represents a single value change.

type ResetModal

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

ResetModal shows values that will be reset and confirms.

func NewResetModal

func NewResetModal(diffs []ResetDiff) *ResetModal

NewResetModal creates a reset confirmation modal.

func (*ResetModal) IsDone

func (m *ResetModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ResetModal) Result

func (m *ResetModal) Result() any

Result returns the confirmation result.

func (*ResetModal) Update

func (m *ResetModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the reset modal.

func (*ResetModal) View

func (m *ResetModal) View() string

View renders the reset modal.

type ResetResultMsg

type ResetResultMsg struct {
	Confirmed bool
}

ResetResultMsg is sent when reset is confirmed or canceled.

type RunConfirmModal

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

RunConfirmModal shows the command that will be executed and confirms.

func NewRunConfirmModal

func NewRunConfirmModal(cfg runner.RunConfig) *RunConfirmModal

NewRunConfirmModal creates a run confirmation modal.

func (*RunConfirmModal) IsDone

func (m *RunConfirmModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*RunConfirmModal) Result

func (m *RunConfirmModal) Result() any

Result returns the confirmation result.

func (*RunConfirmModal) Update

func (m *RunConfirmModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the run confirm modal.

func (*RunConfirmModal) View

func (m *RunConfirmModal) View() string

View renders the run confirm modal.

type RunConfirmResultMsg

type RunConfirmResultMsg struct {
	Config    runner.RunConfig
	Confirmed bool
}

RunConfirmResultMsg is sent when workflow execution is confirmed or canceled.

type SelectModal

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

SelectModal presents a list of options to choose from.

func NewSelectModal

func NewSelectModal(title, description string, options []string, current, defaultVal string) *SelectModal

NewSelectModal creates a new selection modal.

func (*SelectModal) IsDone

func (m *SelectModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*SelectModal) Result

func (m *SelectModal) Result() any

Result returns the selected value.

func (*SelectModal) Update

func (m *SelectModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the select modal.

func (*SelectModal) View

func (m *SelectModal) View() string

View renders the select modal.

type SelectResultMsg

type SelectResultMsg struct {
	Value string
}

SelectResultMsg is sent when a selection is made.

type SimpleBranchModal

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

SimpleBranchModal is a branch selector without bubbles/list complexity.

func NewSimpleBranchModal

func NewSimpleBranchModal(title string, branches []string, current, defaultBranch string) *SimpleBranchModal

NewSimpleBranchModal creates a simple branch modal with filtering.

func (*SimpleBranchModal) IsDone

func (m *SimpleBranchModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*SimpleBranchModal) Result

func (m *SimpleBranchModal) Result() any

Result returns the selected branch.

func (*SimpleBranchModal) SetSize

func (m *SimpleBranchModal) SetSize(_, height int)

SetSize updates the modal dimensions.

func (*SimpleBranchModal) Update

func (m *SimpleBranchModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the simple branch modal.

func (*SimpleBranchModal) View

func (m *SimpleBranchModal) View() string

View renders the simple branch modal.

type Sizer added in v1.2.0

type Sizer interface {
	SetSize(width, height int)
}

Sizer is implemented by modals that render themselves against the terminal dimensions. Stack hands those out on Push and on every resize, so a modal never has to guess how much room it has.

type Stack

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

Stack manages a stack of modal contexts.

func NewStack

func NewStack() *Stack

NewStack creates a new empty modal stack.

func (*Stack) Clear

func (s *Stack) Clear()

Clear removes all contexts from the stack.

func (*Stack) Current

func (s *Stack) Current() Context

Current returns the top context without removing it.

func (*Stack) Find added in v1.2.2

func (s *Stack) Find(match func(Context) bool) Context

Find returns the first context on the stack that satisfies match, searching from the top down. A long-running operation uses it to reach the modal reporting on it, which need not be the modal the user is looking at.

func (*Stack) HasActive

func (s *Stack) HasActive() bool

HasActive returns true if there's at least one modal on the stack.

func (*Stack) Pop

func (s *Stack) Pop() Context

Pop removes and returns the top context.

func (*Stack) Push

func (s *Stack) Push(ctx Context)

Push adds a context to the top of the stack.

func (*Stack) Render

func (s *Stack) Render(background string) string

Render renders the modal overlay on top of the background.

func (*Stack) SetSize

func (s *Stack) SetSize(width, height int)

SetSize updates the dimensions for modal rendering.

func (*Stack) Update

func (s *Stack) Update(msg tea.Msg) tea.Cmd

Update processes a message for the current modal.

type ValidationErrorModal

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

ValidationErrorModal displays validation errors and allows override or fixing.

func NewValidationErrorModal

func NewValidationErrorModal(errors map[string][]string) *ValidationErrorModal

NewValidationErrorModal creates a new validation error modal.

func (*ValidationErrorModal) IsDone

func (m *ValidationErrorModal) IsDone() bool

IsDone returns true if the modal is finished.

func (*ValidationErrorModal) Result

func (m *ValidationErrorModal) Result() any

Result returns nil for validation error modal.

func (*ValidationErrorModal) Update

func (m *ValidationErrorModal) Update(msg tea.Msg) (Context, tea.Cmd)

Update handles input for the validation error modal.

func (*ValidationErrorModal) View

func (m *ValidationErrorModal) View() string

View renders the validation error modal.

type ValidationErrorResultMsg

type ValidationErrorResultMsg struct {
	Override bool
}

ValidationErrorResultMsg is returned when the modal closes.

Jump to

Keyboard shortcuts

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