dashboard

package
v0.0.0-...-c863b29 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package dashboard provides the OCA operator dashboard — a read-only web UI showing cross-project ADV changes, tmux sessions, and Temporal/worker health, updated in real-time via SSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunPollers

func RunPollers(ctx context.Context, s *State, pollers []Poller, interval time.Duration)

RunPollers starts all pollers at the given interval, running them concurrently per cycle. Blocks until ctx is cancelled.

Types

type ADVOpsPoller

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

ADVOpsPoller populates the ADV Ops panel in the dashboard snapshot. It runs the worktree census and a read-only session debt scan. Temporal-based checks (workflows, search attributes) are optional and degrade gracefully.

func NewADVOpsPoller

func NewADVOpsPoller(config advruntime.Config) *ADVOpsPoller

NewADVOpsPoller creates a poller with the given ADV runtime config.

func (*ADVOpsPoller) Poll

func (p *ADVOpsPoller) Poll(ctx context.Context, s *State) error

Poll updates the ADVOps row in the snapshot.

type ADVOpsRow

type ADVOpsRow struct {
	Status             string `json:"status"`
	WorkflowQueues     int    `json:"workflow_queues"`
	StaleQueues        int    `json:"stale_queues"`
	MissingSearchAttrs int    `json:"missing_search_attrs"`
	SessionDebt        int    `json:"session_debt"`
	WorktreeDebt       int    `json:"worktree_debt"`
	RecoverySteps      int    `json:"recovery_steps"`
	Message            string `json:"message,omitempty"`
}

ADVOpsRow represents ADV runtime state for the dashboard panel.

type ChangeRow

type ChangeRow struct {
	ID          string `json:"id"`
	ChangeID    string `json:"change_id"`
	Title       string `json:"title"`
	Status      string `json:"status"`
	ActiveGate  string `json:"active_gate"`
	CurrentGate string `json:"current_gate"`
	TasksDone   int    `json:"tasks_done"`
	TasksTotal  int    `json:"tasks_total"`
	DoomLoop    bool   `json:"doom_loop"`
	Project     string `json:"project"`
	LastSeenAgo string `json:"last_seen_ago,omitempty"`
}

ChangeRow represents a single ADV change in the dashboard.

type Config

type Config struct {
	Listener net.Listener
	Logger   *slog.Logger
}

Config holds dashboard server configuration.

type HealthPoller

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

HealthPoller implements Poller by checking Temporal and worker health.

func NewHealthPoller

func NewHealthPoller(checker healthChecker, logger *slog.Logger) *HealthPoller

NewHealthPoller creates a new health poller.

func (*HealthPoller) Poll

func (p *HealthPoller) Poll(ctx context.Context, s *State) error

Poll checks Temporal reachability and worker liveness.

type HealthRow

type HealthRow struct {
	TemporalReachable bool   `json:"temporal_reachable"`
	WorkerRunning     bool   `json:"worker_running"`
	Uptime            string `json:"uptime,omitempty"`
}

HealthRow represents system health status.

type Poller

type Poller interface {
	// Poll executes one data-fetch cycle and updates the state.
	Poll(ctx context.Context, s *State) error
}

Poller is the interface for background data sources that populate the state.

type Server

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

Server is the dashboard HTTP server.

func NewServer

func NewServer(cfg Config) (*Server, error)

NewServer creates a new dashboard server with all routes registered.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the HTTP handler for the server (for testing with httptest).

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the dashboard server and blocks until ctx is cancelled. Shutdown sequence: ctx cancelled (SSE handlers exit) → http.Server.Shutdown.

type SessionPoller

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

SessionPoller implements Poller by fetching tmux sessions.

func NewSessionPoller

func NewSessionPoller(lister sessionLister, logger *slog.Logger) *SessionPoller

NewSessionPoller creates a new session poller.

func (*SessionPoller) Poll

func (p *SessionPoller) Poll(ctx context.Context, s *State) error

Poll fetches tmux sessions and updates the state.

type SessionRow

type SessionRow struct {
	Name     string `json:"name"`
	Attached bool   `json:"attached"`
	Path     string `json:"path"`
}

SessionRow represents a tmux session in the dashboard.

type Snapshot

type Snapshot struct {
	Changes  []ChangeRow  `json:"changes"`
	Sessions []SessionRow `json:"sessions"`
	Health   HealthRow    `json:"health"`
	ADVOps   ADVOpsRow    `json:"adv_ops"`
	Warm     bool         `json:"warm"`
	Version  uint64       `json:"version"`
}

Snapshot is a point-in-time view of all dashboard data.

type State

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

State is the shared in-memory dashboard state cache.

func NewState

func NewState() *State

NewState creates an empty dashboard state.

func (*State) SetWarm

func (s *State) SetWarm(warm bool)

Warm marks the state as fully populated.

func (*State) Snapshot

func (s *State) Snapshot() Snapshot

Snapshot returns a copy of the current state.

func (*State) Update

func (s *State) Update(fn func(snap *Snapshot))

Update atomically replaces the state snapshot and bumps the version.

func (*State) Version

func (s *State) Version() uint64

Version returns the current monotonic version counter.

type TemporalPoller

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

TemporalPoller implements Poller by fetching ADV change workflows from Temporal.

func NewTemporalPoller

func NewTemporalPoller(client workflowLister, logger *slog.Logger) *TemporalPoller

NewTemporalPoller creates a new Temporal poller.

func (*TemporalPoller) Poll

func (p *TemporalPoller) Poll(ctx context.Context, s *State) error

Poll fetches all ADV change workflows from Temporal and updates the state. Returns nil even on Temporal errors (graceful degradation).

Jump to

Keyboard shortcuts

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