console

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package console implements the interactive `truestamp console` TUI: a multi-pane Bubble Tea application that holds an authenticated WebSocket connection to the Truestamp backend and lets the user observe live events, create timestamped items, and inspect connection diagnostics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts Options) error

Run launches the interactive console TUI. Blocks until the user quits.

Types

type HealthTarget

type HealthTarget struct {
	// Name is a short, human-readable label rendered in the table,
	// e.g. "Truestamp API" or "NIST Beacon (entropy)".
	Name string

	// URL is the address we probe. The check uses HEAD and falls
	// back to GET if the server doesn't allow HEAD (some endpoints
	// reply 405 Method Not Allowed).
	URL string
}

HealthTarget is a service the CLI talks to during normal operation. The Connection pane probes each target and reports whether it's reachable so a user diagnosing a problem can tell at a glance whether their network is broken, the Truestamp service is down, or a third-party verification source is unhealthy.

func DefaultHealthTargets

func DefaultHealthTargets(healthURL, keyringURL string) []HealthTarget

DefaultHealthTargets returns the canonical list of services the Connection pane probes for liveness. The Truestamp health and keyring URLs are passed in (they're computed from base_url over in package config) so user overrides flow through; the third- party verification endpoints (NIST, Stellar, Blockstream) use production URLs by design — we don't have testnet URLs in the CLI's config surface, and a user verifying a mainnet item would always pull from these regardless.

Probing /health (instead of the api_url root) gives a much stronger green-light signal: the server only returns 200 when the app is up AND its database is reachable. A 5xx here means the user's machine reached the host fine but Truestamp itself is sick, which is exactly the diagnostic we want to surface.

Exported because cmd/console.go calls it to populate console.Options before invoking console.Run.

type Options

type Options struct {
	WSURL  string
	APIKey string

	// APIURL is the base JSON:API URL (e.g. https://www.truestamp.com/api/json).
	// Threaded into the Teams pane so it can call ListMyMemberships /
	// GetTeam without re-importing the top-level config package.
	APIURL string

	// ActiveTeamID is the team id currently stored in config.toml. The
	// Teams pane uses this to mark the row in the membership list and
	// drive the access-loss check on startup. May be empty when no
	// team has been configured yet.
	ActiveTeamID string

	// Logger receives diagnostic / postmortem entries from the
	// wschannel transport and from the TUI itself. May be nil — the
	// TUI substitutes a discard logger so panes can call Log methods
	// unconditionally.
	Logger *slog.Logger

	// LogFilePath is shown on the Connection pane so the user can
	// `tail -f` it if they need to debug something.
	LogFilePath string

	// ConfigFilePath is the path to the user's TOML settings file
	// (e.g. ~/.config/truestamp/config.toml on macOS/Linux). Surfaced
	// on the Connection pane so a user who can't sign in can find
	// the file and edit it directly without knowing CLI internals.
	// May be empty when the platform's home directory can't be
	// resolved; the pane suppresses the line in that case.
	ConfigFilePath string

	// HealthTargets is the list of services the Connection pane
	// probes for liveness. Populated by cmd/console.go from the
	// active configuration so user-overridden api_url / keyring_url
	// values are honored. Empty disables the section entirely.
	HealthTargets []HealthTarget
}

Options carries the runtime configuration into the TUI.

type ScopeSummary

type ScopeSummary struct {
	UserID string `json:"user_id"`
	TeamID string `json:"team_id"`
	Plan   string `json:"plan"`
}

ScopeSummary mirrors the `scope` map in the welcome envelope.

type ServerInfo

type ServerInfo struct {
	Version string `json:"version"`
}

ServerInfo holds the server build metadata included in the welcome.

type StreamMeta

type StreamMeta struct {
	ID    string `json:"id"`
	Scope string `json:"scope"`
	Title string `json:"title"`
}

StreamMeta is one entry in the stream catalog.

type Welcome

type Welcome struct {
	Scope   ScopeSummary `json:"scope"`
	Streams []StreamMeta `json:"streams"`
	Server  ServerInfo   `json:"server"`
}

Welcome is the parsed shape of the join reply for `console:lobby`.

Directories

Path Synopsis
Package chrome provides the structural primitives that wrap every console pane: a fixed Page layout (header + body + footer), a Theme that centralizes colors / paddings / separators, a Header that draws the tab bar plus status pill, and a Footer that auto-renders keybinding hints from the active pane's help.KeyMap.
Package chrome provides the structural primitives that wrap every console pane: a fixed Page layout (header + body + footer), a Theme that centralizes colors / paddings / separators, a Header that draws the tab bar plus status pill, and a Footer that auto-renders keybinding hints from the active pane's help.KeyMap.
Package events projects raw `stream` payloads from the console wire protocol into a canonical Row that drives the Monitor pane's table renderer.
Package events projects raw `stream` payloads from the console wire protocol into a canonical Row that drives the Monitor pane's table renderer.
Package keys centralises all keyboard bindings for the console TUI.
Package keys centralises all keyboard bindings for the console TUI.

Jump to

Keyboard shortcuts

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