tui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tui implements VORTEX's full-screen terminal UI (a Bubble Tea application). This file defines the shared Lip Gloss color palette and styles used across every view, plus small render helpers (pills, status dots, spinner). Note: unlike the rest of VORTEX (stdlib-only), the TUI depends on the Charm ecosystem (bubbletea/lipgloss/bubbles) — an approved, deliberate departure for this feature.

Index

Constants

View Source
const (
	ColorPrimary    = "#378ADD" // blue
	ColorSuccess    = "#1D9E75" // green
	ColorWarning    = "#EF9F27" // amber
	ColorDanger     = "#D85A30" // red
	ColorPurple     = "#534AB7"
	ColorText       = "#E0E0E0"
	ColorTextDim    = "#8B8B8B"
	ColorBorder     = "#2D2D2D"
	ColorBackground = "#0D0D0D"
	ColorSelected   = "#1A2A3A"
)

Color palette — dark theme matching the web dashboard.

Variables

View Source
var (
	TitleStyle    = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(ColorPrimary))
	SubtitleStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(ColorTextDim))

	BorderStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color(ColorBorder))

	SelectedStyle = lipgloss.NewStyle().
					Background(lipgloss.Color(ColorSelected)).
					Foreground(lipgloss.Color(ColorText))

	ActiveStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color(ColorPrimary))

	InactiveStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(lipgloss.Color(ColorTextDim))

	StatusOKStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorSuccess)).
					Bold(true)

	StatusWarnStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorWarning)).
					Bold(true)

	StatusErrorStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color(ColorDanger)).
						Bold(true)

	CodeStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorText)).
				Background(lipgloss.Color(ColorBorder))

	TableHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(lipgloss.Color(ColorPrimary))

	TableRowStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorText))

	TableAltRowStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color(ColorText)).
						Background(lipgloss.Color("#151515"))

	HelpStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorTextDim))

	InputStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color(ColorPrimary)).
				Padding(0, 1)

	ChatUserStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorPrimary)).
					Align(lipgloss.Right)

	ChatAgentStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorSuccess)).
					Align(lipgloss.Left)

	ChatSystemStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorTextDim)).
					Align(lipgloss.Center)
)

Shared styles. These are package-level so views share a consistent look.

Functions

func APIKeyFilePath

func APIKeyFilePath() string

APIKeyFilePath returns the path where `vortex setup` persists the plaintext API key for the TUI to read back: <user-config>/vortex/tui-key. The apikeys store only holds bcrypt hashes (the raw secret is unrecoverable from it), so the setup wizard writes the secret here once for the local dashboard/TUI.

func Pill

func Pill(text, color string) string

Pill renders a small colored pill: "● text" in the given hex color.

func Spinner

func Spinner() spinner.Model

Spinner returns a configured Bubble Tea spinner (dot style, primary color).

func StatusDot

func StatusDot(ok bool) string

StatusDot returns a "●" colored green when ok, red otherwise.

Types

type AICostData

type AICostData struct {
	Provider        string  `json:"provider"`
	TotalUSD        float64 `json:"total_usd"`
	RequestsToday   int     `json:"requests_today"`
	DailyBudget     float64 `json:"daily_budget"`
	RemainingBudget float64 `json:"remaining_budget"`
	Free            bool    `json:"free"`
}

AICostData mirrors GET /api/ai/cost.

type AgentsData

type AgentsData struct {
	ActiveAgents  int   `json:"active_agents"`
	TotalMessages int64 `json:"total_messages"`
	QueueDepth    int   `json:"queue_depth"`
}

AgentsData mirrors GET /api/agents/status.

type AuditData

type AuditData struct {
	Entries []AuditEntryData `json:"entries"`
}

AuditData mirrors GET /api/audit.

type AuditEntryData

type AuditEntryData struct {
	Seq       int64          `json:"seq"`
	Timestamp string         `json:"timestamp"`
	Actor     string         `json:"actor"`
	Action    string         `json:"action"`
	Resource  string         `json:"resource"`
	Detail    map[string]any `json:"detail"`
}

AuditEntryData is one audit entry.

type Client

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

Client talks to a running VORTEX management server, returning typed data.

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient constructs a client with defaults applied.

func (*Client) AICost

func (c *Client) AICost() (*AICostData, error)

AICost fetches today's AI usage and budget.

func (*Client) Agents

func (c *Client) Agents() (*AgentsData, error)

Agents fetches GET /api/agents/status.

func (*Client) Approve

func (c *Client) Approve(sessionID string, approved bool) (string, error)

Approve posts an approve/reject decision for a pending agent tool action and returns the result transcript (the action executes server-side on approval, which may call a slow tool, so this uses the long submit timeout).

func (*Client) Audit

func (c *Client) Audit(limit int) (*AuditData, error)

Audit fetches GET /api/audit?limit=N.

func (*Client) ForgeStatus

func (c *Client) ForgeStatus(jobID string) (*ForgeJobData, error)

func (*Client) Health

func (c *Client) Health() (*HealthData, error)

Health fetches GET /health.

func (*Client) History

func (c *Client) History() ([]SessionSummaryData, error)

History fetches the list of stored conversation sessions.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected reports whether the server responds 200 to /health within 1s.

func (*Client) LoadAPIKey

func (c *Client) LoadAPIKey() string

LoadAPIKey resolves an API key from VORTEX_API_KEY, then the persisted setup key file (APIKeyFilePath). It returns "" when none is found.

func (*Client) Metrics

func (c *Client) Metrics() (*MetricsData, error)

Metrics fetches and parses the Prometheus /metrics exposition.

func (*Client) Namespaces

func (c *Client) Namespaces() (*NamespacesData, error)

Namespaces fetches GET /api/namespaces (handles array or object form).

func (*Client) Plugins

func (c *Client) Plugins() (*PluginsData, error)

Plugins fetches GET /api/plugins.

func (*Client) Reload

func (c *Client) Reload() error

Reload triggers a config reload via the control plane.

func (*Client) Secrets

func (c *Client) Secrets() (*SecretsData, error)

Secrets fetches GET /api/secrets/status.

func (*Client) SessionHistory

func (c *Client) SessionHistory(sessionID string) ([]SessionMessageData, error)

SessionHistory fetches the messages of a past session.

func (*Client) Status

func (c *Client) Status() (*StatusData, error)

Status fetches GET /api/status.

func (*Client) Submit

func (c *Client) Submit(msg, sessionID string) (string, error)

Submit POSTs a message to the agent runtime and returns the response. It uses a dedicated 180s client/context (not the 5s default) because the agent may wait on a slow AI provider.

type ClientConfig

type ClientConfig struct {
	BaseURL string // default http://localhost:9090
	APIKey  string
	Timeout time.Duration // default 5s
}

ClientConfig configures the TUI's API client.

type ForgeJobData

type ForgeJobData struct {
	ID              string          `json:"id"`
	Message         string          `json:"message"`
	State           string          `json:"state"`
	Progress        string          `json:"progress"`
	ProgressHistory []string        `json:"progress_history"`
	Questions       []ForgeQuestion `json:"questions"`
	Result          string          `json:"result"`
	DurationMs      int64           `json:"duration_ms"`
	Error           string          `json:"error"`
}

ForgeJobData mirrors GET /api/forge/status/{id}.

type ForgeQuestion

type ForgeQuestion struct {
	Question string   `json:"question"`
	Options  []string `json:"options"`
	Key      string   `json:"key"`
}

ForgeQuestion is a structured clarifying question (option-selection UI).

type HealthData

type HealthData struct {
	Status      string      `json:"status"`
	Version     string      `json:"version"`
	ClusterName string      `json:"cluster_name"`
	Uptime      string      `json:"uptime"`
	ConfigHash  string      `json:"config_hash"`
	Routes      []RouteData `json:"routes"`
}

HealthData mirrors GET /health.

type MetricsData

type MetricsData struct {
	RequestsTotal  map[string]float64 // by route
	ActiveConns    map[string]float64 // by route
	P99LatencyMs   map[string]float64 // by route
	ClusterMembers float64
}

MetricsData is parsed from the Prometheus /metrics exposition.

type NamespaceData

type NamespaceData struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	OrgID string `json:"org_id"`
}

NamespaceData is one tenant namespace.

type NamespacesData

type NamespacesData struct {
	Namespaces []NamespaceData `json:"namespaces"`
}

NamespacesData mirrors GET /api/namespaces (array or {namespaces:[...]}).

type PluginData

type PluginData struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`
}

PluginData is one installed plugin.

type PluginsData

type PluginsData struct {
	Plugins []PluginData `json:"plugins"`
}

PluginsData mirrors GET /api/plugins.

type RouteData

type RouteData struct {
	Name     string `json:"name"`
	Protocol string `json:"protocol"`
	Listen   string `json:"listen"`
	Active   int64  `json:"active"`
}

RouteData is one route's live health (mirrors api.RouteHealth).

type SecretStatusData

type SecretStatusData struct {
	Name string `json:"name"`
	Set  bool   `json:"set"`
}

SecretStatusData is one declared secret's set/unset state.

type SecretsData

type SecretsData struct {
	Secrets []SecretStatusData `json:"secrets"`
}

SecretsData mirrors GET /api/secrets/status.

type SessionMessageData

type SessionMessageData struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

SessionMessageData mirrors one message of GET /api/agents/history/{id}.

type SessionSummaryData

type SessionSummaryData struct {
	SessionID string `json:"session_id"`
	Summary   string `json:"summary"`
	UpdatedAt string `json:"updated_at"`
}

ForgeStatus fetches GET /api/forge/status/{id}. SessionSummaryData mirrors one entry of GET /api/agents/history.

type StatusData

type StatusData struct {
	NodeID        string `json:"node_id"`
	TrustDomain   string `json:"trust_domain"`
	TLSProvider   string `json:"tls_provider"`
	SecretBackend string `json:"secret_backend"`
	PolicyDefault bool   `json:"policy_default"`
	PluginCount   int    `json:"plugin_count"`
	AuditCount    int64  `json:"audit_entry_count"`
	ClusterName   string `json:"cluster_name"`
	Version       string `json:"version"`
	WorkingDir    string `json:"working_dir"`
}

StatusData mirrors GET /api/status.

Directories

Path Synopsis
Package app is the root Bubble Tea application for the VORTEX terminal UI.
Package app is the root Bubble Tea application for the VORTEX terminal UI.
Package views implements the individual screens of the VORTEX terminal UI.
Package views implements the individual screens of the VORTEX terminal UI.

Jump to

Keyboard shortcuts

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