Documentation
¶
Overview ¶
Package diffview renders unified diffs from `gh pr diff` in a TUI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCIRelated ¶ added in v0.1.17
IsCIRelated reports whether a path is one of the file kinds whose changes affect CI behavior (workflows, test/build configs, coverage).
Types ¶
type CIRisk ¶ added in v0.1.17
type CIRisk int
CIRisk classifies how a file affects CI confidence. Used to pin risky files to the top of the sidebar and to gate 100% progress.
type CISignal ¶ added in v0.1.17
type CISignal struct {
Risk CIRisk
Reasons []string // human-readable summary, e.g. "test marked .skip" or "continue-on-error added"
}
CISignal is a per-file detection result.
func DetectCIRisk ¶ added in v0.1.17
DetectCIRisk inspects a file's path and diff body for CI-related changes and returns a CISignal. Returns CIRiskNone for files that don't match any CI-relevant path pattern.
Content-level weakening signals are only inspected on workflow files (where they're unambiguous). For other config files we conservatively report CIRiskConfig — the reviewer's judgment is the gate.
type File ¶
File is one file's worth of changes from a unified diff.
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
Highlighter colorizes diff content lines using chroma based on file extension. Lexers and the formatter are looked up once per extension and reused. When NO_COLOR is set or the lexer is unknown, Highlight returns the input unchanged.
func NewHighlighter ¶
func NewHighlighter() *Highlighter
func (*Highlighter) Highlight ¶
func (h *Highlighter) Highlight(path, src string) string
Highlight returns the colorized form of src for the lexer matching path's extension. Falls back to src on any error or when disabled.
func (*Highlighter) HighlightWithBg ¶ added in v0.1.14
func (h *Highlighter) HighlightWithBg(path, src string, bg lipgloss.Color) string
HighlightWithBg tokenises src with the lexer for path and renders each token with both its syntax foreground AND the given diff background. This gives the hunk/diffs.com look where chroma's colors stay vivid on top of a soft +/- tint, without relying on fragile mid-stream ANSI rewriting.
Returns src wrapped in a single bg style if no lexer matches or highlighting is disabled. The caller is responsible for any extra padding needed to reach a target pane width.
type Line ¶
Line is one rendered line of the diff (file header, hunk header, or content). Kind drives coloring; Text is the raw text without trailing newline.
type Model ¶
type Model struct {
Title string // e.g. "#687 wall drawing UX"
Files []File
// BlobByPath maps file path -> blob SHA for the PR's current head, used
// to detect "changed since you checked" against persisted review state.
BlobByPath map[string]string
// CISignals records the per-file CI risk classification computed once
// at load time. Populated by ensureDetectors.
CISignals map[string]CISignal
// ReviewState is the loaded per-file checklist for this PR. Optional;
// when nil, review-tracking UI is hidden entirely. The owner+repo+number
// fields are kept here so Save can write back to the right key.
ReviewState *reviewstate.PRState
ReviewStore *reviewstate.Store
RepoOwner string
RepoName string
// contains filtered or unexported fields
}
Model is the bubbletea model for the PR diff viewer.