shared

package
v0.33.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset         = "\033[0m"
	ColorRed           = "\033[38;2;247;118;142m" // #f7768e - soft red for errors
	ColorGreen         = "\033[38;2;158;206;106m" // #9ece6a - green for success
	ColorBlue          = "\033[38;2;122;162;247m" // #7aa2f7 - blue for accent
	ColorCyan          = "\033[38;2;125;207;255m" // #7dcfff - cyan variant
	ColorMagenta       = "\033[38;2;187;154;247m" // #bb9af7 - purple for secondary
	ColorWhite         = "\033[38;2;169;177;214m" // #a9b1d6 - light gray-blue for primary text
	ColorGray          = "\033[38;2;86;95;137m"   // #565f89 - dim gray
	ColorAmber         = "\033[38;2;224;175;104m" // #e0af68 - amber for warnings
	ColorBrightRed     = "\033[38;2;247;118;142m" // Same as ColorRed
	ColorStrikethrough = "\033[9m"
	ColorDim           = "\033[2m"
)

ANSI Color Codes - Tokyo Night Theme

View Source
const (
	LipglossRed     = "#f7768e"
	LipglossGreen   = "#9ece6a"
	LipglossBlue    = "#7aa2f7"
	LipglossCyan    = "#7dcfff"
	LipglossMagenta = "#bb9af7"
	LipglossWhite   = "#a9b1d6"
	LipglossGray    = "#565f89"
	LipglossAmber   = "#e0af68"
)

Lipgloss Color Names - Tokyo Night Theme Hex Values

Variables

View Source
var (
	UserColor       = Color{ANSI: ColorBlue, Lipgloss: LipglossBlue}       // Blue for user prompts
	AssistantColor  = Color{ANSI: ColorWhite, Lipgloss: LipglossWhite}     // Light gray-blue for assistant
	ErrorColor      = Color{ANSI: ColorRed, Lipgloss: LipglossRed}         // Soft red for errors
	SuccessColor    = Color{ANSI: ColorGreen, Lipgloss: LipglossGreen}     // Green for success
	StatusColor     = Color{ANSI: ColorMagenta, Lipgloss: LipglossMagenta} // Purple for status/info
	AccentColor     = Color{ANSI: ColorBlue, Lipgloss: LipglossBlue}       // Blue for accents
	DimColor        = Color{ANSI: ColorGray, Lipgloss: LipglossGray}       // Dim gray
	BorderColor     = Color{ANSI: ColorGray, Lipgloss: LipglossGray}       // Gray for borders
	HeaderColor     = Color{ANSI: ColorBlue, Lipgloss: LipglossBlue}       // Blue for headers
	SpinnerColor    = Color{ANSI: ColorMagenta, Lipgloss: LipglossMagenta} // Purple for spinners
	DiffAddColor    = Color{ANSI: ColorGreen, Lipgloss: LipglossGreen}     // Green for additions
	DiffRemoveColor = Color{ANSI: ColorRed, Lipgloss: LipglossRed}         // Red for removals
	WarningColor    = Color{ANSI: ColorAmber, Lipgloss: LipglossAmber}     // Amber for warnings
)

Predefined colors for consistent theming - Tokyo Night Theme

Functions

func CalculateConversationHeight added in v0.27.0

func CalculateConversationHeight(totalHeight int) int

Layout calculation utilities

func CalculateInputHeight added in v0.27.0

func CalculateInputHeight(totalHeight int) int

func CalculateStatusHeight added in v0.27.0

func CalculateStatusHeight(totalHeight int) int

func CreateColoredText

func CreateColoredText(text string, color Color) string

CreateColoredText creates colored text with automatic reset

func CreateDimText added in v0.20.0

func CreateDimText(text string) string

CreateDimText creates text with dim/faint styling

func CreateSeparator

func CreateSeparator(width int, char string) string

CreateSeparator creates a separator line with the given width and character

func CreateStrikethroughText added in v0.20.0

func CreateStrikethroughText(text string) string

CreateStrikethroughText creates text with strikethrough styling

func CreateStyledText

func CreateStyledText(text, colorCode string) string

CreateStyledText creates text with color and reset, commonly used pattern

func FormatCurrentTokenUsage added in v0.33.2

func FormatCurrentTokenUsage(conversationRepo domain.ConversationRepository) string

FormatCurrentTokenUsage returns current session token usage string

func FormatResponsiveMessage

func FormatResponsiveMessage(content string, width int) string

FormatResponsiveMessage formats a message with responsive text wrapping

func FormatToolCall

func FormatToolCall(toolName string, args map[string]any) string

FormatToolCall formats a tool call for consistent display across the application

func FormatToolCallWithOptions added in v0.33.3

func FormatToolCallWithOptions(toolName string, args map[string]any, expanded bool) string

FormatToolCallWithOptions formats a tool call with options for expansion

func FormatWarning added in v0.27.0

func FormatWarning(message string) string

FormatWarning creates a properly formatted warning message

func GetResponsiveWidth

func GetResponsiveWidth(terminalWidth int) int

GetResponsiveWidth calculates appropriate width based on terminal size

func Reset

func Reset() string

Reset returns the ANSI reset code

func RoundedBorder added in v0.33.1

func RoundedBorder() lipgloss.Border

RoundedBorder returns a rounded border style for lipgloss

func TruncateText added in v0.29.6

func TruncateText(text string, maxLength int) string

TruncateText truncates text to fit within maxLength, adding "..." if needed

func WrapText

func WrapText(text string, width int) string

WrapText wraps text to fit within the specified width using wordwrap

Types

type ApprovalComponent added in v0.27.0

type ApprovalComponent interface {
	SetWidth(width int)
	SetHeight(height int)
	Render(toolExecution *domain.ToolExecutionSession, selectedIndex int) string
}

ApprovalComponent interface for approval display

type ApprovalRequestMsg

type ApprovalRequestMsg struct {
	Action      string
	Description string
}

ApprovalRequestMsg requests user approval for an action

type ApprovalResponseMsg

type ApprovalResponseMsg struct {
	Approved   bool
	ApproveAll bool
}

ApprovalResponseMsg provides approval response

type AutocompleteInterface

type AutocompleteInterface interface {
	Update(inputText string, cursorPos int)
	HandleKey(key tea.KeyMsg) (bool, string)
	IsVisible() bool
	SetWidth(width int)
	Render() string
	GetSelectedCommand() string
	Hide()
}

AutocompleteInterface defines the interface for autocomplete functionality

type ClearErrorMsg

type ClearErrorMsg struct{}

ClearErrorMsg clears any displayed error

type ClearInputMsg

type ClearInputMsg struct{}

ClearInputMsg clears the input field

type Color

type Color struct {
	ANSI     string
	Lipgloss string
}

Color represents a color that can be used in both ANSI and Lipgloss contexts

func (Color) GetLipglossColor

func (c Color) GetLipglossColor() lipgloss.Color

GetLipglossColor returns a lipgloss color for the given Color

type CommonStyles

type CommonStyles struct {
	Header          lipgloss.Style
	Border          lipgloss.Style
	Separator       lipgloss.Style
	Input           lipgloss.Style
	Status          lipgloss.Style
	HelpBar         lipgloss.Style
	Conversation    lipgloss.Style
	BashIndicator   lipgloss.Style
	ModelIndicator  lipgloss.Style
	PlaceholderText lipgloss.Style
}

CommonStyles contains reusable lipgloss styles

func NewCommonStyles

func NewCommonStyles() *CommonStyles

NewCommonStyles creates a new set of common styles with consistent theming

type ConversationRenderer added in v0.27.0

type ConversationRenderer interface {
	SetConversation([]domain.ConversationEntry)
	GetScrollOffset() int
	CanScrollUp() bool
	CanScrollDown() bool
	ToggleToolResultExpansion(index int)
	ToggleAllToolResultsExpansion()
	IsToolResultExpanded(index int) bool
	SetWidth(width int)
	SetHeight(height int)
	Render() string
}

ConversationRenderer interface for conversation display

type DebugKeyMsg

type DebugKeyMsg struct {
	Key     string
	Handler string
}

DebugKeyMsg provides debug information about key presses

type FileSelectedMsg

type FileSelectedMsg struct {
	FilePath string
}

FileSelectedMsg indicates file selection

type FileSelectionRequestMsg

type FileSelectionRequestMsg struct{}

FileSelectionRequestMsg requests file selection UI

type FocusRequestMsg

type FocusRequestMsg struct {
	ComponentID string
}

FocusRequestMsg requests focus change

type HelpBarComponent added in v0.27.0

type HelpBarComponent interface {
	SetShortcuts(shortcuts []KeyShortcut)
	IsEnabled() bool
	SetEnabled(enabled bool)
	SetWidth(width int)
	SetHeight(height int)
	Render() string
}

HelpBarComponent interface for help bar

type HideHelpBarMsg

type HideHelpBarMsg struct{}

HideHelpBarMsg hides the help bar when typing other characters

type InputComponent added in v0.27.0

type InputComponent interface {
	GetInput() string
	ClearInput()
	SetPlaceholder(text string)
	GetCursor() int
	SetCursor(position int)
	SetText(text string)
	SetWidth(width int)
	SetHeight(height int)
	Render() string
	HandleKey(key tea.KeyMsg) (tea.Model, tea.Cmd)
	CanHandle(key tea.KeyMsg) bool
	NavigateHistoryUp()
	NavigateHistoryDown()
	IsAutocompleteVisible() bool
	AddToHistory(text string) error
}

InputComponent interface for input handling

type KeyShortcut

type KeyShortcut struct {
	Key         string
	Description string
}

KeyShortcut represents a keyboard shortcut with description

type ModelSelectedMsg

type ModelSelectedMsg struct {
	Model string
}

ModelSelectedMsg indicates model selection

type ResizeMsg

type ResizeMsg struct {
	Width  int
	Height int
}

ResizeMsg handles terminal resize

type ScrollDirection

type ScrollDirection int

ScrollDirection represents different scroll directions

const (
	ScrollUp ScrollDirection = iota
	ScrollDown
	ScrollToTop
	ScrollToBottom
)

type ScrollRequestMsg

type ScrollRequestMsg struct {
	ComponentID string
	Direction   ScrollDirection
	Amount      int
}

ScrollRequestMsg requests scrolling in a component

type SetInputMsg

type SetInputMsg struct {
	Text string
}

SetInputMsg sets text in the input field

type SetStatusMsg

type SetStatusMsg struct {
	Message    string
	Spinner    bool
	TokenUsage string
	StatusType StatusType
	Progress   *StatusProgress
}

SetStatusMsg sets a status message

type SetupFileSelectionMsg added in v0.27.0

type SetupFileSelectionMsg struct {
	Files []string
}

SetupFileSelectionMsg sets up file selection state with files

type ShowErrorMsg

type ShowErrorMsg struct {
	Error  string
	Sticky bool // Whether error persists until dismissed
}

ShowErrorMsg displays an error message

type StatusComponent added in v0.27.0

type StatusComponent interface {
	ShowStatus(message string)
	ShowError(message string)
	ShowSpinner(message string)
	ClearStatus()
	IsShowingError() bool
	IsShowingSpinner() bool
	SetTokenUsage(usage string)
	SetWidth(width int)
	SetHeight(height int)
	Render() string
}

StatusComponent interface for status display

type StatusProgress added in v0.27.0

type StatusProgress struct {
	Current int
	Total   int
}

StatusProgress represents progress information for status messages

type StatusType added in v0.27.0

type StatusType int

StatusType represents different types of status messages

const (
	StatusDefault StatusType = iota
	StatusThinking
	StatusGenerating
	StatusWorking
	StatusProcessing
	StatusPreparing
)

type Theme added in v0.27.0

type Theme interface {
	GetUserColor() string
	GetAssistantColor() string
	GetErrorColor() string
	GetStatusColor() string
	GetAccentColor() string
	GetDimColor() string
	GetBorderColor() string
	GetDiffAddColor() string
	GetDiffRemoveColor() string
}

Theme interface for UI theming

type ToggleHelpBarMsg

type ToggleHelpBarMsg struct{}

ToggleHelpBarMsg toggles the help bar visibility

type UpdateHistoryMsg

type UpdateHistoryMsg struct {
	History []domain.ConversationEntry
}

UpdateHistoryMsg updates the conversation history display

type UpdateStatusMsg added in v0.27.0

type UpdateStatusMsg struct {
	Message    string
	StatusType StatusType
}

UpdateStatusMsg updates an existing status message without resetting timer

type UserInputMsg

type UserInputMsg struct {
	Content string
}

UserInputMsg represents user input submission

Jump to

Keyboard shortcuts

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