Documentation
¶
Index ¶
- Constants
- func AgentHookSpoolDir() string
- func AppendCommandEnv(environ []string, env map[string]string) []string
- func BuildCommandEnv(branch, wtPath, repoKey, mainWorktreePath string) map[string]string
- func BuildCommandEnvWithContext(branch, wtPath, repoKey, mainWorktreePath string, lazyCtx LazyWorktreeContext) map[string]string
- func CompressStatusTree(node *StatusTreeNode)
- func DeleteCache(repoKey, worktreeDir string) error
- func DeleteSplittedNoteFile(pathTemplate, wtName string, env map[string]string) error
- func EditorCommand(cfg *config.AppConfig) string
- func EnvMapToList(env map[string]string) []string
- func ExpandWithEnv(input string, env map[string]string) string
- func FilterManagedCommandEnv(environ []string) []string
- func FormatNoteFile(note models.WorktreeNote) []byte
- func IsManagedCommandEnvKey(key string) bool
- func LoadAccessHistory(repoKey, worktreeDir string) (map[string]int64, error)
- func LoadCache(repoKey, worktreeDir string) ([]*models.WorktreeInfo, error)
- func LoadCommandHistory(repoKey, worktreeDir string) ([]string, error)
- func LoadWorktreeNotes(repoKey, worktreeDir, worktreeNotesPath, noteType string, ...) (map[string]models.WorktreeNote, error)
- func MigrateRepoNotesToSharedFile(repoKey, worktreeDir, worktreeNotesPath string) (int, error)
- func PagerCommand(cfg *config.AppConfig) string
- func PagerEnv(pager string) string
- func ParseAgentHookPayload(agent models.AgentKind, data []byte) (models.AgentHookEvent, error)
- func ParseNoteFile(data []byte) (models.WorktreeNote, error)
- func RecordAgentHookEvent(dir string, agent models.AgentKind, r io.Reader) error
- func RunWorktreeNoteScript(ctx context.Context, script string, input WorktreeNoteScriptInput) (string, error)
- func SaveAccessHistory(repoKey, worktreeDir string, history map[string]int64) error
- func SaveCache(repoKey, worktreeDir string, worktrees []*models.WorktreeInfo) error
- func SaveCommandHistory(repoKey, worktreeDir string, commands []string) error
- func SavePaletteHistory(repoKey, worktreeDir string, commands []CommandPaletteUsage) error
- func SaveWorktreeNote(...) error
- func SaveWorktreeNoteEntry(repoKey, worktreeDir, worktreeNotesPath, noteType, key string, ...) error
- func SaveWorktreeNotes(repoKey, worktreeDir, worktreeNotesPath, noteType string, ...) error
- func SortStatusTree(node *StatusTreeNode)
- func SplitRepoKey(repoKey string) (owner, repo string)
- func WorktreeNoteKey(repoKey, worktreeDir, worktreeNotesPath, worktreePath string) string
- func WriteAgentHookEvent(dir string, event models.AgentHookEvent) error
- type AgentAdapter
- type AgentHookService
- func (s *AgentHookService) Dir() string
- func (s *AgentHookService) Drain()
- func (s *AgentHookService) EnsureDir() error
- func (s *AgentHookService) HasLiveSessions() bool
- func (s *AgentHookService) PIDAlive(pid int) bool
- func (s *AgentHookService) RestoreSessions(previous map[string]*models.AgentSession)
- func (s *AgentHookService) States() []AgentHookState
- type AgentHookState
- type AgentProcess
- type AgentProcessService
- type AgentSessionService
- func NewAgentSessionService(logf func(string, ...any)) *AgentSessionService
- func NewAgentSessionServiceFromConfig(claudeRoot, piRoot string, logf func(string, ...any)) *AgentSessionService
- func NewAgentSessionServiceWithRoots(claudeRoot, piRoot string, logf func(string, ...any)) *AgentSessionService
- func NewAgentSessionServiceWithStore(claudeRoot, piRoot string, store SessionRegistryStore, ...) *AgentSessionService
- func (s *AgentSessionService) Refresh() ([]*models.AgentSession, error)
- func (s *AgentSessionService) RefreshWithProcesses(processes []*AgentProcess) ([]*models.AgentSession, error)
- func (s *AgentSessionService) Sessions() []*models.AgentSession
- func (s *AgentSessionService) SessionsForWorktree(worktreePath string) []*models.AgentSession
- func (s *AgentSessionService) SetHookService(hooks *AgentHookService)
- func (s *AgentSessionService) WatchRoots() []string
- type AgentWatchService
- func (w *AgentWatchService) NextEvent() <-chan struct{}
- func (w *AgentWatchService) PlanRefresh(now time.Time) RefreshPlan
- func (w *AgentWatchService) ResetWaiting()
- func (w *AgentWatchService) Start() (bool, error)
- func (w *AgentWatchService) Stop()
- func (w *AgentWatchService) TrailingRefreshFired(now time.Time)
- type AvatarCache
- type AvatarImage
- type CICheckCache
- type CIDataService
- type CIFetchResult
- type CIFetchService
- type CIIconProvider
- type CommandExecutor
- type CommandPaletteUsage
- type CreateFromChangesOptions
- type CreateOptions
- type FilterService
- func (f *FilterService) FilterQueryForTarget(target state.FilterTarget) string
- func (f *FilterService) HasActiveFilterForPane(paneIndex int) bool
- func (f *FilterService) SearchQueryForTarget(target state.SearchTarget) string
- func (f *FilterService) SetFilterQuery(target state.FilterTarget, query string)
- func (f *FilterService) SetSearchQuery(target state.SearchTarget, query string)
- type GitCIProvider
- type GitCommonDirResolver
- type GitService
- type GitWatchService
- func (w *GitWatchService) IsUnderRoot(path string) bool
- func (w *GitWatchService) MaybeWatchNewDir(path string)
- func (w *GitWatchService) NextEvent() <-chan struct{}
- func (w *GitWatchService) ResetWaiting()
- func (w *GitWatchService) ShouldRefresh(now time.Time) bool
- func (w *GitWatchService) Signal()
- func (w *GitWatchService) Start(ctx context.Context, cfg *config.AppConfig) (bool, error)
- func (w *GitWatchService) Stop()
- type HistoryService
- type LazyWorktreeContext
- type PRReviewerCache
- type Pager
- type PruneCandidate
- type RefreshPlan
- type ReviewerToken
- type SessionRegistryStore
- type StatusFile
- type StatusService
- type StatusTreeNode
- type WorktreeNoteScriptInput
- type WorktreeService
Constants ¶
const ( EnvWorktreeBranch = "WORKTREE_BRANCH" EnvMainWorktreePath = "MAIN_WORKTREE_PATH" EnvWorktreePath = "WORKTREE_PATH" EnvWorktreeName = "WORKTREE_NAME" EnvRepoName = "REPO_NAME" EnvRepoOwner = "REPO_OWNER" EnvRepoRepoName = "REPO_REPONAME" EnvLazyWorktreeType = "LAZYWORKTREE_TYPE" EnvLazyWorktreeNumber = "LAZYWORKTREE_NUMBER" EnvLazyWorktreeTemplate = "LAZYWORKTREE_TEMPLATE" EnvLazyWorktreeSuggestedName = "LAZYWORKTREE_SUGGESTED_NAME" EnvLazyWorktreeTitle = "LAZYWORKTREE_TITLE" EnvLazyWorktreeURL = "LAZYWORKTREE_URL" EnvLazyWorktreeDescription = "LAZYWORKTREE_DESCRIPTION" )
Environment variable names managed by LazyWorktree command execution.
const ( // DefaultReviewerCacheTTL is how long a successful reviewer lookup is reused. DefaultReviewerCacheTTL = 60 * time.Second // DefaultReviewerRetryBackoff is how long to wait before retrying a lookup // that failed, so a missing CLI or a broken connection is not hammered. DefaultReviewerRetryBackoff = 30 * time.Second )
const DefaultCICacheTTL = 30 * time.Second
DefaultCICacheTTL is the default time-to-live for CI cache entries.
const GitWatchDebounce = 600 * time.Millisecond
GitWatchDebounce is the debounce window for watcher events.
Variables ¶
This section is empty.
Functions ¶
func AgentHookSpoolDir ¶ added in v1.49.0
func AgentHookSpoolDir() string
AgentHookSpoolDir returns the directory where hook shims spool events.
func AppendCommandEnv ¶ added in v1.48.0
AppendCommandEnv appends generated command env after filtering stale managed values from the parent environment.
func BuildCommandEnv ¶
BuildCommandEnv builds environment variables for worktree commands.
func BuildCommandEnvWithContext ¶ added in v1.48.0
func BuildCommandEnvWithContext(branch, wtPath, repoKey, mainWorktreePath string, lazyCtx LazyWorktreeContext) map[string]string
BuildCommandEnvWithContext builds environment variables for worktree commands, including managed LAZYWORKTREE_* keys. Contextual values are empty when the source metadata is unavailable.
func CompressStatusTree ¶
func CompressStatusTree(node *StatusTreeNode)
CompressStatusTree squashes single-child directory chains (e.g., a/b/c becomes one node).
func DeleteCache ¶ added in v1.48.0
DeleteCache removes the on-disk worktree cache file for the given repo.
func DeleteSplittedNoteFile ¶ added in v1.42.0
DeleteSplittedNoteFile removes the note file for a specific worktree.
func EditorCommand ¶
EditorCommand determines the editor command to use.
func EnvMapToList ¶
EnvMapToList converts environment variables to KEY=VALUE pairs.
func ExpandWithEnv ¶
ExpandWithEnv expands environment variables using the provided map first.
func FilterManagedCommandEnv ¶ added in v1.48.0
FilterManagedCommandEnv removes lazyworktree-managed variables from environ.
func FormatNoteFile ¶ added in v1.42.0
func FormatNoteFile(note models.WorktreeNote) []byte
FormatNoteFile serialises a worktree note as YAML frontmatter + markdown body.
func IsManagedCommandEnvKey ¶ added in v1.48.0
IsManagedCommandEnvKey reports whether key is controlled by lazyworktree.
func LoadAccessHistory ¶
LoadAccessHistory loads access history from file.
func LoadCache ¶
func LoadCache(repoKey, worktreeDir string) ([]*models.WorktreeInfo, error)
LoadCache loads worktree data from the cache file.
func LoadCommandHistory ¶
LoadCommandHistory loads command history from file.
func LoadWorktreeNotes ¶ added in v1.35.0
func LoadWorktreeNotes(repoKey, worktreeDir, worktreeNotesPath, noteType string, env map[string]string) (map[string]models.WorktreeNote, error)
LoadWorktreeNotes loads worktree notes from file. When noteType is "splitted", notes are loaded from individual files matching the pathTemplate with env variables expanded. For other types (including empty), the existing onejson behaviour is used.
func MigrateRepoNotesToSharedFile ¶ added in v1.37.0
MigrateRepoNotesToSharedFile moves per-repo worktree notes into the shared notes file when worktreeNotesPath is configured. Old absolute-path keys are converted to repo-relative keys. Entries already present in the shared file with a newer UpdatedAt are preserved. The per-repo file is removed on success. Returns the number of migrated notes.
func PagerCommand ¶
PagerCommand determines the pager command to use.
func ParseAgentHookPayload ¶ added in v1.49.0
ParseAgentHookPayload converts a raw hook stdin payload into a spool event.
func ParseNoteFile ¶ added in v1.42.0
func ParseNoteFile(data []byte) (models.WorktreeNote, error)
ParseNoteFile parses a splitted note file (YAML frontmatter + markdown body).
func RecordAgentHookEvent ¶ added in v1.49.0
RecordAgentHookEvent reads a hook payload from r and spools it into dir. Hook commands run through an intermediate shell, so resolve the matching agent ancestor rather than recording the shell PID.
func RunWorktreeNoteScript ¶ added in v1.36.0
func RunWorktreeNoteScript(ctx context.Context, script string, input WorktreeNoteScriptInput) (string, error)
RunWorktreeNoteScript executes worktree_note_script and returns the generated note text.
func SaveAccessHistory ¶
SaveAccessHistory saves access history to file.
func SaveCache ¶
func SaveCache(repoKey, worktreeDir string, worktrees []*models.WorktreeInfo) error
SaveCache saves worktree data to the cache file.
func SaveCommandHistory ¶
SaveCommandHistory saves command history to file.
func SavePaletteHistory ¶
func SavePaletteHistory(repoKey, worktreeDir string, commands []CommandPaletteUsage) error
SavePaletteHistory saves palette usage history to file.
func SaveWorktreeNote ¶ added in v1.36.0
func SaveWorktreeNote(repoKey, worktreeDir, worktreeNotesPath, noteType, worktreePath, noteText string, env map[string]string) error
SaveWorktreeNote stores a single note for a worktree path. noteType and env are forwarded to LoadWorktreeNotes/SaveWorktreeNotes.
func SaveWorktreeNoteEntry ¶ added in v1.49.0
func SaveWorktreeNoteEntry(repoKey, worktreeDir, worktreeNotesPath, noteType, key string, notes map[string]models.WorktreeNote, env map[string]string) error
SaveWorktreeNoteEntry persists a single note entry identified by key. For splitted mode it writes or removes only that worktree's file, leaving other note files untouched so concurrent writers cannot be clobbered by a stale in-memory map. For other modes it saves the full map.
func SaveWorktreeNotes ¶ added in v1.35.0
func SaveWorktreeNotes(repoKey, worktreeDir, worktreeNotesPath, noteType string, notes map[string]models.WorktreeNote, env map[string]string) error
SaveWorktreeNotes saves worktree notes to file. When noteType is "splitted", notes are saved as individual files. For other types (including empty), the existing onejson behaviour is used.
func SortStatusTree ¶
func SortStatusTree(node *StatusTreeNode)
SortStatusTree sorts tree nodes: directories first, then alphabetically.
func SplitRepoKey ¶ added in v1.42.0
SplitRepoKey splits a repository key like "owner/repo" into owner and repo. If the key contains no slash, owner is empty and repo is the full key.
func WorktreeNoteKey ¶ added in v1.37.0
WorktreeNoteKey returns the storage key for a worktree note.
Default mode stores notes in per-repo files and uses full worktree paths as keys. Shared-file mode (worktreeNotesPath set) uses repo-relative keys for cross-system sync.
func WriteAgentHookEvent ¶ added in v1.49.0
func WriteAgentHookEvent(dir string, event models.AgentHookEvent) error
WriteAgentHookEvent atomically writes one event into the spool directory.
Types ¶
type AgentAdapter ¶ added in v1.46.0
type AgentAdapter interface {
Name() string
WatchRoot() string
Discover(
seen map[string]struct{},
cached func(path string, parse func() (*models.AgentSession, error)) (*models.AgentSession, error),
) ([]*models.AgentSession, error)
}
AgentAdapter abstracts per-agent transcript discovery so new agent types can be added without changing core logic.
type AgentHookService ¶ added in v1.49.0
type AgentHookService struct {
// contains filtered or unexported fields
}
AgentHookService drains spooled hook events and tracks per-session state.
func NewAgentHookService ¶ added in v1.49.0
func NewAgentHookService(dir string, logf func(format string, args ...any)) *AgentHookService
NewAgentHookService creates a hook service reading events from dir.
func (*AgentHookService) Dir ¶ added in v1.49.0
func (s *AgentHookService) Dir() string
Dir returns the spool directory this service consumes.
func (*AgentHookService) Drain ¶ added in v1.49.0
func (s *AgentHookService) Drain()
Drain consumes all pending spool files and folds them into session states.
func (*AgentHookService) EnsureDir ¶ added in v1.49.0
func (s *AgentHookService) EnsureDir() error
EnsureDir creates the hook spool before the watcher starts so the first event is observable even when the directory did not previously exist.
func (*AgentHookService) HasLiveSessions ¶ added in v1.49.0
func (s *AgentHookService) HasLiveSessions() bool
HasLiveSessions reports whether any hook-tracked session still has a live process.
func (*AgentHookService) PIDAlive ¶ added in v1.49.0
func (s *AgentHookService) PIDAlive(pid int) bool
PIDAlive reports whether the given hook-reported PID is still running.
func (*AgentHookService) RestoreSessions ¶ added in v1.49.0
func (s *AgentHookService) RestoreSessions(previous map[string]*models.AgentSession)
RestoreSessions rehydrates live hook state from the persisted session registry after a restart. Pending hook events always take precedence.
func (*AgentHookService) States ¶ added in v1.49.0
func (s *AgentHookService) States() []AgentHookState
States returns a snapshot of the current hook-tracked session states.
type AgentHookState ¶ added in v1.49.0
type AgentHookState struct {
Agent models.AgentKind
SessionID string
TranscriptPath string
CWD string
Model string
Source string
PID int
LastEventName string
LastEventAt time.Time
Ended bool
}
AgentHookState is the accumulated view of one hook-reported session.
type AgentProcess ¶ added in v1.43.0
type AgentProcess struct {
PID int
Agent models.AgentKind
Source string
Command string
Args string
CWD string
OpenFiles []string
}
AgentProcess describes a live agent process that may map to a session.
type AgentProcessService ¶ added in v1.43.0
type AgentProcessService struct {
// contains filtered or unexported fields
}
AgentProcessService snapshots live agent CLI processes (Claude, Codex, Copilot, and pi). The ps/lsof process scan is deprecated and opt-in via the agent_sessions.process_scan configuration key; hook events installed with `lazyworktree setup-hooks` are the default liveness source.
func NewAgentProcessService ¶ added in v1.43.0
func NewAgentProcessService(logf func(string, ...any)) *AgentProcessService
NewAgentProcessService builds a process service with the default command runner.
func NewAgentProcessServiceWithRunner ¶ added in v1.43.0
func NewAgentProcessServiceWithRunner(runCmd agentProcessRunner, logf func(string, ...any)) *AgentProcessService
NewAgentProcessServiceWithRunner builds a process service with an injected runner for tests.
func (*AgentProcessService) Processes ¶ added in v1.43.0
func (s *AgentProcessService) Processes() []*AgentProcess
Processes returns the last live-process snapshot.
func (*AgentProcessService) Refresh ¶ added in v1.43.0
func (s *AgentProcessService) Refresh() ([]*AgentProcess, error)
Refresh discovers live Claude, Codex, and pi processes.
type AgentSessionService ¶ added in v1.43.0
type AgentSessionService struct {
// contains filtered or unexported fields
}
AgentSessionService discovers Claude and pi transcript sessions from disk.
func NewAgentSessionService ¶ added in v1.43.0
func NewAgentSessionService(logf func(string, ...any)) *AgentSessionService
NewAgentSessionService builds a service using the default agent transcript locations.
func NewAgentSessionServiceFromConfig ¶ added in v1.43.0
func NewAgentSessionServiceFromConfig(claudeRoot, piRoot string, logf func(string, ...any)) *AgentSessionService
NewAgentSessionServiceFromConfig builds a service using config values when non-empty, falling back to the default agent transcript locations.
func NewAgentSessionServiceWithRoots ¶ added in v1.43.0
func NewAgentSessionServiceWithRoots(claudeRoot, piRoot string, logf func(string, ...any)) *AgentSessionService
NewAgentSessionServiceWithRoots builds a service with explicit roots for tests.
func NewAgentSessionServiceWithStore ¶ added in v1.46.0
func NewAgentSessionServiceWithStore(claudeRoot, piRoot string, store SessionRegistryStore, logf func(string, ...any)) *AgentSessionService
NewAgentSessionServiceWithStore builds a service with explicit roots and registry storage.
func (*AgentSessionService) Refresh ¶ added in v1.43.0
func (s *AgentSessionService) Refresh() ([]*models.AgentSession, error)
Refresh re-discovers all transcript sessions and updates the cache.
func (*AgentSessionService) RefreshWithProcesses ¶ added in v1.43.0
func (s *AgentSessionService) RefreshWithProcesses(processes []*AgentProcess) ([]*models.AgentSession, error)
RefreshWithProcesses re-discovers transcript sessions and enriches them with live-process matches.
func (*AgentSessionService) Sessions ¶ added in v1.43.0
func (s *AgentSessionService) Sessions() []*models.AgentSession
Sessions returns the last discovered sessions.
func (*AgentSessionService) SessionsForWorktree ¶ added in v1.43.0
func (s *AgentSessionService) SessionsForWorktree(worktreePath string) []*models.AgentSession
SessionsForWorktree returns sessions whose cwd is the selected worktree or a child directory.
func (*AgentSessionService) SetHookService ¶ added in v1.49.0
func (s *AgentSessionService) SetHookService(hooks *AgentHookService)
SetHookService attaches a hook spool consumer to the session service.
func (*AgentSessionService) WatchRoots ¶ added in v1.43.0
func (s *AgentSessionService) WatchRoots() []string
WatchRoots returns the directories that should be watched for transcript changes.
type AgentWatchService ¶ added in v1.43.0
type AgentWatchService struct {
Started bool
Waiting bool
Roots []string
// SpoolRoots is the subset of Roots that contain hook spool .json files.
// .json events are only accepted from these roots; all roots accept .jsonl.
SpoolRoots []string
Events chan struct{}
Done chan struct{}
Paths map[string]struct{}
Mu sync.Mutex
Watcher *fsnotify.Watcher
// Debounce throttles how often transcript-write bursts trigger a refresh.
// A value <= 0 disables throttling. See PlanRefresh.
Debounce time.Duration
LastRefresh time.Time
// contains filtered or unexported fields
}
AgentWatchService watches agent transcript directories for JSONL changes.
func NewAgentWatchService ¶ added in v1.43.0
func NewAgentWatchService(roots []string, debounce time.Duration, logf func(string, ...any)) *AgentWatchService
NewAgentWatchService creates a watcher for the provided roots. debounce bounds how often transcript-write events trigger a full session re-parse.
func (*AgentWatchService) NextEvent ¶ added in v1.43.0
func (w *AgentWatchService) NextEvent() <-chan struct{}
NextEvent returns the next watcher event channel if a wait is not already active.
func (*AgentWatchService) PlanRefresh ¶ added in v1.48.0
func (w *AgentWatchService) PlanRefresh(now time.Time) RefreshPlan
PlanRefresh decides how a watcher event should be handled. An active agent appends to its transcript many times per second; without throttling every append triggers a full re-parse of every session JSONL and pegs a CPU core. Outside the debounce window the event refreshes immediately (leading edge). Inside it the immediate refresh is dropped, but the first such event arms a single trailing-edge refresh at the end of the window so the final write of a burst still renders promptly rather than waiting for the periodic auto-refresh. A Debounce <= 0 disables throttling.
func (*AgentWatchService) ResetWaiting ¶ added in v1.43.0
func (w *AgentWatchService) ResetWaiting()
ResetWaiting clears the pending wait flag after an event is processed.
func (*AgentWatchService) Start ¶ added in v1.43.0
func (w *AgentWatchService) Start() (bool, error)
Start initialises the watcher and begins listening for transcript changes.
func (*AgentWatchService) Stop ¶ added in v1.43.0
func (w *AgentWatchService) Stop()
Stop stops the watcher and closes resources.
func (*AgentWatchService) TrailingRefreshFired ¶ added in v1.48.0
func (w *AgentWatchService) TrailingRefreshFired(now time.Time)
TrailingRefreshFired records that the scheduled trailing-edge refresh has run, clearing the pending flag and starting a fresh debounce window from now.
type AvatarCache ¶ added in v1.48.0
type AvatarCache struct {
// contains filtered or unexported fields
}
AvatarCache downloads and stores small PNG avatars for terminal rendering.
func NewAvatarCache ¶ added in v1.48.0
func NewAvatarCache(dir string) *AvatarCache
NewAvatarCache creates an avatar cache rooted at dir.
func NewDefaultAvatarCache ¶ added in v1.48.0
func NewDefaultAvatarCache() *AvatarCache
NewDefaultAvatarCache creates the default lazyworktree avatar cache.
func (*AvatarCache) Fetch ¶ added in v1.48.0
func (c *AvatarCache) Fetch(ctx context.Context, rawURL string) (*AvatarImage, error)
Fetch returns cached PNG avatar data, downloading and normalising it when needed.
type AvatarImage ¶ added in v1.48.0
AvatarImage is a terminal-ready PNG representation of an author avatar.
type CICheckCache ¶
type CICheckCache interface {
// Get retrieves cached CI checks for a branch.
// Returns the checks, fetch time, and whether the entry exists.
Get(branch string) ([]*models.CICheck, time.Time, bool)
// Set stores CI checks for a branch with the current timestamp.
Set(branch string, checks []*models.CICheck)
// Clear removes all cached entries.
Clear()
// IsFresh returns true if the cache entry exists and is within the TTL.
IsFresh(branch string, ttl time.Duration) bool
}
CICheckCache provides cache management for CI check data.
func NewCICheckCache ¶
func NewCICheckCache() CICheckCache
NewCICheckCache creates a new thread-safe CI check cache.
type CIDataService ¶
type CIDataService interface {
// Sort returns a copy of checks sorted with GitHub Actions first.
Sort(checks []*models.CICheck) []*models.CICheck
// StatusIcon returns the appropriate icon for CI status.
// Draft PRs show "D" instead of CI status.
StatusIcon(status string, isDraft, useIcons bool, iconProvider CIIconProvider) string
// ExtractRunID extracts the run ID from a GitHub Actions URL.
// Example: https://github.com/owner/repo/actions/runs/12345678/job/98765432 -> 12345678
ExtractRunID(link string) string
// ExtractJobID extracts the job ID from a GitHub Actions URL.
// Example: https://github.com/owner/repo/actions/runs/12345678/job/98765432 -> 98765432
ExtractJobID(link string) string
// ExtractRepo extracts the owner/repo from a GitHub URL.
// Example: https://github.com/owner/repo/actions/runs/12345678 -> owner/repo
ExtractRepo(link string) string
}
CIDataService provides stateless CI check operations.
func NewCIDataService ¶
func NewCIDataService() CIDataService
NewCIDataService creates a new CIDataService.
type CIFetchResult ¶
CIFetchResult contains the result of a CI status fetch operation.
type CIFetchService ¶
type CIFetchService interface {
// CreateFetchForPR creates a fetch function for PR-based CI status.
// The returned function can be called to perform the fetch and return a result.
CreateFetchForPR(ctx context.Context, git GitCIProvider, prNumber int, branch string) func() CIFetchResult
// CreateFetchForCommit creates a fetch function for commit-based CI status.
// The returned function can be called to perform the fetch and return a result.
CreateFetchForCommit(ctx context.Context, git GitCIProvider, worktreePath, branch string) func() CIFetchResult
}
CIFetchService creates commands for fetching CI status. This service abstracts the creation of fetch operations.
func NewCIFetchService ¶
func NewCIFetchService() CIFetchService
NewCIFetchService creates a new CIFetchService.
type CIIconProvider ¶
CIIconProvider provides CI status icons.
type CommandExecutor ¶
type CommandExecutor interface {
Run(cmd string, cwd string, env map[string]string) tea.Cmd
RunWithPager(cmd string, cwd string, env map[string]string) tea.Cmd
RunInteractive(cmd *exec.Cmd, callback tea.ExecCallback) tea.Cmd
}
CommandExecutor runs shell commands for the application.
type CommandPaletteUsage ¶
type CommandPaletteUsage struct {
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
Count int `json:"count"`
}
CommandPaletteUsage tracks usage frequency and recency for command palette items.
func LoadPaletteHistory ¶
func LoadPaletteHistory(repoKey, worktreeDir string) ([]CommandPaletteUsage, error)
LoadPaletteHistory loads palette usage history from file.
type CreateFromChangesOptions ¶
type CreateFromChangesOptions struct {
SourcePath string
NewBranch string
TargetPath string
CurrentBranch string
Env map[string]string
}
CreateFromChangesOptions contains parameters for creating a worktree from existing changes.
type CreateOptions ¶
CreateOptions contains parameters for worktree creation.
type FilterService ¶
type FilterService struct {
FilterQuery string
StatusFilterQuery string
LogFilterQuery string
WorktreeSearchQuery string
StatusSearchQuery string
LogSearchQuery string
}
FilterService stores filter and search queries by target.
func NewFilterService ¶
func NewFilterService(initialFilter string) *FilterService
NewFilterService creates a new FilterService with an optional initial filter.
func (*FilterService) FilterQueryForTarget ¶
func (f *FilterService) FilterQueryForTarget(target state.FilterTarget) string
FilterQueryForTarget returns the filter query for the given target.
func (*FilterService) HasActiveFilterForPane ¶
func (f *FilterService) HasActiveFilterForPane(paneIndex int) bool
HasActiveFilterForPane reports whether a pane has a non-empty filter applied.
func (*FilterService) SearchQueryForTarget ¶
func (f *FilterService) SearchQueryForTarget(target state.SearchTarget) string
SearchQueryForTarget returns the search query for the given target.
func (*FilterService) SetFilterQuery ¶
func (f *FilterService) SetFilterQuery(target state.FilterTarget, query string)
SetFilterQuery sets the filter query for the given target.
func (*FilterService) SetSearchQuery ¶
func (f *FilterService) SetSearchQuery(target state.SearchTarget, query string)
SetSearchQuery sets the search query for the given target.
type GitCIProvider ¶
type GitCIProvider interface {
// FetchCIStatus fetches CI status for a PR.
FetchCIStatus(ctx context.Context, prNumber int, branch string) ([]*models.CICheck, error)
// FetchCIStatusByCommit fetches CI status for a commit SHA.
FetchCIStatusByCommit(ctx context.Context, sha, path string) ([]*models.CICheck, error)
// GetHeadSHA returns the HEAD commit SHA for a worktree path.
GetHeadSHA(ctx context.Context, path string) string
// IsGitHub returns true if the repository is hosted on GitHub.
IsGitHub(ctx context.Context) bool
}
GitCIProvider defines the interface for git service CI operations. This interface enables dependency injection for testing CI-related functionality.
type GitCommonDirResolver ¶
type GitCommonDirResolver interface {
RunGit(ctx context.Context, args []string, cwd string, okReturncodes []int, strip, silent bool) string
}
GitCommonDirResolver resolves the git common directory for a repository.
type GitService ¶
type GitService interface {
RunGit(ctx context.Context, args []string, cwd string, okReturncodes []int, strip, silent bool) string
RunCommandChecked(ctx context.Context, args []string, cwd, errorPrefix string) bool
GetMainBranch(ctx context.Context) string
GetMergedBranches(ctx context.Context, baseBranch string) []string
RenameWorktree(ctx context.Context, oldPath, newPath, oldBranch, newBranch string) bool
ExecuteCommands(ctx context.Context, cmdList []string, cwd string, env map[string]string) error
RunGitWithCombinedOutput(ctx context.Context, args []string, cwd string, env map[string]string) ([]byte, error)
}
GitService defines the subset of git operations needed by WorktreeService.
type GitWatchService ¶
type GitWatchService struct {
Started bool
Waiting bool
CommonDir string
Roots []string
Events chan struct{}
Done chan struct{}
Paths map[string]struct{}
Mu sync.Mutex
Watcher *fsnotify.Watcher
LastRefresh time.Time
// contains filtered or unexported fields
}
GitWatchService manages git watcher state.
func NewGitWatchService ¶
func NewGitWatchService(git GitCommonDirResolver, logf func(string, ...any)) *GitWatchService
NewGitWatchService creates a new GitWatchService.
func (*GitWatchService) IsUnderRoot ¶
func (w *GitWatchService) IsUnderRoot(path string) bool
IsUnderRoot reports whether the path is under any watch root.
func (*GitWatchService) MaybeWatchNewDir ¶
func (w *GitWatchService) MaybeWatchNewDir(path string)
MaybeWatchNewDir registers newly created directories under watch roots.
func (*GitWatchService) NextEvent ¶
func (w *GitWatchService) NextEvent() <-chan struct{}
NextEvent returns the event channel if waiting is not already active.
func (*GitWatchService) ResetWaiting ¶
func (w *GitWatchService) ResetWaiting()
ResetWaiting clears the waiting flag after an event is processed.
func (*GitWatchService) ShouldRefresh ¶
func (w *GitWatchService) ShouldRefresh(now time.Time) bool
ShouldRefresh checks debounce timing for watcher events.
func (*GitWatchService) Signal ¶
func (w *GitWatchService) Signal()
Signal notifies listeners of watcher activity.
func (*GitWatchService) Stop ¶
func (w *GitWatchService) Stop()
Stop stops the watcher and closes channels.
type HistoryService ¶
type HistoryService interface {
LoadCommands(repoKey string) []string
SaveCommands(repoKey string, cmds []string)
AddCommand(repoKey string, cmd string)
LoadAccessHistory(repoKey string) map[string]int64
SaveAccessHistory(repoKey string, history map[string]int64)
RecordAccess(repoKey string, path string)
LoadPaletteHistory(repoKey string) []CommandPaletteUsage
SavePaletteHistory(repoKey string, commands []CommandPaletteUsage)
AddPaletteUsage(repoKey string, id string)
}
HistoryService persists command and palette history.
type LazyWorktreeContext ¶ added in v1.48.0
type LazyWorktreeContext struct {
Type string
Number string
Template string
SuggestedName string
Title string
URL string
Description string
}
LazyWorktreeContext holds optional source metadata exposed to command env.
func LazyWorktreeContextFromIssue ¶ added in v1.48.0
func LazyWorktreeContextFromIssue(issue *models.IssueInfo, template, suggestedName string) LazyWorktreeContext
LazyWorktreeContextFromIssue returns command context for issue-backed creation.
func LazyWorktreeContextFromPR ¶ added in v1.48.0
func LazyWorktreeContextFromPR(pr *models.PRInfo, template, suggestedName string) LazyWorktreeContext
LazyWorktreeContextFromPR returns command context for PR/MR-backed worktrees.
type PRReviewerCache ¶ added in v1.50.0
type PRReviewerCache interface {
// Get returns the cached summary for a key, if a lookup has succeeded.
Get(key string) (*models.PRReviewerSummary, bool)
// ShouldFetch reports whether a fresh lookup is warranted: no successful
// result within ttl, no failure within retryBackoff, and nothing in flight.
ShouldFetch(key string, ttl, retryBackoff time.Duration) bool
// MarkFetching claims a key for one lookup, returning false when another
// lookup already holds it.
MarkFetching(key string) (ReviewerToken, bool)
// Complete finishes the lookup a token was issued for, releasing the claim
// and recording the outcome. It does nothing when the token no longer owns
// the key, or when the cache has been invalidated since the token was
// issued.
Complete(token ReviewerToken, summary *models.PRReviewerSummary, err error)
// Invalidate makes every entry due for a fresh lookup and drops the results
// of anything still in flight. Summaries already fetched are kept, so a
// refresh that fails still has last known good reviewers to show.
Invalidate()
}
PRReviewerCache stores reviewer lookups for the worktree currently on screen.
func NewPRReviewerCache ¶ added in v1.50.0
func NewPRReviewerCache() PRReviewerCache
NewPRReviewerCache creates a thread-safe reviewer cache.
type Pager ¶
type Pager interface {
Show(content string, env []string, cwd string) tea.Cmd
ShowFileDiff(sf models.StatusFile, wt *models.WorktreeInfo) tea.Cmd
ShowCommitDiff(sha string, wt *models.WorktreeInfo) tea.Cmd
}
Pager defines how diffs and content are displayed.
type PruneCandidate ¶
type PruneCandidate struct {
Worktree *models.WorktreeInfo // nil for branch-only candidates
Branch string // branch name (always set)
Source string // "pr", "git", or "both"
}
PruneCandidate represents a worktree or stale branch that is a candidate for pruning.
func FindPruneCandidates ¶ added in v1.49.0
func FindPruneCandidates(worktrees []*models.WorktreeInfo, mergedBranches []string, includeStaleBranches bool) []PruneCandidate
FindPruneCandidates identifies merged worktrees and merged branches without worktrees from already-fetched repository state.
type RefreshPlan ¶ added in v1.48.0
type RefreshPlan struct {
// Now requests an immediate (leading-edge) refresh.
Now bool
// TrailingIn, when > 0, requests a single trailing-edge refresh scheduled
// this far in the future so the final write of a burst still renders without
// waiting for the periodic auto-refresh.
TrailingIn time.Duration
}
RefreshPlan describes how a watcher event should be handled.
type ReviewerToken ¶ added in v1.50.0
type ReviewerToken struct {
// contains filtered or unexported fields
}
ReviewerToken identifies one in-flight reviewer lookup. It is handed out by MarkFetching and handed back to Complete, which is how the cache tells a current response apart from one that was overtaken by events.
func (ReviewerToken) Key ¶ added in v1.50.0
func (t ReviewerToken) Key() string
Key returns the cache key the token was issued for.
func (ReviewerToken) Valid ¶ added in v1.50.0
func (t ReviewerToken) Valid() bool
Valid reports whether the token was issued by MarkFetching.
type SessionRegistryStore ¶ added in v1.46.0
type SessionRegistryStore interface {
Load() (map[string]*models.AgentSession, error)
Save(sessions []*models.AgentSession) error
}
SessionRegistryStore persists agent session metadata across restarts.
func NewTestSessionRegistryStore ¶ added in v1.46.0
func NewTestSessionRegistryStore(path string) SessionRegistryStore
NewTestSessionRegistryStore builds a registry store rooted at an explicit path for tests.
type StatusFile ¶
type StatusFile = models.StatusFile
StatusFile represents a file entry from git status.
type StatusService ¶
type StatusService struct {
Tree *StatusTreeNode
TreeFlat []*StatusTreeNode
CollapsedDirs map[string]bool
Index int
}
StatusService manages status tree state.
func NewStatusService ¶
func NewStatusService() *StatusService
NewStatusService creates a new StatusService.
func (*StatusService) ClampIndex ¶
func (s *StatusService) ClampIndex()
ClampIndex ensures Index is within the valid range for the flat list.
func (*StatusService) RebuildFlat ¶
func (s *StatusService) RebuildFlat()
RebuildFlat rebuilds the flattened tree representation.
func (*StatusService) RestoreSelection ¶
func (s *StatusService) RestoreSelection(path string)
RestoreSelection sets Index based on the provided path if it exists.
func (*StatusService) SelectedPath ¶
func (s *StatusService) SelectedPath() string
SelectedPath returns the path of the currently selected node.
func (*StatusService) ToggleCollapse ¶
func (s *StatusService) ToggleCollapse(path string)
ToggleCollapse toggles a directory collapse state and rebuilds the flat list.
type StatusTreeNode ¶
type StatusTreeNode struct {
Path string // Full path (e.g., "internal/app" or "internal/app/app.go")
File *StatusFile // nil for directories
Children []*StatusTreeNode // nil for files
Compression int // Number of compressed path segments (e.g., "a/b" = 1)
Depth int // Cached depth for rendering
}
StatusTreeNode represents a node in the status file tree (directory or file).
func BuildStatusTree ¶
func BuildStatusTree(files []StatusFile) *StatusTreeNode
BuildStatusTree builds a tree structure from a flat list of files. Files are grouped by directory, with directories sorted before files.
func FlattenStatusTree ¶
func FlattenStatusTree(node *StatusTreeNode, collapsed map[string]bool, depth int) []*StatusTreeNode
FlattenStatusTree returns visible nodes respecting collapsed state.
func (*StatusTreeNode) CollectFiles ¶
func (n *StatusTreeNode) CollectFiles() []*StatusFile
CollectFiles recursively collects all StatusFile pointers from this node and its children.
func (*StatusTreeNode) IsDir ¶
func (n *StatusTreeNode) IsDir() bool
IsDir returns true if this node is a directory.
func (*StatusTreeNode) Name ¶
func (n *StatusTreeNode) Name() string
Name returns the display name for this node.
type WorktreeNoteScriptInput ¶ added in v1.36.0
type WorktreeNoteScriptInput struct {
Content string
Type string
Number int
Title string
URL string
Description string
}
WorktreeNoteScriptInput contains the context passed to worktree_note_script.
type WorktreeService ¶
type WorktreeService interface {
// Create creates a new worktree.
Create(ctx context.Context, opts CreateOptions) error
// CreateFromChanges moves changes from an existing worktree to a new one.
CreateFromChanges(ctx context.Context, opts CreateFromChangesOptions) error
// Delete removes a worktree and optionally its branch.
Delete(ctx context.Context, path, branch string, deleteBranch bool) error
// Rename moves a worktree and conditionally renames its branch.
Rename(ctx context.Context, oldPath, newPath, oldBranch, newBranch string) error
// Push pushes a worktree's branch to its upstream.
Push(ctx context.Context, wt *models.WorktreeInfo, args []string, env map[string]string) (string, error)
// Sync synchronizes a worktree's branch with its upstream (pull + push).
Sync(ctx context.Context, wt *models.WorktreeInfo, pullArgs, pushArgs []string, env map[string]string) (string, error)
// UpdateFromBase updates a branch from its PR base branch.
UpdateFromBase(ctx context.Context, wt *models.WorktreeInfo, mergeMethod string, env map[string]string) (string, error)
// Absorb merges or rebases a worktree into the main branch.
Absorb(ctx context.Context, wt *models.WorktreeInfo, mainWorktree *models.WorktreeInfo, mergeMethod string) error
// GetPruneCandidates identifies worktrees and stale branches that have been merged and are candidates for pruning.
GetPruneCandidates(ctx context.Context, worktrees []*models.WorktreeInfo, includeStaleBranches bool) ([]PruneCandidate, error)
// ExecuteCommands runs a list of shell commands in the specified directory.
ExecuteCommands(ctx context.Context, commands []string, cwd string, env map[string]string) error
}
WorktreeService handles high-level worktree lifecycle and synchronization operations.
func NewWorktreeService ¶
func NewWorktreeService(git GitService) WorktreeService
NewWorktreeService creates a new WorktreeService.
Source Files
¶
- agent_hooks.go
- agent_hooks_unix.go
- agent_processes.go
- agent_registry.go
- agent_sessions.go
- agent_sessions_hooks.go
- agent_watch.go
- avatar.go
- ci_cache.go
- ci_data.go
- ci_fetch.go
- environment.go
- executor.go
- filter.go
- note_frontmatter.go
- note_script.go
- pager.go
- persistence.go
- reviewer_cache.go
- status_tree.go
- watch.go
- worktree.go
- worktree_notes_mutation.go