model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package model defines the core domain types for scry.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOversized  = errors.New("patch exceeds size threshold")
	ErrBinaryFile = errors.New("binary file")
	ErrSubmodule  = errors.New("submodule change")
)

Sentinel errors for PatchService edge cases.

Functions

This section is empty.

Types

type AppState

type AppState struct {
	Compare          ResolvedCompare
	Files            []FileSummary
	SelectedFile     int // Index into Files. -1 when Files is empty.
	Patches          map[string]PatchLoadState
	CacheGeneration  int
	IgnoreWhitespace bool
	SearchQuery      string
	FocusPane        Pane
}

AppState is the top-level UI state threaded through the Bubble Tea model.

type CompareMode

type CompareMode string
const (
	CompareThreeDot CompareMode = "three-dot"
	CompareTwoDot   CompareMode = "two-dot"
)

type CompareRequest

type CompareRequest struct {
	Repo             RepoContext
	BaseRef          string
	HeadRef          string
	Mode             CompareMode
	IgnoreWhitespace bool
}

type DiffLine

type DiffLine struct {
	Kind  LineKind
	OldNo *int
	NewNo *int
	Text  string
}

type FilePatch

type FilePatch struct {
	Summary FileSummary
	Hunks   []Hunk
}

type FileStatus

type FileStatus string
const (
	StatusAdded    FileStatus = "A"
	StatusModified FileStatus = "M"
	StatusDeleted  FileStatus = "D"
	StatusRenamed  FileStatus = "R"
	StatusCopied   FileStatus = "C"
	StatusTypeChg  FileStatus = "T"
	StatusUnmerged FileStatus = "U"
)

type FileSummary

type FileSummary struct {
	Path        string
	OldPath     string
	Status      FileStatus
	Additions   int
	Deletions   int
	IsBinary    bool
	IsSubmodule bool
}

type Hunk

type Hunk struct {
	Header           string
	OldStart, OldLen int
	NewStart, NewLen int
	Lines            []DiffLine
}

type LineKind

type LineKind string
const (
	LineContext   LineKind = "context"
	LineAdded     LineKind = "added"
	LineDeleted   LineKind = "deleted"
	LineNoNewline LineKind = "no-newline"
)

type LoadStatus

type LoadStatus string

LoadStatus tracks the lifecycle of an async patch load.

const (
	LoadIdle    LoadStatus = "idle"
	LoadLoading LoadStatus = "loading"
	LoadLoaded  LoadStatus = "loaded"
	LoadFailed  LoadStatus = "failed"
)

type Pane

type Pane string

Pane identifies a UI focus area.

const (
	PaneFiles  Pane = "files"
	PanePatch  Pane = "patch"
	PaneSearch Pane = "search"
)

type PatchLoadState

type PatchLoadState struct {
	Status     LoadStatus
	Patch      *FilePatch
	Err        error
	Generation int
}

PatchLoadState holds the result of loading a single file's patch.

type RepoContext

type RepoContext struct {
	WorktreeRoot     string // git rev-parse --show-toplevel
	GitDir           string // git rev-parse --absolute-git-dir (per-worktree)
	GitCommonDir     string // git rev-parse --git-common-dir (shared across worktrees)
	IsLinkedWorktree bool   // GitDir != GitCommonDir after path canonicalization
}

RepoContext is resolved once at startup via git rev-parse. In a linked worktree, .git is a file (not a directory), so code must NEVER construct paths via WorktreeRoot + ".git" + "...".

type ResolvedCompare

type ResolvedCompare struct {
	Repo      RepoContext
	BaseRef   string
	HeadRef   string
	MergeBase string // SHA of merge-base in three-dot mode; empty string in two-dot mode.
	DiffRange string // Range string passed to git diff: "base...head" or "base..head".
}

Jump to

Keyboard shortcuts

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