core

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package core provides core types and interfaces for the Kafui UI framework.

Index

Constants

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

func BatchCommands(cmds ...tea.Cmd) tea.Cmd

BatchCommands combines multiple commands into a single batch command

func CalculateTableDimensions

func CalculateTableDimensions(totalWidth int, columnWeights []float64) []int

CalculateTableDimensions calculates optimal dimensions for table columns

func CenterString

func CenterString(s string, width int) string

CenterString centers a string within the specified width

func CreateTimer

func CreateTimer(id string, duration time.Duration) tea.Cmd

Timer utilities for creating periodic updates

func DebugMessage

func DebugMessage(format string, args ...interface{}) tea.Cmd

DebugMessage creates a debug message for development

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes to human-readable string

func FormatCount

func FormatCount(count int) string

FormatCount formats a count with appropriate units

func FormatDuration

func FormatDuration(d time.Duration) string

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

func FormatTime(t time.Time) string

FormatTime formats a time.Time to a human-readable string

func HighlightMatches

func HighlightMatches(text, query string) string

Color utilities for highlighting text

func IsHover added in v0.1.35

func IsHover(msg tea.MouseMsg) bool

IsHover reports whether msg is pointer motion with no button held, which is what drives hover highlighting.

func IsKeyMatch

func IsKeyMatch(msg tea.KeyMsg, bindings ...key.Binding) bool

IsKeyMatch checks if a key message matches any of the provided key bindings

func IsLeftRelease added in v0.1.35

func IsLeftRelease(msg tea.MouseMsg) bool

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 MaxLength

func MaxLength(maxLen int) func(string) error

func MinLength

func MinLength(minLen int) func(string) error

func NewConsumerGroupsLoadErrorMsg

func NewConsumerGroupsLoadErrorMsg(err error) tea.Cmd

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

func NewContextsLoadErrorMsg(err error) tea.Cmd

NewContextsLoadErrorMsg creates a command that sends a ContextsLoadErrorMsg

func NewContextsLoadedMsg

func NewContextsLoadedMsg(contexts []string) tea.Cmd

NewContextsLoadedMsg creates a command that sends a ContextsLoadedMsg

func NewDataErrorMsg

func NewDataErrorMsg(dataType string, err error) tea.Cmd

func NewDataLoadedMsg

func NewDataLoadedMsg(dataType string, data interface{}) tea.Cmd

Common message creation functions

func NewErrorMsg

func NewErrorMsg(message string) tea.Cmd

NewErrorMsg creates an error status message

func NewInfoMsg

func NewInfoMsg(message string) tea.Cmd

NewInfoMsg creates an informational status message

func NewMessageConsumeErrorMsg

func NewMessageConsumeErrorMsg(err error) tea.Cmd

NewMessageConsumeErrorMsg creates a command that sends a MessageConsumeErrorMsg

func NewMessagesConsumedMsg

func NewMessagesConsumedMsg(messages []api.Message) tea.Cmd

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 NewPageChangeMsg(pageID string, data interface{}) tea.Cmd

func NewPermanentErrorMsg

func NewPermanentErrorMsg(message string) tea.Cmd

NewPermanentErrorMsg creates a permanent error status message (no auto-dismiss)

func NewResourceSelectedMsg

func NewResourceSelectedMsg(resourceID, resourceType string, item interface{}) tea.Cmd

func NewSchemasLoadErrorMsg

func NewSchemasLoadErrorMsg(err error) tea.Cmd

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

func NewSuccessMsg(message string) tea.Cmd

NewSuccessMsg creates a success status message

func NewTopicsLoadErrorMsg

func NewTopicsLoadErrorMsg(err error) tea.Cmd

NewTopicsLoadErrorMsg creates a command that sends a TopicsLoadErrorMsg

func NewTopicsLoadedMsg

func NewTopicsLoadedMsg(topics map[string]api.Topic) tea.Cmd

NewTopicsLoadedMsg creates a command that sends a TopicsLoadedMsg

func NewWarningMsg

func NewWarningMsg(message string) tea.Cmd

NewWarningMsg creates a warning status message

func NotEmpty

func NotEmpty(input string) error

Common validation rules

func NotifyError

func NotifyError(title string, err error) tea.Cmd

NotifyError builds an error notification from an error value.

func PadString

func PadString(s string, width int) string

PadString pads a string to the specified width

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

func ScopeOf(page any) keys.Scope

ScopeOf returns the key scope for a page, defaulting to a list screen.

func TruncateString

func TruncateString(s string, maxLen int) string

TruncateString truncates a string to the specified length with ellipsis

func ValidateStringInput

func ValidateStringInput(input string, rules ...func(string) error) error

ValidateStringInput validates string input for common use cases

func WrapText

func WrapText(text string, width int) []string

WrapText wraps text to fit within the specified width

Types

type ActionProvider added in v0.1.35

type ActionProvider interface {
	ContextActions() []menu.Entry
}

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 BackMsg

type BackMsg struct{}

Page navigation messages

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

func (b *BaseComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd)

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 struct {
	Items []string
}

Page navigation messages

type ClearSearchMsg

type ClearSearchMsg struct{}

Search 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

func (c *Common) ActiveProfileName() string

ActiveProfileName returns the resolved active profile name (empty when authz is disabled or no profile covers the current cluster).

func (*Common) ApplyAppConfig

func (c *Common) ApplyAppConfig(cfg appconfig.Config)

ApplyAppConfig installs the loaded kafui config and syncs derived UI settings.

func (*Common) AuthzEnabled

func (c *Common) AuthzEnabled() bool

AuthzEnabled reports whether a permission profile is active.

func (*Common) Can

func (c *Common) Can(action authz.Action, rt authz.ResourceType, name string) bool

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

func (c *Common) GetLayout(width, height int) *layout.Layout

GetLayout returns the current layout, calculating it if necessary

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

func (c *Common) IsReadOnly() bool

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

func (c *Common) UpdateLayout(width, height int)

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

type ConsumptionErrorMsg struct {
	TopicName string
	Error     error
}

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

type DataErrorMsg struct {
	Type  string
	Error error
}

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

type DataLoader interface {
	LoadData() tea.Cmd
	RefreshData() tea.Cmd
}

DataLoader handles data loading operations

type DetailPageCloseMsg

type DetailPageCloseMsg struct{}

Detail page messages

type DetailPageOpenMsg

type DetailPageOpenMsg struct {
	ResourceID   string
	ResourceType string
	Data         interface{}
}

Detail page messages

type Dimensions

type Dimensions struct {
	Width  int
	Height int
}

Dimensions represents width and height

type DimensionsUpdateMsg

type DimensionsUpdateMsg struct {
	Width  int
	Height int
}

UI messages

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 FilterAppliedMsg

type FilterAppliedMsg struct {
	Count int
	Query string
}

Search messages

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 indicates the footer has focus
	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
	Footer       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 NewHelpSystem

func NewHelpSystem() *HelpSystem

NewHelpSystem creates a new help system

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

func (h *HelpSystem) Hide()

Hide hides the help system

func (*HelpSystem) IsVisible

func (h *HelpSystem) IsVisible() bool

IsVisible returns whether the help system is visible

func (*HelpSystem) Render

func (h *HelpSystem) Render() string

Render renders the help system

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

func (*HelpSystem) Show

func (h *HelpSystem) Show()

Show shows the help system

func (*HelpSystem) Toggle

func (h *HelpSystem) Toggle()

Toggle toggles the help system visibility

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

type KeyBinding struct {
	Key  key.Binding
	Help string
}

KeyBinding represents a key binding with help text

type KeyHandler

type KeyHandler interface {
	HandleKey(key tea.KeyMsg) tea.Cmd
	GetKeyBindings() []key.Binding
}

KeyHandler handles keyboard input

type KeyScoper added in v0.1.35

type KeyScoper interface {
	KeyScope() keys.Scope
}

KeyScoper lets a page declare the key scope it resolves against. Pages that do not implement it are treated as list screens.

type LoadingMsg

type LoadingMsg struct {
	Active bool
	Label  string
}

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

type MessagesConsumedMsg struct {
	Messages []api.Message
}

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
	HandleNavigation(msg tea.Msg) (Page, tea.Cmd)
	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

type PaletteProvider interface {
	PaletteEntries() []menu.Entry
}

PaletteProvider supplies page-specific destinations and commands to the command palette, on top of the application-wide entries the shell adds.

type QuitMsg

type QuitMsg struct{}

Page navigation messages

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 ResourceLoadMsg

type ResourceLoadMsg struct {
	ResourceType string
}

Resource messages

type ResourceManager

type ResourceManager interface {
	LoadResources() tea.Cmd
	GetCurrentResourceType() string
	SwitchResource(resourceType string) tea.Cmd
}

ResourceManager manages resource operations

type ResourceSelectedMsg

type ResourceSelectedMsg struct {
	ResourceID   string
	ResourceType string
	Item         interface{}
}

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

func (*RetryError) Unwrap

func (re *RetryError) Unwrap() error

Unwrap returns the wrapped error

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

func (*RetryState) Reset

func (rs *RetryState) Reset()

Reset resets the retry state

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 SearchModeChangeMsg

type SearchModeChangeMsg struct {
	Mode SearchMode
}

Search messages

type SearchMsg

type SearchMsg struct {
	Query string
	Mode  SearchMode
}

Search messages

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 StatusMsg

type StatusMsg struct {
	Message string
	Type    StatusType
}

UI messages

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 TimerTickMsg

type TimerTickMsg struct {
	Time time.Time
	ID   string
}

UI messages

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

type TopicsLoadedMsg struct {
	Topics map[string]api.Topic
}

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 UIState

type UIState uint8

UIState represents the high-level state of the application

const (
	// StateNormal indicates normal operation mode
	StateNormal UIState = iota
	// StateHelp indicates help overlay is shown
	StateHelp
	// StateSearch indicates search mode is active
	StateSearch
	// StateModal indicates a modal dialog is open
	StateModal
)

func (UIState) String

func (s UIState) String() string

String returns a human-readable representation of the UI state

type Unwinder added in v0.1.35

type Unwinder interface {
	Unwind() (tea.Cmd, bool)
}

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

type WindowSizeMsg

type WindowSizeMsg struct {
	Width  int
	Height int
}

UI messages

Jump to

Keyboard shortcuts

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