Help us shape the future of Go! Take the 2026 Go Developer Survey

tui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilters added in v0.3.0

func ApplyFilters(all []*models.Worktree, f FilterState) []*models.Worktree

ApplyFilters returns a new slice containing only the worktrees from all that match the active boolean filters in f. Query is ignored (reserved for Feature 2's fuzzy ranking). Empty filter (all toggles false) returns all unchanged.

func RankBySearch added in v0.3.0

func RankBySearch(items []*models.Worktree, query string) []*models.Worktree

RankBySearch applies a fuzzy search query to a list of worktrees, returning only matching entries sorted by match score (descending). Uses the same searchable string as WorktreeItem.FilterValue() (branch+name+path). An empty query returns items unchanged with no ranking cost (early return).

Types

type FilterState added in v0.3.0

type FilterState struct {
	Query        string
	DirtyOnly    bool
	LockedOnly   bool
	PrunableOnly bool
	DetachedOnly bool
	DivergedOnly bool // currently unused: no ahead/behind data available yet
}

FilterState holds the active filter toggles and search query. All boolean filters are combined with AND semantics - a worktree must match all enabled filters to appear in the list. Query is used for fuzzy-search ranking (applied after boolean filters in resortWorktrees) and is ignored by ApplyFilters itself.

func (FilterState) ActiveFilters added in v0.3.0

func (f FilterState) ActiveFilters() []string

ActiveFilters returns a slice of the names of enabled toggles, in order. Used by the status line/help to show which filters are active.

type Model

type Model struct {

	// PrintPath is set when the user presses 'n' on a worktree; main.go
	// checks this once the program exits and prints it to stdout for a
	// shell wrapper function to cd into.
	PrintPath string
	// contains filtered or unexported fields
}

Model is treebrush's top-level Bubble Tea model. All three modes (repo scan/picker, worktree list, delete-confirm dialog) live in one Model so Update can transition between them without re-plumbing shared state (the current repo, terminal size) through separate program instances. Each mode's own fields are grouped into scan/worktree/confirm so only the active mode's state needs attention at a time.

func NewForRepo

func NewForRepo(dir string, gitClient *git.Client, persister state.Persister) (Model, error)

NewForRepo builds a Model already scoped to the repo containing dir, ready to load its worktrees on Init. gitClient runs git commands and persister loads/saves the sort choice - both injected so callers (and tests) can substitute fakes instead of a real git binary and disk.

func NewScanning

func NewScanning(root string, matcher *config.ExcludeMatcher, gitClient *git.Client, persister state.Persister) Model

NewScanning builds a Model that recursively scans root for git repositories (see internal/scan), streaming discoveries into a picker. gitClient and persister are carried along so enterRepo can hand them to the worktree mode it transitions into.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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