tui

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 38 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 the human review interface: a full-screen Bubble Tea program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(in io.Reader, out io.Writer, getenv func(string) string, title ConfirmHeading, screen *Screen) func(publish.Preview) (publish.Confirmation, error)

Confirm runs the confirmation view full screen for loupe publish. title is what the header names, which loupe publish builds from the run and the flags it was given. screen is nil except in a test, as Config.Screen is.

Types

type Config

type Config struct {
	Dir    string
	Getenv func(string) string
	Now    func() time.Time
	// Output is where the program draws; it decides which colors the terminal supports.
	Output io.Writer
	// GitHub is called when the human publishes and, with WatchPR, for each check of the live pull request. A failed
	// check only tags the header, so reviewing never needs credentials.
	GitHub func() (github.Client, error)
	// WatchPR re-reads the pull request while review is open (specs/050-pr-state-awareness). Only loupe review sets
	// it; the standalone confirmation and tests that publish do not.
	WatchPR bool
	// OpenURL opens the published review in a browser; nil offers no o on the published screen.
	OpenURL func(string) error
	// UpdateNotice, when set, shows when review opens.
	UpdateNotice string
	// Screen is set only by a test, to stand in for a terminal.
	Screen *Screen
}

type ConfirmHeading

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

ConfirmHeading is what the confirmation header names: the two things a wrong keypress could change, and where they go.

func ConfirmTitle

func ConfirmTitle(ref, action, inline string, comments int) ConfirmHeading

type ConfirmModel

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

ConfirmModel is the confirmation view as a program of its own, for loupe publish.

func NewConfirmModel

func NewConfirmModel(preview publish.Preview, getenv func(string) string, output io.Writer, title ConfirmHeading) *ConfirmModel

func (*ConfirmModel) Confirmed

func (c *ConfirmModel) Confirmed() bool

Confirmed is true only when the program ended on y or p.

func (*ConfirmModel) Init

func (c *ConfirmModel) Init() tea.Cmd

func (*ConfirmModel) Message

func (c *ConfirmModel) Message() string

Message is the opening prose the human typed, empty when they typed none.

func (*ConfirmModel) Update

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

func (*ConfirmModel) View

func (c *ConfirmModel) View() tea.View

type GlyphSet

type GlyphSet = style.GlyphSet

GlyphSet is the style package's, so both surfaces draw the same characters.

type Model

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

Model is the review program. It holds no lock: every decision goes through draft.Mutate at the displayed version.

func New

func New(cfg Config) (*Model, error)

func (*Model) Decide

func (m *Model) Decide(findingID string, fn func(*draft.Draft) error) (bool, error)

Decide applies fn to the finding as displayed and reports whether it was recorded. A refusal reloads the draft and becomes the notice, so the human sees the finding as it now is. Other findings the draft brings with it are named in m.elsewhere for the caller's notice.

func (*Model) Err

func (m *Model) Err() error

Err is the failure that ended the program, if any; refusals during review are notices, not errors.

func (*Model) Init

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

func (*Model) PublishedURL

func (m *Model) PublishedURL() string

PublishedURL is the review this program sent, empty when it sent none.

func (*Model) Returned

func (m *Model) Returned() (Returned, bool)

Returned reports the return this program made, if it made one.

func (*Model) StopWatching

func (m *Model) StopWatching()

StopWatching cancels a check in flight. The program calls nothing after it quits, so reviewSession calls this once the program has ended.

func (*Model) Update

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

func (*Model) View

func (m *Model) View() tea.View

func (*Model) WaitForSend

func (m *Model) WaitForSend()

WaitForSend blocks until a review the human confirmed has its outcome recorded, for when the program ended before that, as on a signal.

type Returned

type Returned struct {
	Applier            string
	Accepted, Rejected int
}

Returned is what a return in this program handed the applier, for the line review leaves in the terminal.

type Screen

type Screen struct{ Width, Height int }

Screen is a test's stand-in for a terminal, which bubbletea cannot ask for a size. The program starts at its size and drops no keys as it opens or moves to the next finding: those pauses guard a human's typeahead, and a test types only once the screen shows what it waits for.

Jump to

Keyboard shortcuts

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