tui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package tui provides terminal user interface components for interactive review.

Description

This package implements the interactive diff review TUI using bubbletea. It allows users to review, accept, reject, and edit proposed code changes before they are applied.

Thread Safety

TUI components are designed for single-threaded use within the bubbletea event loop. Do not access TUI state from multiple goroutines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffReviewConfig

type DiffReviewConfig struct {
	// Editor is the command to invoke for editing (default: $EDITOR or "vi").
	Editor string

	// ConfirmAcceptAll requires typing "yes" for Accept All (safety).
	ConfirmAcceptAll bool

	// ShowLineNumbers shows line numbers in diff output.
	ShowLineNumbers bool

	// ContextLines is the number of context lines to show around changes.
	ContextLines int

	// Width overrides terminal width (0 = auto-detect).
	Width int

	// Height overrides terminal height (0 = auto-detect).
	Height int
}

DiffReviewConfig configures the diff review TUI.

func DefaultDiffReviewConfig

func DefaultDiffReviewConfig() DiffReviewConfig

DefaultDiffReviewConfig returns sensible defaults.

type DiffReviewModel

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

DiffReviewModel is the bubbletea model for interactive diff review.

Description

Manages the state of the diff review session, including navigation, decisions, and rendering.

func NewDiffReviewModel

func NewDiffReviewModel(changes []*diff.ProposedChange, config DiffReviewConfig) DiffReviewModel

NewDiffReviewModel creates a new diff review model.

Inputs

  • changes: The proposed changes to review.
  • config: Configuration options.

Outputs

  • DiffReviewModel: Ready-to-use model for tea.NewProgram.

func (DiffReviewModel) Changes

func (m DiffReviewModel) Changes() []*diff.ProposedChange

Changes returns the changes with updated hunk statuses.

func (DiffReviewModel) Init

func (m DiffReviewModel) Init() tea.Cmd

Init implements tea.Model.

func (DiffReviewModel) Result

func (m DiffReviewModel) Result() *diff.ReviewResult

Result returns the review result after the TUI exits.

Description

Returns the current state of all decisions. If the TUI hasn't finished yet, this returns the decisions made so far.

func (DiffReviewModel) Update

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

Update implements tea.Model.

func (DiffReviewModel) View

func (m DiffReviewModel) View() string

View implements tea.Model.

type DoneMsg

type DoneMsg struct {
	Result *diff.ReviewResult
}

DoneMsg signals the review is complete.

type EditorResultMsg

type EditorResultMsg struct {
	FilePath string
	Content  string
	Err      error
}

EditorResultMsg contains the result of external editor invocation.

type ViewMode

type ViewMode int

ViewMode determines how changes are displayed.

const (
	// ViewFile shows entire file diff.
	ViewFile ViewMode = iota

	// ViewHunk shows individual hunks.
	ViewHunk

	// ViewSummary shows review summary.
	ViewSummary
)

Jump to

Keyboard shortcuts

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