sidebar

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: 5 Imported by: 0

Documentation

Overview

Package sidebar renders the left-hand run list for the squad TUI: a vertical, grouped, selectable list of active and recent agent runs.

Each row encodes two orthogonal signals via shape and color:

shape  — process liveness (▶ alive, ◇ alive-paused, ∙ exited)
color  — run state (cyan working, green completed, red failed)

The renderer is pure: a Snapshot in, a styled string out. Tests use fixed-width fixtures plus ANSI stripping for stable goldens; the app layer handles input routing and state transitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(s Snapshot) string

Render returns the sidebar's full styled output. Lines are joined with "\n"; no trailing newline.

Types

type Group

type Group struct {
	Title string
	Runs  []Run
}

Group is a named bucket of rows. The default grouping function buckets runs into Working / Needs input / Recent based on State + Alive; callers can pass a custom Group slice to override.

func Bucket

func Bucket(runs []Run, recentWindow time.Duration) []Group

Bucket partitions runs into the default group set: Working / Needs Input / Recent. Recent excludes anything older than `recentWindow` (use 24h by default; pass 0 for "all terminal runs").

type Run

type Run struct {
	ID        string // session ID — opaque key for selection
	Agent     string // e.g. "go-review" or "bug-hunt:fix-bug"
	State     State
	Alive     bool // is the subprocess still running?
	Elapsed   time.Duration
	LastEvent string // optional one-liner; rendered dim on selected row
}

Run is one row's worth of data. Designed to be cheap to construct from a session.Meta + a liveness probe.

type Snapshot

type Snapshot struct {
	Groups   []Group // pre-bucketed; if nil, derive via Bucket(Runs, ...)
	Runs     []Run   // used when Groups is nil
	Selected string  // session ID of the currently selected row
	Width    int     // terminal column width for this pane
	// MaxPerGroup truncates each group with a "… N more" footer. 0 = no
	// truncation.
	MaxPerGroup int
}

Snapshot is the input to Render.

type State

type State int

State is the run's high-level status. Orthogonal to Run.Alive: an agent can be Working+alive (normal), NeedsInput+alive (paused for a human), or Completed+!alive (terminal).

const (
	StateConnecting State = iota
	StateWorking
	StateNeedsInput
	StateCompleted
	StateFailed
	StateBudget
)

Jump to

Keyboard shortcuts

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