Documentation
¶
Overview ¶
Package render provides agent output rendering functionality for the REPL.
Package render provides agent output rendering functionality for the REPL.
Index ¶
- Constants
- Variables
- func GetCurrentFrame(index int) string
- func RenderWelcome(w io.Writer, info WelcomeInfo, termWidth int)
- func StyledSymbol(symbol string, success bool) string
- type InlineSpinner
- type ManagedSpinner
- type Spinner
- type SpinnerManager
- func (m *SpinnerManager) ActiveID() uint64
- func (m *SpinnerManager) GenerateID() string
- func (m *SpinnerManager) GetActiveSpinnerWithID() (*ManagedSpinner, string, bool)
- func (m *SpinnerManager) GetSpinnerByID(id string) (*ManagedSpinner, bool)
- func (m *SpinnerManager) HasActiveSpinners() bool
- func (m *SpinnerManager) LiveCount() int
- func (m *SpinnerManager) NewSpinner() *ManagedSpinner
- func (m *SpinnerManager) NewSpinnerWithID(id string) *ManagedSpinner
- func (m *SpinnerManager) RemoveSpinner(id string)
- func (m *SpinnerManager) StopAll()
- type WelcomeInfo
Constants ¶
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
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 ¶
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
var SpinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
SpinnerFrames contains the braille spinner animation frames
Functions ¶
func GetCurrentFrame ¶
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 ¶
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 ¶
NewSpinner creates a new standalone spinner with default frames. Note: For coordinated spinners, use NewSpinnerManager().NewSpinner() instead.
func (*Spinner) SetMessage ¶
SetMessage sets the message to display after the spinner
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.