tui

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tui is sitrep's full-screen dashboard: tabs for a Watch view and a Top view, a detail pane, jumping to a session's terminal, and the queue and prune screens. It reads a snapshot from an Engine and changes state only by running the same fixed sitrep commands, after a confirm, through that Engine; --read-only turns every one of them off.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Frame

func Frame(ctx context.Context, eng Engine, tab string, width int, showEnded bool) (string, error)

Frame is one frame of a tab as plain text, for `sitrep status`.

func Run

func Run(opts Options, eng Engine) error

Run shows the dashboard until the user quits.

Types

type Engine

type Engine struct {
	// Snapshot reads everything: all sessions, every queue item.
	Snapshot func(ctx context.Context) (snapshot.Snapshot, error)
	// Command runs one fixed sitrep command line (without the program name) and returns what it printed. An error carries its message.
	Command func(ctx context.Context, args ...string) (string, error)
}

Engine is what the dashboard gets its data from and acts through.

type Hidden

type Hidden struct {
	Ended         int `json:"ended"`
	StrandedItems int `json:"stranded_items"`
}

type Options

type Options struct {
	Tab        string // watch or top
	Interval   time.Duration
	ReadOnly   bool
	NoBell     bool
	QuitOnJump bool
}

Options are the dashboard's settings.

type Queue

type Queue struct {
	Count int      `json:"count"`
	Items []string `json:"items"`
}

type Session

type Session struct {
	ID           string `json:"id"`
	Short        string `json:"short"`
	Dir          string `json:"dir"`
	Cwd          string `json:"cwd"`
	Running      bool   `json:"running"`
	State        string `json:"state"`
	StateLabel   string `json:"state_label"`
	Age          int64  `json:"age"`
	StateChanged int64  `json:"state_changed"`
	Idle         bool   `json:"idle"`
	NeedsInput   bool   `json:"needs_input"`
	Snoozed      bool   `json:"snoozed"`
	QuietSecs    *int64 `json:"quiet_secs"`
	PID          *int64 `json:"pid"`
	Pinned       bool   `json:"pinned"`
	Highlight    bool   `json:"highlight"`
	Objective    string `json:"objective"`
	Progress     string `json:"progress"`
	Now          string `json:"now"`
	Queue        Queue  `json:"queue"`
}

type Settings

type Settings struct {
	QueueItems       int    `json:"queue_items"`
	HighlightSeconds int    `json:"highlight_seconds"`
	HighlightSGR     string `json:"highlight_sgr"`
}

type Snapshot

type Snapshot struct {
	Version   int       `json:"version"`
	Generated int64     `json:"generated"`
	Registry  string    `json:"registry"`
	Settings  Settings  `json:"settings"`
	Inbox     Queue     `json:"inbox"`
	Hidden    Hidden    `json:"hidden"`
	Sessions  []Session `json:"sessions"`
}

Snapshot is the document `sitrep ls --json -a` prints.

func FromSnapshot

func FromSnapshot(s snapshot.Snapshot) Snapshot

FromSnapshot makes the dashboard's own copy of a snapshot, cleaned again as everything it shows is.

type Theme

type Theme struct {
	Tab, TabActive, Rule, Label, Dim, Err, Status, StatusKey, Hot, Attn lipgloss.Style
	Plain                                                               bool
}

Theme holds every style the views use. The plain theme has none, so tests compare text.

Jump to

Keyboard shortcuts

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