ui

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateColumnWidths added in v0.0.12

func CalculateColumnWidths(data [][]string) []int

CalculateColumnWidths calculates the maximum width for each column in the data

func FormatASCIITable

func FormatASCIITable(data [][]string) string

FormatASCIITable formats query results as an ASCII table for display in the terminal

func FormatASCIITableBottom added in v0.0.12

func FormatASCIITableBottom(data [][]string) string

FormatASCIITableBottom draws just the bottom border based on data

func FormatASCIITableBottomWithWidths added in v0.0.12

func FormatASCIITableBottomWithWidths(data [][]string, columnWidths []int) string

FormatASCIITableBottomWithWidths draws just the bottom border with specified column widths

func FormatASCIITableHeader

func FormatASCIITableHeader(headers [][]string) string

FormatASCIITableHeader formats just the header part of an ASCII table

func FormatASCIITableRowsOnly added in v0.0.12

func FormatASCIITableRowsOnly(data [][]string) string

FormatASCIITableRowsOnly formats only the data rows (no headers, no borders) Used for streaming subsequent batches

func FormatASCIITableRowsOnlyWithWidths added in v0.0.12

func FormatASCIITableRowsOnlyWithWidths(data [][]string, columnWidths []int) string

FormatASCIITableRowsOnlyWithWidths formats only the data rows with specified column widths

func FormatExpandTable

func FormatExpandTable(data [][]string, styles *Styles) string

FormatExpandTable formats query results in expanded vertical format

func NewTable

func NewTable() table.Model

NewTable creates a new table model with some default styling.

func OverlayModalOnView

func OverlayModalOnView(background string, modal ModalOverlay) string

OverlayOnView overlays modal content onto a view, preserving background where modal doesn't cover

Types

type AICQLModal added in v0.0.2

type AICQLModal struct {
	Active   bool
	CQL      string // The generated CQL query
	Selected int    // 0: Execute, 1: Edit, 2: Cancel
}

AICQLModal represents a modal for displaying AI-generated CQL with execution options

func NewAICQLModal added in v0.0.2

func NewAICQLModal(cql string) *AICQLModal

NewAICQLModal creates a new CQL execution modal

func (*AICQLModal) NextChoice added in v0.0.2

func (m *AICQLModal) NextChoice()

NextChoice moves to the next button

func (*AICQLModal) PrevChoice added in v0.0.2

func (m *AICQLModal) PrevChoice()

PrevChoice moves to the previous button

func (*AICQLModal) Render added in v0.0.2

func (m *AICQLModal) Render(screenWidth, screenHeight int, styles *Styles) string

Render renders the CQL execution modal

type AICQLResultMsg

type AICQLResultMsg struct {
	Plan           *ai.AIResult
	CQL            string
	Error          error
	ConversationID string // Track which conversation this result is for
}

AICQLResultMsg is sent when AI CQL generation completes

type AIInfoResponseMsg

type AIInfoResponseMsg struct {
	Response  string
	Cancelled bool
}

AIInfoResponseMsg is sent when user provides additional information

type AIMessage added in v0.0.2

type AIMessage struct {
	Role            string // "user", "assistant", or "system"
	Content         string // The raw message content (unwrapped)
	Type            string // Optional type like "cancelled", "selection", etc.
	SystemGenerated bool   // true if this message was generated by the system, not typed by user
}

AIMessage represents a single message in the AI conversation

type AIModal

type AIModal struct {
	State          AIModalState
	UserRequest    string       // The natural language request
	Plan           *ai.AIResult // The generated plan
	CQL            string       // The rendered CQL
	Error          string       // Error message if any
	Selected       int          // 0: Cancel, 1: Execute, 2: Edit
	Width          int
	Height         int
	ScreenHeight   int    // Current screen height for dynamic sizing
	ShowPlan       bool   // Toggle between showing plan JSON and CQL
	FollowUpInput  string // Input for follow-up questions
	CursorPosition int    // Cursor position in follow-up input
	// contains filtered or unexported fields
}

AIModal represents the AI-powered CQL generation modal

func NewAIModal

func NewAIModal(userRequest string) AIModal

NewAIModal creates a new AI modal for generating CQL

func (*AIModal) NextChoice

func (m *AIModal) NextChoice()

NextChoice moves to the next choice

func (*AIModal) PrevChoice

func (m *AIModal) PrevChoice()

PrevChoice moves to the previous choice

func (*AIModal) Render

func (m *AIModal) Render(screenWidth, screenHeight int, styles *Styles) string

Render renders the AI modal

func (*AIModal) SetError

func (m *AIModal) SetError(err error)

SetError sets an error state

func (*AIModal) SetResult

func (m *AIModal) SetResult(plan *ai.AIResult, cql string)

SetResult sets the generation result

func (*AIModal) ToggleView

func (m *AIModal) ToggleView()

ToggleView toggles between showing plan JSON and CQL

func (*AIModal) Update

func (m *AIModal) Update(msg tea.Msg) tea.Cmd

Update handles messages for the AI modal

type AIModalState

type AIModalState int

AIModalState represents the state of the AI modal

const (
	AIModalStateGenerating AIModalState = iota
	AIModalStatePreview
	AIModalStateError
	AIModalStateFollowUp     // New state for entering follow-up questions
	AIModalStateInfoFollowUp // New state for the info follow-up input
)

type AIRequestMoreInfoMsg

type AIRequestMoreInfoMsg struct {
	Message string
}

AIRequestMoreInfoMsg is sent when AI needs more information from user

type AIRequestUserSelectionMsg

type AIRequestUserSelectionMsg struct {
	SelectionType string
	Options       []string
}

AIRequestUserSelectionMsg is sent when AI needs user to select from options

type AISelectionModal

type AISelectionModal struct {
	Active         bool
	Title          string   // e.g., "Select a keyspace"
	Message        string   // e.g., "Multiple keyspaces found. Please select one:"
	SelectionType  string   // The type being selected (e.g., "keyspace", "table")
	Options        []string // The list of options to choose from
	Selected       int      // Currently selected option index
	ScrollOffset   int      // Scroll offset for long lists
	Width          int
	Height         int
	AllowCancel    bool   // Show cancel button
	AllowCustom    bool   // Allow user to enter custom text
	CustomInput    string // Custom input text
	InputMode      bool   // Whether we're in custom input mode
	MaxVisibleOpts int    // Maximum visible options (set during render based on screen height)
}

AISelectionModal represents a modal for user to select from AI-provided options

func NewAISelectionModal

func NewAISelectionModal(selectionType string, options []string) *AISelectionModal

NewAISelectionModal creates a new selection modal

func (*AISelectionModal) GetSelection

func (m *AISelectionModal) GetSelection() string

GetSelection returns the selected value or custom input

func (*AISelectionModal) NextOption

func (m *AISelectionModal) NextOption()

NextOption moves to the next option

func (*AISelectionModal) PrevOption

func (m *AISelectionModal) PrevOption()

PrevOption moves to the previous option

func (*AISelectionModal) Render

func (m *AISelectionModal) Render(screenWidth, screenHeight int, styles *Styles) string

Render renders the selection modal

func (*AISelectionModal) ToggleInputMode

func (m *AISelectionModal) ToggleInputMode()

ToggleInputMode toggles between selection and custom input mode

type AISelectionResultMsg

type AISelectionResultMsg struct {
	Selection     string
	SelectionType string // The type of selection (e.g., "keyspace", "table")
	Cancelled     bool
}

AISelectionResultMsg is sent when user completes a selection

type CompletionModal

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

CompletionModal represents a modal for showing completions

func NewCompletionModal

func NewCompletionModal(completions []string, currentIndex int) CompletionModal

NewCompletionModal creates a new completion modal

func (CompletionModal) GetOverlay

func (cm CompletionModal) GetOverlay(screenWidth, screenHeight int, styles *Styles) ModalOverlay

GetOverlay returns the modal content and positioning information

func (CompletionModal) RenderContent

func (cm CompletionModal) RenderContent(styles *Styles) string

RenderContent renders just the modal content without positioning

type ConnectionOptions

type ConnectionOptions struct {
	Host                string
	Port                int
	Keyspace            string
	Username            string
	Password            string
	RequireConfirmation bool
	ConnectTimeout      int    // Connection timeout in seconds
	RequestTimeout      int    // Request timeout in seconds
	Debug               bool   // Enable debug logging
	ConfigFile          string // Path to custom config file
	SSL                 bool   // Enable SSL/TLS connection
	Consistency         string // Default consistency level (e.g., "QUORUM")
	PageSize            int    // Page size for results
}

ConnectionOptions holds command-line connection options

type HistoryManager

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

HistoryManager manages command history persistence

func NewAIHistoryManager added in v0.0.2

func NewAIHistoryManager() (*HistoryManager, error)

NewAIHistoryManager creates a new history manager specifically for AI conversations

func NewAIHistoryManagerWithPath added in v0.0.23

func NewAIHistoryManagerWithPath(customPath string) (*HistoryManager, error)

NewAIHistoryManagerWithPath creates a new AI history manager with a custom path

func NewHistoryManager

func NewHistoryManager() (*HistoryManager, error)

NewHistoryManager creates a new history manager

func NewHistoryManagerWithPath added in v0.0.23

func NewHistoryManagerWithPath(customPath string) (*HistoryManager, error)

NewHistoryManagerWithPath creates a new history manager with a custom path

func (*HistoryManager) GetHistory

func (hm *HistoryManager) GetHistory() []string

GetHistory returns the command history

func (*HistoryManager) SaveCommand

func (hm *HistoryManager) SaveCommand(command string) error

SaveCommand adds a command to history and saves to file

func (*HistoryManager) SearchHistory

func (hm *HistoryManager) SearchHistory(query string) []string

SearchHistory searches for commands containing the given string

type HistoryModal

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

HistoryModal represents a modal for showing command history

func NewHistoryModal

func NewHistoryModal(history []string, currentIndex int, screenWidth int) HistoryModal

NewHistoryModal creates a new history modal

func (HistoryModal) GetOverlay

func (hm HistoryModal) GetOverlay(screenWidth, screenHeight int, styles *Styles) ModalOverlay

GetOverlay returns the modal content and positioning information

func (HistoryModal) RenderContent

func (hm HistoryModal) RenderContent(styles *Styles) string

RenderContent renders just the modal content without positioning

type HistorySearchModal

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

HistorySearchModal represents a modal for searching command history

func NewHistorySearchModal

func NewHistorySearchModal(query string, results []string, selectedIndex int, screenWidth int) HistorySearchModal

NewHistorySearchModal creates a new history search modal

func (HistorySearchModal) GetOverlay

func (hsm HistorySearchModal) GetOverlay(screenWidth, screenHeight int, styles *Styles) ModalOverlay

GetOverlay returns the modal content and positioning information

func (HistorySearchModal) RenderContent

func (hsm HistorySearchModal) RenderContent(styles *Styles) string

RenderContent renders just the modal content without positioning

type Layer

type Layer struct {
	Content string
	X       int
	Y       int
	Width   int
	Height  int
	ZIndex  int
}

Layer represents a renderable layer with position and size

func RenderModal

func RenderModal(content string, width, height int) Layer

RenderModal renders a modal as a centered overlay

type LayerManager

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

LayerManager manages multiple layers for rendering

func NewLayerManager

func NewLayerManager(width, height int) *LayerManager

NewLayerManager creates a new layer manager

func (*LayerManager) AddLayer

func (lm *LayerManager) AddLayer(layer Layer)

AddLayer adds a new layer to the manager

func (*LayerManager) Clear

func (lm *LayerManager) Clear()

Clear removes all layers

func (*LayerManager) Render

func (lm *LayerManager) Render(base string) string

Render composites all layers into a single view

type MainModel

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

MainModel is the main Bubble Tea model for the application.

func NewMainModel

func NewMainModel() (*MainModel, error)

NewMainModel creates a new MainModel.

func NewMainModelWithConnectionOptions

func NewMainModelWithConnectionOptions(options ConnectionOptions) (*MainModel, error)

NewMainModelWithConnectionOptions creates a new MainModel with connection options.

func NewMainModelWithOptions

func NewMainModelWithOptions(noConfirm bool) (*MainModel, error)

NewMainModelWithOptions creates a new MainModel with options.

func (*MainModel) Init

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

Init initializes the main model.

func (*MainModel) Update

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

Update updates the main model.

func (*MainModel) View

func (m *MainModel) View() string

View renders the main model.

type Modal struct {
	Type     ModalType
	Title    string
	Message  string
	Command  string
	Choices  []string
	Selected int
	Width    int
	Height   int
}

Modal represents a modal dialog

func NewConfirmationModal

func NewConfirmationModal(command string) Modal

NewConfirmationModal creates a new confirmation modal for dangerous commands

func (*Modal) NextChoice

func (m *Modal) NextChoice()

NextChoice moves to the next choice

func (*Modal) PrevChoice

func (m *Modal) PrevChoice()

PrevChoice moves to the previous choice

func (Modal) Render

func (m Modal) Render(screenWidth, screenHeight int, styles *Styles, background string) string

Render renders the modal centered on screen

type ModalOverlay

type ModalOverlay struct {
	Content string
	X       int // Horizontal position
	Y       int // Vertical position
	Width   int // Width of the modal
	Height  int // Height of the modal
}

ModalOverlay represents positioning information for a modal

type ModalType

type ModalType int

ModalType represents the type of modal

const (
	ModalNone ModalType = iota
	ModalConfirmDangerous
)

type SlidingWindowTable

type SlidingWindowTable struct {
	// Configuration
	MaxRows        int   // Maximum rows to keep in memory (e.g., 10000)
	MaxMemoryBytes int64 // Maximum memory usage in bytes (e.g., 10MB)

	// Data storage
	Headers     []string   // Column headers with (PK)/(C) indicators (always kept)
	ColumnNames []string   // Original column names without indicators (for data lookup)
	Rows        [][]string // Current window of rows
	ColumnTypes []string   // Column types (always kept)

	// Window tracking
	FirstRowIndex int64 // Global index of first row in window
	TotalRowsSeen int64 // Total rows processed (may be more than in memory)
	CurrentMemory int64 // Approximate current memory usage

	// Indicators for UI
	DataDroppedAtStart bool // True if we've dropped rows from the beginning
	DataAvailableAtEnd bool // True if more data can be loaded

	// Capture tracking
	LastCapturedRow int64 // Index of the last row written to capture file
	// contains filtered or unexported fields
}

SlidingWindowTable manages a sliding window of table data with memory limits

func NewSlidingWindowTable

func NewSlidingWindowTable(maxRows int, maxMemoryMB int) *SlidingWindowTable

NewSlidingWindowTable creates a new sliding window table

func (*SlidingWindowTable) AddRow

func (swt *SlidingWindowTable) AddRow(row []string)

AddRow adds a row to the sliding window, potentially evicting old rows

func (*SlidingWindowTable) CanScrollDown

func (swt *SlidingWindowTable) CanScrollDown() bool

CanScrollDown returns true if there's data after the current window

func (*SlidingWindowTable) CanScrollUp

func (swt *SlidingWindowTable) CanScrollUp() bool

CanScrollUp returns true if there's data before the current window

func (*SlidingWindowTable) GetStatusInfo

func (swt *SlidingWindowTable) GetStatusInfo() string

GetStatusInfo returns information about the sliding window state

func (*SlidingWindowTable) GetUncapturedRows

func (swt *SlidingWindowTable) GetUncapturedRows() [][]string

GetUncapturedRows returns rows that haven't been written to capture file yet

func (*SlidingWindowTable) GetVisibleRows

func (swt *SlidingWindowTable) GetVisibleRows(startIdx, endIdx int) [][]string

GetVisibleRows returns rows for display within the specified range

func (*SlidingWindowTable) LoadMoreRows

func (swt *SlidingWindowTable) LoadMoreRows(maxRows int) int

LoadMoreRows loads more rows from the streaming result if available

func (*SlidingWindowTable) MarkRowsAsCaptured

func (swt *SlidingWindowTable) MarkRowsAsCaptured(count int)

MarkRowsAsCaptured updates the last captured row index

func (*SlidingWindowTable) Reset

func (swt *SlidingWindowTable) Reset()

Reset clears the sliding window

type StatusBarModel

type StatusBarModel struct {
	Username     string
	Host         string
	Latency      string
	Consistency  string
	PagingSize   int
	Tracing      bool
	HasTraceData bool // Whether trace data is available to view
	Keyspace     string
	Version      string
	OutputFormat string
}

StatusBarModel is the Bubble Tea model for the status bar.

func NewStatusBarModel

func NewStatusBarModel() StatusBarModel

NewStatusBarModel creates a new StatusBarModel.

func (StatusBarModel) View

func (m StatusBarModel) View(width int, styles *Styles, currentView string) string

View renders the status bar.

type Styles

type Styles struct {
	Accent lipgloss.Color
	Ok     lipgloss.Color
	Warn   lipgloss.Color
	Error  lipgloss.Color
	Muted  lipgloss.Color
	Border lipgloss.Color

	AccentText  lipgloss.Style
	MutedText   lipgloss.Style
	ErrorText   lipgloss.Style
	SuccessText lipgloss.Style
	WarnText    lipgloss.Style
}

Styles contains the styles for the application.

func DefaultStyles

func DefaultStyles() *Styles

DefaultStyles returns the default styles for the application.

type TopBarModel

type TopBarModel struct {
	LastCommand  string
	QueryTime    time.Duration
	RowCount     int
	HasQueryData bool
	AutoFetch    bool
	HasMoreData  bool // Indicates if there's more data to fetch
}

TopBarModel is the Bubble Tea model for the top status bar.

func NewTopBarModel

func NewTopBarModel() TopBarModel

NewTopBarModel creates a new TopBarModel.

func (TopBarModel) View

func (m TopBarModel) View(width int, styles *Styles, viewMode string) string

View renders the top status bar.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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