Help us shape the future of Go! Take the 2026 Go Developer Survey

sync

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sync provides a TUI component for displaying sync progress.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompleteMsg

type CompleteMsg struct {
	Summary string
}

CompleteMsg indicates sync is complete

type DetailMark added in v0.19.2

type DetailMark int

DetailMark selects the status glyph shown on a detail row. Using a typed constant (rather than a bare bool) keeps the three states distinct at the call site and matches the streaming handler's markers.

const (
	// MarkDone shows a green ✓ for a completed item.
	MarkDone DetailMark = iota
	// MarkWarn shows an orange ⚠ for a skipped/attention item.
	MarkWarn
	// MarkInProgress shows a dim → for an item still in flight.
	MarkInProgress
)

type LazyHeaders added in v0.30.1

type LazyHeaders[K comparable] struct {
	// contains filtered or unexported fields
}

LazyHeaders decides when a keyed section's header should be emitted to a streaming display: at most once, on the section's first item, and only for sections that were explicitly started. Successive emitted headers are separated from the previous one by a blank line.

It holds no output of its own — callers emit based on its decisions — so the same logic drives both the non-TTY sync handler (which writes lines straight to output) and the bubbletea sync model (which accumulates tea.Cmds). Keeping the rule in one place stops the two from drifting apart.

The zero value is not ready for use; construct with NewLazyHeaders.

func NewLazyHeaders added in v0.30.1

func NewLazyHeaders[K comparable]() *LazyHeaders[K]

NewLazyHeaders returns a ready-to-use tracker keyed by K.

func (*LazyHeaders[K]) Any added in v0.30.1

func (l *LazyHeaders[K]) Any() bool

Any reports whether any header has been emitted, e.g. to decide whether a trailing separator is needed before a summary line.

func (*LazyHeaders[K]) CommitOnItem added in v0.30.1

func (l *LazyHeaders[K]) CommitOnItem(key K) (emit, separate bool)

CommitOnItem is called as a section produces an item. It reports whether the section's header should be emitted now (emit) — true exactly once, for the first item of a started, not-yet-committed section — and whether that header needs a blank-line separator from the previous section (separate). Items for a section that was never started return (false, false), so callers that drive items without starting a phase stay headerless.

func (*LazyHeaders[K]) Committed added in v0.30.1

func (l *LazyHeaders[K]) Committed(key K) bool

Committed reports whether the given section's header has been emitted.

func (*LazyHeaders[K]) Start added in v0.30.1

func (l *LazyHeaders[K]) Start(key K)

Start records that a section has begun. Its header is not emitted yet — that happens lazily on the first item via CommitOnItem — so a section that starts but never produces an item stays silent.

type Model

type Model struct {
	core.BaseModel // Embedded for ReadySignaler interface
	CurrentPhase   Phase
	CurrentDetail  string // Current operation being performed
	TotalOps       int
	CompletedOps   int
	Progress       progress.Model

	Summary string
	// contains filtered or unexported fields
}

Model is the bubbletea model for sync progress. It embeds core.BaseModel for standard lifecycle handling. Uses tea.Printf to print completed items above the active UI.

func NewModel

func NewModel(totalOps int) *Model

NewModel creates a new sync model

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the model

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*Model) View

func (m *Model) View() tea.View

View renders the model - shows only the active progress (package-manager pattern) Completed items are printed above via tea.Printf

type Phase

type Phase string

Phase represents a sync phase

const (
	PhaseTrunk    Phase = "trunk"
	PhaseBranches Phase = "branches"
	PhaseGitHub   Phase = "github"
	PhaseClean    Phase = "clean"
	PhaseRestack  Phase = "restack"
)

Phase constants

type PhaseCompleteMsg

type PhaseCompleteMsg struct {
	Phase Phase
}

PhaseCompleteMsg indicates a phase has completed

type PhaseDetailMsg

type PhaseDetailMsg struct {
	Phase   Phase
	Message string
	Mark    DetailMark // Status glyph for the row (defaults to MarkDone)
}

PhaseDetailMsg adds a detail line to a phase (printed above TUI)

type PhaseStartMsg

type PhaseStartMsg struct {
	Phase   Phase
	Message string // Phase header message (e.g., "📥 Pulling from remote...")
}

PhaseStartMsg indicates a phase has started

type ProgressTickMsg

type ProgressTickMsg struct {
	Completed int
	Total     int
}

ProgressTickMsg updates the progress bar

Jump to

Keyboard shortcuts

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