Documentation
¶
Overview ¶
Package core provides core types and interfaces for the Kafui UI framework.
Index ¶
- Constants
- func BatchCommands(cmds ...tea.Cmd) tea.Cmd
- func CalculateTableDimensions(totalWidth int, columnWeights []float64) []int
- func CenterString(s string, width int) string
- func CreateTimer(id string, duration time.Duration) tea.Cmd
- func DebugMessage(format string, args ...interface{}) tea.Cmd
- func FormatBytes(bytes int64) string
- func FormatCount(count int) string
- func FormatDuration(d time.Duration) string
- func FormatStatusMessage(message string, statusType StatusType) string
- func FormatTime(t time.Time) string
- func HighlightMatches(text, query string) string
- func IsHover(msg tea.MouseMsg) bool
- func IsKeyMatch(msg tea.KeyMsg, bindings ...key.Binding) bool
- func IsLeftRelease(msg tea.MouseMsg) bool
- func MaxLength(maxLen int) func(string) error
- func MinLength(minLen int) func(string) error
- func NewConsumerGroupsLoadErrorMsg(err error) tea.Cmd
- func NewConsumerGroupsLoadedMsg(groups []api.ConsumerGroup) tea.Cmd
- func NewContextsLoadErrorMsg(err error) tea.Cmd
- func NewContextsLoadedMsg(contexts []string) tea.Cmd
- func NewDataErrorMsg(dataType string, err error) tea.Cmd
- func NewDataLoadedMsg(dataType string, data interface{}) tea.Cmd
- func NewErrorMsg(message string) tea.Cmd
- func NewInfoMsg(message string) tea.Cmd
- func NewMessageConsumeErrorMsg(err error) tea.Cmd
- func NewMessagesConsumedMsg(messages []api.Message) tea.Cmd
- func NewNotification(sev StatusType, title, message string) tea.Cmd
- func NewPageChangeMsg(pageID string, data interface{}) tea.Cmd
- func NewPermanentErrorMsg(message string) tea.Cmd
- func NewResourceSelectedMsg(resourceID, resourceType string, item interface{}) tea.Cmd
- func NewSchemasLoadErrorMsg(err error) tea.Cmd
- func NewSchemasLoadedMsg(schemas []api.SchemaInfo) tea.Cmd
- func NewStatusMsg(message string, statusType StatusType) tea.Cmd
- func NewSuccessMsg(message string) tea.Cmd
- func NewTopicsLoadErrorMsg(err error) tea.Cmd
- func NewTopicsLoadedMsg(topics map[string]api.Topic) tea.Cmd
- func NewWarningMsg(message string) tea.Cmd
- func NotEmpty(input string) error
- func NotifyError(title string, err error) tea.Cmd
- func PadString(s string, width int) string
- func RetryWithBackoff(cmd tea.Cmd, config RetryConfig) tea.Cmd
- func ScopeOf(page any) keys.Scope
- func TruncateString(s string, maxLen int) string
- func ValidateStringInput(input string, rules ...func(string) error) error
- func WrapText(text string, width int) []string
- type ActionProvider
- type BackMsg
- type BaseComponent
- func (b *BaseComponent) ApplyConfig(config ComponentConfig)
- func (b *BaseComponent) GetHeight() int
- func (b *BaseComponent) GetID() string
- func (b *BaseComponent) GetWidth() int
- func (b *BaseComponent) Init() tea.Cmd
- func (b *BaseComponent) SetDimensions(width, height int)
- func (b *BaseComponent) SetID(id string)
- func (b *BaseComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (b *BaseComponent) View() string
- type BreadcrumbUpdateMsg
- type ClearSearchMsg
- type ClickTracker
- type Common
- func (c *Common) ActiveCapabilities() []api.Capability
- func (c *Common) ActiveProfileName() string
- func (c *Common) ApplyAppConfig(cfg appconfig.Config)
- func (c *Common) AuthzEnabled() bool
- func (c *Common) Can(action authz.Action, rt authz.ResourceType, name string) bool
- func (c *Common) GetLayout(width, height int) *layout.Layout
- func (c *Common) HasCapability(cap api.Capability) bool
- func (c *Common) IsReadOnly() bool
- func (c *Common) UpdateLayout(width, height int)
- type Component
- type ComponentConfig
- type ComponentWithLayout
- type ConfigReloadedMsg
- type ConfirmResolvedMsg
- type ConnectionState
- type ConsumerGroupsLoadErrorMsg
- type ConsumerGroupsLoadedMsg
- type ConsumptionErrorMsg
- type ConsumptionStartedMsg
- type ConsumptionStoppedMsg
- type ContextsLoadErrorMsg
- type ContextsLoadedMsg
- type DataErrorMsg
- type DataLoadedMsg
- type DataLoader
- type DetailPageCloseMsg
- type DetailPageOpenMsg
- type Dimensions
- type DimensionsUpdateMsg
- type EventHandler
- type FilterAppliedMsg
- type FocusManager
- func (fm *FocusManager) AddComponent(component Focusable)
- func (fm *FocusManager) Clear()
- func (fm *FocusManager) FocusComponent(id string) tea.Cmd
- func (fm *FocusManager) FocusNext() tea.Cmd
- func (fm *FocusManager) FocusPrevious() tea.Cmd
- func (fm *FocusManager) GetComponentCount() int
- func (fm *FocusManager) GetFocusableComponents() []Focusable
- func (fm *FocusManager) GetFocusedComponent() Focusable
- func (fm *FocusManager) GetFocusedComponentID() string
- func (fm *FocusManager) HandleKeyMsg(msg tea.KeyMsg) tea.Cmd
- func (fm *FocusManager) IsEnabled() bool
- func (fm *FocusManager) RemoveComponent(id string)
- func (fm *FocusManager) SetEnabled(enabled bool)
- type FocusState
- type Focusable
- type FocusableComponent
- type HelpBinding
- type HelpSection
- type HelpStyles
- type HelpSystem
- func (h *HelpSystem) GetKeyBindingHelp(keyBinding key.Binding) string
- func (h *HelpSystem) GetQuickHelp() string
- func (h *HelpSystem) Hide()
- func (h *HelpSystem) IsVisible() bool
- func (h *HelpSystem) Render() string
- func (h *HelpSystem) SetCurrentPage(page Page)
- func (h *HelpSystem) SetDimensions(width, height int)
- func (h *HelpSystem) Show()
- func (h *HelpSystem) Toggle()
- type InputModeReporter
- type KeyBinding
- type KeyHandler
- type KeyScoper
- type LoadingMsg
- type LoadingState
- type MessageConsumeErrorMsg
- type MessageConsumedMsg
- type MessagesConsumedMsg
- type NotificationMsg
- type Page
- type PageChangeMsg
- type PaletteProvider
- type QuitMsg
- type RefreshDataMsg
- type ResourceChangeMsg
- type ResourceLoadMsg
- type ResourceManager
- type ResourceSelectedMsg
- type RetryCommand
- type RetryConfig
- type RetryError
- type RetryState
- type RetryableOperation
- type SchemasLoadErrorMsg
- type SchemasLoadedMsg
- type SearchMode
- type SearchModeChangeMsg
- type SearchMsg
- type ShowConfirmMsg
- type SidebarToggledMsg
- type StatefulPage
- type StatusBarConfig
- type StatusMessage
- type StatusMsg
- type StatusType
- type Theme
- type TimerTickMsg
- type TopicSelectedMsg
- type TopicsLoadErrorMsg
- type TopicsLoadedMsg
- type UIConfig
- type UIState
- type Unwinder
- type ViewRenderer
- type WindowSizeMsg
Constants ¶
const DoubleClickWindow = 400 * time.Millisecond
DoubleClickWindow is how close together two clicks on the same spot must be to count as a double click. 400ms is the common desktop default; shorter and deliberate double clicks get missed on a slow terminal link.
Variables ¶
This section is empty.
Functions ¶
func BatchCommands ¶
BatchCommands combines multiple commands into a single batch command
func CalculateTableDimensions ¶
CalculateTableDimensions calculates optimal dimensions for table columns
func CenterString ¶
CenterString centers a string within the specified width
func CreateTimer ¶
Timer utilities for creating periodic updates
func DebugMessage ¶
DebugMessage creates a debug message for development
func FormatBytes ¶
FormatBytes formats bytes to human-readable string
func FormatCount ¶
FormatCount formats a count with appropriate units
func FormatDuration ¶
FormatDuration formats a duration to a human-readable string
func FormatStatusMessage ¶
func FormatStatusMessage(message string, statusType StatusType) string
FormatStatusMessage formats a status message with type prefix
func FormatTime ¶
FormatTime formats a time.Time to a human-readable string
func HighlightMatches ¶
Color utilities for highlighting text
func IsHover ¶ added in v0.1.35
IsHover reports whether msg is pointer motion with no button held, which is what drives hover highlighting.
func IsKeyMatch ¶
IsKeyMatch checks if a key message matches any of the provided key bindings
func IsLeftRelease ¶ added in v0.1.35
IsLeftRelease reports whether msg is the release half of a left click, which is the only mouse event that should ever act. Acting on press makes a drag that starts on a row fire the row's action.
func NewConsumerGroupsLoadErrorMsg ¶
NewConsumerGroupsLoadErrorMsg creates a command that sends a ConsumerGroupsLoadErrorMsg
func NewConsumerGroupsLoadedMsg ¶
func NewConsumerGroupsLoadedMsg(groups []api.ConsumerGroup) tea.Cmd
NewConsumerGroupsLoadedMsg creates a command that sends a ConsumerGroupsLoadedMsg
func NewContextsLoadErrorMsg ¶
NewContextsLoadErrorMsg creates a command that sends a ContextsLoadErrorMsg
func NewContextsLoadedMsg ¶
NewContextsLoadedMsg creates a command that sends a ContextsLoadedMsg
func NewDataLoadedMsg ¶
Common message creation functions
func NewErrorMsg ¶
NewErrorMsg creates an error status message
func NewInfoMsg ¶
NewInfoMsg creates an informational status message
func NewMessageConsumeErrorMsg ¶
NewMessageConsumeErrorMsg creates a command that sends a MessageConsumeErrorMsg
func NewMessagesConsumedMsg ¶
NewMessagesConsumedMsg creates a command that sends a MessagesConsumedMsg
func NewNotification ¶
func NewNotification(sev StatusType, title, message string) tea.Cmd
NewNotification builds a command emitting a NotificationMsg.
func NewPageChangeMsg ¶
func NewPermanentErrorMsg ¶
NewPermanentErrorMsg creates a permanent error status message (no auto-dismiss)
func NewResourceSelectedMsg ¶
func NewSchemasLoadErrorMsg ¶
NewSchemasLoadErrorMsg creates a command that sends a SchemasLoadErrorMsg
func NewSchemasLoadedMsg ¶
func NewSchemasLoadedMsg(schemas []api.SchemaInfo) tea.Cmd
NewSchemasLoadedMsg creates a command that sends a SchemasLoadedMsg
func NewStatusMsg ¶
func NewStatusMsg(message string, statusType StatusType) tea.Cmd
func NewSuccessMsg ¶
NewSuccessMsg creates a success status message
func NewTopicsLoadErrorMsg ¶
NewTopicsLoadErrorMsg creates a command that sends a TopicsLoadErrorMsg
func NewTopicsLoadedMsg ¶
NewTopicsLoadedMsg creates a command that sends a TopicsLoadedMsg
func NewWarningMsg ¶
NewWarningMsg creates a warning status message
func NotifyError ¶
NotifyError builds an error notification from an error value.
func RetryWithBackoff ¶
func RetryWithBackoff(cmd tea.Cmd, config RetryConfig) tea.Cmd
RetryWithBackoff creates a command that executes another command with exponential backoff
func ScopeOf ¶ added in v0.1.35
ScopeOf returns the key scope for a page, defaulting to a list screen.
func TruncateString ¶
TruncateString truncates a string to the specified length with ellipsis
func ValidateStringInput ¶
ValidateStringInput validates string input for common use cases
Types ¶
type ActionProvider ¶ added in v0.1.35
ActionProvider supplies the contextual actions menu (`a`, right-click) for whatever the page currently has focused or selected. Entries the user may not perform must be returned Disabled with a Reason rather than omitted, so the action's existence stays discoverable.
type BaseComponent ¶
type BaseComponent struct {
// contains filtered or unexported fields
}
BaseComponent provides common functionality for all UI components. Embed this struct in your component to get default implementations.
Example:
type SearchBar struct {
BaseComponent
textInput textinput.Model
// ... other fields
}
func NewBaseComponent ¶
func NewBaseComponent(width, height int) BaseComponent
NewBaseComponent creates a new BaseComponent with the given dimensions.
func (*BaseComponent) ApplyConfig ¶
func (b *BaseComponent) ApplyConfig(config ComponentConfig)
ApplyConfig applies the configuration to a base component.
func (*BaseComponent) GetHeight ¶
func (b *BaseComponent) GetHeight() int
GetHeight returns the component's height.
func (*BaseComponent) GetID ¶
func (b *BaseComponent) GetID() string
GetID returns the component's identifier.
func (*BaseComponent) GetWidth ¶
func (b *BaseComponent) GetWidth() int
GetWidth returns the component's width.
func (*BaseComponent) Init ¶
func (b *BaseComponent) Init() tea.Cmd
Init provides a default initialization that does nothing. Override this method in your component if initialization is needed.
func (*BaseComponent) SetDimensions ¶
func (b *BaseComponent) SetDimensions(width, height int)
SetDimensions sets the component's dimensions. This is used for layout calculations.
func (*BaseComponent) SetID ¶
func (b *BaseComponent) SetID(id string)
SetID sets the component's identifier.
func (*BaseComponent) Update ¶
Update provides a default update that does nothing. Override this method in your component to handle messages.
func (*BaseComponent) View ¶
func (b *BaseComponent) View() string
View provides a default view that returns empty string. Override this method in your component to render content.
type BreadcrumbUpdateMsg ¶
type BreadcrumbUpdateMsg struct {
Items []string
}
Page navigation messages
type ClickTracker ¶ added in v0.1.35
type ClickTracker struct {
// contains filtered or unexported fields
}
ClickTracker classifies left clicks as single or double. The controls spec wants double click to activate, but a bare "click the already-selected row" rule cannot distinguish a user re-selecting a row from one opening it, so both gestures exist and this is what tells them apart.
The zero value is ready to use. A tracker is per-pane: two panes tracking clicks independently is what stops a click in one and a click in the other from reading as a double click.
func (*ClickTracker) Click ¶ added in v0.1.35
func (c *ClickTracker) Click(msg tea.MouseMsg) (double bool)
Click records a left-click release and reports whether it completes a double click. A double click resets the tracker, so three rapid clicks are one single and one double rather than two doubles.
type Common ¶
type Common struct {
// DataSource is the Kafka data source
DataSource api.KafkaDataSource
// Styles contains all application styles
Styles *stylesPkg.Styles
// Layout contains the current layout configuration
Layout *layout.Layout
// LayoutConfig contains layout configuration options
LayoutConfig *layout.LayoutConfig
// Config contains UI configuration
Config *UIConfig
// AppConfig is the effective kafui-owned configuration (read-only flags,
// optional integrations, UI prefs). Never nil.
AppConfig *appconfig.Config
// Redactor masks secrets when displaying configuration.
Redactor *appconfig.Redactor
// Collector is the background cluster statistics collector (may be nil in
// lightweight/test contexts; callers must nil-check).
Collector *cluster.Collector
// MetricsCollector is the background metrics collector feeding the metrics
// page (may be nil in lightweight/test contexts; callers must nil-check).
MetricsCollector *metrics.Collector
// Gate is the local authorization gate. Nil in lightweight/test contexts,
// which means allow-all (see Can). Pages must query permissions through the
// Can/AuthzEnabled/ActiveProfileName helpers, never a global.
Gate *authz.Gate
// Identity is the acting local user (OS user), shown in the header and
// whoami view and recorded in the audit log.
Identity string
// InitialResource is the CLI --resource deep-link (UI-9), consumed once by
// the main page at construction time so the sidebar/breadcrumb reflect it
// from the start (BUG-7) instead of racing an async switch against the
// page's own default-resource Init().
InitialResource string
}
Common provides shared context and dependencies across all UI components. This pattern ensures consistent dependency injection and makes testing easier.
func NewCommon ¶
func NewCommon(dataSource api.KafkaDataSource) *Common
NewCommon creates a new Common context with the given data source. It initializes default styles and configuration.
func NewCommonWithConfig ¶
func NewCommonWithConfig(dataSource api.KafkaDataSource, config *UIConfig) *Common
NewCommonWithConfig creates a new Common context with custom configuration
func (*Common) ActiveCapabilities ¶
func (c *Common) ActiveCapabilities() []api.Capability
ActiveCapabilities returns the capability set of the active cluster from the collector cache, or nil if the collector is unavailable / has no data yet.
func (*Common) ActiveProfileName ¶
ActiveProfileName returns the resolved active profile name (empty when authz is disabled or no profile covers the current cluster).
func (*Common) ApplyAppConfig ¶
ApplyAppConfig installs the loaded kafui config and syncs derived UI settings.
func (*Common) AuthzEnabled ¶
AuthzEnabled reports whether a permission profile is active.
func (*Common) Can ¶
Can reports whether the active profile permits action on the named resource. A nil Gate (tests / authz disabled) is allow-all. This is the single helper pages use to hide/disable mutating keys; blocked attempts still route the guard's typed error to the status bar. Use "" as name for create/unnamed checks (name patterns are ignored for those).
func (*Common) HasCapability ¶
func (c *Common) HasCapability(cap api.Capability) bool
HasCapability reports whether the active cluster advertises the given capability. Returns true when capabilities are unknown (collector not ready) so features are not hidden before the first collection cycle.
func (*Common) IsReadOnly ¶
IsReadOnly reports whether the active cluster is read-only, honoring both the per-cluster config flag and the global --read-only CLI flag (via the Gate).
func (*Common) UpdateLayout ¶
UpdateLayout recalculates the layout based on new dimensions
type Component ¶
type Component interface {
// Init initializes the component and returns an initial command.
Init() tea.Cmd
// Update handles messages and returns updated component and commands.
Update(msg tea.Msg) (tea.Model, tea.Cmd)
// View renders the component to a string.
View() string
// SetDimensions sets the component's dimensions.
SetDimensions(width, height int)
}
Component defines the interface that all UI components must implement. This pattern is inspired by Elm architecture and Bubble Tea conventions.
type ComponentConfig ¶
type ComponentConfig struct {
// ID is a unique identifier for the component
ID string
// Width and Height set initial dimensions
Width int
Height int
// Common context for accessing shared dependencies
Common *Common
}
ComponentConfig holds common configuration for components.
type ComponentWithLayout ¶
type ComponentWithLayout interface {
Component
// GetLayout returns the component's layout rectangle.
GetLayout() layout.Rectangle
// SetLayout sets the component's layout rectangle.
SetLayout(rect layout.Rectangle)
}
ComponentWithLayout extends Component with layout-specific methods.
type ConfigReloadedMsg ¶
type ConfigReloadedMsg struct {
Config interface{} // *appconfig.Config
}
ConfigReloadedMsg carries a freshly-loaded kafui config when the on-disk file changed while kafui is running (AC-16). The shell hot-applies reloadable settings (UI prefs, cluster extensions) but never reconnects the active cluster. Carried as interface{} to avoid an appconfig import in core.
type ConfirmResolvedMsg ¶
type ConfirmResolvedMsg struct {
Confirmed bool
}
ConfirmResolvedMsg reports the outcome of a confirmation dialog.
type ConnectionState ¶
type ConnectionState uint8
ConnectionState represents the connection state to Kafka
const ( // ConnectionUnknown indicates connection state is unknown ConnectionUnknown ConnectionState = iota // ConnectionConnected indicates active connection ConnectionConnected // ConnectionDisconnected indicates no connection ConnectionDisconnected // ConnectionReconnecting indicates reconnection in progress ConnectionReconnecting )
func (ConnectionState) String ¶
func (c ConnectionState) String() string
String returns a human-readable representation of the connection state
type ConsumerGroupsLoadErrorMsg ¶
type ConsumerGroupsLoadErrorMsg struct {
Error error
}
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type ConsumerGroupsLoadedMsg ¶
type ConsumerGroupsLoadedMsg struct {
Groups []api.ConsumerGroup
}
Consumer groups loaded messages
type ConsumptionErrorMsg ¶
Topic-specific messages
type ConsumptionStartedMsg ¶
type ConsumptionStartedMsg struct {
TopicName string
}
Topic-specific messages
type ConsumptionStoppedMsg ¶
type ConsumptionStoppedMsg struct {
TopicName string
}
Topic-specific messages
type ContextsLoadErrorMsg ¶
type ContextsLoadErrorMsg struct {
Error error
}
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type ContextsLoadedMsg ¶
type ContextsLoadedMsg struct {
Contexts []string
}
Contexts loaded messages
type DataErrorMsg ¶
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type DataLoadedMsg ¶
type DataLoadedMsg struct {
Type string
Data interface{}
}
Generic loading messages (for backward compatibility during migration)
type DataLoader ¶
DataLoader handles data loading operations
type DetailPageOpenMsg ¶
Detail page messages
type Dimensions ¶
Dimensions represents width and height
type EventHandler ¶
type EventHandler interface {
HandleKeyEvent(msg tea.KeyMsg) tea.Cmd
HandleDataEvent(msg DataLoadedMsg) tea.Cmd
HandleErrorEvent(msg DataErrorMsg) tea.Cmd
HandleTimerEvent(msg TimerTickMsg) tea.Cmd
}
EventHandler handles different types of events
type FocusManager ¶
type FocusManager struct {
// contains filtered or unexported fields
}
FocusManager handles focus management for components within pages
func NewFocusManager ¶
func NewFocusManager() *FocusManager
NewFocusManager creates a new focus manager
func (*FocusManager) AddComponent ¶
func (fm *FocusManager) AddComponent(component Focusable)
AddComponent adds a focusable component to the manager
func (*FocusManager) Clear ¶
func (fm *FocusManager) Clear()
Clear removes all components and resets focus
func (*FocusManager) FocusComponent ¶
func (fm *FocusManager) FocusComponent(id string) tea.Cmd
FocusComponent focuses a specific component by ID
func (*FocusManager) FocusNext ¶
func (fm *FocusManager) FocusNext() tea.Cmd
FocusNext moves focus to the next focusable component
func (*FocusManager) FocusPrevious ¶
func (fm *FocusManager) FocusPrevious() tea.Cmd
FocusPrevious moves focus to the previous focusable component
func (*FocusManager) GetComponentCount ¶
func (fm *FocusManager) GetComponentCount() int
GetComponentCount returns the number of focusable components
func (*FocusManager) GetFocusableComponents ¶
func (fm *FocusManager) GetFocusableComponents() []Focusable
GetFocusableComponents returns all focusable components
func (*FocusManager) GetFocusedComponent ¶
func (fm *FocusManager) GetFocusedComponent() Focusable
GetFocusedComponent returns the currently focused component
func (*FocusManager) GetFocusedComponentID ¶
func (fm *FocusManager) GetFocusedComponentID() string
GetFocusedComponentID returns the ID of the currently focused component
func (*FocusManager) HandleKeyMsg ¶
func (fm *FocusManager) HandleKeyMsg(msg tea.KeyMsg) tea.Cmd
HandleKeyMsg handles key messages for focus navigation
func (*FocusManager) IsEnabled ¶
func (fm *FocusManager) IsEnabled() bool
IsEnabled returns whether focus management is enabled
func (*FocusManager) RemoveComponent ¶
func (fm *FocusManager) RemoveComponent(id string)
RemoveComponent removes a focusable component from the manager
func (*FocusManager) SetEnabled ¶
func (fm *FocusManager) SetEnabled(enabled bool)
SetEnabled enables or disables focus management
type FocusState ¶
type FocusState uint8
FocusState represents which component currently has focus
const ( // FocusNone indicates no component has focus FocusNone FocusState = iota // FocusMain indicates the main content area has focus FocusMain // FocusSidebar indicates the sidebar has focus FocusSidebar // FocusSearch indicates the search input has focus FocusSearch FocusFooter )
func (FocusState) String ¶
func (f FocusState) String() string
String returns a human-readable representation of the focus state
type Focusable ¶
type Focusable interface {
// Focus gives focus to the component
Focus() tea.Cmd
// Blur removes focus from the component
Blur() tea.Cmd
// IsFocused returns whether the component currently has focus
IsFocused() bool
// GetID returns a unique identifier for the component
GetID() string
// CanFocus returns whether the component can receive focus
CanFocus() bool
}
Focusable represents a component that can receive focus
type FocusableComponent ¶
type FocusableComponent struct {
// contains filtered or unexported fields
}
FocusableComponent provides a base implementation of Focusable
func NewFocusableComponent ¶
func NewFocusableComponent(id string) *FocusableComponent
NewFocusableComponent creates a new focusable component
func (*FocusableComponent) Blur ¶
func (f *FocusableComponent) Blur() tea.Cmd
Blur implements Focusable
func (*FocusableComponent) CanFocus ¶
func (f *FocusableComponent) CanFocus() bool
CanFocus implements Focusable
func (*FocusableComponent) Focus ¶
func (f *FocusableComponent) Focus() tea.Cmd
Focus implements Focusable
func (*FocusableComponent) GetID ¶
func (f *FocusableComponent) GetID() string
GetID implements Focusable
func (*FocusableComponent) IsFocused ¶
func (f *FocusableComponent) IsFocused() bool
IsFocused implements Focusable
func (*FocusableComponent) SetCanFocus ¶
func (f *FocusableComponent) SetCanFocus(canFocus bool)
SetCanFocus sets whether the component can receive focus
type HelpBinding ¶
type HelpBinding struct {
Key string
Description string
Important bool // Highlight important bindings
}
HelpBinding represents a key binding with description
type HelpSection ¶
type HelpSection struct {
Title string
Bindings []HelpBinding
}
HelpSection represents a section in the help display
type HelpStyles ¶
type HelpStyles struct {
Container lipgloss.Style
Title lipgloss.Style
SectionTitle lipgloss.Style
KeyBinding lipgloss.Style
Description lipgloss.Style
Separator lipgloss.Style
}
HelpStyles contains styling for the help system
type HelpSystem ¶
type HelpSystem struct {
// contains filtered or unexported fields
}
HelpSystem provides an enhanced help system with context-sensitive information
func (*HelpSystem) GetKeyBindingHelp ¶
func (h *HelpSystem) GetKeyBindingHelp(keyBinding key.Binding) string
GetKeyBindingHelp returns help text for a specific key binding
func (*HelpSystem) GetQuickHelp ¶
func (h *HelpSystem) GetQuickHelp() string
GetQuickHelp returns a quick help string for display in status bars
func (*HelpSystem) IsVisible ¶
func (h *HelpSystem) IsVisible() bool
IsVisible returns whether the help system is visible
func (*HelpSystem) SetCurrentPage ¶
func (h *HelpSystem) SetCurrentPage(page Page)
SetCurrentPage sets the current page for context-sensitive help
func (*HelpSystem) SetDimensions ¶
func (h *HelpSystem) SetDimensions(width, height int)
SetDimensions sets the dimensions for the help system
type InputModeReporter ¶ added in v0.1.35
type InputModeReporter interface {
IsInputMode() bool
}
InputModeReporter is implemented by pages that can hold a focused text field. While it reports true, only ctrl+c escapes — every other key is typed.
type KeyBinding ¶
KeyBinding represents a key binding with help text
type KeyHandler ¶
KeyHandler handles keyboard input
type KeyScoper ¶ added in v0.1.35
KeyScoper lets a page declare the key scope it resolves against. Pages that do not implement it are treated as list screens.
type LoadingMsg ¶
LoadingMsg toggles a page's shared loading indicator (UI-12). Active starts/stops the centered spinner; Label is the optional caption.
type LoadingState ¶
type LoadingState uint8
LoadingState represents the loading state of a component
const ( // LoadingIdle indicates no loading is in progress LoadingIdle LoadingState = iota // LoadingInitial indicates initial data load LoadingInitial // LoadingRefresh indicates data refresh LoadingRefresh // LoadingMore indicates loading additional data LoadingMore )
type MessageConsumeErrorMsg ¶
type MessageConsumeErrorMsg struct {
Error error
}
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type MessageConsumedMsg ¶
type MessageConsumedMsg struct {
Message interface{}
}
Topic-specific messages
type MessagesConsumedMsg ¶
Messages consumed
type NotificationMsg ¶
type NotificationMsg struct {
Severity StatusType
Title string
Message string
Sticky bool // when true, does not auto-dismiss
}
NotificationMsg is the unified, shell-owned notification (toast) message. Every datasource error or success surfaced as a tea.Cmd should land here.
type Page ¶
type Page interface {
Init() tea.Cmd
Update(msg tea.Msg) (tea.Model, tea.Cmd)
View() string
SetDimensions(width, height int)
GetID() string
// Navigation methods for enhanced routing
GetTitle() string
GetHelp() []key.Binding
OnFocus() tea.Cmd
OnBlur() tea.Cmd
}
Page represents a UI page component
type PageChangeMsg ¶
type PageChangeMsg struct {
PageID string
Data interface{}
}
Page navigation messages
type PaletteProvider ¶ added in v0.1.35
PaletteProvider supplies page-specific destinations and commands to the command palette, on top of the application-wide entries the shell adds.
type RefreshDataMsg ¶
type RefreshDataMsg struct {
Type string
}
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type ResourceChangeMsg ¶
type ResourceChangeMsg struct {
ResourceType string
Data interface{}
}
Resource messages
type ResourceManager ¶
type ResourceManager interface {
LoadResources() tea.Cmd
GetCurrentResourceType() string
SwitchResource(resourceType string) tea.Cmd
}
ResourceManager manages resource operations
type ResourceSelectedMsg ¶
Resource messages
type RetryCommand ¶
type RetryCommand struct {
// Command to execute
Cmd tea.Cmd
// Retry configuration
Config RetryConfig
// Current retry state
State *RetryState
// Error handler called on each retry
OnError func(err error, attempt int) tea.Cmd
// Success handler called on success
OnSuccess func(result tea.Msg) tea.Cmd
}
RetryCommand wraps a command with retry logic
func NewRetryCommand ¶
func NewRetryCommand(cmd tea.Cmd, config RetryConfig) *RetryCommand
NewRetryCommand creates a new retry command
func (*RetryCommand) Execute ¶
func (rc *RetryCommand) Execute() tea.Cmd
Execute executes the retry command
type RetryConfig ¶
type RetryConfig struct {
// MaxRetries is the maximum number of retry attempts
MaxRetries int
// InitialDelay is the delay before the first retry
InitialDelay time.Duration
// MaxDelay is the maximum delay between retries
MaxDelay time.Duration
// Multiplier is the factor by which the delay increases
Multiplier float64
// Jitter adds randomness to prevent thundering herd
Jitter float64
}
RetryConfig holds configuration for retry operations
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns the default retry configuration
type RetryError ¶
type RetryError struct {
// Original error
Err error
// Attempt number when this error occurred
Attempt int
// Max retries configured
MaxRetries int
}
RetryError wraps an error with retry information
func (*RetryError) Error ¶
func (re *RetryError) Error() string
Error implements the error interface
type RetryState ¶
type RetryState struct {
// Current attempt number (0-based)
Attempt int
// Last error encountered
LastError error
// Next retry time
NextRetry time.Time
// Config for this retry operation
Config RetryConfig
}
RetryState tracks the state of a retry operation
func NewRetryState ¶
func NewRetryState(config RetryConfig) *RetryState
NewRetryState creates a new retry state
func (*RetryState) CanRetry ¶
func (rs *RetryState) CanRetry() bool
CanRetry returns true if another retry attempt is allowed
func (*RetryState) GetDelay ¶
func (rs *RetryState) GetDelay() time.Duration
GetDelay calculates the delay for the current attempt
func (*RetryState) RecordAttempt ¶
func (rs *RetryState) RecordAttempt(err error) time.Duration
RecordAttempt records a failed attempt and returns the delay before next retry
type RetryableOperation ¶
type RetryableOperation[T any] struct { // Operation to execute Operation func() (T, error) // Retry configuration Config RetryConfig }
RetryableOperation represents an operation that can be retried
func NewRetryableOperation ¶
func NewRetryableOperation[T any](operation func() (T, error), config RetryConfig) *RetryableOperation[T]
NewRetryableOperation creates a new retryable operation
func (*RetryableOperation[T]) Execute ¶
func (ro *RetryableOperation[T]) Execute() (T, error)
Execute executes the retryable operation
type SchemasLoadErrorMsg ¶
type SchemasLoadErrorMsg struct {
Error error
}
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type SchemasLoadedMsg ¶
type SchemasLoadedMsg struct {
Schemas []api.SchemaInfo
}
Schema loaded messages
type SearchMode ¶
type SearchMode int
SearchMode represents different search modes
const ( SearchModeSimple SearchMode = iota SearchModeAdvanced SearchModeRegex SearchModeFuzzy )
type ShowConfirmMsg ¶
type ShowConfirmMsg struct {
Title string
Message string
Danger bool
ConfirmLabel string
OnConfirm tea.Cmd
}
ShowConfirmMsg asks the shell to display a modal confirmation dialog. OnConfirm is dispatched only if the user confirms.
type SidebarToggledMsg ¶
type SidebarToggledMsg struct {
Visible bool
}
SidebarToggledMsg reports that the user explicitly toggled the template sidebar (UI-15). The shell persists the preference to the kafui config.
type StatefulPage ¶
type StatefulPage interface {
Page
GetState() UIState
GetFocusState() FocusState
SetState(UIState)
SetFocusState(FocusState)
}
StatefulPage extends Page with state management capabilities
type StatusBarConfig ¶
type StatusBarConfig struct {
// ShowByDefault indicates whether status bar should be visible
ShowByDefault bool
// DefaultTTL is the default time-to-live for messages
DefaultTTL time.Duration
// MaxMessageLength is the maximum length of a message before truncation
MaxMessageLength int
}
StatusBarConfig holds configuration for the status bar
func DefaultStatusBarConfig ¶
func DefaultStatusBarConfig() StatusBarConfig
DefaultStatusBarConfig returns the default status bar configuration
type StatusMessage ¶
type StatusMessage struct {
// Type of status message
Type StatusType
// Message to display
Message string
// TTL is the time-to-live for the message (0 = no auto-dismiss)
TTL time.Duration
// Timestamp when the message was created
Timestamp time.Time
}
StatusMessage represents a status message to be displayed
func NewStatusMessage ¶
func NewStatusMessage(statusType StatusType, message string, ttl time.Duration) StatusMessage
NewStatusMessage creates a new status message
func (StatusMessage) IsExpired ¶
func (sm StatusMessage) IsExpired() bool
IsExpired returns true if the message has expired based on its TTL
type StatusType ¶
type StatusType int
StatusType represents different status message types
const ( StatusInfo StatusType = iota StatusError StatusSuccess StatusWarning )
type Theme ¶
type Theme struct {
Primary string
Secondary string
Accent string
Error string
Success string
Warning string
Info string
}
Theme represents visual styling configuration
type TopicSelectedMsg ¶
type TopicSelectedMsg struct {
TopicName string
Topic interface{}
}
Topic-specific messages
type TopicsLoadErrorMsg ¶
type TopicsLoadErrorMsg struct {
Error error
}
Typed data messages - replacing generic DataLoadedMsg and DataErrorMsg
type TopicsLoadedMsg ¶
Topics loaded messages
type UIConfig ¶
type UIConfig struct {
// ShowSidebar indicates whether sidebar should be shown by default
ShowSidebar bool
// CompactMode indicates whether compact layout mode is enabled
CompactMode bool
// Theme name (e.g., "dark", "light")
Theme string
// ScreenshotDir is the directory for debug screenshots (defaults to temp dir)
ScreenshotDir string
// ConsumerGroupRefreshInterval is the auto-refresh interval selected on the
// consumer-group detail page (0 = off). Persisted for the session so the
// choice survives re-opening the page.
// ponytail: session-scoped only — writing it back to the on-disk kafui config
// is deferred to the application-config feature.
ConsumerGroupRefreshInterval time.Duration
}
UIConfig contains UI-specific configuration
func DefaultUIConfig ¶
func DefaultUIConfig() *UIConfig
DefaultUIConfig returns the default UI configuration
type Unwinder ¶ added in v0.1.35
Unwinder lets a page consume one level of Esc before the shell navigates back: closing its own overlay, leaving text entry, or clearing an active filter. Returning false means the page has nothing left to unwind and the shell should go to the parent screen.
type ViewRenderer ¶
type ViewRenderer interface {
Render(model interface{}) string
SetTheme(theme Theme)
SetDimensions(width, height int)
}
ViewRenderer handles view rendering