tui

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tui provides the terminal user interface for GitHubby

Index

Constants

View Source
const (
	// ExitConfirmTimeout is the duration before exit confirmation expires
	ExitConfirmTimeout = 2 * time.Second
	// MessageDisplayDuration is how long temporary messages are shown
	MessageDisplayDuration = 3 * time.Second
)

Variables

View Source
var (
	// Primary colors
	ColorPrimary   = lipgloss.AdaptiveColor{Light: "#7C3AED", Dark: "#A78BFA"} // Purple
	ColorSecondary = lipgloss.AdaptiveColor{Light: "#059669", Dark: "#34D399"} // Green
	ColorAccent    = lipgloss.AdaptiveColor{Light: "#0284C7", Dark: "#38BDF8"} // Blue

	// Status colors
	ColorSuccess = lipgloss.AdaptiveColor{Light: "#16A34A", Dark: "#4ADE80"}
	ColorWarning = lipgloss.AdaptiveColor{Light: "#CA8A04", Dark: "#FACC15"}
	ColorError   = lipgloss.AdaptiveColor{Light: "#DC2626", Dark: "#F87171"}
	ColorInfo    = lipgloss.AdaptiveColor{Light: "#0284C7", Dark: "#38BDF8"}

	// Neutral colors
	ColorMuted    = lipgloss.AdaptiveColor{Light: "#6B7280", Dark: "#9CA3AF"}
	ColorSubtle   = lipgloss.AdaptiveColor{Light: "#9CA3AF", Dark: "#6B7280"}
	ColorBorder   = lipgloss.AdaptiveColor{Light: "#E5E7EB", Dark: "#374151"}
	ColorSelected = lipgloss.AdaptiveColor{Light: "#F3F4F6", Dark: "#1F2937"}
)

Color palette

Functions

func ChangeScreen

func ChangeScreen(screen Screen) tea.Cmd

ChangeScreen returns a command to change to a screen

func ClearMessageCmd

func ClearMessageCmd(delay time.Duration) tea.Cmd

ClearMessageCmd returns a command to clear message after delay

func ErrorCmd

func ErrorCmd(err error) tea.Cmd

ErrorCmd returns a command to set an error

func ExitTimeoutCmd

func ExitTimeoutCmd(timeout time.Duration) tea.Cmd

ExitTimeoutCmd returns a command for exit confirmation timeout

func PopScreenCmd

func PopScreenCmd() tea.Cmd

PopScreenCmd returns a command to pop the screen stack

func PrintNonInteractiveHelp

func PrintNonInteractiveHelp()

PrintNonInteractiveHelp prints help when not in an interactive terminal

func PushScreenCmd

func PushScreenCmd(screen Screen) tea.Cmd

PushScreenCmd returns a command to push a screen

func QuitCmd

func QuitCmd() tea.Cmd

QuitCmd returns a command to quit the app

func RefreshDashboardCmd

func RefreshDashboardCmd() tea.Cmd

RefreshDashboardCmd returns a command to refresh dashboard

func Run

func Run(ctx context.Context, startScreen Screen, isAuthenticated bool, username string) error

Run starts the TUI application (legacy)

func RunApp

func RunApp(ctx context.Context, opts ...AppOption) error

RunApp starts the unified TUI application (creates new App instance)

func RunAppInstance

func RunAppInstance(ctx context.Context, app *App) error

RunAppInstance runs an existing App instance

func RunDashboard

func RunDashboard(ctx context.Context, username string) error

RunDashboard starts the TUI in dashboard mode (legacy)

func RunOnboarding

func RunOnboarding(ctx context.Context) error

RunOnboarding starts the TUI in onboarding mode (legacy)

Types

type App

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

App is the main TUI application model

func NewApp

func NewApp(opts ...AppOption) *App

NewApp creates a new TUI application

func (*App) Context

func (a *App) Context() context.Context

Context returns the app context

func (*App) DeleteProfileInfo

func (a *App) DeleteProfileInfo() (string, string)

DeleteProfileInfo returns the profile ID and name for deletion confirmation

func (*App) GitHubClient

func (a *App) GitHubClient() github.Client

GitHubClient returns the GitHub client

func (*App) Height

func (a *App) Height() int

Height returns the terminal height

func (*App) Init

func (a *App) Init() tea.Cmd

Init initializes the app

func (*App) IsAuthenticated

func (a *App) IsAuthenticated() bool

IsAuthenticated returns whether the user is authenticated

func (*App) PopScreen

func (a *App) PopScreen() tea.Cmd

PopScreen returns to the previous screen

func (*App) ProfilesToSync

func (a *App) ProfilesToSync() []*state.SyncProfile

ProfilesToSync returns the list of profiles to sync (for batch sync)

func (*App) PushScreen

func (a *App) PushScreen(screen Screen) tea.Cmd

PushScreen pushes current screen to stack and sets new screen

func (*App) RegisterScreen

func (a *App) RegisterScreen(screen Screen, model ScreenModel)

RegisterScreen registers a pre-created screen model

func (*App) RegisterScreenFactory

func (a *App) RegisterScreenFactory(screen Screen, factory ScreenFactory)

RegisterScreenFactory registers a factory function for lazy screen creation

func (*App) ResetToScreen

func (a *App) ResetToScreen(screen Screen) tea.Cmd

ResetToScreen clears the stack and sets a new screen

func (*App) SelectedProfile

func (a *App) SelectedProfile() *state.SyncProfile

SelectedProfile returns the currently selected profile for quick sync

func (*App) SetProfilesToSync

func (a *App) SetProfilesToSync(profiles []*state.SyncProfile)

SetProfilesToSync sets the list of profiles for batch sync

func (*App) SetScreen

func (a *App) SetScreen(screen Screen) tea.Cmd

SetScreen changes the current screen

func (*App) SetSelectedProfile

func (a *App) SetSelectedProfile(profile *state.SyncProfile)

SetSelectedProfile sets the selected profile for quick sync

func (*App) Storage

func (a *App) Storage() *state.Storage

Storage returns the state storage

func (*App) Styles

func (a *App) Styles() *Styles

Styles returns the app styles

func (*App) Token

func (a *App) Token() string

Token returns the authentication token

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*App) Username

func (a *App) Username() string

Username returns the authenticated username

func (*App) View

func (a *App) View() string

View renders the app

func (*App) Width

func (a *App) Width() int

Width returns the terminal width

type AppOption

type AppOption func(*App)

AppOption configures the App

func WithAuth

func WithAuth(authenticated bool, username, token string) AppOption

WithAuth sets the authentication state

func WithContext

func WithContext(ctx context.Context) AppOption

WithContext sets the context for the App

func WithGitHubClient

func WithGitHubClient(client github.Client) AppOption

WithGitHubClient sets the GitHub client

func WithStorage

func WithStorage(storage *state.Storage) AppOption

WithStorage sets the state storage

func WithVersion

func WithVersion(version, commit, buildDate string) AppOption

WithVersion sets the app version info for display

type AuthCompleteMsg

type AuthCompleteMsg struct {
	Token    string
	Username string
	Error    error
}

AuthCompleteMsg signals authentication completed

type AuthRequiredMsg

type AuthRequiredMsg struct{}

AuthRequiredMsg signals authentication is required

type ClearMessageMsg

type ClearMessageMsg struct{}

ClearMessageMsg signals a temporary message should be cleared

type DeleteProfileCancelledMsg

type DeleteProfileCancelledMsg struct{}

DeleteProfileCancelledMsg signals user cancelled profile deletion

type DeleteProfileConfirmedMsg

type DeleteProfileConfirmedMsg struct {
	ProfileID   string
	ProfileName string
}

DeleteProfileConfirmedMsg signals user confirmed profile deletion

type DeleteProfileRequestMsg

type DeleteProfileRequestMsg struct {
	ProfileID   string
	ProfileName string
}

DeleteProfileRequestMsg signals user wants to delete a profile (shows confirmation)

type DeleteProgressMsg

type DeleteProgressMsg struct {
	ReleaseName string
	Success     bool
	Error       error
	Current     int
	Total       int
}

DeleteProgressMsg signals progress during release deletion

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg signals an error occurred

type ExitTimeoutMsg

type ExitTimeoutMsg struct{}

ExitTimeoutMsg signals exit confirmation timeout expired

type KeyMap

type KeyMap struct {
	// Navigation
	Up       key.Binding
	Down     key.Binding
	Left     key.Binding
	Right    key.Binding
	Home     key.Binding
	End      key.Binding
	PageUp   key.Binding
	PageDown key.Binding

	// Selection
	Select     key.Binding
	SelectAll  key.Binding
	SelectNone key.Binding
	Toggle     key.Binding

	// Actions
	Confirm key.Binding
	Cancel  key.Binding
	Back    key.Binding
	Help    key.Binding
	Quit    key.Binding
	Refresh key.Binding

	// Search/Filter
	Filter key.Binding
	Search key.Binding
	Clear  key.Binding

	// Tabs/Screens
	Tab      key.Binding
	ShiftTab key.Binding
	NextTab  key.Binding
	PrevTab  key.Binding
}

KeyMap defines the key bindings for the TUI

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings

func GetKeyMap

func GetKeyMap() KeyMap

GetKeyMap returns the global key map

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns key bindings for the full help view

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns key bindings for the short help view

type NewSyncRequestedMsg

type NewSyncRequestedMsg struct{}

NewSyncRequestedMsg signals user wants to start a new sync

type OrgsLoadedMsg

type OrgsLoadedMsg struct {
	Orgs  []*gh.Organization
	Error error
}

OrgsLoadedMsg signals organizations have been fetched

type ProfileSavedMsg

type ProfileSavedMsg struct {
	Profile *state.SyncProfile
	Error   error
}

ProfileSavedMsg signals a profile was saved

type ProfileSelectedMsg

type ProfileSelectedMsg struct {
	Profile *state.SyncProfile
}

ProfileSelectedMsg signals a profile was selected

type QuickSyncRequestedMsg

type QuickSyncRequestedMsg struct {
	ProfileID string
}

QuickSyncRequestedMsg signals user wants to quick sync a profile

type QuitMsg

type QuitMsg struct{}

QuitMsg signals app quit

type RefreshDashboardMsg

type RefreshDashboardMsg struct{}

RefreshDashboardMsg signals dashboard should refresh data

type ReleasesLoadedMsg

type ReleasesLoadedMsg struct {
	Releases []*gh.RepositoryRelease
	Error    error
}

ReleasesLoadedMsg signals releases have been fetched

type ReposLoadedMsg

type ReposLoadedMsg struct {
	Repos []*gh.Repository
	Error error
}

ReposLoadedMsg signals repositories have been fetched

type Screen

type Screen int

Screen represents a TUI screen type

const (
	ScreenOnboarding Screen = iota
	ScreenDashboard
	ScreenSyncWizard
	ScreenSyncProgress
	ScreenClean
	ScreenSettings
	ScreenConfirmDelete
	// Legacy screens (kept for compatibility during transition)
	ScreenRepos
)

type ScreenChangeMsg

type ScreenChangeMsg struct {
	Screen Screen
}

ScreenChangeMsg signals a direct screen change

type ScreenFactory

type ScreenFactory func(ctx context.Context, app *App) ScreenModel

ScreenFactory creates a screen with dependencies

type ScreenModel

type ScreenModel interface {
	tea.Model
	// Title returns the screen title for the header
	Title() string
	// ShortHelp returns key bindings for the footer help
	ShortHelp() []key.Binding
}

ScreenModel is the interface that all screens must implement

type ScreenPopMsg

type ScreenPopMsg struct{}

ScreenPopMsg signals a screen pop (return to previous)

type ScreenPushMsg

type ScreenPushMsg struct {
	Screen Screen
}

ScreenPushMsg signals a screen push (saves current to stack)

type Styles

type Styles struct {
	// App-level styles
	App     lipgloss.Style
	Content lipgloss.Style

	// Header styles
	Header       lipgloss.Style
	HeaderTitle  lipgloss.Style
	HeaderStatus lipgloss.Style

	// Footer styles
	Footer    lipgloss.Style
	HelpKey   lipgloss.Style
	HelpValue lipgloss.Style

	// Menu styles
	MenuItem         lipgloss.Style
	MenuItemSelected lipgloss.Style
	MenuItemDisabled lipgloss.Style

	// List styles
	ListTitle     lipgloss.Style
	ListItem      lipgloss.Style
	ListItemDesc  lipgloss.Style
	ListSelected  lipgloss.Style
	ListPaginator lipgloss.Style

	// Form styles
	FormTitle       lipgloss.Style
	FormDescription lipgloss.Style
	FormInput       lipgloss.Style
	FormPlaceholder lipgloss.Style

	// Progress styles
	ProgressBar      lipgloss.Style
	ProgressLabel    lipgloss.Style
	ProgressPercent  lipgloss.Style
	ProgressComplete lipgloss.Style

	// Status styles
	Success lipgloss.Style
	Warning lipgloss.Style
	Error   lipgloss.Style
	Info    lipgloss.Style
	Muted   lipgloss.Style

	// Box styles
	Box            lipgloss.Style
	BoxTitle       lipgloss.Style
	BoxHighlighted lipgloss.Style

	// Badge styles
	Badge        lipgloss.Style
	BadgePrivate lipgloss.Style
	BadgePublic  lipgloss.Style

	// Spinner
	Spinner lipgloss.Style
}

Styles contains all the TUI styles

func DefaultStyles

func DefaultStyles() *Styles

DefaultStyles returns the default style configuration

func GetStyles

func GetStyles() *Styles

GetStyles returns the global styles instance

type SyncAllProfilesMsg

type SyncAllProfilesMsg struct{}

SyncAllProfilesMsg signals user wants to sync all profiles

type SyncCompleteMsg

type SyncCompleteMsg struct {
	Result *sync.Result
	Record *state.SyncRecord
	Error  error
}

SyncCompleteMsg signals sync completed

type SyncPendingProfilesMsg

type SyncPendingProfilesMsg struct{}

SyncPendingProfilesMsg signals user wants to sync pending profiles

type SyncProgressMsg

type SyncProgressMsg struct {
	RepoName string
	Status   sync.ProgressStatus
	Message  string
	Current  int
	Total    int
}

SyncProgressMsg signals progress during sync

type UpdateAvailableMsg added in v1.0.1

type UpdateAvailableMsg struct {
	CurrentVersion string
	LatestVersion  string
}

UpdateAvailableMsg signals that an update is available

type UpdateCompleteMsg added in v1.0.3

type UpdateCompleteMsg struct {
	NewVersion string
	Error      error
}

UpdateCompleteMsg signals that an update has completed

type UpdateErrorMsg added in v1.0.3

type UpdateErrorMsg struct {
	Error error
}

UpdateErrorMsg signals that an update failed

Directories

Path Synopsis
Package components provides reusable TUI components
Package components provides reusable TUI components
Package screens provides TUI screen implementations
Package screens provides TUI screen implementations
Package util provides utility functions for the TUI
Package util provides utility functions for the TUI

Jump to

Keyboard shortcuts

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