Documentation
¶
Overview ¶
Package ui provides the user interface for the application.
Index ¶
- Constants
- Variables
- func GetAssistantMessageStyle(terminalWidth int) lipgloss.Style
- func GetChatBoxStyle(terminalWidth, terminalHeight int) lipgloss.Style
- func GetChatLayoutDimensions(terminalWidth, terminalHeight int) (viewportWidth, viewportHeight, inputHeight int)
- func GetChatTitleStyle(terminalWidth int) lipgloss.Style
- func GetInputBoxStyle(terminalWidth int) lipgloss.Style
- func GetStatusStyle(terminalWidth int) lipgloss.Style
- func GetTerminalWidth() int
- func GetUserMessageStyle(terminalWidth int) lipgloss.Style
- func InitSpinner() spinner.Model
- func InitTerminalSize() (int, int)
- func InitTextArea(width, height int) textarea.Model
- func InitViewport(width, height int) viewport.Model
- func RenderAssistantMessage(personaName, message string, terminalWidth int, messageIndex int, ...) string
- func RenderChatBoxBorder(content string, terminalWidth, terminalHeight int) string
- func RenderChatBoxTitle(title string, terminalWidth int) string
- func RenderError(message string) string
- func RenderGeneratingAudioStatus(terminalWidth int) string
- func RenderHelpBox(title, content string, terminalWidth int) string
- func RenderInfo(message string) string
- func RenderInputBox(content string, terminalWidth int) string
- func RenderMessageSpacing() string
- func RenderMessageWithSeparator(message string, isLast bool) string
- func RenderMuted(message string) string
- func RenderMutedStatus(terminalWidth int) string
- func RenderPersonaDetails(persona, voice, instructions, prompt string, historyCount int, ...) string
- func RenderPersonaListBox(personas []string, terminalWidth int) string
- func RenderPlayingStatus(terminalWidth int) string
- func RenderRecordingStatus(terminalWidth int) string
- func RenderSubtitle(subtitle string) string
- func RenderSuccess(message string) string
- func RenderThinkingStatus(terminalWidth int) string
- func RenderTitle(title string) string
- func RenderTranscribingStatus(terminalWidth int) string
- func RenderUserMessage(message string, terminalWidth int, messageIndex int, isLatest bool) string
- func RenderWarning(message string) string
- type AppMode
- type ChatModel
- type ChatState
- type PersonaItem
Constants ¶
const ( // Borders and padding BORDER_SIZE = 1 HORIZONTAL_MARGIN = 2 VERTICAL_MARGIN = 1 // Reserved space TITLE_HEIGHT = 2 // Title + border STATUS_HEIGHT = 2 // Status message INPUT_HEIGHT = 2 // Input box + border HELP_TEXT_HEIGHT = 1 // Help text BOTTOM_MARGIN = 2 // Extra margin at bottom MIN_VIEWPORT_HEIGHT = 10 // Minimum height for chat viewport // Minimum dimensions MIN_TERMINAL_WIDTH = 40 MIN_TERMINAL_HEIGHT = 20 MIN_MESSAGE_WIDTH = 20 )
Layout constants
Variables ¶
var ( PrimaryColor = lipgloss.Color("#FF6B9D") SecondaryColor = lipgloss.Color("#B8E6B8") AccentColor = lipgloss.Color("#FFE66D") BackgroundColor = lipgloss.Color("#1A1A2E") TextColor = lipgloss.Color("#FFFFFF") MutedColor = lipgloss.Color("#8E8E93") ErrorColor = lipgloss.Color("#FF4757") SuccessColor = lipgloss.Color("#2ECC71") WarningColor = lipgloss.Color("#F39C12") InfoColor = lipgloss.Color("#3498DB") TitleColor = lipgloss.Color("#6143df") ContentColor = lipgloss.Color("#ff79d0") // Message background colors (improved for better contrast) UserBgColor = lipgloss.Color("#2563eb") // Modern blue AssistantBgColor = lipgloss.Color("#6143df") // Modern purple SystemBgColor = lipgloss.Color("#6b7280") // Neutral gray )
Theme colors
var ( // Header styles TitleStyle = lipgloss.NewStyle(). Foreground(TitleColor). Bold(true).Transform(strings.ToUpper).MarginBottom(1).MarginTop(1).MarginLeft(2) ContentStyle = lipgloss.NewStyle(). Foreground(ContentColor).MarginLeft(4) SubtitleStyle = lipgloss.NewStyle(). Foreground(SecondaryColor). Bold(true). MarginBottom(0) MutedStyle = lipgloss.NewStyle(). Foreground(MutedColor). Italic(true) // Message styles UserMessageStyle = lipgloss.NewStyle(). Foreground(AccentColor). Bold(true). Padding(0, 1). Border(lipgloss.RoundedBorder()). BorderForeground(AccentColor). BorderLeft(true) AssistantMessageStyle = lipgloss.NewStyle(). Foreground(SecondaryColor). Padding(0, 1). Border(lipgloss.RoundedBorder()). BorderForeground(SecondaryColor). BorderLeft(true) SystemMessageStyle = lipgloss.NewStyle(). Foreground(MutedColor). Italic(true) // Status styles SuccessStyle = lipgloss.NewStyle(). Foreground(SuccessColor). Bold(true) ErrorStyle = lipgloss.NewStyle(). Foreground(ErrorColor). Bold(true) WarningStyle = lipgloss.NewStyle(). Foreground(WarningColor). Bold(true) InfoStyle = lipgloss.NewStyle(). Foreground(InfoColor). Bold(true) // Input styles InputStyle = lipgloss.NewStyle(). Foreground(TextColor). Border(lipgloss.RoundedBorder()). BorderForeground(PrimaryColor). MarginBottom(1) // List styles ListItemStyle = lipgloss.NewStyle(). Foreground(TextColor). Padding(0, 2) SelectedListItemStyle = lipgloss.NewStyle(). Foreground(BackgroundColor). Background(PrimaryColor). Bold(true). Padding(0, 2) // Progress styles ProgressBarStyle = lipgloss.NewStyle(). Foreground(PrimaryColor) ProgressTextStyle = lipgloss.NewStyle(). Foreground(MutedColor) )
Common styles
var ClockEmojis = []string{"🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕘", "🕙"}
ClockEmojis for message age indication
Functions ¶
func GetChatBoxStyle ¶
GetChatBoxStyle Chat box styles
func GetChatLayoutDimensions ¶
func GetChatLayoutDimensions(terminalWidth, terminalHeight int) (viewportWidth, viewportHeight, inputHeight int)
GetChatLayoutDimensions Responsive layout helper
func GetChatTitleStyle ¶
func GetInputBoxStyle ¶
GetInputBoxStyle box style
func GetStatusStyle ¶
GetStatusStyle Status message style
func GetTerminalWidth ¶
func GetTerminalWidth() int
GetTerminalWidth returns the current terminal width with fallback
func GetUserMessageStyle ¶
GetUserMessageStyle styles with proper width
func InitTerminalSize ¶
InitTerminalSize returns width and height, using defaults on error.
func InitTextArea ¶
InitTextArea initializes the textarea component.
func InitViewport ¶
InitViewport initializes the viewport component.
func RenderAssistantMessage ¶
func RenderChatBoxBorder ¶
func RenderChatBoxTitle ¶
RenderChatBoxTitle Chat box with decorative border
func RenderError ¶
func RenderGeneratingAudioStatus ¶
RenderGeneratingAudioStatus Status messages with animated emojis
func RenderHelpBox ¶
RenderHelpBox renders help content in a chat-style box
func RenderInfo ¶
func RenderInputBox ¶
func RenderMessageSpacing ¶
func RenderMessageSpacing() string
Helper function to add visual spacing between message groups
func RenderMessageWithSeparator ¶
RenderMessageWithSeparator Enhanced message rendering with better visual separation
func RenderMutedStatus ¶
RenderMutedStatus Status messages with animated emojis
func RenderPersonaDetails ¶
func RenderPersonaDetails(persona, voice, instructions, prompt string, historyCount int, terminalWidth int) string
RenderPersonaDetails renders persona details in a chat-style box
func RenderPersonaListBox ¶
RenderPersonaListBox renders persona list in a chat-style box
func RenderPlayingStatus ¶
RenderPlayingStatus Status messages with animated emojis
func RenderRecordingStatus ¶
RenderRecordingStatus Status messages with animated emojis
func RenderSubtitle ¶
func RenderSuccess ¶
func RenderThinkingStatus ¶
RenderThinkingStatus Status messages with animated emojis
func RenderTranscribingStatus ¶
RenderTranscribingStatus Status messages with animated emojis
func RenderUserMessage ¶
RenderUserMessage message renderers with PlaceHorizontal:
func RenderWarning ¶
Types ¶
type ChatModel ¶
type ChatModel struct {
// contains filtered or unexported fields
}
func NewChatModel ¶
func NewChatModelWithSelector ¶
func NewChatModelWithSelector(manager *storage.Manager, config *config.Config, openaiAPIKey string) *ChatModel
NewChatModelWithSelector creates a new chat model that starts with persona selection
func (*ChatModel) Cleanup ¶
func (m *ChatModel) Cleanup()
Cleanup cleans up resources when the chat is closed
func (*ChatModel) SwitchToPersona ¶
SwitchToPersona switches the chat model to a specific persona
type PersonaItem ¶
type PersonaItem struct {
// contains filtered or unexported fields
}
PersonaItem pour la liste des personas
func (PersonaItem) Description ¶
func (i PersonaItem) Description() string
func (PersonaItem) FilterValue ¶
func (i PersonaItem) FilterValue() string
func (PersonaItem) Title ¶
func (i PersonaItem) Title() string