review

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package review implements the diff review panel for grut. It displays changed files with their diffs and supports hunk-level approve/reject decisions for structured code review workflows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSummary

func GenerateSummary(files []ReviewFile) string

GenerateSummary produces a structured plain-text summary of all review decisions. The output is designed for pasting into PR descriptions or review comments.

Types

type HunkState

type HunkState int

HunkState represents the review decision for a single diff hunk.

const (
	HunkPending  HunkState = iota // not yet reviewed
	HunkApproved                  // approved (to be staged)
	HunkRejected                  // rejected (to be unstaged/skipped)
)

type Panel

type Panel struct {
	panels.BasePanel
	// contains filtered or unexported fields
}

Panel is the diff review panel. It displays changed files and their diffs, supporting hunk-level approve/reject decisions.

func New

func New(gc gitOps) *Panel

New creates a new review panel with the given git client. gc may be nil; the panel will show an error until a client is available.

func (*Panel) Init

func (p *Panel) Init(ctx context.Context) tea.Cmd

Init implements panels.Panel.

func (*Panel) KeyBindings

func (p *Panel) KeyBindings() []panels.KeyBinding

KeyBindings implements panels.Panel.

func (*Panel) SetActionsCfg

func (p *Panel) SetActionsCfg(cfg config.ActionsConfig)

SetActionsCfg stores the actions configuration for right-click menus.

func (*Panel) SetFiles

func (p *Panel) SetFiles(files []ReviewFile)

SetFiles directly injects review file data for testing. It resets cursor positions and rebuilds rendered lines.

func (*Panel) Update

func (p *Panel) Update(msg tea.Msg) (panels.Panel, tea.Cmd)

Update implements panels.Panel. It handles review-related messages and keyboard events for navigation, approve/reject, and summary display.

func (*Panel) View

func (p *Panel) View(width, height int) string

View implements panels.Panel. It renders the review panel content into the given width×height area.

type ReviewFile

type ReviewFile struct {
	Path       string
	HunkStates []HunkState // per-hunk decision state
	Diff       git.FileDiff
}

ReviewFile tracks review state for a single changed file.

Jump to

Keyboard shortcuts

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