render

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package render provides agent output rendering functionality for the REPL.

Package render provides agent output rendering functionality for the REPL.

Index

Constants

View Source
const (
	ColorYellow  = lipgloss.Color("11") // Primary UI color (agent header/footer)
	ColorRed     = lipgloss.Color("9")  // Error indicator
	ColorGray    = lipgloss.Color("8")  // Dim/secondary (timing, meta info)
	ColorCyan    = lipgloss.Color("14") // Commands/executables that exist
	ColorGreen   = lipgloss.Color("10") // Strings (quoted text)
	ColorBlue    = lipgloss.Color("12") // Flags/options
	ColorMagenta = lipgloss.Color("13") // Variables
)

ANSI color codes as defined in the spec

View Source
const (
	SymbolExec          = "▶" // Exec tool (shell command) start
	SymbolToolPending   = "○" // Non-exec tool pending/executing
	SymbolToolComplete  = "●" // Non-exec tool complete
	SymbolSuccess       = "✓" // Success
	SymbolError         = "✗" // Error
	SymbolSystemMessage = "→" // System message
)

Symbols as defined in the spec

Variables

View Source
var (
	// HeaderStyle is used for agent header/footer lines
	HeaderStyle = lipgloss.NewStyle().Foreground(ColorYellow)

	// ExecStartStyle is used for the exec tool start symbol
	ExecStartStyle = lipgloss.NewStyle().Foreground(ColorYellow)

	// ToolPendingStyle is used for pending/executing tool status
	ToolPendingStyle = lipgloss.NewStyle().Foreground(ColorYellow)

	// SuccessStyle is used for success indicators
	SuccessStyle = lipgloss.NewStyle().Foreground(ColorYellow)

	// ErrorStyle is used for error indicators
	ErrorStyle = lipgloss.NewStyle().Foreground(ColorRed)

	// DimStyle is used for secondary information like timing
	DimStyle = lipgloss.NewStyle().Foreground(ColorGray)

	// SystemMessageStyle is used for system/status messages
	SystemMessageStyle = lipgloss.NewStyle().Foreground(ColorYellow)
)

Style definitions using Lip Gloss

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

SpinnerFrames contains the braille spinner animation frames

Functions

func GetCurrentFrame

func GetCurrentFrame(index int) string

GetCurrentFrame returns the current spinner frame for a given index This is useful for inline spinners where the caller manages the animation

func RenderWelcome

func RenderWelcome(w io.Writer, info WelcomeInfo, termWidth int)

RenderWelcome renders the welcome screen to the given writer. The welcome screen displays the GSH logo on the left and configuration info on the right.

func StyledSymbol

func StyledSymbol(symbol string, success bool) string

StyledSymbol returns a symbol with appropriate styling applied

Types

type InlineSpinner

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

InlineSpinner manages a spinner that updates inline without owning the whole line

func NewInlineSpinner

func NewInlineSpinner(writer io.Writer) *InlineSpinner

NewInlineSpinner creates a new inline spinner

func (*InlineSpinner) ClearAndFinish

func (s *InlineSpinner) ClearAndFinish()

ClearAndFinish clears the spinner line - caller should print final state

func (*InlineSpinner) SetPrefix

func (s *InlineSpinner) SetPrefix(prefix string)

SetPrefix sets the prefix text shown before the spinner

func (*InlineSpinner) SetSuffix

func (s *InlineSpinner) SetSuffix(suffix string)

SetSuffix sets the suffix text shown after the spinner

func (*InlineSpinner) Start

func (s *InlineSpinner) Start(ctx context.Context) func()

Start begins the inline spinner animation and returns a stop function. The stop function blocks until the spinner has fully stopped.

type ManagedSpinner

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

ManagedSpinner represents a spinner managed by SpinnerManager

func (*ManagedSpinner) ID

func (s *ManagedSpinner) ID() string

ID returns the string ID of this spinner (empty if not set)

func (*ManagedSpinner) IsRunning

func (s *ManagedSpinner) IsRunning() bool

IsRunning returns whether the spinner has been started and not stopped

func (*ManagedSpinner) SetMessage

func (s *ManagedSpinner) SetMessage(message string)

SetMessage sets the message to display after the spinner

func (*ManagedSpinner) Start

func (s *ManagedSpinner) Start(ctx context.Context) func()

Start registers this spinner as live and potentially starts it rendering. Returns a stop function that removes this spinner and waits for cleanup.

type Spinner

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

Spinner manages an animated spinner display (standalone, not managed) Deprecated: Use SpinnerManager.NewSpinner() for coordinated spinners

func NewSpinner

func NewSpinner(writer io.Writer) *Spinner

NewSpinner creates a new standalone spinner with default frames. Note: For coordinated spinners, use NewSpinnerManager().NewSpinner() instead.

func (*Spinner) SetMessage

func (s *Spinner) SetMessage(message string)

SetMessage sets the message to display after the spinner

func (*Spinner) Start

func (s *Spinner) Start(ctx context.Context) func()

Start begins the spinner animation and returns a stop function. The stop function blocks until the spinner has fully stopped and cleared the line. The spinner runs in a goroutine and updates the display using ANSI escape codes.

type SpinnerManager

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

SpinnerManager coordinates multiple spinners to ensure only one renders at a time. When multiple spinners are live, only the most recently created one actually renders. When that spinner stops, the next most recent one takes over. It also supports string ID mapping for script API compatibility.

func NewSpinnerManager

func NewSpinnerManager(writer io.Writer) *SpinnerManager

NewSpinnerManager creates a new spinner manager

func (*SpinnerManager) ActiveID

func (m *SpinnerManager) ActiveID() uint64

ActiveID returns the ID of the currently active spinner (for testing)

func (*SpinnerManager) GenerateID

func (m *SpinnerManager) GenerateID() string

GenerateID generates a new unique string spinner ID

func (*SpinnerManager) GetActiveSpinnerWithID

func (m *SpinnerManager) GetActiveSpinnerWithID() (*ManagedSpinner, string, bool)

GetActiveSpinnerWithID returns the most recently started spinner with its string ID

func (*SpinnerManager) GetSpinnerByID

func (m *SpinnerManager) GetSpinnerByID(id string) (*ManagedSpinner, bool)

GetSpinnerByID returns a spinner by its string ID

func (*SpinnerManager) HasActiveSpinners

func (m *SpinnerManager) HasActiveSpinners() bool

HasActiveSpinners returns true if there are any active spinners

func (*SpinnerManager) LiveCount

func (m *SpinnerManager) LiveCount() int

LiveCount returns the number of live spinners (for testing)

func (*SpinnerManager) NewSpinner

func (m *SpinnerManager) NewSpinner() *ManagedSpinner

NewSpinner creates a new managed spinner without a string ID. The spinner doesn't start rendering until Start is called.

func (*SpinnerManager) NewSpinnerWithID

func (m *SpinnerManager) NewSpinnerWithID(id string) *ManagedSpinner

NewSpinnerWithID creates a new managed spinner with an optional string ID. If id is empty, no string ID mapping is created. The spinner doesn't start rendering until Start is called.

func (*SpinnerManager) RemoveSpinner

func (m *SpinnerManager) RemoveSpinner(id string)

RemoveSpinner stops and removes a spinner by its string ID

func (*SpinnerManager) StopAll

func (m *SpinnerManager) StopAll()

StopAll stops all active spinners

type WelcomeInfo

type WelcomeInfo struct {
	// PredictModel is the name/identifier of the prediction model (empty if not configured)
	PredictModel string
	// AgentModel is the name/identifier of the agent model (empty if not configured)
	AgentModel string
	// Version is the gsh version string
	Version string
}

WelcomeInfo contains information to display in the welcome screen.

Jump to

Keyboard shortcuts

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