status

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package status provides the animated run-status indicator that anchors the squad TUI footer. It owns a single line: a shimmering glyph encoding the run state, a bold label, optional detail text, an elapsed timer, and a trailing "esc to interrupt" affordance shown only while a run is alive.

The renderer is pure (Render takes a frame counter and elapsed duration, not the wall clock) so callers can golden-test the output without time flakiness. The bubble-tea Model wraps Render with a 32ms ticker.

Index

Constants

View Source
const TickInterval = 32 * time.Millisecond

TickInterval is the animation cadence (~31 FPS). Lifted from codex's status indicator — fast enough that the shimmer reads as motion, slow enough that a sleeping terminal doesn't burn CPU.

Variables

This section is empty.

Functions

func Render

func Render(s Snapshot) string

Render returns a single styled line. ANSI escapes are emitted unless the caller has set lipgloss.SetColorProfile(termenv.Ascii) — which test code should do to produce stable goldens.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is a Bubble Tea wrapper around Render. It owns the animation tick and the start timestamp; callers update state/label/detail via setters.

func New

func New() Model

New returns a Model in StateIdle.

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the animation ticker.

func (*Model) SetDetail

func (m *Model) SetDetail(detail string)

SetDetail sets the secondary text shown after the label.

func (*Model) SetInterrupt

func (m *Model) SetInterrupt(b bool)

SetInterrupt toggles the "esc to interrupt" hint.

func (*Model) SetLabel

func (m *Model) SetLabel(label string)

SetLabel overrides the default label for the current state.

func (*Model) SetState

func (m *Model) SetState(s State)

SetState transitions the indicator. Starting from StateIdle or StateError into StateWorking resets the elapsed timer; transitioning to a terminal state (Completed/Error/Paused) freezes it.

func (*Model) SetWidth

func (m *Model) SetWidth(w int)

SetWidth sets the render width for right-aligning the timer.

func (Model) Snapshot

func (m Model) Snapshot() Snapshot

Snapshot returns the current immutable render input.

func (Model) Update

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

Update advances the animation frame and refreshes elapsed time. It schedules the next tick.

func (Model) View

func (m Model) View() string

View renders the current snapshot. Width comes from the host model.

type Snapshot

type Snapshot struct {
	State     State
	Label     string        // e.g. "Working", "Completed"
	Detail    string        // e.g. "31/40 iter · 142 tools · $1.84/$5.00"
	Elapsed   time.Duration // since the run started
	Frame     uint64        // animation tick counter
	Width     int           // terminal width for right-aligning the timer
	Interrupt bool          // show "esc to interrupt" affordance
}

Snapshot is the immutable input to Render. Keeping the render function pure (no time.Now, no internal state) makes it trivially testable.

type State

type State int

State is what the indicator is currently communicating.

const (
	StateIdle State = iota
	StateConnecting
	StateWorking
	StateCompleted
	StateError
	StatePaused // budget exceeded, awaiting input, etc.
)

type TickMsg

type TickMsg time.Time

TickMsg is delivered every TickInterval. Exported so callers that multiplex bubble tea programs can route ticks correctly.

Jump to

Keyboard shortcuts

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