Documentation
¶
Overview ¶
Package activity is the observational record of user-facing mutations in a Bubble Tea app: it feeds a footer's status slot (the most-recent operation and an in-flight count) and a scrollable operation-log overlay (every recorded mutation, newest-first). It is deliberately observational - it records what a mutation is doing and how it resolved, but it never gates a write. Callers keep their own re-entrancy guards; the registry only watches. Every method runs on the single Bubble Tea Update goroutine, so the registry needs no locking (mirroring package task); it owns no goroutines of its own.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
ID uint64 // registry-assigned, monotonic from 1
Pending string // in-flight text, e.g. "creating issue in PROJ…"
Done string // resolved text, e.g. "PROJ-88 created" (set by Finish)
Ref string // the affected item's reference when known, for a hyperlink (may be "")
Status Status
Err error // set by Fail
}
Entry is one recorded operation. It is a value type: Recent and Log hand out copies, so a caller reading the footer or the log can never reach back in and mutate the registry's own state.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry records mutations for the footer and the operation log. It is purely observational: Start/Finish/Fail note what a mutation is doing and how it ended, but nothing here ever blocks or de-duplicates a write - the caller's own re-entrancy guard stays authoritative, and the registry just watches from the side.
All methods are called from the single Bubble Tea Update goroutine (the async work runs off-loop in a task command and reports back as a message that is applied on that same goroutine), so the entry slice needs no locking, exactly as package task's Manager avoids locking its generation map. The registry owns no goroutines.
func (*Registry) Fail ¶
Fail resolves op id as failed with err. Like Finish it updates in place and is a no-op for an unknown id.
func (*Registry) Finish ¶
Finish resolves op id as done: done is the resolved text, ref the affected item's reference (or ""). The matching pending entry is updated in place at the same id. A no-op if id is unknown - it may have aged out of the bounded log, and a purely observational record must never panic on a stale handle.
func (*Registry) Log ¶
Log returns the recorded entries newest-first, capped at the retention bound. Retention is already bounded, so this walks the retained slice in reverse into a fresh copy - the caller gets its own snapshot and cannot mutate registry state through it.
func (*Registry) Recent ¶
Recent returns the most-recently-started entry (the highest id, whether still pending or already resolved) and true, or a zero Entry and false when nothing has been recorded. Entries are kept in start order, so the last one is the newest.
func (*Registry) Start ¶
Start records a pending operation and returns its id (monotonic from 1). The returned id is the caller's handle for the later Finish or Fail; a zero-value handle is never a valid id, so "not recorded" is unambiguous. When the log is already at capacity the oldest entry is dropped, which never affects ids because lastID keeps climbing.