tui

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = time.Now

Now is overridable in tests for stable staleness output.

Functions

This section is empty.

Types

type Layer

type Layer struct {
	Stack          string `json:"stack"`
	Position       int    `json:"position"`
	Branch         string `json:"branch"`
	Title          string `json:"title"` // PR title (shown in --all mode)
	PRNumber       int    `json:"pr_number"`
	PRState        string `json:"pr_state"`        // "OPEN", "MERGED", or ""
	CIStatus       string `json:"ci_status"`       // SUCCESS, FAILURE, PENDING, ""
	ReviewDecision string `json:"review_decision"` // APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, ""
	UpdatedAt      string `json:"updated_at"`      // RFC3339; "" if unknown
	// ChangesSinceReview is the number of commits added since the current
	// user's last review on this PR; 0 means "no prior review or no new
	// commits since."
	ChangesSinceReview int  `json:"changes_since_review"`
	IsCurrent          bool `json:"is_current"`
	NeedsSync          bool `json:"needs_sync"`
	Depth              int  `json:"depth"` // nesting depth for tree view (--all mode)
}

Layer is one branch in a stack, also used as JSON output.

type Model

type Model struct {
	// Layers and Cursor describe the currently visible view. When Tabs is
	// non-empty these mirror m.Tabs[m.ActiveTab] and are swapped on tab change.
	Layers []Layer
	Cursor int

	// Tabs, when set, enables the tab bar across the top. Leave nil for a
	// single-view TUI (e.g. cn status --all without tabs).
	Tabs      []Tab
	ActiveTab int

	// Updater is invoked to push a new PR title. If nil, the rename action is
	// disabled.
	Updater TitleUpdater
	// contains filtered or unexported fields
}

Model is the bubbletea model for cn status.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Result added in v0.1.3

func (m Model) Result() Result

func (Model) Update

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

func (Model) View

func (m Model) View() string

type PendingAction added in v0.1.3

type PendingAction int

PendingAction is an action the user triggered that the caller should run after the TUI exits.

const (
	ActionNone     PendingAction = iota
	ActionCheckout               // git checkout the selected branch
	ActionOpenPR                 // open the PR in the browser
	ActionSync                   // run cn sync from the selected branch
	ActionSubmit                 // run cn submit
	ActionViewDiff               // open PR diff in the chainrail viewer
)

type Result added in v0.1.3

type Result struct {
	Action   PendingAction
	Branch   string
	PRNumber int
}

Result is returned after the TUI exits and carries any pending action.

type Tab added in v0.1.5

type Tab struct {
	Label  string
	Layers []Layer
	Cursor int
}

Tab is one view in the status TUI (Mine / Review / All).

type TitleUpdater added in v0.1.5

type TitleUpdater func(ctx context.Context, number int, newTitle string) error

TitleUpdater pushes a new PR title to the remote. status.go wires this to the gh client; tests inject a fake.

Jump to

Keyboard shortcuts

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