tui

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package tui is the interactive terminal UI behind the CLI's "tui" command: a live, keyboard-driven view of apps, databases, deployments, nodes, domains, alerts and backups over the public HTTP API only.

Index

Constants

View Source
const (
	SecApps      = "apps"
	SecDeploys   = "deployments"
	SecAttention = "alerts"
	SecDatabases = "databases"
	SecNodes     = "nodes"
	SecDomains   = "domains"
	SecBackups   = "backups"
	SecMesh      = "mesh"
	SecServer    = "server"
)

Section names used as keys of Fast.Errs and Slow.Errs.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, api API, opts Options, in io.Reader, out io.Writer) error

Run starts the UI on in/out and blocks until the user quits or ctx ends.

Types

type API

type API interface {
	Fast(ctx context.Context) Fast
	Slow(ctx context.Context) Slow
	Restart(ctx context.Context, app string) error
	Start(ctx context.Context, app string) error
	Stop(ctx context.Context, app string) error
	Deploy(ctx context.Context, app, image string) error
	Rollback(ctx context.Context, app, deployID string) error
	Logs(ctx context.Context, kind LogKind, name string, onLine func(LogLine) error) error
}

API is everything the UI needs from the control plane, so tests can fake it.

type AppRow

type AppRow struct {
	Name     string
	Status   string
	Tone     Tone
	Image    string
	Strategy string
	Node     string
	Replicas int
	Domains  []string
}

AppRow is one app in the apps view.

type AttentionRow

type AttentionRow struct {
	Severity string
	Kind     string
	Subject  string
	Title    string
	Detail   string
}

AttentionRow is one item of the alerts/attention feed.

type BackupRow

type BackupRow struct {
	Resource  string
	Kind      string
	Status    string
	SizeBytes int64
	StartedAt time.Time
}

BackupRow is one backup attempt in the backups view.

type Cell

type Cell struct {
	Text string
	Tone Tone
}

Cell is one table cell; Tone colours its text.

type DBRow

type DBRow struct {
	Name     string
	Engine   string
	Version  string
	Node     string
	Schedule string
	Retain   int
	Public   bool
	Stopped  bool
}

DBRow is one database in the databases view.

type DeployRow

type DeployRow struct {
	ID         string
	App        string
	Status     string
	Trigger    string
	Env        string
	Commit     string
	Branch     string
	StartedAt  time.Time
	DurationMS int64
	IsLive     bool
}

DeployRow is one deployment in the deployments view.

type DomainRow

type DomainRow struct {
	Domain string
	App    string
	TLS    string
	Kind   string
}

DomainRow is one domain in the domains view.

type Fast

type Fast struct {
	Apps      []AppRow
	Deploys   []DeployRow
	Attention []AttentionRow
	Errs      map[string]string
}

Fast is the data refreshed on every tick. A section present in Errs failed and its field is ignored, so stale data survives a blip.

type LiveAPI

type LiveAPI struct {
	Client  *apiclient.Client
	Timeout time.Duration
}

LiveAPI implements API over the HTTP client, one batched list call per section.

func (LiveAPI) Deploy

func (l LiveAPI) Deploy(ctx context.Context, app, image string) error

Deploy redeploys app with image.

func (LiveAPI) Fast

func (l LiveAPI) Fast(parent context.Context) Fast

Fast fetches apps, deployments and the attention feed concurrently.

func (LiveAPI) Logs

func (l LiveAPI) Logs(ctx context.Context, kind LogKind, name string, onLine func(LogLine) error) error

Logs tails an app or database log stream until ctx ends.

func (LiveAPI) Restart

func (l LiveAPI) Restart(ctx context.Context, app string) error

Restart restarts app.

func (LiveAPI) Rollback

func (l LiveAPI) Rollback(ctx context.Context, app, deployID string) error

Rollback redeploys a past succeeded deploy of app.

func (LiveAPI) Slow

func (l LiveAPI) Slow(parent context.Context) Slow

Slow fetches databases, nodes, domains, backups, mesh and server version.

func (LiveAPI) Start

func (l LiveAPI) Start(ctx context.Context, app string) error

Start starts a stopped app.

func (LiveAPI) Stop

func (l LiveAPI) Stop(ctx context.Context, app string) error

Stop stops app.

type LogKind

type LogKind int

LogKind selects which resource a log stream tails.

const (
	LogApp LogKind = iota
	LogDatabase
)

Log stream sources.

type LogLine

type LogLine struct {
	Text   string
	Stream string
}

LogLine is one streamed log line.

type MeshInfo

type MeshInfo struct {
	Enabled bool
	Peers   int
	Healthy int
}

MeshInfo is the header's mesh summary.

type Model

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

Model is the Bubble Tea model for the whole UI.

func New

func New(ctx context.Context, api API, opts Options) Model

New builds a Model; ctx bounds every background call it makes.

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the first fetches and the refresh ticker.

func (Model) Update

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

Update routes messages to the handlers below.

func (Model) View

func (m Model) View() string

View renders header, tabs, body and footer to exactly m.h lines.

type NodeRow

type NodeRow struct {
	Name        string
	Address     string
	Status      string
	Schedulable bool
	Local       bool
	LastSeen    time.Time
}

NodeRow is one node in the nodes view.

type Options

type Options struct {
	Prog      string
	Profile   string
	Host      string
	ReadOnly  bool
	Color     bool
	Refresh   time.Duration
	SlowEvery int
	LogBuffer int
	Now       func() time.Time
}

Options configures a Model. Zero values pick sane defaults.

type Row

type Row struct {
	Key   string
	Ref   string
	Cells []Cell
}

Row is one table row; Key identifies the resource and Ref names the app a drill-down should open (empty when there is none).

type ServerInfo

type ServerInfo struct {
	Version         string
	UpdateAvailable bool
}

ServerInfo is the header's control plane summary.

type Slow

type Slow struct {
	Databases []DBRow
	Nodes     []NodeRow
	Domains   []DomainRow
	Backups   []BackupRow
	Mesh      MeshInfo
	Server    ServerInfo
	Errs      map[string]string
}

Slow is the data refreshed every few ticks.

type Tone

type Tone int

Tone is the dashboard's status colour vocabulary (web/src/components/kit/tone.ts).

const (
	ToneNeutral Tone = iota
	ToneSuccess
	ToneWarning
	ToneDanger
	ToneInfo
)

Tones, in the dashboard's own order.

Jump to

Keyboard shortcuts

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