ui

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorSpinnerAccent = "205" // Magenta/Pink - used for spinner
	ColorBashMode      = "34"  // Green - inspired by GitHub bash syntax highlighting
	ColorBorderDefault = "240" // Gray - default border color
	ColorTextDim       = "240" // Gray - dim text color
)

UI Color constants for consistency

Variables

This section is empty.

Functions

func FormatError

func FormatError(message string) string

FormatError creates a properly formatted error message without duplicate symbols

func FormatErrorCLI

func FormatErrorCLI(message string) string

FormatErrorCLI creates an error message with ❌ prefix for CLI output

func FormatMessage

func FormatMessage(msgType MessageType, message string) string

FormatMessage formats a message with appropriate icons and styling

func FormatResponsiveCodeBlock added in v0.16.0

func FormatResponsiveCodeBlock(code string, terminalWidth int) string

FormatResponsiveCodeBlock formats code blocks with responsive width

func FormatResponsiveMessage added in v0.16.0

func FormatResponsiveMessage(message string, terminalWidth int) string

FormatResponsiveMessage formats a message with responsive width

func FormatSuccess

func FormatSuccess(message string) string

FormatSuccess creates a properly formatted success message

func FormatToolCall added in v0.14.0

func FormatToolCall(toolName string, args map[string]interface{}) string

FormatToolCall formats a tool call for consistent display across the application

func FormatToolResult added in v0.14.0

func FormatToolResult(result *domain.ToolExecutionResult) string

FormatToolResult formats a tool execution result for display Returns a compact 3-line summary by default

func FormatToolResultExpanded added in v0.14.0

func FormatToolResultExpanded(result *domain.ToolExecutionResult) string

FormatToolResultExpanded formats a tool execution result with full details This is shown when user presses Ctrl+R to expand

func FormatToolResultExpandedResponsive added in v0.16.0

func FormatToolResultExpandedResponsive(result *domain.ToolExecutionResult, terminalWidth int) string

FormatToolResultExpandedResponsive formats a tool execution result with full details and responsive width

func FormatToolResultForLLM added in v0.14.0

func FormatToolResultForLLM(result *domain.ToolExecutionResult) string

FormatToolResultForLLM formats tool execution results specifically for LLM consumption This returns the actual tool data in a format the LLM can understand and use

func FormatToolResultForUI added in v0.14.0

func FormatToolResultForUI(result *domain.ToolExecutionResult) string

FormatToolResultForUI formats tool execution results specifically for UI display This shows a compact "ToolName(args)" format with 2 lines of preview

func FormatToolResultForUIResponsive added in v0.16.0

func FormatToolResultForUIResponsive(result *domain.ToolExecutionResult, terminalWidth int) string

FormatToolResultForUIResponsive formats tool execution results for UI display with responsive width

func FormatWarning

func FormatWarning(message string) string

FormatWarning creates a properly formatted warning message

func GetResponsiveWidth added in v0.16.0

func GetResponsiveWidth(terminalWidth int) int

GetResponsiveWidth calculates appropriate width based on terminal size

func WrapText added in v0.16.0

func WrapText(text string, width int) string

WrapText wraps text to the specified width using wordwrap

Types

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 AutocompleteImpl

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

AutocompleteImpl implements inline autocomplete functionality

func NewAutocomplete

func NewAutocomplete(theme Theme, commandRegistry *commands.Registry) *AutocompleteImpl

NewAutocomplete creates a new autocomplete component

func (*AutocompleteImpl) GetSelectedCommand

func (a *AutocompleteImpl) GetSelectedCommand() string

GetSelectedCommand returns the currently selected command

func (*AutocompleteImpl) HandleKey

func (a *AutocompleteImpl) HandleKey(key tea.KeyMsg) (bool, string)

HandleKey processes key input for autocomplete navigation

func (*AutocompleteImpl) Hide

func (a *AutocompleteImpl) Hide()

Hide hides the autocomplete

func (*AutocompleteImpl) IsVisible

func (a *AutocompleteImpl) IsVisible() bool

IsVisible returns whether autocomplete is currently visible

func (*AutocompleteImpl) Render

func (a *AutocompleteImpl) Render() string

Render returns the autocomplete suggestions as a string

func (*AutocompleteImpl) SetWidth

func (a *AutocompleteImpl) SetWidth(width int)

SetWidth sets the width for rendering

func (*AutocompleteImpl) Update

func (a *AutocompleteImpl) Update(inputText string, cursorPos int)

Update handles autocomplete logic

type ClearErrorMsg

type ClearErrorMsg struct{}

ClearErrorMsg clears any displayed error

type ClearInputMsg

type ClearInputMsg struct{}

ClearInputMsg clears the input field

type CommandOption

type CommandOption struct {
	Command     string
	Description string
}

CommandOption represents a command option for autocomplete

type ComponentFactory

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

ComponentFactory creates UI components with injected dependencies

func NewComponentFactory

func NewComponentFactory(theme Theme, layout Layout, modelService domain.ModelService) *ComponentFactory

func (*ComponentFactory) CreateConversationView

func (f *ComponentFactory) CreateConversationView() ConversationRenderer

func (*ComponentFactory) CreateHelpBar added in v0.16.0

func (f *ComponentFactory) CreateHelpBar() HelpBarComponent

func (*ComponentFactory) CreateInputView

func (f *ComponentFactory) CreateInputView() InputComponent

func (*ComponentFactory) CreateStatusView

func (f *ComponentFactory) CreateStatusView() StatusComponent

func (*ComponentFactory) SetCommandRegistry

func (f *ComponentFactory) SetCommandRegistry(registry *commands.Registry)

SetCommandRegistry updates the command registry for the factory

type ConversationRenderer

type ConversationRenderer interface {
	Renderer
	SetConversation([]domain.ConversationEntry)
	SetScrollOffset(offset int)
	GetScrollOffset() int
	CanScrollUp() bool
	CanScrollDown() bool
	ToggleToolResultExpansion(index int)
	IsToolResultExpanded(index int) bool
}

ConversationRenderer interface for rendering conversation history

type ConversationViewImpl

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

ConversationViewImpl implements ConversationRenderer

func (*ConversationViewImpl) CanScrollDown

func (cv *ConversationViewImpl) CanScrollDown() bool

func (*ConversationViewImpl) CanScrollUp

func (cv *ConversationViewImpl) CanScrollUp() bool

func (*ConversationViewImpl) GetID

func (cv *ConversationViewImpl) GetID() string

func (*ConversationViewImpl) GetScrollOffset

func (cv *ConversationViewImpl) GetScrollOffset() int

func (*ConversationViewImpl) Init

func (cv *ConversationViewImpl) Init() tea.Cmd

func (*ConversationViewImpl) IsToolResultExpanded added in v0.14.0

func (cv *ConversationViewImpl) IsToolResultExpanded(index int) bool

func (*ConversationViewImpl) Render

func (cv *ConversationViewImpl) Render() string

func (*ConversationViewImpl) SetConversation

func (cv *ConversationViewImpl) SetConversation(conversation []domain.ConversationEntry)

func (*ConversationViewImpl) SetHeight

func (cv *ConversationViewImpl) SetHeight(height int)

func (*ConversationViewImpl) SetScrollOffset

func (cv *ConversationViewImpl) SetScrollOffset(offset int)

func (*ConversationViewImpl) SetWidth

func (cv *ConversationViewImpl) SetWidth(width int)

func (*ConversationViewImpl) ToggleToolResultExpansion added in v0.14.0

func (cv *ConversationViewImpl) ToggleToolResultExpansion(index int)

func (*ConversationViewImpl) Update

func (cv *ConversationViewImpl) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ConversationViewImpl) View

func (cv *ConversationViewImpl) View() string

type DebugKeyMsg added in v0.16.0

type DebugKeyMsg struct {
	Key     string
	Handler string
}

DebugKeyMsg provides debug information about key presses

type DefaultLayout

type DefaultLayout struct{}

DefaultLayout implements Layout interface with default spacing

func NewDefaultLayout

func NewDefaultLayout() *DefaultLayout

func (*DefaultLayout) CalculateConversationHeight

func (l *DefaultLayout) CalculateConversationHeight(totalHeight int) int

func (*DefaultLayout) CalculateInputHeight

func (l *DefaultLayout) CalculateInputHeight(totalHeight int) int

func (*DefaultLayout) CalculateStatusHeight

func (l *DefaultLayout) CalculateStatusHeight(totalHeight int) int

func (*DefaultLayout) GetMargins

func (l *DefaultLayout) GetMargins() (top, right, bottom, left int)

type DefaultTheme

type DefaultTheme struct{}

DefaultTheme implements Theme interface with default colors

func NewDefaultTheme

func NewDefaultTheme() *DefaultTheme

func (*DefaultTheme) GetAccentColor

func (t *DefaultTheme) GetAccentColor() string

func (*DefaultTheme) GetAssistantColor

func (t *DefaultTheme) GetAssistantColor() string

func (*DefaultTheme) GetBorderColor

func (t *DefaultTheme) GetBorderColor() string

func (*DefaultTheme) GetDimColor

func (t *DefaultTheme) GetDimColor() string

func (*DefaultTheme) GetErrorColor

func (t *DefaultTheme) GetErrorColor() string

func (*DefaultTheme) GetStatusColor

func (t *DefaultTheme) GetStatusColor() string

func (*DefaultTheme) GetUserColor

func (t *DefaultTheme) GetUserColor() string

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.16.0

type HelpBarComponent interface {
	ViewComponent
	SetShortcuts(shortcuts []KeyShortcut)
	IsEnabled() bool
	SetEnabled(enabled bool)
}

HelpBarComponent interface for bottom help bar display

type HelpBarImpl added in v0.16.0

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

HelpBarImpl implements HelpBarComponent

func (*HelpBarImpl) GetID added in v0.16.0

func (hb *HelpBarImpl) GetID() string

func (*HelpBarImpl) Init added in v0.16.0

func (hb *HelpBarImpl) Init() tea.Cmd

func (*HelpBarImpl) IsEnabled added in v0.16.0

func (hb *HelpBarImpl) IsEnabled() bool

func (*HelpBarImpl) Render added in v0.16.0

func (hb *HelpBarImpl) Render() string

func (*HelpBarImpl) SetEnabled added in v0.16.0

func (hb *HelpBarImpl) SetEnabled(enabled bool)

func (*HelpBarImpl) SetHeight added in v0.16.0

func (hb *HelpBarImpl) SetHeight(height int)

func (*HelpBarImpl) SetShortcuts added in v0.16.0

func (hb *HelpBarImpl) SetShortcuts(shortcuts []KeyShortcut)

func (*HelpBarImpl) SetWidth added in v0.16.0

func (hb *HelpBarImpl) SetWidth(width int)

func (*HelpBarImpl) Update added in v0.16.0

func (hb *HelpBarImpl) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*HelpBarImpl) View added in v0.16.0

func (hb *HelpBarImpl) View() string

type HideHelpBarMsg added in v0.16.0

type HideHelpBarMsg struct{}

HideHelpBarMsg hides the help bar when typing other characters

type InputComponent

type InputComponent interface {
	ViewComponent
	InputHandler
	GetInput() string
	ClearInput()
	SetPlaceholder(text string)
	GetCursor() int
	SetCursor(position int)
}

InputComponent interface for input handling components

type InputHandler

type InputHandler interface {
	HandleKey(key tea.KeyMsg) (tea.Model, tea.Cmd)
	CanHandle(key tea.KeyMsg) bool
}

InputHandler interface for components that handle key input

type InputViewImpl

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

InputViewImpl implements InputComponent

func (*InputViewImpl) CanHandle

func (iv *InputViewImpl) CanHandle(key tea.KeyMsg) bool

func (*InputViewImpl) ClearInput

func (iv *InputViewImpl) ClearInput()

func (*InputViewImpl) GetCursor

func (iv *InputViewImpl) GetCursor() int

func (*InputViewImpl) GetID

func (iv *InputViewImpl) GetID() string

func (*InputViewImpl) GetInput

func (iv *InputViewImpl) GetInput() string

func (*InputViewImpl) HandleKey

func (iv *InputViewImpl) HandleKey(key tea.KeyMsg) (tea.Model, tea.Cmd)

func (*InputViewImpl) Init

func (iv *InputViewImpl) Init() tea.Cmd

func (*InputViewImpl) Render

func (iv *InputViewImpl) Render() string

func (*InputViewImpl) SetCursor

func (iv *InputViewImpl) SetCursor(position int)

func (*InputViewImpl) SetHeight

func (iv *InputViewImpl) SetHeight(height int)

func (*InputViewImpl) SetPlaceholder

func (iv *InputViewImpl) SetPlaceholder(text string)

func (*InputViewImpl) SetText

func (iv *InputViewImpl) SetText(text string)

func (*InputViewImpl) SetWidth

func (iv *InputViewImpl) SetWidth(width int)

func (*InputViewImpl) Update

func (iv *InputViewImpl) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*InputViewImpl) View

func (iv *InputViewImpl) View() string

type KeyShortcut added in v0.16.0

type KeyShortcut struct {
	Key         string
	Description string
}

KeyShortcut represents a keyboard shortcut with description

type Layout

type Layout interface {
	CalculateConversationHeight(totalHeight int) int
	CalculateInputHeight(totalHeight int) int
	CalculateStatusHeight(totalHeight int) int
	GetMargins() (top, right, bottom, left int)
}

Layout interface for managing component positioning

type MessageType

type MessageType int

MessageType represents different types of messages

const (
	MessageSuccess MessageType = iota
	MessageError
	MessageWarning
	MessageInfo
	MessageProgress
)

type ModelSelectedMsg

type ModelSelectedMsg struct {
	Model string
}

ModelSelectedMsg indicates model selection

type ModelSelectorImpl

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

ModelSelectorImpl implements model selection UI

func NewModelSelector

func NewModelSelector(models []string, modelService domain.ModelService, theme Theme) *ModelSelectorImpl

NewModelSelector creates a new model selector

func (*ModelSelectorImpl) GetSelected

func (m *ModelSelectorImpl) GetSelected() string

GetSelected returns the selected model

func (*ModelSelectorImpl) Init

func (m *ModelSelectorImpl) Init() tea.Cmd

func (*ModelSelectorImpl) IsCancelled

func (m *ModelSelectorImpl) IsCancelled() bool

IsCancelled returns true if selection was cancelled

func (*ModelSelectorImpl) IsSelected

func (m *ModelSelectorImpl) IsSelected() bool

IsSelected returns true if a model was selected

func (*ModelSelectorImpl) SetHeight

func (m *ModelSelectorImpl) SetHeight(height int)

SetHeight sets the height of the model selector

func (*ModelSelectorImpl) SetWidth

func (m *ModelSelectorImpl) SetWidth(width int)

SetWidth sets the width of the model selector

func (*ModelSelectorImpl) Update

func (m *ModelSelectorImpl) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ModelSelectorImpl) View

func (m *ModelSelectorImpl) View() string

type Renderer

type Renderer interface {
	Render() string
	SetWidth(width int)
	SetHeight(height int)
}

Renderer interface for components that can render themselves

type ResizeMsg

type ResizeMsg struct {
	Width  int
	Height int
}

ResizeMsg handles terminal resize

type ScrollDirection

type ScrollDirection int
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 SelectionComponent

type SelectionComponent interface {
	ViewComponent
	GetOptions() []string
	SetOptions(options []string)
	GetSelected() string
	GetSelectedIndex() int
	SetSelected(index int)
	IsSelected() bool
	IsCancelled() bool
}

SelectionComponent interface for selection components (models, files, etc.)

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
}

SetStatusMsg sets a status message

type ShowErrorMsg

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

ShowErrorMsg displays an error message

type StateUpdater

type StateUpdater interface {
	Update(msg tea.Msg) (tea.Model, tea.Cmd)
}

StateUpdater interface for components that can update their state

type StatusComponent

type StatusComponent interface {
	ViewComponent
	ShowStatus(message string)
	ShowError(message string)
	ShowSpinner(message string)
	ClearStatus()
	IsShowingError() bool
	IsShowingSpinner() bool
}

StatusComponent interface for status display components

type StatusViewImpl

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

StatusViewImpl implements StatusComponent

func (*StatusViewImpl) ClearStatus

func (sv *StatusViewImpl) ClearStatus()

func (*StatusViewImpl) GetID

func (sv *StatusViewImpl) GetID() string

func (*StatusViewImpl) Init

func (sv *StatusViewImpl) Init() tea.Cmd

func (*StatusViewImpl) IsShowingError

func (sv *StatusViewImpl) IsShowingError() bool

func (*StatusViewImpl) IsShowingSpinner

func (sv *StatusViewImpl) IsShowingSpinner() bool

func (*StatusViewImpl) Render

func (sv *StatusViewImpl) Render() string

func (*StatusViewImpl) SetHeight

func (sv *StatusViewImpl) SetHeight(height int)

func (*StatusViewImpl) SetTokenUsage

func (sv *StatusViewImpl) SetTokenUsage(usage string)

func (*StatusViewImpl) SetWidth

func (sv *StatusViewImpl) SetWidth(width int)

func (*StatusViewImpl) ShowError

func (sv *StatusViewImpl) ShowError(message string)

func (*StatusViewImpl) ShowSpinner

func (sv *StatusViewImpl) ShowSpinner(message string)

func (*StatusViewImpl) ShowStatus

func (sv *StatusViewImpl) ShowStatus(message string)

func (*StatusViewImpl) Update

func (sv *StatusViewImpl) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*StatusViewImpl) View

func (sv *StatusViewImpl) View() string

type Theme

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

Theme interface for styling components

type ToggleHelpBarMsg added in v0.16.0

type ToggleHelpBarMsg struct{}

ToggleHelpBarMsg toggles the help bar visibility

type UpdateHistoryMsg

type UpdateHistoryMsg struct {
	History []domain.ConversationEntry
}

UpdateHistoryMsg updates the conversation history display

type UserInputMsg

type UserInputMsg struct {
	Content string
}

UserInputMsg represents user input submission

type ViewComponent

type ViewComponent interface {
	Renderer
	StateUpdater
	GetID() string
}

ViewComponent interface combining all UI component capabilities

Jump to

Keyboard shortcuts

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