tree

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tree flattens a data.Snapshot into the rows of the TUI's left pane: projects, their coordinator, the "Ready to deliver" group, tasks by attention, review tasks under the task they review, and runs under their task. The selection is kept by a stable key, so a refresh never moves the cursor.

Index

Constants

View Source
const QuotaWarn = 50.0

QuotaWarn is the used percent from which a run row shows its account's quota.

Variables

This section is empty.

Functions

func RunGlyph

func RunGlyph(r *run.Run, in Info) string

RunGlyph is the glyph of a run row (the preview title shows it too).

func RunLabel

func RunLabel(r *run.Run) string

RunLabel is the short name of a run under its task: r<attempt>, or "coord".

Types

type Info

type Info struct {
	Now  time.Time
	Live map[string]tmux.Liveness // run id → pane liveness

	Theme style.Theme
	// contains filtered or unexported fields
}

Info is what rendering needs beyond the rows: liveness, open asks and quota, taken from one snapshot.

func NewInfo

func NewInfo(s *data.Snapshot, live map[string]tmux.Liveness, now time.Time, th style.Theme) Info

NewInfo indexes s for rendering.

func (Info) Quota

func (in Info) Quota(account, profile string) (float64, bool, bool)

Quota returns the worst used percent that applies to a run of account and profile, and whether a cooldown holds either.

type Kind

type Kind int

Kind is a row kind.

const (
	Project Kind = iota
	Coord        // the project's live coordinator
	Deliver      // "Ready to deliver" group of a project
	Task
	Run
	Earlier // "+N earlier": the older runs of a task
)

Row kinds.

type Model

type Model struct {
	Rows       []Row
	Off        int  // first visible row
	ShowClosed bool // closed tasks are listed (a reload is needed after a change)
	// Filter keeps the rows whose id, title or profile contain it (case-insensitive) and
	// their ancestors; every row is expanded meanwhile.
	Filter string
	Hover  string // the key of the row under the pointer (hover is opt-in), else ""
	// contains filtered or unexported fields
}

Model is the tree's state: rows, the selected key, the expansion and the scroll.

func New

func New() Model

New returns an empty tree.

func (*Model) Clamp

func (m *Model) Clamp(h int)

Clamp keeps the scroll offset inside the rows for a window of h rows.

func (*Model) Cursor

func (m *Model) Cursor() string

Cursor returns the selected key.

func (*Model) EnsureVisible

func (m *Model) EnsureVisible(h int)

EnsureVisible scrolls so the cursor is inside a window of h rows.

func (*Model) Expansion

func (m *Model) Expansion() map[string]bool

Expansion returns the explicit expansion choices (not the "+N earlier" rows, which need a load) for the UI state file.

func (*Model) History

func (m *Model) History() []string

History lists the tasks whose "+N earlier" row is expanded: their full run history must be loaded (data.Request.History).

func (*Model) Index

func (m *Model) Index() int

Index returns the selected row's index (-1: no rows).

func (*Model) Move

func (m *Model) Move(delta int)

Move moves the cursor by delta rows.

func (*Model) Parent

func (m *Model) Parent(i int) int

Parent returns the index of row i's parent row (-1: none).

func (*Model) Rebuild

func (m *Model) Rebuild(s *data.Snapshot)

Rebuild replaces the rows from s, keeping the selected key. When that row is gone the cursor stays at the same index.

func (*Model) Render

func (m *Model) Render(w, h int, focused bool, in Info) []string

Render returns the visible rows (from Off) for a pane of w x h; focused marks the cursor row strongly.

func (*Model) Select

func (m *Model) Select(key string) bool

Select moves the cursor to key; false when no row has it.

func (*Model) SelectIndex

func (m *Model) SelectIndex(i int)

SelectIndex moves the cursor to row i (clamped).

func (*Model) Selected

func (m *Model) Selected() *Row

Selected returns the selected row, nil without rows.

func (*Model) SetExpanded

func (m *Model) SetExpanded(key string, on bool) bool

SetExpanded expands or collapses key. It returns false when the row cannot expand or already is in that state.

func (*Model) SetExpansion

func (m *Model) SetExpansion(e map[string]bool)

SetExpansion replaces the explicit expansion choices (before the first Rebuild).

func (*Model) VisibleOff

func (m *Model) VisibleOff(h int) int

VisibleOff is the scroll offset clamped for a window of h rows.

type Row

type Row struct {
	Key     string // p:<project> c:<project> g:deliver:<project> t:<task> r:<run> h:<task>
	Kind    Kind
	Depth   int
	Project string
	Proj    *registry.ProjectRow // Project
	Task    *task.Task           // Task
	Run     *run.Run             // Run, Coord
	// Count is the open tasks of a Project, the tasks of a Deliver group and the older
	// runs behind an Earlier row; Ready is the ready tasks of a Project.
	Count, Ready int
	CanExpand    bool
	Expanded     bool
}

Row is one line of the tree.

func (*Row) ToggleCells

func (r *Row) ToggleCells() (from, to int)

ToggleCells is the width of a row's indent and expansion arrow: a click inside toggles the row.

Jump to

Keyboard shortcuts

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