tui

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package tui implements the Bubbletea TUI for Snappy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlashTickMsg added in v0.8.0

type FlashTickMsg struct {
	ID uint64
}

FlashTickMsg advances the border flash animation by one frame.

type LaunchdController added in v0.10.0

type LaunchdController struct{}

LaunchdController implements ServiceController using the real service package.

func (LaunchdController) Install added in v0.11.0

Install writes the plist and bootstraps the launchd agent.

func (LaunchdController) ResolveBinaryPath added in v0.11.0

func (LaunchdController) ResolveBinaryPath() (string, error)

ResolveBinaryPath returns the canonical path of the running executable.

func (LaunchdController) Start added in v0.10.0

func (LaunchdController) Start(label string) error

Start enables and starts the agent (kickstart), falling back to bootstrap if needed.

func (LaunchdController) Status added in v0.10.0

func (LaunchdController) Status(label string) (*service.Info, error)

Status queries launchctl for the current state of the agent.

func (LaunchdController) Stop added in v0.10.0

func (LaunchdController) Stop(label string) error

Stop disables and unloads the launchd agent via bootout.

func (LaunchdController) Uninstall added in v0.11.0

func (LaunchdController) Uninstall(label string) error

Uninstall stops and removes the launchd agent.

type Model

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

Model is the Bubbletea model for the Snappy TUI.

func NewModel

func NewModel(cfg *config.Config, runner platform.CommandRunner, log *logger.Logger, params ModelParams) Model

NewModel creates a Model with the given dependencies. When DaemonActive is true, auto-snapshots are disabled because a background service holds the lock.

func (Model) Init

func (m Model) Init() tea.Cmd

Init returns the initial commands: a refresh, a tick timer, and a background color request. The UI tick is started when auto-snapshot is enabled or a daemon is active, since it drives the countdown timer and keeps snapshot ages fresh.

func (Model) Update

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

Update handles incoming messages and returns the updated model and any commands to execute.

func (Model) View

func (m Model) View() tea.View

View renders the full TUI screen as a tea.View.

type ModelParams added in v0.8.0

type ModelParams struct {
	APFSVolume       string
	APFSContainer    string
	TMStatus         string
	VolumeName       string
	Version          string
	Lock             *service.LockFile // pre-acquired persistent lock, or nil
	DaemonActive     bool
	ServiceCtrl      ServiceController // nil disables service features
	ServiceInstalled bool
	ServiceRunning   bool
	ConfigFile       string // resolved config file path for service plist
}

ModelParams groups the string and boolean parameters for NewModel, preventing accidental argument reordering at call sites.

type OpenLogDirResultMsg added in v0.7.0

type OpenLogDirResultMsg struct {
	Err error
}

OpenLogDirResultMsg reports the result of attempting to open the log directory.

type RefreshResultMsg

type RefreshResultMsg struct {
	Snapshots   []snapshot.Snapshot
	TMStatus    string
	APFSInfo    platform.APFSInfo
	DiskInfo    platform.DiskInfo
	DiskErr     bool
	SnapshotErr error
	APFSErr     error
	Tidemark    int64
	TidemarkErr error
}

RefreshResultMsg carries the result of a full data refresh.

type RefreshTickMsg

type RefreshTickMsg struct{}

RefreshTickMsg signals that the periodic refresh timer has fired.

type ServiceController added in v0.10.0

type ServiceController interface {
	Status(label string) (*service.Info, error)
	Start(label string) error
	Stop(label string) error
	Install(cfg service.PlistConfig) error
	Uninstall(label string) error
	ResolveBinaryPath() (string, error)
}

ServiceController abstracts launchd service operations for testability.

type ServiceInstallResultMsg added in v0.11.0

type ServiceInstallResultMsg struct {
	Err error
}

ServiceInstallResultMsg carries the result of a service install attempt.

type ServiceStatusResultMsg added in v0.10.0

type ServiceStatusResultMsg struct {
	Info *service.Info
	Err  error
}

ServiceStatusResultMsg carries the result of a service status probe.

type ServiceToggleResultMsg added in v0.10.0

type ServiceToggleResultMsg struct {
	Action string // "start" or "stop"
	Err    error
}

ServiceToggleResultMsg carries the result of a service start or stop.

type ServiceUninstallResultMsg added in v0.11.0

type ServiceUninstallResultMsg struct {
	Err error
}

ServiceUninstallResultMsg carries the result of a service uninstall attempt.

type SnapshotCreatedMsg

type SnapshotCreatedMsg struct {
	Date    string
	Err     error
	Skipped bool
}

SnapshotCreatedMsg signals that a snapshot creation attempt completed. Skipped is true when an auto-snapshot was skipped because another process already holds the lock.

type ThinResultMsg

type ThinResultMsg struct {
	Deleted      int
	ThinnedDates []string
	FailedDates  []string
	EstaleCount  int
	Err          error
}

ThinResultMsg signals that a thinning operation completed.

type UITickMsg added in v0.6.0

type UITickMsg struct{}

UITickMsg drives a 1-second UI refresh so the countdown timer stays current.

Jump to

Keyboard shortcuts

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