Documentation
¶
Overview ¶
Package components provides reusable UI components for the TUI. ABOUTME: Error visualization component with themed styling ABOUTME: Displays errors with appropriate color and formatting
Package components provides reusable UI components for the TUI. ABOUTME: Help overlay component showing keyboard shortcuts ABOUTME: Displays themed help information with keybindings
Package components provides reusable UI components for the Jeff TUI. ABOUTME: Huh-based tool approval component using confirm form ABOUTME: Provides themed approval dialogs for tool execution
ABOUTME: Huh-based email compose form for /contact command ABOUTME: Provides themed form with recipient, subject, and body fields
ABOUTME: Huh-based feedback form component for collecting user feedback ABOUTME: Provides themed form with rating and message fields
Package components provides reusable UI components for the Jeff TUI. ABOUTME: Core component interfaces defining standard behaviors for all UI components ABOUTME: Provides Sizeable, Focusable, Helpable, and Component interfaces for standardization
Package components provides reusable UI components for the TUI. ABOUTME: Progress bar component using bubbles progress ABOUTME: Displays completion percentage with theme colors
Package components provides reusable UI components for the TUI. ABOUTME: Interactive table component using bubbles table ABOUTME: Renders tabular data with theme colors and keyboard navigation
Package components provides reusable UI components for the TUI. ABOUTME: Smooth state transition utilities for UI animations ABOUTME: Provides fade-in, slide-in effects for components
Index ¶
- type ApprovalDecision
- type Component
- type ComposeData
- type ErrorDisplay
- type FadeTransition
- type FeedbackData
- type Focusable
- type HelpOverlay
- type Helpable
- type HuhApproval
- func (h *HuhApproval) GetDecision() ApprovalDecision
- func (h *HuhApproval) GetSize() (int, int)
- func (h *HuhApproval) Init() tea.Cmd
- func (h *HuhApproval) IsApproved() bool
- func (h *HuhApproval) IsComplete() bool
- func (h *HuhApproval) SetApproved(approved bool)
- func (h *HuhApproval) SetSize(width, height int) tea.Cmd
- func (h *HuhApproval) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *HuhApproval) View() string
- type HuhCompose
- func (h *HuhCompose) GetData() ComposeData
- func (h *HuhCompose) GetSize() (int, int)
- func (h *HuhCompose) Init() tea.Cmd
- func (h *HuhCompose) IsAborted() bool
- func (h *HuhCompose) IsComplete() bool
- func (h *HuhCompose) SetSize(width, height int) tea.Cmd
- func (h *HuhCompose) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *HuhCompose) View() string
- type HuhFeedback
- func (h *HuhFeedback) GetData() FeedbackData
- func (h *HuhFeedback) GetSize() (int, int)
- func (h *HuhFeedback) Init() tea.Cmd
- func (h *HuhFeedback) IsAborted() bool
- func (h *HuhFeedback) IsComplete() bool
- func (h *HuhFeedback) SetSize(width, height int) tea.Cmd
- func (h *HuhFeedback) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *HuhFeedback) View() string
- type Progress
- type Sizeable
- type Table
- type TransitionState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalDecision ¶
type ApprovalDecision string
ApprovalDecision represents the user's decision on tool approval
const ( // DecisionApprove approves this single tool execution DecisionApprove ApprovalDecision = "approve" // DecisionDeny denies this single tool execution DecisionDeny ApprovalDecision = "deny" // DecisionAlwaysAllow always allows this tool without future prompts DecisionAlwaysAllow ApprovalDecision = "always_allow" // DecisionNeverAllow blocks this tool permanently DecisionNeverAllow ApprovalDecision = "never_allow" )
type Component ¶
Component is the base interface that all UI components should implement. It combines the standard Bubble Tea Model interface with size management, ensuring that components can both handle the Bubble Tea update cycle and respond to terminal resize events.
By implementing Component, a type automatically satisfies tea.Model and Sizeable, making it compatible with the Bubble Tea framework while supporting our size propagation system.
Example usage:
type ChatMessage struct {
content string
width int
height int
}
// Implement tea.Model
func (c *ChatMessage) Init() tea.Cmd {
return nil
}
func (c *ChatMessage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return c, nil
}
func (c *ChatMessage) View() string {
return lipgloss.NewStyle().
Width(c.width).
Render(c.content)
}
// Implement Sizeable
func (c *ChatMessage) SetSize(width, height int) tea.Cmd {
c.width = width
c.height = height
return nil
}
func (c *ChatMessage) GetSize() (int, int) {
return c.width, c.height
}
// Now ChatMessage implements Component and can be used throughout the UI
Interface composition pattern:
// A component that is both focusable and provides help
type FullFeaturedComponent interface {
Component
Focusable
Helpable
}
// Check if a component implements optional interfaces
if focusable, ok := component.(Focusable); ok {
cmd := focusable.Focus()
}
if helpable, ok := component.(Helpable); ok {
helpText := helpable.HelpView()
}
type ComposeData ¶ added in v0.3.6
ComposeData represents the email compose data
type ErrorDisplay ¶
type ErrorDisplay struct {
// contains filtered or unexported fields
}
ErrorDisplay shows formatted errors
func NewErrorDisplay ¶
func NewErrorDisplay(theme themes.Theme, title, message, details string) *ErrorDisplay
NewErrorDisplay creates a new error display
func (*ErrorDisplay) GetSize ¶
func (e *ErrorDisplay) GetSize() (int, int)
GetSize implements the Sizeable interface
func (*ErrorDisplay) SetSize ¶
func (e *ErrorDisplay) SetSize(width, height int) tea.Cmd
SetSize implements the Sizeable interface
func (*ErrorDisplay) View ¶
func (e *ErrorDisplay) View() string
View implements tea.Model and renders the error display
type FadeTransition ¶
type FadeTransition struct {
// contains filtered or unexported fields
}
FadeTransition handles fade-in/out animations
func NewFadeTransition ¶
func NewFadeTransition(duration time.Duration) *FadeTransition
NewFadeTransition creates a new fade transition
func (*FadeTransition) FadeIn ¶
func (f *FadeTransition) FadeIn() tea.Cmd
FadeIn starts fade-in animation
func (*FadeTransition) GetOpacity ¶
func (f *FadeTransition) GetOpacity() float64
GetOpacity returns current opacity (0.0 to 1.0)
func (*FadeTransition) IsComplete ¶
func (f *FadeTransition) IsComplete() bool
IsComplete returns whether transition is done
type FeedbackData ¶ added in v0.3.6
FeedbackData represents the collected feedback
type Focusable ¶
type Focusable interface {
// Focus gives keyboard focus to the component. This typically triggers
// visual changes to indicate the focused state and may return a command
// to perform focus-related initialization (e.g., blinking cursor).
Focus() tea.Cmd
// Blur removes keyboard focus from the component. This typically triggers
// visual changes to indicate the unfocused state and may return a command
// to perform cleanup (e.g., stop cursor blinking).
Blur() tea.Cmd
// IsFocused returns true if the component currently has keyboard focus.
// This allows parent components to route keyboard events appropriately.
IsFocused() bool
}
Focusable components can receive keyboard focus and respond to focus changes. When a component is focused, it typically becomes the primary recipient of keyboard input and may render differently to indicate its focused state.
Example usage:
type InputField struct {
value string
focused bool
}
func (i *InputField) Focus() tea.Cmd {
i.focused = true
return nil
}
func (i *InputField) Blur() tea.Cmd {
i.focused = false
return nil
}
func (i *InputField) IsFocused() bool {
return i.focused
}
func (i *InputField) View() string {
if i.focused {
return focusedStyle.Render(i.value)
}
return normalStyle.Render(i.value)
}
Focus management in parent components:
case key.Matches(msg, m.keymap.NextField):
if m.currentField != nil {
m.currentField.Blur()
}
m.currentField = m.nextField
return m, m.currentField.Focus()
type HelpOverlay ¶
type HelpOverlay struct {
// contains filtered or unexported fields
}
HelpOverlay displays keyboard shortcuts
func NewHelpOverlay ¶
func NewHelpOverlay(theme themes.Theme) *HelpOverlay
NewHelpOverlay creates a new help overlay
func (*HelpOverlay) GetSize ¶
func (h *HelpOverlay) GetSize() (int, int)
GetSize implements the Sizeable interface
func (*HelpOverlay) SetSize ¶
func (h *HelpOverlay) SetSize(width, height int) tea.Cmd
SetSize implements the Sizeable interface Phase 1 Task 3: Invalidates cache when size changes
func (*HelpOverlay) View ¶
func (h *HelpOverlay) View() string
View implements tea.Model and renders the help overlay Phase 1 Task 3: Uses caching to avoid expensive re-renders
type Helpable ¶
type Helpable interface {
// HelpView returns a formatted string containing help text for the component.
// The returned string should be ready to display, including any styling.
// Return an empty string if the component has no help to display.
HelpView() string
}
Helpable components can provide contextual help text to users. This interface allows components to document their keyboard shortcuts, functionality, and usage in a consistent way.
Example usage:
type FileManager struct {
// ... fields ...
}
func (f *FileManager) HelpView() string {
return lipgloss.JoinVertical(lipgloss.Left,
"File Manager Help",
"",
"↑/↓ Navigate files",
"enter Open file",
"d Delete file",
"r Rename file",
"? Toggle help",
)
}
Parent components can aggregate help from children:
func (m *Model) aggregateHelp() string {
var helpSections []string
for _, child := range m.helpableChildren {
if help := child.HelpView(); help != "" {
helpSections = append(helpSections, help)
}
}
return lipgloss.JoinVertical(lipgloss.Left, helpSections...)
}
type HuhApproval ¶
type HuhApproval struct {
// contains filtered or unexported fields
}
HuhApproval is a Huh-based approval dialog for tool execution
func NewHuhApproval ¶
func NewHuhApproval(theme themes.Theme, toolName, description string) *HuhApproval
NewHuhApproval creates a new Huh approval dialog Uses Select instead of Confirm because Select works properly with Enter key
func (*HuhApproval) GetDecision ¶
func (h *HuhApproval) GetDecision() ApprovalDecision
GetDecision returns the user's decision
func (*HuhApproval) GetSize ¶
func (h *HuhApproval) GetSize() (int, int)
GetSize implements the Sizeable interface
func (*HuhApproval) IsApproved ¶
func (h *HuhApproval) IsApproved() bool
IsApproved returns whether the tool was approved (including always allow)
func (*HuhApproval) IsComplete ¶
func (h *HuhApproval) IsComplete() bool
IsComplete returns whether the form is complete
func (*HuhApproval) SetApproved ¶
func (h *HuhApproval) SetApproved(approved bool)
SetApproved sets the approval state (for testing)
func (*HuhApproval) SetSize ¶
func (h *HuhApproval) SetSize(width, height int) tea.Cmd
SetSize implements the Sizeable interface
type HuhCompose ¶ added in v0.3.6
type HuhCompose struct {
// contains filtered or unexported fields
}
HuhCompose is a Huh-based email compose form
func NewHuhCompose ¶ added in v0.3.6
func NewHuhCompose(theme themes.Theme, initialTo string) *HuhCompose
NewHuhCompose creates a new email compose form
func (*HuhCompose) GetData ¶ added in v0.3.6
func (h *HuhCompose) GetData() ComposeData
GetData returns the compose data
func (*HuhCompose) GetSize ¶ added in v0.3.6
func (h *HuhCompose) GetSize() (int, int)
GetSize implements the Sizeable interface
func (*HuhCompose) Init ¶ added in v0.3.6
func (h *HuhCompose) Init() tea.Cmd
Init implements tea.Model
func (*HuhCompose) IsAborted ¶ added in v0.3.6
func (h *HuhCompose) IsAborted() bool
IsAborted returns whether the form was cancelled
func (*HuhCompose) IsComplete ¶ added in v0.3.6
func (h *HuhCompose) IsComplete() bool
IsComplete returns whether the form is complete
func (*HuhCompose) SetSize ¶ added in v0.3.6
func (h *HuhCompose) SetSize(width, height int) tea.Cmd
SetSize implements the Sizeable interface
func (*HuhCompose) View ¶ added in v0.3.6
func (h *HuhCompose) View() string
View implements tea.Model
type HuhFeedback ¶ added in v0.3.6
type HuhFeedback struct {
// contains filtered or unexported fields
}
HuhFeedback is a Huh-based feedback form
func NewHuhFeedback ¶ added in v0.3.6
func NewHuhFeedback(theme themes.Theme) *HuhFeedback
NewHuhFeedback creates a new feedback form
func (*HuhFeedback) GetData ¶ added in v0.3.6
func (h *HuhFeedback) GetData() FeedbackData
GetData returns the collected feedback data
func (*HuhFeedback) GetSize ¶ added in v0.3.6
func (h *HuhFeedback) GetSize() (int, int)
GetSize implements the Sizeable interface
func (*HuhFeedback) Init ¶ added in v0.3.6
func (h *HuhFeedback) Init() tea.Cmd
Init implements tea.Model
func (*HuhFeedback) IsAborted ¶ added in v0.3.6
func (h *HuhFeedback) IsAborted() bool
IsAborted returns whether the form was cancelled
func (*HuhFeedback) IsComplete ¶ added in v0.3.6
func (h *HuhFeedback) IsComplete() bool
IsComplete returns whether the form is complete
func (*HuhFeedback) SetSize ¶ added in v0.3.6
func (h *HuhFeedback) SetSize(width, height int) tea.Cmd
SetSize implements the Sizeable interface
func (*HuhFeedback) View ¶ added in v0.3.6
func (h *HuhFeedback) View() string
View implements tea.Model
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress is a themed progress bar component
func NewProgress ¶
NewProgress creates a new progress bar
type Sizeable ¶
type Sizeable interface {
// SetSize updates the component's dimensions and returns any command
// needed to complete the resize operation. For example, a component
// might need to invalidate cached content or trigger a re-layout.
//
// The width and height parameters represent the available space for
// the component in terminal cells.
SetSize(width, height int) tea.Cmd
// GetSize returns the current dimensions of the component in terminal cells.
// This allows parent components to query child dimensions for layout calculations.
GetSize() (int, int)
}
Sizeable components can be resized to fit different terminal dimensions. Components implementing this interface can respond to terminal resize events and adjust their rendering accordingly.
Example usage:
type MyComponent struct {
width int
height int
}
func (m *MyComponent) SetSize(width, height int) tea.Cmd {
m.width = width
m.height = height
return nil
}
func (m *MyComponent) GetSize() (int, int) {
return m.width, m.height
}
When a WindowSizeMsg is received, parent components should propagate the size to their children:
case tea.WindowSizeMsg:
if m.child != nil {
cmd := m.child.SetSize(msg.Width, msg.Height)
return m, cmd
}
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a themed table component
func (*Table) GetSelectedRow ¶
GetSelectedRow returns the currently selected row index
type TransitionState ¶
type TransitionState int
TransitionState represents animation state
const ( // TransitionIdle indicates no animation is active TransitionIdle TransitionState = iota // TransitionFadingIn indicates fade-in animation is in progress TransitionFadingIn // TransitionFadingOut indicates fade-out animation is in progress TransitionFadingOut // TransitionComplete indicates animation has finished TransitionComplete )