ui

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 FormatSuccess

func FormatSuccess(message string) string

FormatSuccess creates a properly formatted success message

func FormatWarning

func FormatWarning(message string) string

FormatWarning creates a properly formatted warning message

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) 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
}

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) 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) Update

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

func (*ConversationViewImpl) View

func (cv *ConversationViewImpl) View() string

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