tui

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package tui provides interactive terminal UI components for spec.

Package tui provides interactive terminal UI components for spec.

The theme sub-system resolves a colour palette from user preferences or terminal capabilities and exposes semantic style constructors that all views and components reference. No hardcoded colour values outside this file.

Index

Constants

View Source
const ViewCount = 6

ViewCount is the total number of top-level views.

Variables

View Source
var CommonGateTypes = []GateType{
	{Name: "Section has content", Description: "Require a section to be non-empty", Value: "section_not_empty"},
	{Name: "PR stack exists", Description: "Require PR stack plan in §7.3", Value: "pr_stack_exists"},
	{Name: "PRs approved", Description: "All PRs must be approved", Value: "prs_approved"},
	{Name: "Decisions resolved", Description: "All decisions must be resolved", Value: "decisions_resolved"},
	{Name: "Custom expression", Description: "Write a custom expression", Value: "expr"},
	{Name: "No gate", Description: "Skip adding a gate", Value: "none"},
}

CommonGateTypes are the built-in gate types.

View Source
var CommonRoles = []string{"anyone", "author", "pm", "tl", "designer", "engineer", "qa", "security"}

Common roles

View Source
var StageIcons = []string{"📥", "📝", "👀", "🎨", "🔧", "🏗️", "👁️", "✅", "🚀", "📊", "🎉", "📦", "🔒", "💬", "📋", "○"}

Common icons for stages

Functions

func ConfirmPreset

func ConfirmPreset(preset PresetOption) (bool, error)

ConfirmPreset shows a preset preview and asks for confirmation.

func IsInteractive

func IsInteractive() bool

IsInteractive returns true if stdin is a terminal.

func PrintError

func PrintError(message string)

PrintError prints an error message.

func PrintSuccess

func PrintSuccess(message string)

PrintSuccess prints a success message.

func PrintTitle

func PrintTitle(title string)

PrintTitle prints a title.

func PromptAddAnotherGate

func PromptAddAnotherGate() (bool, error)

PromptAddAnotherGate asks if the user wants to add another gate.

func PromptConfirm

func PromptConfirm(title string) (bool, error)

PromptConfirm asks for yes/no confirmation.

func PromptExpression

func PromptExpression() (string, string, error)

PromptExpression prompts for a custom expression.

func PromptGateType

func PromptGateType() (string, error)

PromptGateType prompts the user to select a gate type.

func PromptMultiSelectStages

func PromptMultiSelectStages(stages []string, title, description string) ([]string, error)

PromptMultiSelectStages prompts to select multiple stages.

func PromptSectionSlug

func PromptSectionSlug() (string, error)

PromptSectionSlug prompts for a section slug.

func PromptSelectStage

func PromptSelectStage(stages []string, title, description string) (string, error)

PromptSelectStage prompts to select a stage from a list.

func PromptStageIcon

func PromptStageIcon() (string, error)

PromptStageIcon prompts for a stage icon.

func PromptStageName

func PromptStageName(existing []string) (string, error)

PromptStageName prompts for a stage name.

func PromptStageOwner

func PromptStageOwner(defaultOwner string) (string, error)

PromptStageOwner prompts for a stage owner role.

func PromptStagePosition

func PromptStagePosition(stages []string) (afterStage string, err error)

PromptStagePosition prompts for where to insert a new stage.

func SelectPreset

func SelectPreset(presets []PresetOption) (string, error)

SelectPreset prompts the user to select a pipeline preset.

func ThemeNames added in v0.6.0

func ThemeNames() []string

ThemeNames returns the ordered list of available named themes.

Types

type App added in v0.6.0

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

App is the top-level Bubble Tea model. It owns the tab strip, header, status bar, and delegates to the active view.

func New added in v0.6.0

func New(rc *config.ResolvedConfig, reg *adapter.Registry, role string) App

New creates a new App ready to run as a tea.Program.

func (App) Init added in v0.6.0

func (a App) Init() tea.Cmd

Init runs the initial commands — fetch data + start tick.

func (App) Update added in v0.6.0

func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles all messages.

func (App) View added in v0.6.0

func (a App) View() string

View renders the full application.

type GateType

type GateType struct {
	Name        string
	Description string
	Value       string
}

GateType represents a type of gate.

type GlamourRenderer added in v0.6.0

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

GlamourRenderer renders markdown using Glamour with a pre-resolved style. The TermRenderer is constructed once per (style, width) pair and cached, so termenv.HasDarkBackground is never called on the hot render path.

func (*GlamourRenderer) Render added in v0.6.0

func (g *GlamourRenderer) Render(ctx context.Context, md string, width int) (string, error)

Render implements Renderer.

type KeyMap added in v0.6.0

type KeyMap struct {
	// Navigation
	Up         key.Binding
	Down       key.Binding
	Enter      key.Binding
	Back       key.Binding
	PageUp     key.Binding
	PageDown   key.Binding
	ScrollUp   key.Binding
	ScrollDown key.Binding

	// View switching
	Tab1 key.Binding
	Tab2 key.Binding
	Tab3 key.Binding
	Tab4 key.Binding
	Tab5 key.Binding
	Tab6 key.Binding

	NextTab key.Binding
	PrevTab key.Binding

	// Global actions
	Help    key.Binding
	Search  key.Binding
	Refresh key.Binding
	Quit    key.Binding

	// Spec actions
	Advance key.Binding
	Edit    key.Binding
	Build   key.Binding
	Block   key.Binding
	Unblock key.Binding
	Revert  key.Binding
	Focus   key.Binding
	Unfocus key.Binding
	Open    key.Binding
	Yank    key.Binding
	Decide  key.Binding
	Push    key.Binding
	Sync    key.Binding

	// Archive
	Archive key.Binding
	Restore key.Binding

	// Creation
	NewSpec   key.Binding
	NewIntake key.Binding
	Standup   key.Binding
}

KeyMap defines all keybindings for the TUI.

func DefaultKeyMap added in v0.6.0

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default keybindings.

func (KeyMap) ActionBindings added in v0.6.0

func (k KeyMap) ActionBindings() []key.Binding

ActionBindings returns the action bindings for help display.

func (KeyMap) GlobalBindings added in v0.6.0

func (k KeyMap) GlobalBindings() []key.Binding

GlobalBindings returns bindings shown in every context.

func (KeyMap) NavigationBindings added in v0.6.0

func (k KeyMap) NavigationBindings() []key.Binding

NavigationBindings returns the nav-related bindings for help display.

func (KeyMap) SettingsBindings added in v0.8.0

func (k KeyMap) SettingsBindings() []key.Binding

SettingsBindings returns keybindings for the Settings tab edit flow.

func (KeyMap) ViewBindings added in v0.6.0

func (k KeyMap) ViewBindings() []key.Binding

ViewBindings returns the view-switching bindings for help display.

type PlainRenderer added in v0.6.0

type PlainRenderer struct{}

PlainRenderer is a plain-text fallback with no ANSI styling.

func (PlainRenderer) Render added in v0.6.0

func (PlainRenderer) Render(ctx context.Context, md string, _ int) (string, error)

type PresetOption

type PresetOption struct {
	Name        string
	Description string
	Stages      []string
	Features    []string
}

PresetOption represents a pipeline preset for selection.

type Renderer added in v0.6.0

type Renderer interface {
	Render(ctx context.Context, md string, width int) (string, error)
}

Renderer renders markdown content into ANSI-styled terminal text.

func NewGlamourRenderer added in v0.6.0

func NewGlamourRenderer(theme Theme) Renderer

NewGlamourRenderer creates a renderer whose style is derived from the already-resolved Theme. No terminal I/O is performed at construction time.

func NewPlainRenderer added in v0.6.0

func NewPlainRenderer() Renderer

NewPlainRenderer creates a plain-text renderer.

type StageInput

type StageInput struct {
	Name     string
	Owner    string
	Icon     string
	Position string // "after:<stage>" or "before:<stage>"
}

StageInput holds input for creating a new stage.

type Styles added in v0.6.0

type Styles struct {
	// Layout
	Header    lipgloss.Style
	StatusBar lipgloss.Style
	TabActive lipgloss.Style
	TabNormal lipgloss.Style
	Content   lipgloss.Style

	// Text
	Title    lipgloss.Style
	Subtitle lipgloss.Style
	Muted    lipgloss.Style
	Bold     lipgloss.Style

	// Semantic
	Success lipgloss.Style
	Warning lipgloss.Style
	Error   lipgloss.Style
	Accent  lipgloss.Style

	// Table
	RowSelected lipgloss.Style
	RowNormal   lipgloss.Style

	// Section headers within views
	SectionTitle lipgloss.Style
	Separator    lipgloss.Style
}

Styles holds pre-built lipgloss styles derived from the active theme.

func NewStyles added in v0.6.0

func NewStyles(t Theme) Styles

NewStyles constructs all styles from a theme.

type Theme added in v0.6.0

type Theme struct {
	Base    lipgloss.Color // background / deepest layer
	Surface lipgloss.Color // panels, selected rows
	Overlay lipgloss.Color // borders, separators
	Text    lipgloss.Color // primary text
	SubText lipgloss.Color // secondary, dimmed
	Accent  lipgloss.Color // highlights, active tab
	Success lipgloss.Color // done, approved
	Warning lipgloss.Color // stale, blocked
	Error   lipgloss.Color // critical, failed
	Muted   lipgloss.Color // disabled, inactive
}

Theme holds the semantic colour palette for the entire TUI.

func ResolveTheme added in v0.6.0

func ResolveTheme(pref string) Theme

ResolveTheme returns a Theme for the given preference string. An empty string or "auto" detects from the terminal.

type View added in v0.6.0

type View int

View identifies each top-level view in the TUI.

const (
	ViewDashboard View = iota
	ViewPipeline
	ViewSpecs
	ViewTriage
	ViewReviews
	ViewSettings
)

func (View) Label added in v0.6.0

func (v View) Label() string

Label returns the display name for a view.

func (View) Next added in v0.6.0

func (v View) Next() View

Next returns the next view, wrapping around.

func (View) Prev added in v0.6.0

func (v View) Prev() View

Prev returns the previous view, wrapping around.

func (View) Shortcut added in v0.6.0

func (v View) Shortcut() string

Shortcut returns the keyboard shortcut for a view.

Directories

Path Synopsis
Package components provides reusable TUI building blocks.
Package components provides reusable TUI building blocks.

Jump to

Keyboard shortcuts

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