tui

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package tui implements a terminal user interface using bubbletea.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfirmPager

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

ConfirmPager is a scrollable diff pager with embedded confirm keybindings. Shown instead of the bare Picker when a tool confirmation includes a diff preview.

func NewConfirmPager

func NewConfirmPager(title, diff, pattern string, response chan<- ui.ConfirmAction, width, height int) *ConfirmPager

NewConfirmPager creates a ConfirmPager from highlighted diff content.

func (*ConfirmPager) HandleKey

func (c *ConfirmPager) HandleKey(msg tea.KeyPressMsg) (action *ui.ConfirmAction, dismissed bool)

HandleKey processes key events. Returns (action, dismissed). action is non-nil when the user picks a confirm action. dismissed is true when the user cancels (esc/ctrl+c).

func (*ConfirmPager) View

func (c *ConfirmPager) View() string

View renders the confirm pager with diff content and keybinding footer.

type HintFunc

type HintFunc func(name string) string

HintFunc resolves a slash command name (e.g. "/hello") to its hint text (e.g. "<name> [arguments]").

type Model

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

Model holds the TUI state.

func NewModel

func NewModel(
	status ui.Status,
	input chan<- ui.UserInput,
	actions chan<- ui.UserAction,
	cancel chan<- struct{},
	historyPath string,
	hintFunc HintFunc,
	workdir string,
) Model

NewModel creates a new TUI model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (Model) Update

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

Update handles all messages and updates the model.

func (Model) View

func (m Model) View() tea.View

View renders the TUI.

type Pager

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

Pager is a scrollable read-only overlay for multi-line command output.

func NewPager

func NewPager(title, content string, width, height int) *Pager

NewPager creates a pager from the given content string.

func (*Pager) HandleKey

func (p *Pager) HandleKey(msg tea.KeyPressMsg) bool

HandleKey processes a key event. Returns true if the pager should be dismissed.

func (*Pager) View

func (p *Pager) View() string

View renders the pager overlay.

type Picker

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

Picker is an interactive overlay for selecting an item from a grouped list.

func NewPicker

func NewPicker(title string, items []ui.PickerItem, width, height int) *Picker

NewPicker creates a picker from the given items. The cursor starts on the current item (if any).

func (*Picker) HandleKey

func (p *Picker) HandleKey(msg tea.KeyPressMsg) (selected *ui.PickerItem, dismissed bool)

HandleKey processes a key event. Returns: handled (always true), selected item (if Enter), dismissed (if Esc).

func (*Picker) View

func (p *Picker) View() string

View renders the picker overlay.

type Position

type Position struct {
	Col  int // Column position
	Line int // Line position
}

Position represents a point in the viewport (column and line).

type State

type State int

State represents the current UI state.

const (
	// StateInput indicates the UI is accepting user input.
	StateInput State = iota
	// StateStreaming indicates the UI is receiving streamed content.
	StateStreaming
)

type UI

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

UI implements a bubbletea-based TUI.

func New

func New(status ui.Status, historyPath string, output *os.File) *UI

New creates a new TUI with the given status information and history file path.

func (*UI) Actions

func (u *UI) Actions() <-chan ui.UserAction

Actions returns the channel for sending UI actions to the assistant.

func (*UI) Cancel

func (u *UI) Cancel() <-chan struct{}

Cancel returns the channel for receiving cancel requests.

func (*UI) Events

func (u *UI) Events() chan<- ui.Event

Events returns the channel for receiving events from the assistant.

func (*UI) Input

func (u *UI) Input() <-chan ui.UserInput

Input returns the channel for sending user input to the assistant.

func (*UI) Run

func (u *UI) Run(ctx context.Context) error

Run starts the TUI, blocking until exit.

func (*UI) SetHintFunc

func (u *UI) SetHintFunc(fn func(string) string)

SetHintFunc sets the function used to resolve slash command hints.

func (*UI) SetWorkdir

func (u *UI) SetWorkdir(dir string)

SetWorkdir sets the working directory for directive autocomplete.

Directories

Path Synopsis
Package autocomplete provides directive name and path completions for the TUI.
Package autocomplete provides directive name and path completions for the TUI.

Jump to

Keyboard shortcuts

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