tui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package tui implements the interactive terminal UI using Bubble Tea.

Architecture: The TUI follows Bubble Tea's Elm-like pattern (Model → Update → View). AppModel is the top-level model that manages four tab sub-models (Create, Connect, Edit, Delete) and an optional passphrase modal overlay. Each sub-model handles its own input and rendering, while AppModel coordinates tab switching, saves, and result propagation back to the CLI layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionKind

type ActionKind int

ActionKind describes what action the user took in the TUI.

const (
	ActionNone    ActionKind = iota // user quit without action
	ActionConnect                   // user selected a connection
	ActionCreated                   // user submitted the new connection form
	ActionEdited                    // user submitted the edit form (password changed, needs modal)
)

type AppModel

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

AppModel is the top-level Bubble Tea model.

func (AppModel) Init

func (m AppModel) Init() tea.Cmd

func (AppModel) Update

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

func (AppModel) View

func (m AppModel) View() string

type AppResult

type AppResult struct {
	Action       ActionKind
	Connection   *model.Connection
	WizardResult *WizardResult
}

AppResult is returned from the TUI to the CLI layer.

func Run

func Run(connections []model.Connection, d *sql.DB, initialTab Tab) *AppResult

Run launches the TUI and returns the user's action.

type ConnectModel

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

ConnectModel is the Bubble Tea model for the Connect tab.

func (*ConnectModel) AddItem

func (m *ConnectModel) AddItem(conn model.Connection)

AddItem inserts a connection in ascending alphabetical position.

func (*ConnectModel) RemoveByName

func (m *ConnectModel) RemoveByName(name string)

RemoveByName removes the first item matching the given connection name.

func (*ConnectModel) SetSize

func (m *ConnectModel) SetSize(w, h int)

func (ConnectModel) Update

func (m ConnectModel) Update(msg tea.Msg) (ConnectModel, *AppResult, tea.Cmd)

func (ConnectModel) View

func (m ConnectModel) View() string

type CreateModel

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

CreateModel is the Bubble Tea model for the New tab.

func (*CreateModel) SetSize

func (m *CreateModel) SetSize(w, h int)

func (CreateModel) Update

func (m CreateModel) Update(msg tea.Msg) (CreateModel, *AppResult, tea.Cmd)

func (CreateModel) View

func (m CreateModel) View() string

type DeleteModel

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

DeleteModel is the Bubble Tea model for the Delete tab. Deletion requires pressing Enter 3 times on the same item within a 1-second window. Moving the cursor or letting the timer expire resets the count.

func (*DeleteModel) AddItem

func (m *DeleteModel) AddItem(conn model.Connection)

AddItem inserts a connection in ascending alphabetical position.

func (*DeleteModel) RemoveByName

func (m *DeleteModel) RemoveByName(name string)

RemoveByName removes the first item matching the given connection name.

func (*DeleteModel) SetSize

func (m *DeleteModel) SetSize(w, h int)

func (DeleteModel) Update

func (m DeleteModel) Update(msg tea.Msg) (DeleteModel, *AppResult, tea.Cmd)

func (DeleteModel) View

func (m DeleteModel) View() string

type EditModel

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

EditModel is the Bubble Tea model for the Edit tab. It has two modes: list mode (select a connection) and form mode (edit fields).

func (*EditModel) AddItem

func (m *EditModel) AddItem(conn model.Connection)

AddItem inserts a connection in ascending alphabetical position.

func (*EditModel) RemoveByName

func (m *EditModel) RemoveByName(name string)

RemoveByName removes the first item matching the given connection name.

func (*EditModel) SetSize

func (m *EditModel) SetSize(w, h int)

func (EditModel) Update

func (m EditModel) Update(msg tea.Msg) (EditModel, *AppResult, tea.Cmd)

func (EditModel) View

func (m EditModel) View() string

type FilterBox

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

FilterBox is a reusable search input rendered inside a bordered box.

func NewFilterBox

func NewFilterBox(width int, promptColor lipgloss.Color) FilterBox

func (*FilterBox) SetValue

func (f *FilterBox) SetValue(s string)

func (*FilterBox) SetWidth

func (f *FilterBox) SetWidth(w int)

func (FilterBox) Update

func (f FilterBox) Update(msg tea.Msg) (FilterBox, tea.Cmd)

func (FilterBox) Value

func (f FilterBox) Value() string

func (FilterBox) View

func (f FilterBox) View() string

type PassphraseModal

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

PassphraseModal is a Bubble Tea sub-model rendered as a centered overlay. It has two modes: "create" (first-time setup, two fields with confirmation) and "enter" (subsequent use, single field). When active, it captures all keyboard input, preventing interaction with the underlying tab.

func (*PassphraseModal) SetSize

func (m *PassphraseModal) SetSize(w, h int)

func (PassphraseModal) Update

func (PassphraseModal) View

func (m PassphraseModal) View() string

type PassphraseResult

type PassphraseResult struct {
	Passphrase string
	Cancelled  bool
}

PassphraseResult is returned when the user submits or cancels the modal.

type Tab

type Tab int

Tab identifies a tab in the TUI.

const (
	TabCreate Tab = iota
	TabConnect
	TabEdit
	TabDelete
)

type WizardResult

type WizardResult struct {
	Name         string
	User         string
	Host         string
	Port         string
	Directory    string
	AuthType     string // "key" or "password"
	IdentityFile string
	Password     string
}

WizardResult holds data collected from the new-connection form.

Jump to

Keyboard shortcuts

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