Documentation
¶
Overview ¶
Package model defines the core domain types for scry.
Index ¶
- Variables
- type AppState
- type CommitState
- type CompareMode
- type CompareRequest
- type DashboardState
- type DiffLine
- type FilePatch
- type FileStatus
- type FileSummary
- type Hunk
- type LayoutMode
- type LineKind
- type LoadStatus
- type Pane
- type PatchLoadState
- type PreviewEntry
- type RepoContext
- type ResolvedCompare
- type WorktreeInfo
Constants ¶
This section is empty.
Variables ¶
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
Layout LayoutMode
// Watch mode state (v0.2).
WatchEnabled bool
WatchInterval time.Duration
LastFingerprint string
RefreshInFlight bool
LastRefreshAt time.Time
// Commit generation state (v0.2).
CommitEnabled bool
CommitAuto bool
CommitState CommitState
// Freshness tracking (v0.3).
GroupByDirectory bool // config-driven directory grouping in file list
FileChangeGen map[string]int // path → CacheGeneration when file last changed
FlaggedFiles map[string]bool // session-scoped file bookmarks
// Worktree dashboard mode (v0.2).
WorktreeMode bool
DashboardState DashboardState
}
AppState is the top-level UI state threaded through the Bubble Tea model.
type CommitState ¶ added in v0.2.0
type CommitState struct {
GeneratedMessage string
Provider string
InFlight bool
Err error
Generation int // monotonic counter to discard stale async results
// Execution state (V2-T8).
Executing bool
CommitSHA string
CommitErr error
}
CommitState holds the state of AI commit message generation and execution.
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 DashboardState ¶ added in v0.2.0
type DashboardState struct {
Worktrees []WorktreeInfo
SelectedIdx int
ScrollOffset int
DrillDown bool // true when viewing a worktree's diff
DrillGeneration int // monotonic counter to discard stale drill-down results
RefreshGeneration int // monotonic counter to discard stale worktree refresh results
// Preview pane state.
PreviewCache map[string]PreviewEntry // cache key (snap) → preview data
PreviewFiles []FileSummary // current selection's preview (for rendering)
// Deletion state.
ConfirmDelete bool // true when awaiting deletion confirmation
DeletePath string // path of worktree to delete
DeleteBranch string // branch name of worktree being deleted
DeleteDirty bool // true if the worktree is dirty (requires force)
DeleteErr string // error message from failed deletion
DeleteIsMain bool // true if user tried to delete main worktree
DeleteInFlight bool // true while async deletion is running
}
DashboardState holds the state for the worktree dashboard view.
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" StatusUntracked FileStatus = "?" )
type FileSummary ¶
type LayoutMode ¶ added in v0.2.0
type LayoutMode string
LayoutMode controls the overall pane arrangement.
const ( LayoutModal LayoutMode = "modal" LayoutSplit LayoutMode = "split" )
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 PaneDashboard Pane = "dashboard"
PaneDashboard is the focus pane for worktree dashboard mode.
type PatchLoadState ¶
type PatchLoadState struct {
Status LoadStatus
Patch *FilePatch
Err error
Generation int
ContentHash string // SHA-256 of patch content for scroll preservation
}
PatchLoadState holds the result of loading a single file's patch.
type PreviewEntry ¶ added in v0.3.0
type PreviewEntry struct {
Files []FileSummary
}
PreviewEntry holds cached preview data for a worktree.
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
WorkingTree bool // true when diffing against the working tree (no head ref).
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", "base..head", or just "base" in working tree mode.
WatchBaseRef string // Symbolic base ref for watch fingerprinting (e.g. "origin/main"); empty when @{upstream} was used.
}
type WorktreeInfo ¶ added in v0.2.0
type WorktreeInfo struct {
Path string // absolute path
Branch string // short branch name (e.g. "main", "feature")
CommitHash string // short commit hash
Subject string // first line of commit message
Dirty bool // true if worktree has uncommitted changes
Bare bool // true if bare worktree
ChangedFiles int // number of changed files from git status
HeadCommittedAt time.Time // committer date of HEAD commit (git-based staleness)
LastActivityAt time.Time // updated when snapshot state changes (dirty, count, commit)
}
WorktreeInfo holds the display state for a single worktree in the dashboard.