theme

package
v1.2.0-alpha.2 Latest Latest
Warning

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

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

Documentation

Overview

Package theme owns every styled surface in the v2 TUI. One Theme instance is constructed at startup (via Default) and passed by pointer to every component that renders. Components read styles off the struct rather than rebuilding them per frame.

The Rev field is the cache key for the transcript block cache (M3): swap the theme, bump Rev, and every cached block re-renders with the new styles. Components never compare Theme pointers — they compare Rev values.

Index

Constants

View Source
const SpinnerInterval = 100 * time.Millisecond

SpinnerInterval is the wall-clock cadence at which the TUI advances the spinner. 100 ms is light enough for a TUI redraw budget and the rate the user requested in v1.

Variables

View Source
var SpinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}

SpinnerFrames is the braille-dot rotation used for any "ing" status (thinking, executing, draining, compacting). One frame per SpinnerInterval; consumers wrap via SpinnerFrame(i).

Functions

func SpinnerFrame

func SpinnerFrame(i int) string

SpinnerFrame returns one frame of the rotation. The argument can be any non-negative tick counter; the function handles wrapping.

Types

type Glyph

type Glyph struct {
	Symbol string
	Color  lipgloss.Color
}

Glyph pairs a status string (task or subagent) with the symbol and foreground color the TUI uses to render it. One source of truth for panels, transcript snapshots, and any future widget that wants consistent lifecycle vocabulary.

type Theme

type Theme struct {
	// Rev is bumped each time the theme is swapped wholesale. Block
	// caches key off this so a theme swap forces a re-render. Default
	// theme starts at Rev = 1 so zero-value Rev (= "uninitialised")
	// stays a discriminator.
	Rev uint64

	// Chat blocks
	UserPrompt lipgloss.Style
	Assistant  lipgloss.Style
	Thinking   lipgloss.Style

	// Tool vocabulary — brown call, green success, RED reserved for
	// real failures only. ToolResult uses soft sky blue so it sits
	// beneath the brown call line as a calm output stream.
	ToolCall   lipgloss.Style
	ToolOK     lipgloss.Style
	ToolErr    lipgloss.Style
	ToolResult lipgloss.Style

	// Diff — M2 change: white text on solid acid-green / glitch-red
	// backgrounds (was neon-fg on pastel-bg in v1). Reads as a filled
	// bar across the transcript column; matches the "pro" diff look
	// the user requested. Fill spans full transcript width via per-row
	// Width() at render time (see components/diff).
	DiffAdd     lipgloss.Style
	DiffRemove  lipgloss.Style
	DiffContext lipgloss.Style
	DiffHeader  lipgloss.Style

	// Side panels — cyan headers, neutral content.
	PanelHeader lipgloss.Style
	PanelRow    lipgloss.Style
	PanelBorder lipgloss.Style

	// Status bar — neon HUD, violet separator.
	StatusBar   lipgloss.Style
	StatusKey   lipgloss.Style
	StatusValue lipgloss.Style
	StatusSep   lipgloss.Style
	StatePill   lipgloss.Style

	// Errors / input / dims — input border cyan.
	ErrorBanner lipgloss.Style
	InputBorder lipgloss.Style
	DimText     lipgloss.Style

	// Welcome banner — cyan ASCII art, violet double-border.
	Banner     lipgloss.Style
	BannerBox  lipgloss.Style
	BannerInfo lipgloss.Style
	Greeting   lipgloss.Style

	// System lifecycle blocks.
	Compacting lipgloss.Style
	Draining   lipgloss.Style
	FooterHint lipgloss.Style

	// Tasks / paste / timeline — timeline sits back as muted grey so
	// every transcript line doesn't read as an error.
	TasksDone      lipgloss.Style
	PasteChip      lipgloss.Style
	Timeline       lipgloss.Style
	TimelineCut    lipgloss.Style
	TimelineAccent lipgloss.Style // cyan-bold variant for yank-mode focus
	TimelineMatch  lipgloss.Style // yellow-bold variant for search-match blocks

	// Context HUD (status-bar context bar).
	ContextBar  lipgloss.Style
	ContextFill lipgloss.Style
	ContextRail lipgloss.Style

	// Turn separator — barely-there chrome between agent loop iterations.
	TurnSep lipgloss.Style
	// contains filtered or unexported fields
}

Theme bundles every lipgloss style the v2 TUI needs. Held by pointer; mutations through theme-swap should produce a new *Theme with a higher Rev, never mutate fields in place.

func Default

func Default() *Theme

Default returns the production NEON TOKYO theme. Construct once at program start and reuse for the session — Rev tracks identity for cache invalidation.

func (*Theme) Glyph

func (t *Theme) Glyph(status string) Glyph

Glyph returns the symbol + color for a status string. Unknown statuses get a neutral dim "·" — visible but not screaming for attention.

func (*Theme) SpinnerStyle

func (t *Theme) SpinnerStyle(status string) (lipgloss.Style, bool)

SpinnerStyle returns the spinner style for an "ing" status. The second return is false when the status is terminal (idle / done / crushed) so the caller can fall back to the static Glyph table.

Jump to

Keyboard shortcuts

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