ui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package ui hosts the bubbletea application that powers `tmh` (no args).

The model is a thin router: each screen is a sub-model with its own Update/View. Heavy work lives in internal/actions; the UI never calls tmux directly outside of polling tmux.Runner via the same actions.

Package ui hosts the bubbletea application and its screens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Runner     tmux.Runner
	State      *appstate.DB
	ConfigPath string
	Profile    string
	LoadConfig func() (*config.Config, error)
}

Deps wires the side-effect surface the UI needs. Tests pass a MockRunner here; production passes CLIRunner + the real config path.

type Keys

type Keys struct {
	Up, Down, Left, Right key.Binding
	PgUp, PgDown          key.Binding
	Top, Bottom           key.Binding

	Enter, Esc, Quit key.Binding
	Tab              key.Binding

	Attach, NewSession, Kill, Sync, Reload key.Binding
	ConfigEditor, Diff, Snapshot, Undo     key.Binding
	Palette, Help, Theme, Search           key.Binding
	Refresh, Settings, History             key.Binding

	// Marks / last-location (4.1 + 4.2)
	PrevLoc  key.Binding // ” — pop last location
	MarkSet  key.Binding // m — begin set-mark two-step
	MarkJump key.Binding // ' — begin jump-to-mark two-step
}

Keys defines every binding the TUI listens for. Centralised here so the help overlay can render them and so they can be overridden in the future from ~/.config/tmh/keys.yml.

func DefaultKeys

func DefaultKeys() Keys

DefaultKeys returns the default key bindings.

type Model

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

Model is the root bubbletea model.

func New

func New(deps Deps) *Model

New constructs the root model.

func (*Model) Init

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

Init triggers the first data load + polling tick + async history load + first pane-refresh tick.

func (*Model) Update

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

Update routes messages to active screens.

func (*Model) View

func (m *Model) View() string

View renders the active screen + persistent overlays (toast, help).

type PaletteAction

type PaletteAction struct {
	Title       string
	Subtitle    string
	Run         func() tea.Cmd
	NeedsParam  bool
	ParamPrompt string // shown as placeholder in param mode
	ParamRun    func(string) tea.Cmd
}

PaletteAction is one row in the command palette. If NeedsParam is true, pressing Enter on this action switches the palette into a parameter-input mode. ParamRun is called with the collected input. Otherwise Run is called directly.

type Screen

type Screen int

Screen identifies which view the app is currently rendering.

const (
	ScreenDashboard Screen = iota
	ScreenDiff
	ScreenPalette
	ScreenHelp
	ScreenError
	ScreenEmpty
	ScreenConfirm
	ScreenSettings
	ScreenHistory
)

type UIDiff

type UIDiff struct {
	TitleEmpty  string
	BackHint    string
	ConfigLabel string
	LiveLabel   string
	EscReturn   string
}

type UIFooter

type UIFooter struct {
	Attach, NewSession, Kill, Dotfiles, Sync, Settings, Palette, History, Help, Quit string
}

type UIKeymap

type UIKeymap struct {
	Title string

	SectionNav, SectionActions, SectionSync, SectionOther string

	NavUpdown, NavCollapse, NavTopBottom, NavPage     string
	ActionAttach, ActionNew, ActionKill, ActionUndo   string
	SyncRefresh, SyncReload, SyncPush, SyncDiff       string
	OtherPalette, OtherSettings, OtherHelp, OtherQuit string
}

type UIModal

type UIModal struct {
	ErrorTitle   string
	ErrorDismiss string
	EmptyTitle   string
	EmptyHint    string
	ConfirmYes   string
	ConfirmNo    string
	KillBody     string
}

type UIPalette

type UIPalette struct {
	Placeholder string
	NoMatches   string
}

type UISettings

type UISettings struct {
	Title    string
	Language string
	Theme    string
	Tmux     string
	Hint     string

	// Category names for the master-detail layout.
	CatAppearance  string
	CatDisplay     string
	CatHistory     string
	CatMarks       string
	CatTmux        string
	CatBehaviour   string
	CatKeybindings string

	// Navigation hints.
	HintCategories string
	HintFields     string
	HintDirty      string
	HintDiscard    string

	// Action feedback.
	Saved           string
	TmuxConfWritten string
}

type UIStrings

type UIStrings struct {
	Loading         string
	NoSessions      string
	NothingSelected string
	AttachHint      string

	Footer   UIFooter
	Modal    UIModal
	Keymap   UIKeymap
	Settings UISettings
	Diff     UIDiff
	Palette  UIPalette
	Toast    UIToast
}

UIStrings holds all translated UI-level strings. Built once per language via LoadStrings() and stored on Model; sub-models receive a copy at construction time. When the active language changes, Model.strings is rebuilt and propagated to long-lived children (dashboard) via SetStrings.

Parametric messages (with {{.name}} placeholders) live under the Tf* method helpers, which defer to i18n.Tf so call-sites can pass template data directly.

func LoadStrings

func LoadStrings() UIStrings

LoadStrings pulls every plain translation from i18n.T into a typed bundle. Call after i18n.Init() (re)sets the active language.

type UIToast

type UIToast struct {
	ReloadTriggered string
	UndoUnavailable string
}

Directories

Path Synopsis
Package errrender turns internal sentinel errors into localized, user-facing strings.
Package errrender turns internal sentinel errors into localized, user-facing strings.
Package pane provides an in-memory cache of pane runtime data fetched via a single batch `tmux list-panes -a` call.
Package pane provides an in-memory cache of pane runtime data fetched via a single batch `tmux list-panes -a` call.
Package picker renders a small interactive fuzzy-filter list of tmh session candidates (declared + live ad-hoc + discovered) so that bare `tmh` invocations behave like sesh — type-to-filter + Enter-to-attach — without forcing users through the full TUI dashboard.
Package picker renders a small interactive fuzzy-filter list of tmh session candidates (declared + live ad-hoc + discovered) so that bare `tmh` invocations behave like sesh — type-to-filter + Enter-to-attach — without forcing users through the full TUI dashboard.
Package refresh provides a cadenced pane-command batch fetcher for the tmh TUI.
Package refresh provides a cadenced pane-command batch fetcher for the tmh TUI.
Package theme defines lipgloss styles for the tmh TUI.
Package theme defines lipgloss styles for the tmh TUI.
Package toast defines toast notification kinds and helpers for the tmh TUI.
Package toast defines toast notification kinds and helpers for the tmh TUI.

Jump to

Keyboard shortcuts

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