Documentation
¶
Overview ¶
Package taskmonitor is the M4 of ADR-0038 — a reusable widget that observes task.> over the bus and renders an in-flight list (with progress bar + per-row cancel button) and a rolling history of finished tasks. Failures expand into an errorview chain renderer directly, so an eh.MarshalError-shaped TaskError payload reads back with the same look as anywhere else in the runtime.
Construction follows the producer-handle pattern: callers pass a task.TaskApiI (typically from task.ForApp(MountCtx)), an IdStack-scoped idPrefix, and an Opts struct. Start subscribes the widget to task.> and (optionally) seeds the in-flight map from the supervisor's task.list.inflight snapshot. Stop tears down cleanly. Render is a single call inside a panel / scroll area.
The widget is intentionally stateless about identity — it does not know its consumer's AppId or RunId. Audit + identity propagation happen at the producer side via task.ForApp; the monitor's job is purely presentation.
Index ¶
- Constants
- Variables
- type Inst
- func (inst *Inst) HistoryCount() (n int)
- func (inst *Inst) InflightCount() (n int)
- func (inst *Inst) OnCancel(cn taskcancel.TaskCancel)
- func (inst *Inst) OnCreated(cr taskcreated.TaskCreated)
- func (inst *Inst) OnDone(d taskdone.TaskDone)
- func (inst *Inst) OnError(e taskerror.TaskError)
- func (inst *Inst) OnProgress(p taskprogress.TaskProgress)
- func (inst *Inst) Render()
- func (inst *Inst) Start() (err error)
- func (inst *Inst) Stop() (err error)
- type Opts
Constants ¶
const DefaultMaxHistory = 20
DefaultMaxHistory caps the rolling history pane. Older terminal rows fall off the front; reads beyond this require the supervisor's audit trail.
Variables ¶
var PackageProps = packageprops.Props{ WASMWASI: packageprops.WASMBlocked, WASMJS: packageprops.WASMBlocked, WASMFreestanding: packageprops.WASMBlocked, }
PackageProps records this package's curated properties (ADR-0080). Seeded by `wasmsurvey props generate`; curate by hand, then `wasmsurvey props verify`.
Functions ¶
This section is empty.
Types ¶
type Inst ¶
type Inst struct {
// contains filtered or unexported fields
}
Inst is the widget instance. Construct via New, then drive Start / Render / Stop from the host's frame loop.
Goroutine safety: ObserverI callbacks land on the bus dispatch goroutine (synchronous for in-proc, separate goroutine for NATS in M4); Render runs on the host's frame goroutine. The mutex guards the in-memory state shared between the two; Render snapshots under the lock and renders outside it.
func New ¶
New constructs a monitor bound to api. idPrefix scopes every widget id under the caller's ids stack — pass a stable short string so two monitors in the same panel don't collide.
func (*Inst) HistoryCount ¶
func (*Inst) InflightCount ¶
InflightCount + HistoryCount expose row counts for callers that want to render a header summary or status line outside the widget body.
func (*Inst) OnCancel ¶
func (inst *Inst) OnCancel(cn taskcancel.TaskCancel)
func (*Inst) OnCreated ¶
func (inst *Inst) OnCreated(cr taskcreated.TaskCreated)
func (*Inst) OnProgress ¶
func (inst *Inst) OnProgress(p taskprogress.TaskProgress)
func (*Inst) Render ¶
func (inst *Inst) Render()
Render draws the widget body. Single-threaded — the host's frame goroutine. Snapshots state under the lock then renders without it so ObserverI callbacks aren't blocked behind the egui scope.
type Opts ¶
type Opts struct {
// MaxHistory is the rolling-window size for the history pane.
// Zero ⇒ DefaultMaxHistory.
MaxHistory int
// DefaultOpen sets the initial collapsed/expanded state of both
// the In-flight and History collapsing headers. Default true so
// consumers see content immediately.
DefaultOpen bool
// SeedFromSupervisor causes Start to issue a single
// task.list.inflight Request through the api to populate the
// in-flight map before subscribing. When false (default), the
// widget starts empty and fills as new task.created events
// arrive. Set true when attaching to a long-running runtime so
// already-running tasks become visible immediately.
SeedFromSupervisor bool
}
Opts configures the widget at construction. Zero value is valid (DefaultOpen on, MaxHistory = DefaultMaxHistory).