activity

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package activity demonstrates per-row in-flight state against an API shaped like Argo CD: the spinner and status label a row shows while work runs on it.

It talks to demoapi over HTTP — a real handler, a real client, real request boundaries — so the timings below are the server's, not a sleep here.

The model

The server is the source of truth. When the user starts work locally, the row is told at once, and that claim lasts until the truth can take over. Everything below is one of those two things.

Observation: one predicate, over the row's own data

o.ActivityColumn = "Sync"
o.BusyWhen = func(r table.KeyedRow) (string, bool) {
    phase := r.Data.(appRow).Phase
    return phase, phase == demoapi.PhaseRunning
}

In Argo, sync status is a comparison (Synced, OutOfSync) and never an activity: a sync in progress leaves it alone. The field that says work is running is operationState.phase — which this table does not show. The predicate reads it from Data and the indicator draws in the Sync cell. demoapi starts scheduled syncs every few seconds, so rows spin with nobody having pressed anything; a read-only dashboard needs nothing more.

Operations: one decision per verb

Who knows when the work ends?

  • Sync is activity.Observed. The POST answers at once and the controller does the work, so the phase says when it ends.
  • Refresh is activity.Held. Argo's refresh is a GET that holds the connection until reconciled and shows nothing on the app meanwhile, so no poll can say it is running or that it stopped. Only the request knows.
  • Sync and follow is activity.Held too — a job handle. It streams the job it was given and ends when the job does.
  • Quick sync is Observed work that finishes between two polls. Nothing a poll returns can show it, so the table reports it with UnobservedMsg rather than leaving the row looking ignored.

Dispatch opens the claim, Done closes the request, and BeginRead / ApplyRead stamp every fetch so the table — not this screen — decides whether a read taken across a write can end a claim. There are no counters here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t theme.Theme) screen.Screen

New returns the activity demo screen.

Types

type Screen

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

Screen is a table over demoapi, plus a poll.

func (*Screen) Actions

func (s *Screen) Actions() action.Set

Actions lists one verb per operation shape. What each claims, and in which mode, is the verbs table above.

func (*Screen) Help

func (s *Screen) Help() []key.Binding

func (*Screen) HelpSections

func (s *Screen) HelpSections() []help.Section

func (*Screen) Init

func (s *Screen) Init() tea.Cmd

func (*Screen) IsCapturingKeys

func (s *Screen) IsCapturingKeys() bool

func (*Screen) Layout

func (s *Screen) Layout() layout.Node

func (*Screen) OnEnter

func (s *Screen) OnEnter(any) tea.Cmd

func (*Screen) SetTheme

func (s *Screen) SetTheme(t theme.Theme)

func (*Screen) Title

func (s *Screen) Title() string

func (*Screen) Update

func (s *Screen) Update(msg tea.Msg) (screen.Screen, tea.Cmd)

Jump to

Keyboard shortcuts

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