watch

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package watch provides fingerprint calculation and tick scheduling for watch mode. It detects repository state changes by computing fingerprints and comparing them across ticks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCmd

func CheckCmd(ctx context.Context, f *Fingerprinter, baseRef string, workingTree bool) tea.Cmd

CheckCmd returns a tea.Cmd that computes the fingerprint asynchronously. The provided context allows cancellation on app shutdown.

func ShouldRefresh

func ShouldRefresh(state *model.AppState, newFingerprint string) bool

ShouldRefresh returns true when the fingerprint has changed and no refresh is already in flight. This implements the debounce/in-flight rule: skip refresh while one is running, reevaluate on next tick.

func TickCmd

func TickCmd(interval time.Duration) tea.Cmd

TickCmd returns a tea.Cmd that sends a TickMsg after the given interval.

Types

type FingerprintMsg

type FingerprintMsg struct {
	Fingerprint string
	Err         error
}

FingerprintMsg carries the result of a fingerprint check.

type Fingerprinter

type Fingerprinter struct {
	Runner gitexec.GitRunner
}

Fingerprinter computes a change fingerprint for the current repo state. The fingerprint is compare-mode aware:

  • Committed-ref mode: concatenates rev-parse of HEAD and base ref.
  • Working-tree mode: additionally incorporates git diff --name-only HEAD to detect staged/unstaged edits.

func (*Fingerprinter) Fingerprint

func (f *Fingerprinter) Fingerprint(ctx context.Context, baseRef string, workingTree bool) (string, error)

Fingerprint returns a string that changes whenever the repository state relevant to the current compare changes. baseRef must be a symbolic ref (e.g., "origin/main") so that rev-parse resolves it live on each tick. Passing an already-resolved SHA would make the base half of the fingerprint static.

type TickMsg

type TickMsg struct {
	At time.Time
}

TickMsg is sent on each watch interval to trigger a fingerprint check.

Jump to

Keyboard shortcuts

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