ui

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HexPurple      = "#541bff" // primary accent
	HexPurpleLight = "#7c5cff" // lighter purple for dark terminals
	HexPink        = "#ff97ea" // secondary accent (reads on dark)
	HexPinkLight   = "#b3408f" // pink that reads on light terminals
	HexGray        = "#7c7985" // muted text
	HexInk         = "#10100f" // near-black body text
	HexPaper       = "#f4f4f5" // off-white body text on dark
	HexWhite       = "#ffffff"
	HexPinkDeep    = "#e688d3" // pink that reads on light terminals (fang help theme only)
	HexRose        = "#d61f69" // error rose, bridges the pink family (fang help theme only)
)

Tabstack brand palette (tabstack.ai), as raw hex. Defined once here so the fang help theme (cmd/tabstack, lipgloss v2) and these output styles (lipgloss v1) share a single source of truth; each consumer wraps these in its own color type and picks a context-appropriate light/dark variant.

Variables

This section is empty.

Functions

This section is empty.

Types

type OutputMode

type OutputMode string

OutputMode selects how results are rendered. Pretty is the styled, human-facing mode; JSON is the machine-facing mode that emits raw JSON (and NDJSON for streams) so output composes with tools like jq.

const (
	ModePretty OutputMode = "pretty"
	ModeJSON   OutputMode = "json"
)

type Renderer

type Renderer struct {
	Out    io.Writer
	Err    io.Writer
	Mode   OutputMode
	Styles Styles
}

Renderer carries everything the output helpers need: where to write, which mode we are in, and the resolved styles.

func (Renderer) PrintCitations

func (r Renderer) PrintCitations(cites []client.Citation)

PrintCitations renders the research source list under a "Sources" heading, numbered to match the [n] markers in the report. In JSON mode nothing is printed since the events already carried the sources. Each entry shows its number, title (when present), and URL.

func (Renderer) PrintError

func (r Renderer) PrintError(err error)

PrintError writes an error to stderr. Pretty mode tags it; JSON mode emits a single {"error": "..."} object so failures stay parseable on the error stream.

func (Renderer) PrintFinalAnswer

func (r Renderer) PrintFinalAnswer(text string)

PrintFinalAnswer renders a terminal "final answer" block. In JSON mode nothing is printed here because the events already carried the data. In pretty mode a short, single-line answer (e.g. an automate result) is boxed, while a long or multi-line report (e.g. research output) is printed plain under a heading, since a border around multi-paragraph text reads poorly.

func (Renderer) PrintJSON

func (r Renderer) PrintJSON(raw json.RawMessage) error

PrintJSON writes raw JSON. In pretty mode it indents; in JSON mode it writes the bytes through as-is so we never reshape a caller-defined schema result.

func (Renderer) PrintMarkdown

func (r Renderer) PrintMarkdown(resp client.ExtractMarkdownResponse) error

PrintMarkdown renders an extract/markdown response. In JSON mode it prints the full response object; in pretty mode it prints the content, with metadata as a short styled header when present.

func (Renderer) RenderEvent

func (r Renderer) RenderEvent(e client.Event) error

RenderEvent prints a single streamed SSE event. In JSON mode it emits one NDJSON line per event so a stream becomes a clean line-delimited log. In pretty mode it formats a timeline line styled by event type.

type Spinner

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

Spinner is a minimal in-place spinner for pretty mode. It is intentionally small: we are not pulling in Bubble Tea for a one-line indicator while a stream is between events. It writes to a TTY, clears its own line, and is safe to Stop multiple times.

Usage pattern in a streaming command:

sp := ui.NewSpinner(out, "working")
sp.Start()
// on each event: sp.Pause(); render(event); sp.Resume()
// at the end:    sp.Stop()

func NewSpinner

func NewSpinner(out io.Writer, label string) *Spinner

NewSpinner builds a spinner that writes to out with the given label.

func (*Spinner) Pause

func (s *Spinner) Pause()

Pause hides the spinner so a real line of output can be written without the spinner frame bleeding into it.

func (*Spinner) Resume

func (s *Spinner) Resume()

Resume re-enables drawing after a Pause.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins animating in a background goroutine.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop permanently halts the spinner and clears its line.

type Styles

type Styles struct {
	Success  lipgloss.Style
	Agent    lipgloss.Style
	Browser  lipgloss.Style
	Muted    lipgloss.Style
	ErrorTag lipgloss.Style
	Label    lipgloss.Style
	Box      lipgloss.Style
	Key      lipgloss.Style
	Cite     lipgloss.Style
}

Styles holds every lipgloss style the CLI uses. We bundle them into a struct rather than scattering package level vars so that colour can be switched off cleanly: when colour is disabled we hand back a Styles whose fields are all no-op styles, and the rest of the code never has to branch on it again.

func NewStyles

func NewStyles(noColor bool) Styles

NewStyles builds the active style set. When noColor is true (either via the --no-color flag or the NO_COLOR environment variable) every style collapses to plain text.

Jump to

Keyboard shortcuts

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