data

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 data reads what the TUI shows: an immutable Snapshot taken in one read transaction, a Watcher that notices commits made by any other connection, and pane liveness. It never writes.

Index

Constants

View Source
const ClosedLimit = 200

ClosedLimit bounds the closed tasks a snapshot reads.

Variables

This section is empty.

Functions

func Liveness

func Liveness(ctx context.Context, tc *tmux.Client, runs []run.Run) map[string]tmux.Liveness

Liveness checks the panes of the active runs with one tmux call (run.CheckLive). The result is keyed by run id; the snapshot's runs are not touched.

func Task

func Task(ctx context.Context, d *db.DB, id string) (*task.Task, error)

Task reads one task with its dependencies (task.Get), for a form prefilled with its current values and version.

Types

type Request

type Request struct {
	ShowClosed bool     // also the done, delivered and cancelled tasks
	History    []string // tasks whose every run is loaded (Snapshot.History)
}

Request says what a Load reads beyond the default set.

type Snapshot

type Snapshot struct {
	At       time.Time
	Projects []registry.ProjectRow
	// Open are the tasks not done, delivered or cancelled; Deliverable the done tasks
	// waiting for delivery (no review tasks); Closed, with Request.ShowClosed, the
	// latest ClosedLimit done, delivered and cancelled tasks.
	Open, Deliverable, Closed []task.Task
	// ReviewOf maps a review task to the task it reviews (task_deps kind review_of).
	ReviewOf map[string]string
	// Runs are the active runs (coordinators included) and the newest run of every
	// task in Open, Deliverable and Closed, newest first.
	Runs []run.Run
	// RunCount is the number of runs of each task that has any.
	RunCount map[string]int
	// History holds every run of the tasks in Request.History, newest first.
	History  map[string][]run.Run
	Needs    *msg.Needs
	Asks     []msg.OpenAsk
	Inbox    []msg.Item            // unread messages to the human (peeked, not marked read)
	Notes    []notify.Notification // unread notifications, newest first
	Unread   int                   // unread notifications
	Quota    []quota.Row
	Cooldown []quota.Cooldown
	Profiles []registry.ProfileRow
	// Unavailable maps the profiles new runs may not use now to why.
	Unavailable map[string]string
	Daemon      bool
	// ReadOnly: the database schema is newer than this binary.
	ReadOnly bool
}

Snapshot is what the database held at one moment. It is never changed once built.

func Load

func Load(ctx context.Context, d *db.DB, dataDir string, req Request, now time.Time) (*Snapshot, error)

Load reads a Snapshot. Every query runs in one read-only transaction: a plain deferred BEGIN (modernc's _txlock=immediate applies only to write transactions), so the snapshot is consistent and never takes the write lock. It ends right after the queries; no read transaction is held between loads.

type Watcher

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

Watcher notices commits to the database. It pins one connection and reads PRAGMA data_version on it, which changes whenever any other connection commits: the CLI, hooks, the daemon, and the TUI's own backend writes (other pool connections). One read costs microseconds and no IO beyond the shared-memory file.

func NewWatcher

func NewWatcher(ctx context.Context, d *db.DB) (*Watcher, error)

NewWatcher pins a connection of d for the watcher's lifetime.

func (*Watcher) Changed

func (w *Watcher) Changed(ctx context.Context) (bool, error)

Changed reports whether another connection committed since the last call; the first call only records the starting version. Not safe for concurrent use.

func (*Watcher) Close

func (w *Watcher) Close() error

Close returns the pinned connection to the pool.

Jump to

Keyboard shortcuts

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