tui

package
v0.0.0-...-772874b Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultReviewerInstructions = `` /* 370-byte string literal not displayed */

DefaultReviewerInstructions is the default content shown in the context input textarea. Users can edit or extend these instructions before generating a review.

Variables

This section is empty.

Functions

func CalcDescriptionPadding

func CalcDescriptionPadding(width int) int

CalcDescriptionPadding returns the horizontal padding for the description pane. Uses capped linear scaling: padding grows with width but caps at a maximum.

func CalcScrollbar

func CalcScrollbar(totalItems, visibleCount, scrollOffset, scrollAreaHeight int) (start, height int)

CalcScrollbar returns scrollbar start position and height.

func CalculateScrollOffset

func CalculateScrollOffset(currentOffset, selectedIndex, totalItems, visibleCount int) int

CalculateScrollOffset returns the scroll offset needed to keep selectedIndex visible.

func DefaultLookPath

func DefaultLookPath(file string) (string, error)

DefaultLookPath uses exec.LookPath to find commands on PATH

func EstimateFilesVisibleCount

func EstimateFilesVisibleCount(panelHeight int) int

EstimateFilesVisibleCount estimates how many files fit in the panel. Each file takes 1 line. Subtract 1 for the position indicator at the bottom.

func EstimateSectionRenderCount

func EstimateSectionRenderCount(panelHeight int) int

EstimateSectionRenderCount estimates how many sections to render. Each section/chapter header takes 1 line (narratives are in Description panel).

func EstimateSectionVisibleCount

func EstimateSectionVisibleCount(panelHeight int) int

EstimateSectionVisibleCount estimates how many sections fit in the panel. Each section/chapter header takes 1 line (narratives are in Description panel). Used for scroll triggering.

func ScrollOffset

func ScrollOffset(current, delta, totalItems, visibleCount int) int

ScrollOffset adjusts an offset by delta, clamping to valid range. Used for mouse scroll handling in section and files panels.

func ToggleCollapse

func ToggleCollapse(collapsed CollapsedPaths, path string)

func Truncate

func Truncate(s string, maxLen int) string

Truncate shortens a string to maxLen, adding "…" if truncated

func TruncatePathMiddle

func TruncatePathMiddle(path string, maxWidth int) string

TruncatePathMiddle truncates a path by replacing middle directories with "..." Example: "src/components/auth/middleware/validate.ts" -> "src/.../validate.ts"

Types

type CheckUntrackedMsg

type CheckUntrackedMsg struct {
	Files []string
	Err   error
}

CheckUntrackedMsg delivers the result of checking for untracked files

type ClearStatusMsg

type ClearStatusMsg struct{}

ClearStatusMsg is sent to clear the status bar message

type CollapsedPaths

type CollapsedPaths map[string]bool

type CommitInfo

type CommitInfo struct {
	Hash    string
	Subject string
	Age     string
}

CommitInfo holds metadata about a git commit

type CommitListErrorMsg

type CommitListErrorMsg struct {
	Err error
}

CommitListErrorMsg indicates failure to load commit list

type CommitListMsg

type CommitListMsg struct {
	Commits []CommitInfo
}

CommitListMsg delivers the list of recent commits

type DiffSource

type DiffSource struct {
	Label            string
	CommandHint      string // Git command shown in parentheses (styled dimmer)
	Command          []string
	NeedsCommit      bool // true for "Specific commit"
	NeedsCommitRange bool // true for "Commit range"
}

DiffSource represents a source of diff content for review generation

func DefaultDiffSources

func DefaultDiffSources() []DiffSource

DefaultDiffSources returns the standard set of diff sources

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg is sent when an error should be displayed in the status bar

type FileNode

type FileNode struct {
	Name     string
	FullPath string
	IsDir    bool
	Children []*FileNode
}

func BuildFileTree

func BuildFileTree(paths []string) *FileNode

func Flatten

func Flatten(root *FileNode, collapsed CollapsedPaths) []*FileNode

type FilterLevel

type FilterLevel int

FilterLevel represents the importance filter threshold

const (
	FilterLevelLow    FilterLevel = iota // Show all hunks
	FilterLevelMedium                    // Show medium + high importance
	FilterLevelHigh                      // Show only high importance
)

func (FilterLevel) Next

func (f FilterLevel) Next() FilterLevel

func (FilterLevel) PassesFilter

func (f FilterLevel) PassesFilter(importance string) bool

func (FilterLevel) String

func (f FilterLevel) String() string

type GenerateCancelledMsg

type GenerateCancelledMsg struct{}

GenerateCancelledMsg indicates user cancelled generation

type GenerateErrorMsg

type GenerateErrorMsg struct {
	Err error
}

GenerateErrorMsg indicates LLM generation failed

type GenerateNeedsRetryMsg

type GenerateNeedsRetryMsg struct {
	Hunks      []diff.ParsedHunk
	MissingIDs []string
	Context    string
}

GenerateNeedsRetryMsg indicates validation failed and retry is needed

type GenerateParams

type GenerateParams struct {
	DiffCommand []string
	LLMCommand  []string // Resolved LLM command to use
	Context     string
	IsRetry     bool
	MissingIDs  []string
	ParsedHunks []diff.ParsedHunk // Set on retry to avoid re-parsing
}

GenerateParams holds parameters for review generation

type GenerateSuccessMsg

type GenerateSuccessMsg struct{}

GenerateSuccessMsg signals that LLM generation completed successfully. The review is written to disk and will be delivered via the watcher.

type GenerateUIState

type GenerateUIState int

GenerateUIState represents the current state of the generate flow

const (
	GenerateUIStateNone GenerateUIState = iota
	GenerateUIStateSourcePicker
	GenerateUIStateCommitSelector
	GenerateUIStateCommitRangeStart
	GenerateUIStateCommitRangeEnd
	GenerateUIStateContextInput
	GenerateUIStateValidationError
	GenerateUIStateUntrackedWarning
)

type GenerateValidationFailedMsg

type GenerateValidationFailedMsg struct {
	Hunks      []diff.ParsedHunk
	Missing    []string
	Duplicates []string
	Invalid    []string
	Response   *LLMResponse // The partial response for "proceed with partial" option
}

GenerateValidationFailedMsg indicates validation failed after retry

type Keybinding

type Keybinding struct {
	Key         string
	Description string
	Context     string // "global", "navigation", "files"
}

Keybinding represents a single keyboard shortcut

type KeybindingRegistry

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

KeybindingRegistry holds all registered keybindings

func NewKeybindingRegistry

func NewKeybindingRegistry() *KeybindingRegistry

NewKeybindingRegistry creates an empty registry

func (*KeybindingRegistry) GetAll

func (r *KeybindingRegistry) GetAll() []Keybinding

GetAll returns all registered keybindings

func (*KeybindingRegistry) GetByContext

func (r *KeybindingRegistry) GetByContext(ctx string) []Keybinding

GetByContext returns keybindings for a specific context

func (*KeybindingRegistry) Register

func (r *KeybindingRegistry) Register(binding Keybinding)

Register adds a keybinding to the registry

type LLMChapter

type LLMChapter struct {
	ID       string       `json:"id"`
	Title    string       `json:"title"`
	Sections []LLMSection `json:"sections"`
}

LLMChapter represents a logical grouping of related sections

type LLMCommandResult

type LLMCommandResult struct {
	Command []string
	Error   string
}

LLMCommandResult represents the result of resolving the LLM command

func ResolveLLMCommand

func ResolveLLMCommand(cfg *config.Config, lookPath LookPathFunc) LLMCommandResult

ResolveLLMCommand determines which LLM command to use. If config has an explicit llmCommand, it validates that command exists. If no llmCommand is configured, it checks for claude on PATH.

type LLMHunkRef

type LLMHunkRef struct {
	ID         string `json:"id"`
	Importance string `json:"importance"`
	IsTest     *bool  `json:"isTest,omitempty"`
}

LLMHunkRef references a hunk by ID with its classified importance

type LLMResponse

type LLMResponse struct {
	Title    string       `json:"title"`
	Chapters []LLMChapter `json:"chapters"`
}

LLMResponse is the classification returned by the LLM

type LLMSection

type LLMSection struct {
	ID    string       `json:"id"`
	Title string       `json:"title"`
	What  string       `json:"what"`
	Why   string       `json:"why"`
	Hunks []LLMHunkRef `json:"hunks"`
}

LLMSection represents a classified section from the LLM

type LookPathFunc

type LookPathFunc func(file string) (string, error)

LookPathFunc is a function type for looking up commands on PATH

type Model

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

func NewModel

func NewModel(workDir string, cfg *config.Config, store *storage.Store, logger *slog.Logger, opts ...ModelOption) Model

func (Model) Commits

func (m Model) Commits() []CommitInfo

Commits returns the loaded commit list (for testing)

func (Model) FilesScrollOffset

func (m Model) FilesScrollOffset() int

func (Model) FilterLevel

func (m Model) FilterLevel() FilterLevel

func (Model) FlattenedFilesCount

func (m Model) FlattenedFilesCount() int

func (Model) FocusedPanel

func (m Model) FocusedPanel() Panel

func (Model) GenerateUIState

func (m Model) GenerateUIState() GenerateUIState

func (Model) Height

func (m Model) Height() int

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) IsGenerating

func (m Model) IsGenerating() bool

func (Model) Ready

func (m Model) Ready() bool

func (Model) Review

func (m Model) Review() *model.Review

func (Model) SectionScrollOffset

func (m Model) SectionScrollOffset() int

func (Model) Selected

func (m Model) Selected() int

func (Model) SelectedFile

func (m Model) SelectedFile() int

func (Model) SetCancelFunc

func (m Model) SetCancelFunc(cancel func()) Model

SetCancelFunc is a test helper to set a cancel function

func (Model) SetFilesScrollOffset

func (m Model) SetFilesScrollOffset(offset int) Model

SetFilesScrollOffset is a test helper to set the files scroll offset

func (Model) SetGenerating

func (m Model) SetGenerating(generating bool) Model

SetGenerating is a test helper to set the generating state

func (Model) SetSectionScrollOffset

func (m Model) SetSectionScrollOffset(offset int) Model

SetSectionScrollOffset is a test helper to set the section scroll offset

func (Model) SetSelectedDiffSource

func (m Model) SetSelectedDiffSource() Model

SetSelectedDiffSource is a test helper to set a default diff source

func (Model) SetShowCancelPrompt

func (m Model) SetShowCancelPrompt(show bool) Model

SetShowCancelPrompt is a test helper to set the cancel prompt state

func (Model) SetUntrackedWarningState

func (m Model) SetUntrackedWarningState(files []string) Model

SetUntrackedWarningState is a test helper to set the untracked warning state

func (Model) ShowCancelPrompt

func (m Model) ShowCancelPrompt() bool

func (Model) ShowHelp

func (m Model) ShowHelp() bool

func (Model) StatusMsg

func (m Model) StatusMsg() string

func (Model) TestFilter

func (m Model) TestFilter() TestFilter

func (Model) Update

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

func (Model) View

func (m Model) View() string

func (Model) ViewportYOffset

func (m Model) ViewportYOffset() int

func (Model) Width

func (m Model) Width() int

func (Model) WorkDir

func (m Model) WorkDir() string

type ModelOption

type ModelOption func(*Model)

ModelOption configures a Model

func WithInitialReview

func WithInitialReview(review *model.Review) ModelOption

WithInitialReview sets an initial review to display (bypasses watcher)

func WithLookPath

func WithLookPath(lookPath LookPathFunc) ModelOption

WithLookPath sets a custom lookPath function (for testing)

type Panel

type Panel int
const (
	PanelDiff    Panel = 0
	PanelSection Panel = 1
	PanelFiles   Panel = 2
)

type ReviewClearedMsg

type ReviewClearedMsg struct{}

ReviewClearedMsg is sent when the review file is deleted

type ReviewReceivedMsg

type ReviewReceivedMsg struct {
	Review model.Review
}

ReviewReceivedMsg is sent when a review file is created/updated

type ScrollbarInfo

type ScrollbarInfo struct {
	Start  int // Line position where scrollbar starts (0-indexed from content top)
	Height int // Number of lines the scrollbar occupies
}

ScrollbarInfo contains the position and size of a scrollbar

type StageCompleteMsg

type StageCompleteMsg struct{}

StageCompleteMsg signals that git add completed successfully

type TestFilter

type TestFilter int
const (
	TestFilterAll       TestFilter = iota // Show all hunks
	TestFilterExcluding                   // Exclude test hunks
	TestFilterOnly                        // Show only test hunks
)

func (TestFilter) Next

func (f TestFilter) Next() TestFilter

func (TestFilter) PassesFilter

func (f TestFilter) PassesFilter(isTest *bool) bool

func (TestFilter) String

func (f TestFilter) String() string

type ValidationResult

type ValidationResult struct {
	Valid             bool
	MissingIDs        []string
	DuplicateIDs      []string
	InvalidImportance []string
}

ValidationResult holds the results of classification validation

type WatchErrorMsg

type WatchErrorMsg struct {
	Err error
}

WatchErrorMsg is sent when file watching fails

Jump to

Keyboard shortcuts

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