screen

package
v1.37.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package screen provides a unified screen management system for modal overlays.

Index

Constants

View Source
const (
	// TipCategoryNavigation groups navigation-focused tips.
	TipCategoryNavigation TipCategory = "navigation"
	// TipCategoryWorktree groups worktree-management tips.
	TipCategoryWorktree TipCategory = "worktree"
	// TipCategoryRepo groups repository-operation tips.
	TipCategoryRepo TipCategory = "repo"
	// TipCategoryTools groups tool-integration tips.
	TipCategoryTools TipCategory = "tools"
	// TipCategoryTips groups generic guidance tips.
	TipCategoryTips TipCategory = "tips"

	// TipOperationGeneral is used when no specific operation context is available.
	TipOperationGeneral TipOperation = "general"
	// TipOperationCreate is used during worktree creation flows.
	TipOperationCreate TipOperation = "create"
	// TipOperationRefresh is used during refresh operations.
	TipOperationRefresh TipOperation = "refresh"
	// TipOperationFetch is used during fetch operations.
	TipOperationFetch TipOperation = "fetch"
	// TipOperationSync is used during synchronisation operations.
	TipOperationSync TipOperation = "sync"
	// TipOperationPush is used during push operations.
	TipOperationPush TipOperation = "push"
	// TipOperationRerun is used during CI rerun operations.
	TipOperationRerun TipOperation = "rerun"
	// TipOperationCommand is used during command execution operations.
	TipOperationCommand TipOperation = "command"
)

Variables

View Source
var LoadingTips = []Tip{
	{ID: "help", Text: "Press '?' to open the help guide at any time.", Category: TipCategoryTips, Operations: []TipOperation{TipOperationGeneral}, Priority: 1, ShowInHelp: true},
	{ID: "search", Text: "Use '/' for incremental search in the focused pane.", Category: TipCategoryNavigation, Operations: []TipOperation{TipOperationGeneral, TipOperationRefresh}, Priority: 1, ShowInHelp: true},
	{ID: "filter", Text: "Press 'f' to filter the focused pane; press Esc to clear an active filter.", Category: TipCategoryNavigation, Operations: []TipOperation{TipOperationGeneral, TipOperationRefresh}, Priority: 1, ShowInHelp: true},
	{ID: "create", Text: "Press 'c' to create a worktree from a branch, PR/MR, issue, or custom flow.", Category: TipCategoryWorktree, Operations: []TipOperation{TipOperationGeneral, TipOperationCreate}, Priority: 2, ShowInHelp: true},
	{ID: "layout", Text: "Press 'L' to toggle between default and top pane layouts.", Category: TipCategoryNavigation, Operations: []TipOperation{TipOperationGeneral, TipOperationRefresh}, Priority: 1, ShowInHelp: true},
	{ID: "panes", Text: "Use '1', '2', '3', '[', ']', or Tab to move between panes quickly.", Category: TipCategoryNavigation, Operations: []TipOperation{TipOperationGeneral}, Priority: 1, ShowInHelp: true},
	{ID: "zoom", Text: "Press '=' to zoom the focused pane, then press '=' again to unzoom.", Category: TipCategoryNavigation, Operations: []TipOperation{TipOperationGeneral}, Priority: 1, ShowInHelp: false},
	{ID: "palette", Text: "Press ':' or Ctrl+P to open the Command Palette, including active tmux and zellij sessions.", Category: TipCategoryTools, Operations: []TipOperation{TipOperationGeneral, TipOperationCommand}, Priority: 1, ShowInHelp: true},
	{ID: "notes", Text: "Press 'i' to open worktree notes; existing notes open in the viewer first.", Category: TipCategoryWorktree, Operations: []TipOperation{TipOperationGeneral, TipOperationCreate}, Priority: 1, ShowInHelp: true},
	{ID: "taskboard", Text: "Press 'T' to open Taskboard and toggle markdown checkbox tasks across worktrees.", Category: TipCategoryWorktree, Operations: []TipOperation{TipOperationGeneral, TipOperationCreate}, Priority: 1, ShowInHelp: true},
	{ID: "sync", Text: "Use 'S' to synchronise with upstream (pull then push) when the worktree is clean.", Category: TipCategoryRepo, Operations: []TipOperation{TipOperationGeneral, TipOperationSync}, Priority: 2, ShowInHelp: true},
	{ID: "push", Text: "Use 'P' to push the current branch to its upstream; set upstream when prompted.", Category: TipCategoryRepo, Operations: []TipOperation{TipOperationGeneral, TipOperationPush}, Priority: 2, ShowInHelp: false},
	{ID: "fetch", Text: "Press 'R' to fetch all remotes and refresh upstream tracking information.", Category: TipCategoryRepo, Operations: []TipOperation{TipOperationGeneral, TipOperationFetch}, Priority: 2, ShowInHelp: false},
	{ID: "refresh", Text: "Press 'r' to refresh worktrees and, on GitHub/GitLab, refresh PR and CI data.", Category: TipCategoryRepo, Operations: []TipOperation{TipOperationGeneral, TipOperationRefresh}, Priority: 2, ShowInHelp: false},
	{ID: "ci", Text: "Press 'v' to open CI checks, Enter to open a job, and Ctrl+v to view logs in the pager.", Category: TipCategoryRepo, Operations: []TipOperation{TipOperationGeneral, TipOperationRefresh, TipOperationRerun}, Priority: 2, ShowInHelp: true},
	{ID: "status-jump", Text: "In the Status pane, use Ctrl+Left and Ctrl+Right to jump between folders.", Category: TipCategoryNavigation, Operations: []TipOperation{TipOperationGeneral, TipOperationRefresh}, Priority: 1, ShowInHelp: true},
	{ID: "run", Text: "Press '!' to run a command in the selected worktree with command history support.", Category: TipCategoryTools, Operations: []TipOperation{TipOperationGeneral, TipOperationCommand}, Priority: 1, ShowInHelp: false},
	{ID: "lazygit", Text: "Press 'g' to open LazyGit in the selected worktree.", Category: TipCategoryTools, Operations: []TipOperation{TipOperationGeneral}, Priority: 1, ShowInHelp: false},
	{ID: "jump", Text: "Press Enter on a worktree to jump there and change directory via shell integration.", Category: TipCategoryWorktree, Operations: []TipOperation{TipOperationGeneral, TipOperationCreate}, Priority: 1, ShowInHelp: false},
}

LoadingTips is the built-in catalogue of loading tips.

Functions

func CompressCommitFileTree

func CompressCommitFileTree(node *CommitFileTreeNode)

CompressCommitFileTree compresses single-child directory chains.

func DefaultSpinnerFrames

func DefaultSpinnerFrames() []string

DefaultSpinnerFrames returns the text-only spinner frames.

func HelpTips added in v1.37.1

func HelpTips() []string

HelpTips returns curated tips for the help screen.

func SetIconProvider

func SetIconProvider(provider iconProvider)

SetIconProvider sets the global icon provider.

func SetIconProviderFunc

func SetIconProviderFunc(fn DeviconFunc)

SetIconProviderFunc sets the function used to get file icons.

func SortCommitFileTree

func SortCommitFileTree(node *CommitFileTreeNode)

SortCommitFileTree sorts nodes: directories first, then files, alphabetically.

Types

type ChecklistItem

type ChecklistItem struct {
	ID          string
	Label       string
	Description string
	Checked     bool
}

ChecklistItem represents a single item with a checkbox state.

type ChecklistScreen

type ChecklistScreen struct {
	// Data fields
	Items    []ChecklistItem
	Filtered []ChecklistItem

	// UI state
	FilterInput  textinput.Model
	FilterActive bool
	Cursor       int
	ScrollOffset int
	Width        int
	Height       int
	Title        string
	Placeholder  string
	NoResults    string
	Thm          *theme.Theme

	// Callbacks
	OnSubmit func([]ChecklistItem) tea.Cmd
	OnCancel func() tea.Cmd
}

ChecklistScreen lets the user select multiple items from a list via checkboxes.

func NewChecklistScreen

func NewChecklistScreen(items []ChecklistItem, title, placeholder, noResults string, maxWidth, maxHeight int, thm *theme.Theme) *ChecklistScreen

NewChecklistScreen builds a checklist screen with 80% of screen size.

func (*ChecklistScreen) SelectedItems

func (s *ChecklistScreen) SelectedItems() []ChecklistItem

SelectedItems returns all checked items.

func (*ChecklistScreen) Type

func (s *ChecklistScreen) Type() Type

Type returns the screen type.

func (*ChecklistScreen) Update

func (s *ChecklistScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input for the checklist screen. Returns nil to signal the screen should close.

func (*ChecklistScreen) View

func (s *ChecklistScreen) View() string

View renders the checklist screen.

type CommandPaletteScreen

type CommandPaletteScreen struct {
	Items        []PaletteItem
	Filtered     []PaletteItem
	FilterInput  textinput.Model
	FilterActive bool
	Cursor       int
	ScrollOffset int
	Width        int
	Height       int
	Thm          *theme.Theme

	// Callbacks
	OnSelect func(actionID string) tea.Cmd
	OnCancel func() tea.Cmd
}

CommandPaletteScreen is the command picker modal.

func NewCommandPaletteScreen

func NewCommandPaletteScreen(items []PaletteItem, maxWidth, maxHeight int, thm *theme.Theme) *CommandPaletteScreen

NewCommandPaletteScreen builds a command palette screen.

func (*CommandPaletteScreen) Type

func (s *CommandPaletteScreen) Type() Type

Type returns the screen type identifier.

func (*CommandPaletteScreen) Update

func (s *CommandPaletteScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input for the command palette.

func (*CommandPaletteScreen) View

func (s *CommandPaletteScreen) View() string

View renders the command palette.

type CommitFileTreeNode

type CommitFileTreeNode struct {
	Path        string
	File        *models.CommitFile // nil for directories
	Children    []*CommitFileTreeNode
	Compression int // Number of compressed path segments
	Depth       int // Cached depth for rendering
}

CommitFileTreeNode represents a node in the commit file tree.

func BuildCommitFileTree

func BuildCommitFileTree(files []models.CommitFile) *CommitFileTreeNode

BuildCommitFileTree constructs a tree from a flat list of commit files.

func (*CommitFileTreeNode) IsDir

func (n *CommitFileTreeNode) IsDir() bool

IsDir returns true if this node is a directory.

type CommitFilesScreen

type CommitFilesScreen struct {
	CommitSHA     string
	WorktreePath  string
	Files         []models.CommitFile
	AllFiles      []models.CommitFile // Original unfiltered files
	Tree          *CommitFileTreeNode
	TreeFlat      []*CommitFileTreeNode
	CollapsedDirs map[string]bool
	Cursor        int
	ScrollOffset  int
	Width         int
	Height        int
	Thm           *theme.Theme
	ShowIcons     bool

	// Commit metadata
	Meta CommitMeta

	// Filter/search support
	FilterInput   textinput.Model
	ShowingFilter bool
	FilterQuery   string
	ShowingSearch bool
	SearchQuery   string

	// Callbacks
	OnShowFileDiff   func(filename string) tea.Cmd
	OnShowCommitDiff func() tea.Cmd
	OnClose          func() tea.Cmd
}

CommitFilesScreen displays files changed in a commit as a collapsible tree. Note: Uses CommitMeta from commit.go for metadata display.

func NewCommitFilesScreen

func NewCommitFilesScreen(sha, wtPath string, files []models.CommitFile, meta CommitMeta, maxWidth, maxHeight int, thm *theme.Theme, showIcons bool) *CommitFilesScreen

NewCommitFilesScreen creates a commit files tree screen.

func (*CommitFilesScreen) ApplyFilter

func (s *CommitFilesScreen) ApplyFilter()

ApplyFilter filters the files list and rebuilds the tree.

func (*CommitFilesScreen) GetSelectedNode

func (s *CommitFilesScreen) GetSelectedNode() *CommitFileTreeNode

GetSelectedNode returns the currently selected node.

func (*CommitFilesScreen) RebuildFlat

func (s *CommitFilesScreen) RebuildFlat()

RebuildFlat rebuilds the flat list from the tree respecting collapsed state.

func (*CommitFilesScreen) SearchNext

func (s *CommitFilesScreen) SearchNext(forward bool)

SearchNext finds the next match for the search query.

func (*CommitFilesScreen) SetTheme

func (s *CommitFilesScreen) SetTheme(thm *theme.Theme)

SetTheme updates the screen's theme.

func (*CommitFilesScreen) ToggleCollapse

func (s *CommitFilesScreen) ToggleCollapse(path string)

ToggleCollapse toggles the collapse state of a directory.

func (*CommitFilesScreen) Type

func (s *CommitFilesScreen) Type() Type

Type returns TypeCommitFiles to identify this screen.

func (*CommitFilesScreen) Update

func (s *CommitFilesScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles key events for the commit files screen.

func (*CommitFilesScreen) View

func (s *CommitFilesScreen) View() string

View renders the commit files screen.

type CommitMeta

type CommitMeta struct {
	SHA     string
	Author  string
	Email   string
	Date    string
	Subject string
	Body    []string
}

CommitMeta holds metadata for a commit.

type CommitScreen

type CommitScreen struct {
	Meta     CommitMeta
	Stat     string
	Diff     string
	UseDelta bool
	Viewport viewport.Model
	Thm      *theme.Theme
}

CommitScreen displays metadata, stats, and diff details for a single commit.

func NewCommitScreen

func NewCommitScreen(meta CommitMeta, stat, diff string, useDelta bool, thm *theme.Theme) *CommitScreen

NewCommitScreen configures the commit detail viewer for the selected SHA.

func (*CommitScreen) SetTheme

func (s *CommitScreen) SetTheme(thm *theme.Theme)

SetTheme updates the theme for this screen.

func (*CommitScreen) Type

func (s *CommitScreen) Type() Type

Type returns the screen type.

func (*CommitScreen) Update

func (s *CommitScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles scrolling and closing events for the commit screen. Returns nil to signal that the screen should be closed.

func (*CommitScreen) View

func (s *CommitScreen) View() string

View renders the commit screen.

type ConfirmScreen

type ConfirmScreen struct {
	Message        string
	SelectedButton int // 0 = Confirm, 1 = Cancel
	Thm            *theme.Theme

	// Callbacks
	OnConfirm func() tea.Cmd
	OnCancel  func() tea.Cmd
}

ConfirmScreen displays a modal confirmation prompt with Accept/Cancel buttons.

func NewConfirmScreen

func NewConfirmScreen(message string, thm *theme.Theme) *ConfirmScreen

NewConfirmScreen creates a confirm screen preloaded with a message.

func NewConfirmScreenWithDefault

func NewConfirmScreenWithDefault(message string, defaultButton int, thm *theme.Theme) *ConfirmScreen

NewConfirmScreenWithDefault creates a confirmation modal with a specified default button.

func (*ConfirmScreen) SetTheme

func (s *ConfirmScreen) SetTheme(thm *theme.Theme)

SetTheme updates the theme for this screen.

func (*ConfirmScreen) Type

func (s *ConfirmScreen) Type() Type

Type returns the screen type.

func (*ConfirmScreen) Update

func (s *ConfirmScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update processes keyboard events for the confirmation dialog. Returns nil to signal that the screen should be closed.

func (*ConfirmScreen) View

func (s *ConfirmScreen) View() string

View renders the confirmation UI box with focused button highlighting.

type DeviconFunc

type DeviconFunc func(name string, isDir bool) string

DeviconFunc is a function type for getting file icons.

var IconProviderFunc DeviconFunc

IconProviderFunc allows injecting the devicon lookup function.

type HelpScreen

type HelpScreen struct {
	Viewport    viewport.Model
	Width       int
	Height      int
	FullText    []string
	SearchInput textinput.Model
	Searching   bool
	SearchQuery string
	Thm         *theme.Theme
	ShowIcons   bool
}

HelpScreen renders searchable documentation for the app controls.

func NewHelpScreen

func NewHelpScreen(maxWidth, maxHeight int, customCommands map[string]*config.CustomCommand, thm *theme.Theme, showIcons bool) *HelpScreen

NewHelpScreen initializes help content with the available screen size.

func (*HelpScreen) SetSize

func (s *HelpScreen) SetSize(maxWidth, maxHeight int)

SetSize updates the help screen dimensions (useful on terminal resize).

func (*HelpScreen) Type

func (s *HelpScreen) Type() Type

Type returns TypeHelp to identify this screen.

func (*HelpScreen) Update

func (s *HelpScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles scrolling and search input for the help screen.

func (*HelpScreen) View

func (s *HelpScreen) View() string

View renders the help content and search input inside the viewport.

type InfoScreen

type InfoScreen struct {
	Message string
	Thm     *theme.Theme

	// Callback
	OnClose func() tea.Cmd
}

InfoScreen displays a modal message with an OK button.

func NewInfoScreen

func NewInfoScreen(message string, thm *theme.Theme) *InfoScreen

NewInfoScreen creates an informational modal with an OK button.

func (*InfoScreen) SetTheme

func (s *InfoScreen) SetTheme(thm *theme.Theme)

SetTheme updates the theme for this screen.

func (*InfoScreen) Type

func (s *InfoScreen) Type() Type

Type returns the screen type.

func (*InfoScreen) Update

func (s *InfoScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update processes keyboard events for the info dialog. Returns nil to signal that the screen should be closed.

func (*InfoScreen) View

func (s *InfoScreen) View() string

View renders the informational UI box with a single OK button.

type InputScreen

type InputScreen struct {
	// Core fields
	Prompt      string
	Placeholder string
	Value       string
	Input       textinput.Model
	ErrorMsg    string
	Thm         *theme.Theme
	ShowIcons   bool

	// Validation
	Validate func(string) string

	// Callbacks
	OnSubmit         func(value string, checked bool) tea.Cmd
	OnCancel         func() tea.Cmd
	OnCheckboxToggle func(checked bool) tea.Cmd

	// Checkbox support
	CheckboxEnabled bool
	CheckboxChecked bool
	CheckboxFocused bool
	CheckboxLabel   string

	// History navigation (bash-style up/down)
	History       []string
	HistoryIndex  int    // -1 = not browsing
	OriginalInput string // Store original input when browsing history
	// contains filtered or unexported fields
}

InputScreen displays a modal input prompt with optional validation, history navigation, and checkbox support.

func NewInputScreen

func NewInputScreen(prompt, placeholder, value string, thm *theme.Theme, showIcons bool) *InputScreen

NewInputScreen creates an input screen with the given parameters.

func (*InputScreen) SetCheckbox

func (s *InputScreen) SetCheckbox(label string, defaultChecked bool)

SetCheckbox enables a checkbox with the given label and default state.

func (*InputScreen) SetHistory

func (s *InputScreen) SetHistory(history []string)

SetHistory enables bash-style history navigation with up/down arrows.

func (*InputScreen) SetValidation

func (s *InputScreen) SetValidation(fn func(string) string)

SetValidation sets a validation function that returns an error message.

func (*InputScreen) Type

func (s *InputScreen) Type() Type

Type returns the screen type.

func (*InputScreen) Update

func (s *InputScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input for the input screen. Returns nil to signal the screen should be closed.

func (*InputScreen) View

func (s *InputScreen) View() string

View renders the input screen.

type IssueSelectionScreen

type IssueSelectionScreen struct {
	Issues       []*models.IssueInfo
	Filtered     []*models.IssueInfo
	FilterInput  textinput.Model
	FilterActive bool
	Cursor       int
	ScrollOffset int
	Width        int
	Height       int
	Thm          *theme.Theme
	ShowIcons    bool

	OnSelect func(*models.IssueInfo) tea.Cmd
	OnCancel func() tea.Cmd
}

IssueSelectionScreen lets the user pick an issue from a filtered list.

func NewIssueSelectionScreen

func NewIssueSelectionScreen(issues []*models.IssueInfo, maxWidth, maxHeight int, thm *theme.Theme, showIcons bool) *IssueSelectionScreen

NewIssueSelectionScreen builds an issue selection screen with 80% of screen size.

func (*IssueSelectionScreen) Selected

func (s *IssueSelectionScreen) Selected() (*models.IssueInfo, bool)

Selected returns the currently selected issue, if any.

func (*IssueSelectionScreen) Type

func (s *IssueSelectionScreen) Type() Type

Type returns the screen type.

func (*IssueSelectionScreen) Update

func (s *IssueSelectionScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input and returns nil to signal the screen should close.

func (*IssueSelectionScreen) View

func (s *IssueSelectionScreen) View() string

View renders the issue selection screen.

type ListSelectionScreen

type ListSelectionScreen struct {
	// Data fields
	Items    []SelectionItem
	Filtered []SelectionItem

	// UI state
	FilterInput  textinput.Model
	FilterActive bool
	Cursor       int
	ScrollOffset int
	Width        int
	Height       int
	Title        string
	Placeholder  string
	NoResults    string
	Thm          *theme.Theme

	// Callbacks
	OnSelect       func(SelectionItem) tea.Cmd
	OnCancel       func() tea.Cmd
	OnCursorChange func(SelectionItem) // For live preview

	// Special key handlers (for CI checks)
	OnCtrlV func(SelectionItem) tea.Cmd // Ctrl+V handler (e.g., view logs)
	OnCtrlR func(SelectionItem) tea.Cmd // Ctrl+R handler (e.g., restart)
	OnEnter func(SelectionItem) tea.Cmd // Enter handler (overrides OnSelect if set)

	// Optional additional hint for footer (e.g., "Ctrl+r to restart")
	FooterHint string
}

ListSelectionScreen lets the user pick from a list of options.

func NewListSelectionScreen

func NewListSelectionScreen(items []SelectionItem, title, placeholder, noResults string, maxWidth, maxHeight int, initialID string, thm *theme.Theme) *ListSelectionScreen

NewListSelectionScreen builds a list selection screen with 80% of screen size.

func (*ListSelectionScreen) Selected

func (s *ListSelectionScreen) Selected() (SelectionItem, bool)

Selected returns the currently selected item, if any.

func (*ListSelectionScreen) Type

func (s *ListSelectionScreen) Type() Type

Type returns the screen type.

func (*ListSelectionScreen) Update

func (s *ListSelectionScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input and returns nil to signal the screen should close.

func (*ListSelectionScreen) View

func (s *ListSelectionScreen) View() string

View renders the list selection screen.

type LoadingScreen

type LoadingScreen struct {
	Message        string
	FrameIdx       int
	BorderColorIdx int
	Tip            string
	TipID          string
	Operation      TipOperation
	Thm            *theme.Theme
	SpinnerFrames  []string
	ShowIcons      bool
}

LoadingScreen displays a modal with a spinner and a contextual tip.

func NewLoadingScreen

func NewLoadingScreen(message string, operation TipOperation, thm *theme.Theme, spinnerFrames []string, showIcons bool) *LoadingScreen

NewLoadingScreen creates a loading modal with the given message. spinnerFrames should be provided by the caller; if nil, text fallback is used.

func (*LoadingScreen) LoadingBorderColours

func (s *LoadingScreen) LoadingBorderColours() []lipgloss.Color

LoadingBorderColours exposes the border colours for tests.

func (*LoadingScreen) SetSpinnerFrames

func (s *LoadingScreen) SetSpinnerFrames(frames []string)

SetSpinnerFrames updates the spinner frames.

func (*LoadingScreen) SetTheme

func (s *LoadingScreen) SetTheme(thm *theme.Theme)

SetTheme updates the theme for this screen.

func (*LoadingScreen) Tick

func (s *LoadingScreen) Tick()

Tick advances the loading animation (spinner frame and border colour).

func (*LoadingScreen) Type

func (s *LoadingScreen) Type() Type

Type returns the screen type.

func (*LoadingScreen) Update

func (s *LoadingScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles key events. Loading screen does not respond to keys.

func (*LoadingScreen) View

func (s *LoadingScreen) View() string

View renders the loading modal with spinner, message, and a contextual tip.

type Manager

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

Manager handles screen state and provides a stack-based interface for modal overlays.

func NewManager

func NewManager() *Manager

NewManager creates a new screen manager.

func (*Manager) Clear

func (m *Manager) Clear()

Clear removes all screens from the stack.

func (*Manager) Current

func (m *Manager) Current() Screen

Current returns the currently active screen, or nil if none.

func (*Manager) IsActive

func (m *Manager) IsActive() bool

IsActive returns true if there is a screen currently displayed.

func (*Manager) Pop

func (m *Manager) Pop() Screen

Pop removes the current screen and restores the previous one. Returns the screen that was removed, or nil if no screen was active.

func (*Manager) Push

func (m *Manager) Push(s Screen)

Push adds a screen to the stack and sets it as the current screen.

func (*Manager) Set

func (m *Manager) Set(s Screen)

Set replaces the current screen without affecting the stack. This is useful for replacing the current screen without pushing/popping.

func (*Manager) StackDepth

func (m *Manager) StackDepth() int

StackDepth returns the number of screens in the stack (excluding current).

func (*Manager) Type

func (m *Manager) Type() Type

Type returns the type of the current screen, or TypeNone if no screen is active.

type NoteViewScreen added in v1.37.0

type NoteViewScreen struct {
	Title    string
	Content  string
	Viewport viewport.Model
	Width    int
	Height   int
	Thm      *theme.Theme

	OnEdit         func() tea.Cmd
	OnEditExternal func() tea.Cmd
	OnClose        func() tea.Cmd
}

NoteViewScreen displays rendered worktree notes in a pager-like modal.

func NewNoteViewScreen added in v1.37.0

func NewNoteViewScreen(title, content string, maxWidth, maxHeight int, thm *theme.Theme) *NoteViewScreen

NewNoteViewScreen creates a scrollable notes viewer modal.

func (*NoteViewScreen) Resize added in v1.37.0

func (s *NoteViewScreen) Resize(maxWidth, maxHeight int)

Resize updates modal and viewport dimensions based on terminal size.

func (*NoteViewScreen) SetTheme added in v1.37.0

func (s *NoteViewScreen) SetTheme(thm *theme.Theme)

SetTheme updates the screen theme.

func (*NoteViewScreen) Type added in v1.37.0

func (s *NoteViewScreen) Type() Type

Type returns the screen type.

func (*NoteViewScreen) Update added in v1.37.0

func (s *NoteViewScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles navigation, close, and edit actions.

func (*NoteViewScreen) View added in v1.37.0

func (s *NoteViewScreen) View() string

View renders the notes viewer modal.

type PRSelectionScreen

type PRSelectionScreen struct {
	// Data fields
	PRs      []*models.PRInfo
	Filtered []*models.PRInfo

	// UI state
	FilterInput  textinput.Model
	FilterActive bool
	Cursor       int
	ScrollOffset int
	Width        int
	Height       int
	Thm          *theme.Theme
	ShowIcons    bool

	// AttachedBranches maps branch names to worktree names for branches already checked out
	AttachedBranches map[string]string

	// StatusMessage shows temporary feedback (e.g., when trying to select attached PR)
	StatusMessage string

	// Callbacks
	OnSelect func(*models.PRInfo) tea.Cmd
	OnCancel func() tea.Cmd
}

PRSelectionScreen lets the user pick a PR from a filtered list.

func NewPRSelectionScreen

func NewPRSelectionScreen(prs []*models.PRInfo, maxWidth, maxHeight int, thm *theme.Theme, showIcons bool) *PRSelectionScreen

NewPRSelectionScreen builds a PR selection screen with 80% of screen size.

func (*PRSelectionScreen) Selected

func (s *PRSelectionScreen) Selected() (*models.PRInfo, bool)

Selected returns the currently selected PR, if any.

func (*PRSelectionScreen) Type

func (s *PRSelectionScreen) Type() Type

Type returns the screen type.

func (*PRSelectionScreen) Update

func (s *PRSelectionScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles updates for the PR selection screen. Returns nil to signal the screen should close.

func (*PRSelectionScreen) View

func (s *PRSelectionScreen) View() string

View renders the PR selection screen.

type PaletteItem

type PaletteItem struct {
	ID          string
	Label       string
	Description string
	IsSection   bool   // Non-selectable section headers
	IsMRU       bool   // Recently used items
	Shortcut    string // Keyboard shortcut display (e.g., "g")
	Icon        string // Category icon (Nerd Font)
}

PaletteItem represents a command in the palette.

type Screen

type Screen interface {
	// Update processes a key message and returns the updated screen and any command.
	// Returning nil for the Screen signals that this screen should be closed.
	Update(msg tea.KeyMsg) (Screen, tea.Cmd)

	// View renders the screen's content.
	View() string

	// Type returns the screen's type identifier.
	Type() Type
}

Screen represents a modal screen overlay that can handle input and render itself.

type SelectionItem

type SelectionItem struct {
	ID          string
	Label       string
	Description string
}

SelectionItem represents a single item in a list selection.

type TaskboardItem added in v1.37.0

type TaskboardItem struct {
	ID           string
	WorktreePath string
	WorktreeName string
	Text         string
	Checked      bool

	IsSection    bool
	SectionLabel string
	OpenCount    int
	DoneCount    int
	TotalCount   int
}

TaskboardItem represents a task row or a section header in the taskboard.

type TaskboardScreen added in v1.37.0

type TaskboardScreen struct {
	Items    []TaskboardItem
	Filtered []TaskboardItem

	FilterInput  textinput.Model
	FilterActive bool
	Cursor       int
	ScrollOffset int
	Width        int
	Height       int
	Title        string
	NoResults    string
	Thm          *theme.Theme

	OnToggle func(itemID string) tea.Cmd
	OnClose  func() tea.Cmd
	OnAdd    func(worktreePath string) tea.Cmd

	DefaultWorktreePath string
}

TaskboardScreen displays worktree tasks grouped by worktree.

func NewTaskboardScreen added in v1.37.0

func NewTaskboardScreen(items []TaskboardItem, title string, maxWidth, maxHeight int, thm *theme.Theme) *TaskboardScreen

NewTaskboardScreen creates a grouped taskboard modal.

func (*TaskboardScreen) Resize added in v1.37.0

func (s *TaskboardScreen) Resize(maxWidth, maxHeight int)

Resize updates modal dimensions from terminal size.

func (*TaskboardScreen) SetItems added in v1.37.0

func (s *TaskboardScreen) SetItems(items []TaskboardItem, preferredID string)

SetItems replaces taskboard items and keeps filter/query state.

func (*TaskboardScreen) Type added in v1.37.0

func (s *TaskboardScreen) Type() Type

Type returns the screen type.

func (*TaskboardScreen) Update added in v1.37.0

func (s *TaskboardScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input.

func (*TaskboardScreen) View added in v1.37.0

func (s *TaskboardScreen) View() string

View renders the taskboard modal.

type TextareaScreen added in v1.35.0

type TextareaScreen struct {
	Prompt      string
	Placeholder string
	Input       textarea.Model
	ErrorMsg    string
	Thm         *theme.Theme
	ShowIcons   bool

	// Validation
	Validate func(string) string

	// Callbacks
	OnSubmit func(value string) tea.Cmd
	OnCancel func() tea.Cmd
	// contains filtered or unexported fields
}

TextareaScreen displays a modal multiline input.

func NewTextareaScreen added in v1.35.0

func NewTextareaScreen(prompt, placeholder, value string, maxWidth, maxHeight int, thm *theme.Theme, showIcons bool) *TextareaScreen

NewTextareaScreen creates a multiline input modal sized relative to the terminal.

func (*TextareaScreen) SetValidation added in v1.35.0

func (s *TextareaScreen) SetValidation(fn func(string) string)

SetValidation sets a validation function that returns an error message.

func (*TextareaScreen) Type added in v1.35.0

func (s *TextareaScreen) Type() Type

Type returns the screen type.

func (*TextareaScreen) Update added in v1.35.0

func (s *TextareaScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles keyboard input for the textarea screen. Returns nil to signal the screen should be closed.

func (*TextareaScreen) View added in v1.35.0

func (s *TextareaScreen) View() string

View renders the multiline input screen.

type Tip added in v1.37.1

type Tip struct {
	ID         string
	Text       string
	Category   TipCategory
	Operations []TipOperation
	Priority   int
	ShowInHelp bool
}

Tip defines a single loading tip.

func SelectLoadingTip added in v1.37.1

func SelectLoadingTip(operation TipOperation, previousTipID string) Tip

SelectLoadingTip selects a contextual tip and avoids immediate repeats when possible.

type TipCategory added in v1.37.1

type TipCategory string

TipCategory classifies loading tips by area of functionality.

type TipOperation added in v1.37.1

type TipOperation string

TipOperation identifies the operation currently running.

func TipOperationFromContext added in v1.37.1

func TipOperationFromContext(loadingOperation, message string) TipOperation

TipOperationFromContext maps app loading context to a tip operation.

type TrustScreen

type TrustScreen struct {
	FilePath string
	Commands []string
	Viewport viewport.Model
	Thm      *theme.Theme

	// Callbacks
	OnTrust  func() tea.Cmd // Called when user trusts the commands
	OnBlock  func() tea.Cmd // Called when user blocks/skips the commands
	OnCancel func() tea.Cmd // Called when user cancels the operation
}

TrustScreen surfaces trust warnings and records commands for a path.

func NewTrustScreen

func NewTrustScreen(filePath string, commands []string, thm *theme.Theme) *TrustScreen

NewTrustScreen warns the user when a repo config has changed or is untrusted.

func (*TrustScreen) SetTheme

func (s *TrustScreen) SetTheme(thm *theme.Theme)

SetTheme updates the theme for this screen.

func (*TrustScreen) Type

func (s *TrustScreen) Type() Type

Type returns the screen type.

func (*TrustScreen) Update

func (s *TrustScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update handles trust decisions and delegates viewport input updates. Returns nil to signal that the screen should be closed.

func (*TrustScreen) View

func (s *TrustScreen) View() string

View renders the trust warning content inside a styled box.

type Type

type Type int

Type identifies the kind of screen being displayed.

const (
	TypeNone Type = iota
	TypeConfirm
	TypeInfo
	TypeInput
	TypeTextarea
	TypeNoteView
	TypeHelp
	TypeTrust
	TypeWelcome
	TypeCommit
	TypePalette
	TypeDiff
	TypePRSelect
	TypeIssueSelect
	TypeListSelect
	TypeLoading
	TypeCommitFiles
	TypeChecklist
	TypeTaskboard
)

Screen type constants.

func (Type) String

func (t Type) String() string

String returns a human-readable name for the screen type.

type UIIcon

type UIIcon int

UIIcon identifies UI-specific icons.

const (
	UIIconHelpTitle UIIcon = iota
	UIIconNavigation
	UIIconStatusPane
	UIIconLogPane
	UIIconCommitTree
	UIIconWorktreeActions
	UIIconBranchNaming
	UIIconViewingTools
	UIIconRepoOps
	UIIconBackgroundRefresh
	UIIconFilterSearch
	UIIconStatusIndicators
	UIIconStatusClean
	UIIconStatusDirty
	UIIconHelpNavigation
	UIIconShellCompletion
	UIIconConfiguration
	UIIconIconConfiguration
	UIIconTip
	UIIconPRSelect
	UIIconIssueSelect
	UIIconCICheck
	UIIconListSelect
)

UIIcon constants.

type WelcomeScreen

type WelcomeScreen struct {
	CurrentDir  string
	WorktreeDir string
	Thm         *theme.Theme

	// Callbacks
	OnRefresh func() tea.Cmd // Called when user presses 'r' to refresh
	OnQuit    func() tea.Cmd // Called when user wants to quit
}

WelcomeScreen shows the initial instructions when no worktrees are open.

func NewWelcomeScreen

func NewWelcomeScreen(currentDir, worktreeDir string, thm *theme.Theme) *WelcomeScreen

NewWelcomeScreen builds the greeting screen shown when no worktrees exist.

func (*WelcomeScreen) SetTheme

func (s *WelcomeScreen) SetTheme(thm *theme.Theme)

SetTheme updates the theme for this screen.

func (*WelcomeScreen) Type

func (s *WelcomeScreen) Type() Type

Type returns the screen type.

func (*WelcomeScreen) Update

func (s *WelcomeScreen) Update(msg tea.KeyMsg) (Screen, tea.Cmd)

Update processes keyboard events for the welcome screen. Returns nil to signal that the screen should be closed.

func (*WelcomeScreen) View

func (s *WelcomeScreen) View() string

View renders the welcome dialog with guidance and action buttons.

Jump to

Keyboard shortcuts

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