Skip to content

tui

import "github.com/ananth/codespace-zed/internal/tui"

Package tui provides interactive terminal UI components built on Bubbletea. It includes a filterable repository picker, a codespace selector with delete and back support, a work-label text input, and a generic spinner for long-running operations.

Index

func RunRepoSelection

func RunRepoSelection(repos []string, recentCount int) (string, error)

RunRepoSelection runs the repo selection TUI.

func RunWithSpinner

func RunWithSpinner(message string, task func() error) error

RunWithSpinner runs a task with a spinner, printing a success/failure line when done.

func RunWithSpinnerResult

func RunWithSpinnerResult[T any](message string, task func() (T, error)) (T, error)

RunWithSpinnerResult runs a task that returns a value, with a spinner.

func Status

func Status(icon, msg string)

Status prints a colored status line to stderr.

func StatusErr

func StatusErr(icon, msg string)

StatusErr prints a colored error status line to stderr.

type RepoModel

RepoModel is the Bubbletea model for repository selection. It supports filtering by typing — the list narrows as the user types, and if the filter matches no existing repo, a "use \<filter>" option appears.

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

func NewRepoModel

func NewRepoModel(repos []string, recentCount int) RepoModel

NewRepoModel creates a repo selection model.

func (RepoModel) Init

func (m RepoModel) Init() tea.Cmd

func (RepoModel) Result

func (m RepoModel) Result() RepoResult

Result returns the repo selection result.

func (RepoModel) Update

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

func (RepoModel) View

func (m RepoModel) View() string

type RepoResult

RepoResult holds the outcome of the repo selection TUI.

type RepoResult struct {
    Repo string
    Quit bool
}

type SelectModel

SelectModel is the Bubbletea model for codespace selection.

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

func NewSelectModel

func NewSelectModel(codespaces []codespace.Codespace, target config.Target, dryRun, allowBack bool) SelectModel

NewSelectModel creates a selection model. If allowBack is true, esc/backspace signals "go back" instead of quit.

func (SelectModel) Init

func (m SelectModel) Init() tea.Cmd

func (SelectModel) Result

func (m SelectModel) Result() SelectResult

Result returns the selection result after the program exits.

func (SelectModel) Update

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

func (SelectModel) View

func (m SelectModel) View() string

type SelectResult

SelectResult holds the outcome of the codespace selection TUI.

type SelectResult struct {
    Selected *codespace.Codespace // nil means "create new"
    Delete   *codespace.Codespace // non-nil means user wants to delete this codespace
    Quit     bool
    Back     bool // user wants to go back to repo selection
}

type SpinnerModel

SpinnerModel runs a background task with a spinner.

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

func NewSpinnerModel

func NewSpinnerModel(message string, task func() error) SpinnerModel

NewSpinnerModel creates a spinner that runs the given task in the background.

func (SpinnerModel) Init

func (m SpinnerModel) Init() tea.Cmd

func (SpinnerModel) Result

func (m SpinnerModel) Result() SpinnerResult

Result returns the spinner result.

func (SpinnerModel) Update

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

func (SpinnerModel) View

func (m SpinnerModel) View() string

type SpinnerResult

SpinnerResult holds the outcome of a spinner task.

type SpinnerResult struct {
    Err  error
    Quit bool
}

type WorkLabelModel

WorkLabelModel is the Bubbletea model for work label input.

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

func NewWorkLabelModel

func NewWorkLabelModel() WorkLabelModel

NewWorkLabelModel creates a work label input model.

func (WorkLabelModel) Init

func (m WorkLabelModel) Init() tea.Cmd

func (WorkLabelModel) Result

func (m WorkLabelModel) Result() WorkLabelResult

Result returns the work label result after the program exits.

func (WorkLabelModel) Update

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

func (WorkLabelModel) View

func (m WorkLabelModel) View() string

type WorkLabelResult

WorkLabelResult holds the outcome of the work label input TUI.

type WorkLabelResult struct {
    Label string
    Quit  bool
}

Generated by gomarkdoc