ui

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RenderInterval         = 100 * time.Millisecond // throttle re-renders
	ChainSyncInterval      = 10 * time.Minute
	ProviderCheckInterval  = 200 * time.Millisecond
	CacheSaveInterval      = 30 * time.Second
	GovernanceSyncInterval = 5 * time.Minute
	OracleSyncInterval     = 30 * time.Second
	MaxConcurrentChecks    = 10
	MaxBlockHistory        = 50
)

Variables

This section is empty.

Functions

func DoubleProgressBar

func DoubleProgressBar(prevotePct, precommitPct float64, width int) string

DoubleProgressBar renders two stacked progress bars: top for prevotes (green), bottom for precommits (cyan). This replaces the previous half-block (▀) design with standard bubbles/progress components.

func FormatPercent

func FormatPercent(percent float64) string

FormatPercent formats a percentage with color based on threshold. Delegates to the shared tui/components implementation.

func FormatVoteGrid

func FormatVoteGrid(pattern string, width int) string

FormatVoteGrid formats the bit array pattern into a colored grid

func ProgressBar

func ProgressBar(percent float64, width int) string

ProgressBar renders a progress bar with the given percentage (0-1). Delegates to the shared tui/components implementation.

func ProgressBarWithLabel

func ProgressBarWithLabel(percent float64, width int, label string) string

ProgressBarWithLabel renders a progress bar with a text label centered inside it. Delegates to the shared tui/components implementation.

func RenderView

func RenderView(ctx ViewContext) string

RenderView renders the complete view

Types

type BackMsg

type BackMsg struct{}

BackMsg is sent by an embedded Model (Embedded=true in ModelConfig) when the user requests to leave the monitor view (q or Esc with nothing expanded). The parent TUI handles this by navigating back.

type BlockRecord

type BlockRecord struct {
	Height           int64
	PrevotePercent   float64
	PrecommitPercent float64
	Round            int
	Step             int
	Elapsed          time.Duration        // total time the block took
	Timestamp        time.Time            // when the record was captured
	Validators       []BlockValidatorVote // vote snapshot per validator
}

BlockRecord stores the final vote state of a completed block.

type BlockValidatorVote

type BlockValidatorVote struct {
	Index       int
	Address     string
	PubKey      string // base64 consensus pubkey for moniker lookup
	VotingPower int64
	Prevoted    bool
	Precommited bool
}

BlockValidatorVote stores a single validator's vote state for a block.

type HubTab

type HubTab int

HubTab represents the active hub dashboard in akt monitor.

const (
	HubNetwork   HubTab = iota // Consensus, validators, governance
	HubProvider                // Provider fleet monitoring
	HubOracleBME               // Oracle prices + BME state
)

type Model

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

Model represents the application state

func NewModel

func NewModel(cfg ModelConfig) Model

NewModel creates a new UI model

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (Model) StatusInfo

func (m Model) StatusInfo() StatusInfo

StatusInfo returns the current status bar information. This allows the parent TUI to render a unified status bar when the monitor model is embedded.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the model

func (Model) View

func (m Model) View() tea.View

View renders the UI

type ModelConfig

type ModelConfig struct {
	Client             *rpc.Client
	RPCClient          *rpc.RPCProviderClient
	Cache              cache.ProviderStore
	MonikerCache       *cache.MonikerCache
	InsecureSkipVerify bool
	Embedded           bool       // when true, q sends BackMsg instead of tea.Quit
	InitialDashboard   string     // "network" (default), "provider", "oracle", "bme"
	Bus                pubsub.Bus // shared event bus; may be nil
}

ModelConfig holds configuration options for creating a new Model.

type OracleEvent

type OracleEvent struct {
	Type      string // "price", "stale_warning", "staled", "recovered", "aggregated"
	Denom     string
	Detail    string
	Timestamp time.Time
}

OracleEvent is a display-friendly record for the oracle event log.

type OraclePriceEntry

type OraclePriceEntry struct {
	Denom     string
	Price     string
	Source    string // oracle provider address
	Timestamp time.Time
}

OraclePriceEntry is a single price feed event.

type OracleState

type OracleState struct {
	// Prices stores the most recent EventPriceData per source+denom.
	Prices []OraclePriceEntry

	// Aggregated stores the most recent aggregated prices per denom.
	Aggregated map[string]*oracletypes.EventAggregatedPrice

	// Events is a capped log of recent oracle events (newest first).
	Events []OracleEvent

	ScrollPos int

	// Version is the detected oracle API version ("v1", "v2", or "none").
	// Empty string means not yet determined.
	Version string

	// BME state — populated from REST queries.
	BMEStatus *bmetypes.QueryStatusResponse
	BMELedger []bmetypes.QueryLedgerRecordEntry
}

OracleState holds live oracle and BME data for the Oracle/BME dashboard.

type ProviderDetail

type ProviderDetail struct {
	Showing  bool
	Provider *rpc.Provider
	Nodes    []rpc.ProviderNodeWithGPU
	Loading  bool
	Error    error
}

ProviderDetail holds the state for the provider detail view.

type ProviderDetailState

type ProviderDetailState struct {
	Showing  bool
	Provider *rpc.Provider
	Nodes    []rpc.ProviderNodeWithGPU
	Loading  bool
	Error    error
}

ProviderDetailState holds the state for provider detail view

type ProviderList

type ProviderList struct {
	Items      []rpc.Provider
	Versions   []string // unique versions, sorted latest first
	Version    string   // currently selected version filter
	VersionIdx int      // index in Versions
}

ProviderList holds the state for the provider list view.

type ProviderLoader

type ProviderLoader struct {
	FirstRun      bool
	Loading       bool
	Total         int
	Checked       int
	ActiveLease   map[string]bool // providers with active leases (priority)
	Queue         []string        // providers to check
	InFlight      map[string]bool // providers currently being checked
	LastSync      time.Time
	LastSave      time.Time
	LastSaveError error
}

ProviderLoader holds the state for background provider loading/checking.

type ProviderViewState

type ProviderViewState struct {
	Providers []rpc.Provider
	Versions  []string
	Selected  string
	Loading   bool
	Loaded    int
	Total     int
	Detail    ProviderDetailState
}

ProviderViewState holds the state for the providers tab

type StatusInfo

type StatusInfo struct {
	Endpoint      string
	WSConnected   bool
	HubTab        HubTab
	ActiveTab     Tab
	DetailShowing bool
}

StatusInfo holds status bar information exposed by the monitor model so the parent TUI can render a unified status bar.

func (StatusInfo) TabHelpText

func (si StatusInfo) TabHelpText() string

TabHelpText returns the keybinding help text for the active hub/tab.

type Tab

type Tab int

Tab represents the active sub-tab within the Network dashboard.

const (
	TabOverview Tab = iota
	TabValidators
	TabGovernance
)

type ViewContext

type ViewContext struct {
	State              *consensus.State
	Endpoint           string
	Width              int
	Height             int
	HubTab             HubTab
	ActiveTab          Tab
	Embedded           bool // when true, skip the bottom help/status lines
	Monikers           map[string]string
	Providers          ProviderViewState
	GovernanceParams   *governance.AllParams
	BlockHistory       []BlockRecord
	ExpandedBlock      int // -1=none, 0=current, 1+=history index
	ExpandedScroll     int
	ExpandedValidators []BlockValidatorVote // frozen snapshot
	ExpandedValidator  int                  // expanded validator (-1=none)
	ValSignHistory     map[int][]bool       // per-validator signing history
	ProposerHistory    []int                // proposer index per historical block (newest first)
	CurrentProposer    int                  // current block's proposer index (-1=unknown)
	WSConnected        bool
	Oracle             OracleState

	// Bubbles component models
	ProviderTable   table.Model
	NodeTable       table.Model
	ValidatorTable  table.Model
	BlockTable      table.Model
	GovModuleIdx    int // selected module index
	GovModuleScroll int // first visible module index
	GovModuleHeight int // visible rows for module list
	GovParamView    viewport.Model
}

ViewContext holds all data needed to render the view

Jump to

Keyboard shortcuts

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