tui

package
v2.0.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package tui implements the Bubbletea terminal UI for Engram.

Following the Gentleman Bubbletea patterns: - Screen constants as iota - Single Model struct holds ALL state - Update() with type switch - Per-screen key handlers returning (tea.Model, tea.Cmd) - Vim keys (j/k) for navigation - PrevScreen for back navigation

Index

Constants

View Source
const (
	TokenSourceEnv  = cloudconfig.LabelSourceEnv
	TokenSourceFile = cloudconfig.LabelSourceFile
	TokenSourceNone = cloudconfig.LabelSourceNone
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Version    string
	Screen     Screen
	PrevScreen Screen
	Width      int
	Height     int
	Cursor     int
	Scroll     int

	// Update notification
	UpdateStatus version.CheckStatus
	UpdateMsg    string

	// Error display
	ErrorMsg string

	// Dashboard
	Stats *store.Stats

	// Search
	SearchInput   textInput
	SearchQuery   string
	SearchResults []store.SearchResult

	// Recent observations
	RecentObservations []store.Observation

	// Observation detail
	SelectedObservation *store.Observation
	DetailScroll        int

	// Timeline
	Timeline *store.TimelineResult

	// Sessions
	Sessions             []store.SessionSummary
	SelectedSessionIdx   int
	SessionObservations  []store.Observation
	SessionDetailScroll  int
	SessionDeleteState   SessionDeleteState
	SessionDeleteID      string
	SessionDeleteProject string

	// Clipboard feedback
	CopyFeedback string // "✓ Copied!" or "" — shown for 2 s after copy

	// Setup
	SetupAgents           []setup.Agent
	SetupResult           *setup.Result
	SetupError            string
	SetupDone             bool
	SetupInstalling       bool
	SetupInstallingName   string // agent name being installed (for display)
	SetupAllowlistPrompt  bool   // true = showing y/n prompt for allowlist
	SetupAllowlistApplied bool   // true = allowlist was added successfully
	SetupAllowlistError   string // error message if allowlist injection failed
	SetupSpinner          spinner.Model

	// Cloud configuration
	CloudConfigInput       textInput
	CloudConfigTokenSource string
	CloudConfigError       string
	CloudConfigFocus       int
	CloudConfigPingStatus  string
	CloudConfigSaving      bool
	CloudConfigTest        bool
	CloudRequestGeneration uint64

	// Cloud status
	CloudStatusServerURL    string
	CloudStatusHealth       string
	CloudStatusLastSync     string
	CloudStatusPendingCount int64
	CloudStatusLastError    string
	CloudStatusHealthError  string
	CloudStatusLoading      bool

	// Cloud enrollment
	CloudEnrollmentItems   []cloudEnrollmentItem
	CloudEnrollmentError   string
	CloudEnrollmentLoading bool
	// contains filtered or unexported fields
}

func New

func New(s *store.Store, version string) Model

New creates a new TUI model connected to the given store.

func (Model) Init

func (m Model) Init() tea.Cmd

Init loads initial data (stats for the dashboard).

func (Model) Update

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

func (Model) View

func (m Model) View() string

type Screen

type Screen int
const (
	ScreenDashboard Screen = iota
	ScreenSearch
	ScreenSearchResults
	ScreenRecent
	ScreenObservationDetail
	ScreenTimeline
	ScreenSessions
	ScreenSessionDetail
	ScreenSetup
	ScreenCloudSettings
	ScreenCloudConfig
	ScreenCloudStatus
	ScreenCloudEnrollment
)

type SessionDeleteState

type SessionDeleteState int
const (
	SessionDeleteStateNone SessionDeleteState = iota
	SessionDeleteStatePrompt
	SessionDeleteStateDeleting
)

Jump to

Keyboard shortcuts

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