app

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package app implements the root Bubble Tea application model, orchestrating plugins, modals, project switching, themes, and global keyboard bindings.

Index

Constants

This section is empty.

Variables

View Source
var ShowToast = msg.ShowToast

ShowToast is re-exported from msg package for backward compatibility.

Functions

func CheckCurrentWorktree

func CheckCurrentWorktree(workDir string) (exists bool, mainPath string)

CheckCurrentWorktree checks if the current working directory is still a valid worktree. Returns (exists, mainPath) where mainPath is the path to switch to if worktree was deleted.

func FocusPlugin

func FocusPlugin(pluginID string) tea.Cmd

FocusPlugin returns a command that requests focusing a plugin by ID.

func GetAllRelatedPaths

func GetAllRelatedPaths(workDir string) []string

GetAllRelatedPaths returns all paths that share the same git repository: the main worktree and all linked worktrees. Each path is absolute. Returns nil if workDir is not in a git repository.

func GetMainWorktreePath

func GetMainWorktreePath(workDir string) string

GetMainWorktreePath returns the path to the main worktree for the repository. Returns empty string if not in a git repo or no main worktree found.

func GetRepoName

func GetRepoName(workDir string) string

GetRepoName returns the git repository name for the given directory. It tries to extract the name from the remote URL first, falling back to the directory name if no remote is configured. Returns empty string if the directory is not a git repository.

func IntroTick

func IntroTick() tea.Cmd

func PluginFocused

func PluginFocused() tea.Cmd

PluginFocused returns a command that sends PluginFocusedMsg.

func Refresh

func Refresh() tea.Cmd

Refresh returns a command to trigger a refresh.

func ReportError

func ReportError(err error) tea.Cmd

ReportError returns a command to report an error.

func SwitchToMainWorktree

func SwitchToMainWorktree(mainPath string) tea.Cmd

SwitchToMainWorktree returns a command that requests switching to the main worktree.

func SwitchWorktree

func SwitchWorktree(path string) tea.Cmd

SwitchWorktree returns a command that requests switching to a worktree by path.

func Tick

func Tick(d time.Duration, tag string) tea.Cmd

Tick returns a custom tick command with a tag.

func WorktreeExists

func WorktreeExists(worktreePath string) bool

WorktreeExists checks if the given worktree path still exists and is valid. Returns false if the directory doesn't exist or is not a valid git worktree.

func WorktreeNameForPath

func WorktreeNameForPath(workDir, targetPath string) string

WorktreeNameForPath returns the worktree name for a given absolute path. Returns empty string if the path is the main worktree or not found.

Types

type ChangelogLoadedMsg

type ChangelogLoadedMsg struct {
	Content string
	Err     error
}

ChangelogLoadedMsg signals that changelog content has been loaded.

type EditorReturnedMsg

type EditorReturnedMsg struct {
	Err error
}

EditorReturnedMsg signals that an external editor process has exited. Used to restore terminal state (mouse support) after returning from vim/etc.

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg represents an error condition.

type FocusPluginByIDMsg

type FocusPluginByIDMsg struct {
	PluginID string
}

FocusPluginByIDMsg requests focusing a specific plugin by ID. Used for cross-plugin navigation (e.g., opening file in file browser from git).

type IntroLetter

type IntroLetter struct {
	Char     rune
	TargetX  float64
	CurrentX float64

	// Overshoot logic
	ReachedTarget bool
	OvershootMax  float64

	// Color interpolation
	StartColor   RGB
	EndColor     RGB
	CurrentColor RGB

	Delay time.Duration
}

type IntroModel

type IntroModel struct {
	Active    bool
	StartTime time.Time
	Letters   []*IntroLetter
	Done      bool // Set to true when animation is finished

	// Repo name fade-in (starts after logo animation completes)
	RepoName      string
	RepoOpacity   float64   // 0.0 to 1.0
	RepoFadeStart time.Time // When the fade began
}

IntroModel handles the intro animation state.

func NewIntroModel

func NewIntroModel(repoName string) IntroModel

func (IntroModel) RepoNameView

func (m IntroModel) RepoNameView() string

RepoNameView returns the repo name with current fade opacity applied. Returns empty string if no repo name or opacity is 0.

func (*IntroModel) Update

func (m *IntroModel) Update(dt time.Duration)

Update progresses the animation

func (IntroModel) View

func (m IntroModel) View() string

type IntroTickMsg

type IntroTickMsg time.Time

IntroTickMsg is sent to update the animation frame.

type IssuePreviewData

type IssuePreviewData struct {
	ID          string   `json:"id"`
	Title       string   `json:"title"`
	Status      string   `json:"status"`
	Type        string   `json:"type"`
	Priority    string   `json:"priority"`
	Points      int      `json:"points"`
	Description string   `json:"description"`
	ParentID    string   `json:"parent_id"`
	Labels      []string `json:"labels"`
	CreatedAt   string   `json:"created_at"`
	UpdatedAt   string   `json:"updated_at"`
}

IssuePreviewData holds lightweight issue data fetched via CLI.

type IssuePreviewResultMsg

type IssuePreviewResultMsg struct {
	Data  *IssuePreviewData
	Error error
}

IssuePreviewResultMsg carries fetched issue data back to the app.

type IssueSearchResult

type IssueSearchResult struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Status   string `json:"status"`
	Type     string `json:"type"`
	Priority string `json:"priority"`
}

IssueSearchResult holds a single search result from td search.

type IssueSearchResultMsg

type IssueSearchResultMsg struct {
	Query   string
	Results []IssueSearchResult
	Error   error
}

IssueSearchResultMsg carries search results back to the app.

type ModalKind

type ModalKind int

ModalKind identifies an app-level modal with explicit priority ordering. Lower values = higher priority (checked first for rendering and input routing).

const (
	ModalNone             ModalKind = iota // No modal open
	ModalPalette                           // Command palette (highest priority)
	ModalHelp                              // Help overlay
	ModalUpdate                            // Update modal
	ModalDiagnostics                       // Diagnostics/version info
	ModalQuitConfirm                       // Quit confirmation dialog
	ModalProjectSwitcher                   // Project switcher
	ModalWorktreeSwitcher                  // Worktree switcher
	ModalThemeSwitcher                     // Theme switcher
	ModalIssueInput                        // Issue ID text input
	ModalIssuePreview                      // Issue preview display (lowest priority)
)

type Model

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

Model is the root Bubble Tea model for the sidecar application.

func New

func New(reg *plugin.Registry, km *keymap.Registry, cfg *config.Config, currentVersion, workDir, projectRoot, initialPluginID string) Model

New creates a new application model. initialPluginID optionally specifies which plugin to focus on startup (empty = first plugin).

func (Model) ActivePlugin

func (m Model) ActivePlugin() plugin.Plugin

ActivePlugin returns the currently active plugin.

func (*Model) ClearToast

func (m *Model) ClearToast()

ClearToast clears any expired toast message.

func (*Model) FocusPluginByID

func (m *Model) FocusPluginByID(id string) tea.Cmd

FocusPluginByID switches to a plugin by its ID.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model and returns initial commands.

func (*Model) NextPlugin

func (m *Model) NextPlugin() tea.Cmd

NextPlugin switches to the next plugin.

func (*Model) PrevPlugin

func (m *Model) PrevPlugin() tea.Cmd

PrevPlugin switches to the previous plugin.

func (*Model) SetActivePlugin

func (m *Model) SetActivePlugin(idx int) tea.Cmd

SetActivePlugin sets the active plugin by index and returns a command to notify the plugin it has been focused.

func (*Model) ShowToast

func (m *Model) ShowToast(msg string, duration time.Duration)

ShowToast displays a temporary status message.

func (Model) Update

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

Update handles all messages and returns the updated model and commands.

func (Model) View

func (m Model) View() string

View renders the entire application UI.

type OpenFullIssueMsg

type OpenFullIssueMsg struct {
	IssueID string
}

OpenFullIssueMsg is broadcast to plugins to open the full rich issue view. Currently handled by the TD monitor plugin via monitor.OpenIssueByIDMsg.

type PluginFocusedMsg

type PluginFocusedMsg = plugin.PluginFocusedMsg

PluginFocusedMsg is sent to a plugin when it becomes the active plugin. Plugins can use this to refresh data or update their state on focus. Re-exported from plugin package for backward compatibility.

type RGB

type RGB struct {
	R, G, B float64
}

type RefreshMsg

type RefreshMsg struct{}

RefreshMsg triggers a full refresh.

type SwitchToMainWorktreeMsg

type SwitchToMainWorktreeMsg struct {
	MainWorktreePath string // Path to the main worktree to switch to
}

SwitchToMainWorktreeMsg requests switching to the main worktree. Sent when the current WorkDir (a worktree) has been deleted and sidecar should gracefully switch to the main repository.

type SwitchWorktreeMsg

type SwitchWorktreeMsg struct {
	WorktreePath string // Absolute path to the worktree
}

SwitchWorktreeMsg requests switching to a different worktree. Used by the worktree switcher modal and workspace plugin "Open in Git Tab" command.

type TabBounds

type TabBounds struct {
	Start, End int
}

TabBounds represents the X position range of a tab for mouse hit testing.

type TaggedTickMsg

type TaggedTickMsg struct {
	Time time.Time
	Tag  string
}

TaggedTickMsg is a tick with an identifying tag.

type TickMsg

type TickMsg time.Time

TickMsg is sent on each clock tick.

type ToastMsg

type ToastMsg = msg.ToastMsg

ToastMsg is re-exported from msg package for backward compatibility.

type UIState

type UIState struct {
	Clock        time.Time
	LastRefresh  time.Time
	ToastMessage string
	ToastExpiry  time.Time
	WorkDir      string
	ProjectRoot  string // Main repo root for shared state (same as WorkDir for non-worktrees)
}

UIState holds header/footer state information.

func NewUIState

func NewUIState() *UIState

NewUIState creates a new UI state.

func (*UIState) ClearExpiredToast

func (u *UIState) ClearExpiredToast()

ClearExpiredToast clears toast if it has expired.

func (*UIState) HasToast

func (u *UIState) HasToast() bool

HasToast returns true if there's an active toast message.

func (*UIState) MarkRefresh

func (u *UIState) MarkRefresh()

MarkRefresh updates the last refresh timestamp.

func (*UIState) SetToast

func (u *UIState) SetToast(msg string, duration time.Duration)

SetToast sets a toast message with expiry.

func (*UIState) UpdateClock

func (u *UIState) UpdateClock()

UpdateClock updates the current clock time.

type UpdateElapsedTickMsg

type UpdateElapsedTickMsg struct{}

UpdateElapsedTickMsg triggers elapsed time update during update.

type UpdateErrorMsg

type UpdateErrorMsg struct {
	Step string // "sidecar", "td", or "check"
	Err  error
}

UpdateErrorMsg signals that an update failed.

type UpdateInstallDoneMsg

type UpdateInstallDoneMsg struct {
	SidecarUpdated    bool
	TdUpdated         bool
	NewSidecarVersion string
	NewTdVersion      string
}

UpdateInstallDoneMsg signals install completed, triggers verify phase.

type UpdateModalState

type UpdateModalState int

UpdateModalState represents the current state of the update modal.

const (
	UpdateModalClosed   UpdateModalState = iota // Modal not visible
	UpdateModalPreview                          // Show release notes before update
	UpdateModalProgress                         // Show multi-phase progress during update
	UpdateModalComplete                         // Show completion message
	UpdateModalError                            // Show error details
)

type UpdatePhase

type UpdatePhase int

UpdatePhase represents a phase of the update process.

const (
	PhaseCheckPrereqs UpdatePhase = iota // Checking prerequisites (go installed)
	PhaseInstalling                      // Installing via go install
	PhaseVerifying                       // Verifying installation
)

func (UpdatePhase) String

func (p UpdatePhase) String() string

String returns the display name for an update phase.

func (UpdatePhase) StringForMethod

func (p UpdatePhase) StringForMethod(method string) string

StringForMethod returns the display name for an update phase, customized for the install method.

type UpdatePhaseChangeMsg

type UpdatePhaseChangeMsg struct {
	Phase  UpdatePhase
	Status string // "pending", "running", "done", "error"
}

UpdatePhaseChangeMsg signals a change in update phase status.

type UpdatePrereqsPassedMsg

type UpdatePrereqsPassedMsg struct{}

UpdatePrereqsPassedMsg signals prerequisites check passed, triggers install phase.

type UpdateSpinnerTickMsg

type UpdateSpinnerTickMsg struct{}

UpdateSpinnerTickMsg triggers spinner animation during update.

type UpdateSuccessMsg

type UpdateSuccessMsg struct {
	SidecarUpdated    bool
	TdUpdated         bool
	NewSidecarVersion string
	NewTdVersion      string
}

UpdateSuccessMsg signals that an update completed successfully.

type WorktreeDeletedMsg

type WorktreeDeletedMsg struct {
	DeletedPath string // Path of the deleted worktree
	MainPath    string // Path to switch to (main worktree)
}

WorktreeDeletedMsg is sent when the current worktree has been deleted.

type WorktreeInfo

type WorktreeInfo struct {
	Path   string // Absolute path to the worktree
	Branch string // Branch name (e.g., "feature-auth")
	IsMain bool   // True if this is the main worktree
}

WorktreeInfo contains information about a git worktree.

func GetWorktrees

func GetWorktrees(workDir string) []WorktreeInfo

GetWorktrees returns all worktrees for the repository containing workDir. Returns nil if workDir is not in a git repository.

Jump to

Keyboard shortcuts

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