tui

package
v1.16.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const StoreProbeTimeout = 15 * time.Second

StoreProbeTimeout bounds a single store health probe so one unreachable backend cannot stall the dashboard. Probes run concurrently, so the whole first paint is bounded by this regardless of how many stores are configured.

Variables

This section is empty.

Functions

func ProbeStatusLabel

func ProbeStatusLabel(kind string) string

func RenderDashboard

func RenderDashboard(w io.Writer, d Dashboard) error

func RenderDashboardWidth

func RenderDashboardWidth(w io.Writer, d Dashboard, width int) error

func SnapshotAgeLabel

func SnapshotAgeLabel(t time.Time) string

Types

type ActionKind

type ActionKind string
const (
	ActionKindInit   ActionKind = "init"
	ActionKindBackup ActionKind = "backup"
	ActionKindCheck  ActionKind = "check"
)

type ActionRunner added in v1.16.0

type ActionRunner interface {
	Start(ctx context.Context, profile ProfileCard, kind ActionKind) <-chan ActionUpdate
}

ActionRunner executes a profile action asynchronously. Start launches the action against ctx and returns a channel that streams progress updates and closes once the final (Done) update has been sent. Implementations must respect ctx cancellation so the model's cancel key can stop a running action.

type ActionUpdate added in v1.16.0

type ActionUpdate struct {
	Panel ActivityPanel
	Done  bool
	Err   error
}

ActionUpdate is a single progress update from a running profile action. Non-final updates carry the live ActivityPanel; the final update sets Done (and Err when the action failed) and is the last value sent before the channel closes.

type ActivityPanel

type ActivityPanel struct {
	Status     ActivityStatus
	ActionKind ActionKind
	Action     string
	Target     string
	Phase      string
	Current    int64
	Total      int64
	IsBytes    bool
	Summary    string
	UpdatedAt  string
	Lines      []string
}

type ActivityStatus

type ActivityStatus string
const (
	ActivityStatusIdle    ActivityStatus = ""
	ActivityStatusRunning ActivityStatus = "running"
	ActivityStatusSuccess ActivityStatus = "success"
	ActivityStatusError   ActivityStatus = "error"
)

type BackupFreshness

type BackupFreshness string
const (
	BackupFreshnessUnknown BackupFreshness = ""
	BackupFreshnessNever   BackupFreshness = "never"
	BackupFreshnessRecent  BackupFreshness = "recent"
	BackupFreshnessStale   BackupFreshness = "stale"
)

type Dashboard

type Dashboard struct {
	ProfileCount    int
	StoreCount      int
	AuthCount       int
	SelectedProfile string
	SelectedView    ProfileView
	Activity        ActivityPanel
	Modal           *Modal
	Profiles        []ProfileCard
}

func BuildDashboard

func BuildDashboard(cfg *engine.ProfilesConfig, probes map[string]StoreProbe) Dashboard

func BuildDashboardFromConfig

func BuildDashboardFromConfig(ctx context.Context, cfg *engine.ProfilesConfig, load SnapshotLoader) Dashboard

type DashboardLayout

type DashboardLayout struct {
	ProfileRows map[int]string
	ProfileRect Rect
	ActionRows  map[int]string
	ActionRect  Rect
}

func LayoutDashboardWidth

func LayoutDashboardWidth(d Dashboard, width int) DashboardLayout

type DashboardLoadError added in v1.16.0

type DashboardLoadError struct {
	Err error
}

DashboardLoadError reports that a dashboard (re)load failed. The model keeps showing the last good dashboard and surfaces the error in the footer.

type DashboardLoadedMsg added in v1.16.0

type DashboardLoadedMsg struct {
	Dashboard Dashboard
}

DashboardLoadedMsg carries a freshly derived dashboard view-model into the model. It is emitted by the command returned from ReloadDashboardCmd.

type FormsBackend added in v1.16.0

type FormsBackend interface {
	forms.ProfileBackend
	forms.StoreBackend
	forms.SecretBackend
	// InitialStoreValues seeds an edit-store form with an existing store's
	// field values.
	InitialStoreValues(name string) map[string]string
	// DeleteProfile removes a profile from the profiles file.
	DeleteProfile(name string) error
	// Reload re-reads the profiles config after a mutation.
	Reload() (*engine.ProfilesConfig, error)
}

FormsBackend is the domain boundary the model uses for profile and store management. It combines the profile and store form backends with the delete, config-reload, and edit-seed operations the model orchestrates around a form. The cmd package implements it by reusing the existing source/store/options/ validation/save helpers.

type Modal struct {
	Kind        ModalKind
	Title       string
	Subtitle    string
	Error       string
	ErrorField  string
	Hint        string
	Message     []string
	Fields      []ModalField
	Selected    int
	SubmitLabel string
	CancelLabel string
}

type ModalField

type ModalField struct {
	Key      string
	Label    string
	Kind     ModalFieldKind
	Value    string
	Options  []string
	Required bool
	Disabled bool
}

type ModalFieldKind

type ModalFieldKind string
const (
	ModalFieldText   ModalFieldKind = "text"
	ModalFieldSelect ModalFieldKind = "select"
)

type ModalKind

type ModalKind string
const (
	ModalKindProfileForm ModalKind = "profile_form"
	ModalKindConfirm     ModalKind = "confirm"
)

type Model added in v1.16.0

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

Model is the root Bubble Tea model for the interactive dashboard. This is the read-only foundation from issue #338: it renders the existing derived Dashboard view-model and supports navigation, but performs no actions or mutations. Async actions and forms land in later Phase 2 stories (#339, #340).

func NewModel added in v1.16.0

func NewModel(d Dashboard) Model

NewModel builds a root model seeded with an already-derived dashboard.

func (Model) Init added in v1.16.0

func (m Model) Init() tea.Cmd

Init kicks off concurrent store probing when the model is configured with a prober; otherwise it renders the seeded dashboard as-is.

func (Model) Update added in v1.16.0

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

func (Model) View added in v1.16.0

func (m Model) View() string

func (Model) WithConfig added in v1.16.0

func (m Model) WithConfig(cfg *engine.ProfilesConfig, prober StoreProber) Model

WithConfig attaches the profiles config and a store prober, enabling concurrent probing on Init. The seeded dashboard should be a probe-less skeleton (BuildDashboard(cfg, nil)) so the first frame renders immediately.

func (Model) WithForms added in v1.16.0

func (m Model) WithForms(backend FormsBackend) Model

WithForms enables the profile create/edit/delete flows (issue #340). Without it the model stays read-only plus actions.

func (Model) WithReload added in v1.16.0

func (m Model) WithReload(cmd tea.Cmd) Model

WithReload attaches a command used to refresh the dashboard on "r".

func (Model) WithRunner added in v1.16.0

func (m Model) WithRunner(runner ActionRunner) Model

WithRunner attaches the async action runner used by the backup/check/init keys.

type ProfileAction

type ProfileAction struct {
	Kind    ActionKind
	Key     string
	Label   string
	Enabled bool
	Reason  string
}

type ProfileCard

type ProfileCard struct {
	Name         string
	Source       string
	StoreRef     string
	AuthRef      string
	Enabled      bool
	Status       ProfileStatus
	StatusNote   string
	StoreHealth  StoreHealth
	Reachability StoreReachability
	Repository   RepositoryState
	BackupState  BackupFreshness
	LastBackup   string
	LastRef      string
	History      []ProfileSnapshot
	Actions      []ProfileAction
}

type ProfileSnapshot

type ProfileSnapshot struct {
	Created string
	Ref     string
}

type ProfileStatus

type ProfileStatus string
const (
	ProfileStatusReady    ProfileStatus = "ready"
	ProfileStatusDisabled ProfileStatus = "disabled"
	ProfileStatusWarning  ProfileStatus = "warning"
	ProfileStatusError    ProfileStatus = "error"
)

type ProfileView

type ProfileView string
const (
	ProfileViewSummary ProfileView = "summary"
	ProfileViewHistory ProfileView = "history"
)

type Rect

type Rect struct {
	X int
	Y int
	W int
	H int
}

type RepositoryState

type RepositoryState string
const (
	RepositoryStateUnknown        RepositoryState = "unknown"
	RepositoryStateInitialized    RepositoryState = "initialized"
	RepositoryStateNotInitialized RepositoryState = "not_initialized"
)

type StoreHealth

type StoreHealth string
const (
	StoreHealthReady            StoreHealth = "ready"
	StoreHealthPending          StoreHealth = "pending"
	StoreHealthDisabled         StoreHealth = "disabled"
	StoreHealthMissingStore     StoreHealth = "missing_store"
	StoreHealthMissingAuth      StoreHealth = "missing_auth"
	StoreHealthProviderMismatch StoreHealth = "provider_mismatch"
	StoreHealthUnavailable      StoreHealth = "unavailable"
	StoreHealthNotInitialized   StoreHealth = "not_initialized"
	StoreHealthUnknown          StoreHealth = "unknown"
)

type StoreProbe

type StoreProbe struct {
	Status    string
	Error     string
	Snapshots []engine.SnapshotEntry
}

type StoreProber added in v1.16.0

type StoreProber interface {
	Probe(ctx context.Context, name string, store engine.ProfileStore) StoreProbe
}

StoreProber checks the health of a single store. Implementations must honor ctx (including its deadline) and must not block past it.

type StoreReachability

type StoreReachability string
const (
	StoreReachabilityUnknown     StoreReachability = "unknown"
	StoreReachabilityPending     StoreReachability = "pending"
	StoreReachabilityReachable   StoreReachability = "reachable"
	StoreReachabilityUnavailable StoreReachability = "unavailable"
)

Directories

Path Synopsis
Package forms provides Bubble Tea form components for the interactive TUI.
Package forms provides Bubble Tea form components for the interactive TUI.

Jump to

Keyboard shortcuts

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