Documentation
¶
Overview ¶
Package progress provides progress reporting for indexing operations.
The Coordinator collects progress events from indexers and aggregates them for display. It tracks per-indexer state (running, done, errored) and counts of processed items.
The UI component (ui.go) provides a bubbletea-based terminal UI that displays real-time progress with spinners, counters, and ETA estimates.
Usage:
coord := progress.NewCoordinator() // Pass coord.Events() to indexers // Run bubbletea with progress.NewModel(coord) // Call coord.Close() when indexing completes
Package progress provides event types and coordination for tracking indexer progress.
Index ¶
- func FormatSummary(summaries []IndexerSummary, totalDuration time.Duration) string
- type Coordinator
- type DoneMsg
- type Event
- func Completed(indexer string, total int) Event
- func Error(indexer string, err error) Event
- func NewEvent(indexer string, eventType EventType) Event
- func Progress(indexer string, current int, item string) Event
- func ProgressWithTotal(indexer string, current, total int, item string) Event
- func Started(indexer string) Event
- func StartedInPhase(indexer, phase string) Event
- type EventType
- type IndexerError
- type IndexerState
- type IndexerSummary
- type Model
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatSummary ¶
func FormatSummary(summaries []IndexerSummary, totalDuration time.Duration) string
FormatSummary formats the final summary grouped by phase. Phases appear in the order they are first seen across summaries. Each row is prefixed with ✓ (completed) or ✗ (error).
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator collects progress events from indexers and tracks their state.
func NewCoordinator ¶
func NewCoordinator() *Coordinator
NewCoordinator creates a new progress coordinator.
func (*Coordinator) Close ¶
func (c *Coordinator) Close()
Close stops the coordinator's event processing.
func (*Coordinator) Errors ¶
func (c *Coordinator) Errors() []IndexerError
Errors returns all errors collected from indexers.
func (*Coordinator) Events ¶
func (c *Coordinator) Events() chan<- Event
Events returns the channel to send events to.
func (*Coordinator) IsClosed ¶ added in v0.8.0
func (c *Coordinator) IsClosed() bool
IsClosed returns true after Close() has been called and all queued events have been processed. The TUI uses this to know it is safe to exit — it must NOT exit based on IsRunning() alone because PostIndexers (e.g. embeddings) run after the main indexers complete and their progress events would be missed if the TUI quit too early.
func (*Coordinator) IsRunning ¶
func (c *Coordinator) IsRunning() bool
IsRunning returns true if any indexer is still running.
func (*Coordinator) State ¶
func (c *Coordinator) State() []*IndexerState
State returns a copy of the current indexer states in order of first appearance.
func (*Coordinator) Summary ¶
func (c *Coordinator) Summary() []IndexerSummary
Summary returns final statistics for all indexers in order of appearance.
type Event ¶
type Event struct {
// Indexer is the name of the indexer (e.g., "fs", "git").
Indexer string
// Type is the event type.
Type EventType
// Current is the number of items processed so far.
Current int
// Total is the total number of items to process (0 if unknown).
Total int
// Item is the current item being processed (optional, for display).
Item string
// Error is set when Type is EventError.
Error error
// Timestamp is when the event occurred.
Timestamp time.Time
// Phase is the optional display group for this indexer (e.g. "Indexing",
// "Vectorizing"). Empty means the coordinator will use "Indexing" as default.
Phase string
}
Event represents a progress update from an indexer.
func ProgressWithTotal ¶
ProgressWithTotal creates a progress event with a known total.
func StartedInPhase ¶ added in v0.8.0
StartedInPhase creates a started event tagged with a phase label. Use this for indexers that belong to a named display group (e.g. "Vectorizing").
type EventType ¶
type EventType int
EventType represents the type of progress event.
const ( // EventStarted indicates an indexer has started. EventStarted EventType = iota // EventProgress indicates progress has been made. EventProgress // EventCompleted indicates an indexer has finished successfully. EventCompleted // EventError indicates an indexer encountered an error. EventError )
type IndexerError ¶
IndexerError records an error from a specific indexer.
type IndexerState ¶
type IndexerState struct {
Name string
Status string // "running", "completed", "error"
Phase string // display group ("Indexing", "Vectorizing", …); empty = "Indexing"
Current int
Total int
Item string
Error error
StartedAt time.Time
EndedAt time.Time
// contains filtered or unexported fields
}
IndexerState tracks the current state of an indexer.
func (*IndexerState) ETA ¶
func (s *IndexerState) ETA() time.Duration
ETA returns the estimated time remaining based on current rate. Returns 0 if total is unknown or rate is too low.
func (*IndexerState) Elapsed ¶
func (s *IndexerState) Elapsed() time.Duration
Elapsed returns the duration since the indexer started. If completed/errored, returns the total duration.
func (*IndexerState) Rate ¶
func (s *IndexerState) Rate() float64
Rate returns the current items/second rate (smoothed over recent samples).
type IndexerSummary ¶
type IndexerSummary struct {
Name string
Phase string // display group ("Indexing", "Vectorizing", …); empty = "Indexing"
Status string // "completed", "error"
Duration time.Duration
Items int
Rate float64
Error error
}
IndexerSummary contains final statistics for an indexer.