ui

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Tool approval UI component for displaying and handling tool approval prompts ABOUTME: Shows formatted tool information with risk levels and interactive approval controls

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Intro screen rendering for first-run experience ABOUTME: Displays ASCII logo, example prompts, services, and keyboard shortcuts

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Layout mode detection and breakpoint logic for responsive UI ABOUTME: Determines whether to show compact or wide layout based on terminal size

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Bubbletea model for interactive chat UI ABOUTME: Manages state, messages, input, viewport, and streaming

ABOUTME: Mux backend integration for interactive mode ABOUTME: Provides types and handlers for using mux backend in the TUI

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Quick actions menu system for keyboard shortcuts ABOUTME: Provides fuzzy-searchable command palette for tools and actions

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Panic recovery utilities for TUI components ABOUTME: Prevents component crashes from taking down the entire application

ABOUTME: Slash command handlers for /feedback and /contact ABOUTME: Handles form completion and email sending via Gmail tools

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Spinner component for showing loading and tool execution states ABOUTME: Provides animated spinners with different styles for various operations

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Status bar component for displaying connection, token, and mode information ABOUTME: Provides comprehensive bottom status bar with color-coded indicators

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Streaming UI enhancements for displaying streaming responses ABOUTME: Provides token rate display, progressive rendering, and typewriter effects

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Bubbletea update function for handling events ABOUTME: Processes keyboard input, window resize, streaming chunks

Package ui provides the Bubble Tea terminal user interface components. ABOUTME: Bubbletea view function for rendering UI ABOUTME: Renders viewport with messages and input textarea

Index

Constants

View Source
const (
	// CompactModeWidthBreakpoint is the minimum width required for wide layout
	// Below this width, the UI switches to compact mode
	CompactModeWidthBreakpoint = 100

	// CompactModeHeightBreakpoint is the minimum height required for wide layout
	// Below this height, the UI switches to compact mode
	CompactModeHeightBreakpoint = 24
)
View Source
const (
	FeedbackAccepted = suggestions.FeedbackAccepted
	FeedbackRejected = suggestions.FeedbackRejected
	FeedbackIgnored  = suggestions.FeedbackIgnored
)

Feedback constants

View Source
const ChatContentOffset = 6

ChatContentOffset is the width offset applied to chat messages for wrapping This accounts for visual decorations like borders and padding in the chat pane

Variables

This section is empty.

Functions

func DetectProvider

func DetectProvider(input string) string

DetectProvider determines which provider to use based on input context

func LogoANSI added in v0.3.0

func LogoANSI() string

LogoANSI returns the embedded ANSI art logo for use in other packages

func ParseActionCommand

func ParseActionCommand(input string) (command, args string)

ParseActionCommand splits a command input into command and arguments

func RecoverPanic

func RecoverPanic(component string, fn func())

RecoverPanic wraps a function with panic recovery If a panic occurs, it logs the error with component name, panic value, and stack trace

Types

type ApprovalPrompt

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

ApprovalPrompt manages the tool approval UI

func NewApprovalPrompt

func NewApprovalPrompt(toolUse *core.ToolUse) *ApprovalPrompt

NewApprovalPrompt creates a new approval prompt for a tool use

func (*ApprovalPrompt) SetWidth

func (a *ApprovalPrompt) SetWidth(width int)

SetWidth sets the width of the approval prompt

func (*ApprovalPrompt) ToggleDetails

func (a *ApprovalPrompt) ToggleDetails()

ToggleDetails toggles the detailed view

func (*ApprovalPrompt) View

func (a *ApprovalPrompt) View() string

View renders the approval prompt

type Autocomplete

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

Autocomplete manages completion state and providers

func NewAutocomplete

func NewAutocomplete() *Autocomplete

NewAutocomplete creates a new autocomplete instance

func (*Autocomplete) GetCompletions

func (ac *Autocomplete) GetCompletions() []Completion

GetCompletions returns all current completions

func (*Autocomplete) GetProvider

func (ac *Autocomplete) GetProvider(name string) (CompletionProvider, bool)

GetProvider retrieves a registered provider by name

func (*Autocomplete) GetSelected

func (ac *Autocomplete) GetSelected() *Completion

GetSelected returns the currently selected completion

func (*Autocomplete) GetSelectedIndex

func (ac *Autocomplete) GetSelectedIndex() int

GetSelectedIndex returns the current selection index

func (*Autocomplete) Hide

func (ac *Autocomplete) Hide()

Hide deactivates autocomplete

func (*Autocomplete) IsActive

func (ac *Autocomplete) IsActive() bool

IsActive returns whether autocomplete is currently showing

func (*Autocomplete) Next

func (ac *Autocomplete) Next()

Next moves selection to next completion

func (*Autocomplete) Previous

func (ac *Autocomplete) Previous()

Previous moves selection to previous completion

func (*Autocomplete) RegisterProvider

func (ac *Autocomplete) RegisterProvider(name string, provider CompletionProvider)

RegisterProvider adds a completion provider

func (*Autocomplete) Show

func (ac *Autocomplete) Show(input string, providerName string)

Show activates autocomplete for the given input and provider

func (*Autocomplete) Update

func (ac *Autocomplete) Update(input string)

Update refreshes completions based on new input

type Card added in v0.1.9

type Card struct {
	ID        string
	Title     string
	Content   string // Raw markdown
	Rendered  string // Cached glamour output
	Timestamp time.Time
	// contains filtered or unexported fields
}

Card represents a display card in the right pane

func NewCard added in v0.1.9

func NewCard(title, content string) *Card

NewCard creates a new display card

func (*Card) InvalidateCache added in v0.1.9

func (c *Card) InvalidateCache()

InvalidateCache clears the rendered cache

func (*Card) Render added in v0.1.9

func (c *Card) Render(width int) string

Render returns the card as styled terminal output

type Completion

type Completion struct {
	// Value is the actual completion text
	Value string
	// Display is what gets shown in the UI (may include formatting)
	Display string
	// Description provides context about the completion
	Description string
	// Score is used for ranking (higher is better)
	Score int
}

Completion represents a single completion suggestion

type CompletionProvider

type CompletionProvider interface {
	// GetCompletions returns completion suggestions for the given input
	GetCompletions(input string) []Completion
}

CompletionProvider is an interface for providing completion suggestions

type ConnectionStatus

type ConnectionStatus int

ConnectionStatus represents API connection state

const (
	// ConnectionDisconnected indicates no active connection
	ConnectionDisconnected ConnectionStatus = iota
	// ConnectionConnected indicates an active connection
	ConnectionConnected
	// ConnectionStreaming indicates an active streaming connection
	ConnectionStreaming
	// ConnectionError indicates a connection error
	ConnectionError
)

type Delta

type Delta = core.Delta

Delta is an alias for core.Delta for use in UI

type DisplayCardMsg added in v0.1.9

type DisplayCardMsg struct {
	Title   string
	Content string
}

DisplayCardMsg is sent when a card should be added to the display pane

type FeedbackType

type FeedbackType = suggestions.FeedbackType

FeedbackType represents user feedback

type FileProvider

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

FileProvider provides file path completions

func NewFileProvider

func NewFileProvider() *FileProvider

NewFileProvider creates a new file completion provider

func (*FileProvider) GetCompletions

func (fp *FileProvider) GetCompletions(input string) []Completion

GetCompletions returns file path completions

func (*FileProvider) SetBasePath

func (fp *FileProvider) SetBasePath(path string)

SetBasePath updates the base directory for file searching

type HistoryProvider

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

HistoryProvider provides command history completions

func NewHistoryProvider

func NewHistoryProvider() *HistoryProvider

NewHistoryProvider creates a new history completion provider

func (*HistoryProvider) AddToHistory

func (hp *HistoryProvider) AddToHistory(command string)

AddToHistory adds a command to history

func (*HistoryProvider) GetCompletions

func (hp *HistoryProvider) GetCompletions(input string) []Completion

GetCompletions returns history-based completions

type LayoutMode

type LayoutMode int

LayoutMode represents the current UI layout configuration

const (
	// LayoutModeWide is used for terminals with sufficient space (>= 100 width, >= 24 height)
	// Displays full-featured UI with all components visible
	LayoutModeWide LayoutMode = iota

	// LayoutModeCompact is used for smaller terminals (< 100 width OR < 24 height)
	// Displays simplified UI with essential features only
	LayoutModeCompact
)

func DetermineLayoutMode

func DetermineLayoutMode(width, height int) LayoutMode

DetermineLayoutMode determines the appropriate layout mode based on terminal dimensions Returns LayoutModeCompact if either dimension is below the breakpoint Returns LayoutModeWide if both dimensions meet or exceed their breakpoints

func (LayoutMode) String

func (l LayoutMode) String() string

String returns a human-readable representation of the layout mode

type Message

type Message struct {
	ID           string // Unique identifier for cache keying
	Role         string
	Content      string
	ContentBlock []core.ContentBlock // For structured content like tool_result blocks

	// Rich component for inline rendering (Phase 3)
	Component   interface{} // Can be *components.Table, *components.Progress, etc.
	ComponentID string      // Unique ID for routing events to component
}

Message represents a chat message in the UI

type Model

type Model struct {
	ConversationID string
	Model          string
	Provider       string // LLM provider: anthropic, openai, gemini, openrouter, ollama
	Messages       []Message
	Input          textarea.Model
	Viewport       viewport.Model
	Width          int

	Height        int
	Streaming     bool
	StreamingText string
	Ready         bool

	// Task 5: Advanced UI Features
	CurrentView  ViewMode
	Status       Status
	ErrorMessage string
	TokensInput  int
	TokensOutput int
	SearchMode   bool
	SearchQuery  string

	// Phase 6C Task 5: Conversation Favorites
	IsFavorite bool // Track if current conversation is favorite

	// Slash commands
	LaunchOnboarding bool // Set when user types /init to trigger onboarding after exit
	// contains filtered or unexported fields
}

Model is the Bubbletea model for interactive mode

func NewModel

func NewModel(conversationID, model, themeName string) *Model

NewModel creates a new UI model

func (*Model) AcceptSuggestion

func (m *Model) AcceptSuggestion()

AcceptSuggestion accepts the top suggestion and applies it

func (*Model) AddDisplayCard added in v0.1.9

func (m *Model) AddDisplayCard(title, content string)

AddDisplayCard adds a new card to the display pane (prepends to show newest first)

func (*Model) AddMessage

func (m *Model) AddMessage(role, content string)

AddMessage adds a message to the conversation

func (*Model) AddMessageWithComponent

func (m *Model) AddMessageWithComponent(role, content string, component interface{})

AddMessageWithComponent adds a message with an embedded component

func (*Model) AddPendingToolUse

func (m *Model) AddPendingToolUse(toolUse *core.ToolUse)

AddPendingToolUse adds a tool use to the pending queue

func (*Model) AnalyzeSuggestions

func (m *Model) AnalyzeSuggestions()

AnalyzeSuggestions analyzes current input and updates suggestions

func (*Model) AppendStreamingText

func (m *Model) AppendStreamingText(chunk string)

AppendStreamingText adds a chunk to the streaming buffer

func (*Model) ApproveMuxTool added in v0.3.10

func (m *Model) ApproveMuxTool(approved bool) tea.Cmd

ApproveMuxTool sends approval response and resumes event processing

func (*Model) ApproveToolUse

func (m *Model) ApproveToolUse() tea.Cmd

ApproveToolUse executes ALL pending tools

func (*Model) ClearConversation

func (m *Model) ClearConversation()

ClearConversation clears all messages (chat pane)

func (*Model) ClearDisplayCards added in v0.1.9

func (m *Model) ClearDisplayCards()

ClearDisplayCards clears all display cards (display pane)

func (*Model) ClearMarkdownCache

func (m *Model) ClearMarkdownCache()

ClearMarkdownCache clears all cached markdown content

func (*Model) ClearScreen

func (m *Model) ClearScreen()

ClearScreen clears the viewport

func (*Model) ClearStreamingText

func (m *Model) ClearStreamingText()

ClearStreamingText discards streaming buffer (e.g., on error)

func (*Model) CommitStreamingText

func (m *Model) CommitStreamingText()

CommitStreamingText converts streaming text into a permanent assistant message

func (*Model) DenyToolUse

func (m *Model) DenyToolUse() tea.Cmd

DenyToolUse rejects ALL pending tools

func (*Model) DismissSuggestions

func (m *Model) DismissSuggestions()

DismissSuggestions hides and clears suggestions

func (*Model) EnterHuhApprovalMode

func (m *Model) EnterHuhApprovalMode() tea.Cmd

EnterHuhApprovalMode creates and shows Huh approval dialog Returns the initialization command that should be executed

func (*Model) EnterQuickActionsMode

func (m *Model) EnterQuickActionsMode()

EnterQuickActionsMode opens the quick actions menu

func (*Model) EnterSearchMode

func (m *Model) EnterSearchMode()

EnterSearchMode activates search mode

func (*Model) ExecuteQuickAction

func (m *Model) ExecuteQuickAction() error

ExecuteQuickAction executes the selected or first filtered action

func (*Model) ExitHuhApprovalMode

func (m *Model) ExitHuhApprovalMode()

ExitHuhApprovalMode closes the approval dialog

func (*Model) ExitQuickActionsMode

func (m *Model) ExitQuickActionsMode()

ExitQuickActionsMode closes the quick actions menu

func (*Model) ExitSearchMode

func (m *Model) ExitSearchMode()

ExitSearchMode deactivates search mode

func (*Model) ExportConversation

func (m *Model) ExportConversation() string

ExportConversation exports the conversation to a string

func (*Model) FocusedPane added in v0.1.9

func (m *Model) FocusedPane() Pane

FocusedPane returns the currently focused pane

func (*Model) GetAutocomplete

func (m *Model) GetAutocomplete() *Autocomplete

GetAutocomplete returns the autocomplete instance

func (*Model) GetContextUsagePercent added in v0.2.0

func (m *Model) GetContextUsagePercent() float64

GetContextUsagePercent returns the current context usage percentage Returns 0 when contextManager is nil to avoid stale reads

func (*Model) GetDisplayCallback added in v0.1.9

func (m *Model) GetDisplayCallback() func(title, content string)

GetDisplayCallback returns a callback function for the display tool to use. The callback sends messages to the display channel which will be processed in the Update loop to maintain thread safety.

func (*Model) GetHuhApproval

func (m *Model) GetHuhApproval() *components.HuhApproval

GetHuhApproval returns the current Huh approval component

func (*Model) GetLayoutMode

func (m *Model) GetLayoutMode() LayoutMode

GetLayoutMode returns the current layout mode

func (*Model) GetPendingToolUses

func (m *Model) GetPendingToolUses() []*core.ToolUse

GetPendingToolUses returns the pending tool uses

func (*Model) GetPrunedMessages

func (m *Model) GetPrunedMessages() []core.Message

GetPrunedMessages returns messages pruned to fit context limit

func (*Model) GetSessionLogger added in v0.3.6

func (m *Model) GetSessionLogger() *logging.SessionLogger

GetSessionLogger returns the session logger

func (*Model) GetTheme

func (m *Model) GetTheme() themes.Theme

GetTheme returns the current theme

func (*Model) Init

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

Init initializes the model

func (*Model) InvalidateMarkdownCache

func (m *Model) InvalidateMarkdownCache()

InvalidateMarkdownCache marks the markdown cache as dirty It will be cleared on next render

func (*Model) IsComposeFormActive added in v0.3.6

func (m *Model) IsComposeFormActive() bool

IsComposeFormActive returns whether the compose form is currently showing

func (*Model) IsContextFull added in v0.2.0

func (m *Model) IsContextFull() bool

IsContextFull returns true when estimated context usage is at 100% or more This is based on the estimated token count of messages, not cumulative API tokens

func (*Model) IsContextNearFull added in v0.2.0

func (m *Model) IsContextNearFull() bool

IsContextNearFull returns true when estimated context usage is at 90% or more This is based on the estimated token count of messages, not cumulative API tokens

func (*Model) IsFeedbackFormActive added in v0.3.6

func (m *Model) IsFeedbackFormActive() bool

IsFeedbackFormActive returns whether the feedback form is currently showing

func (*Model) IsToolApprovalMode

func (m *Model) IsToolApprovalMode() bool

IsToolApprovalMode returns whether tool approval mode is active

func (*Model) ListenForDisplayCards added in v0.1.9

func (m *Model) ListenForDisplayCards() tea.Cmd

ListenForDisplayCards returns a command that listens for display card messages. This should be called from Update when processing display-related messages.

func (*Model) NextView

func (m *Model) NextView()

NextView cycles to the next view mode

func (*Model) RejectTopSuggestion

func (m *Model) RejectTopSuggestion()

RejectTopSuggestion explicitly rejects the top suggestion

func (*Model) RenderIntro

func (m *Model) RenderIntro() string

RenderIntro returns the intro screen content

func (*Model) RenderMessage

func (m *Model) RenderMessage(msg Message) (string, error)

RenderMessage renders a message using glamour for assistant messages with theme colors Phase 1 Task 3: Uses caching to avoid expensive re-renders

func (*Model) SaveConversation

func (m *Model) SaveConversation() error

SaveConversation saves the conversation (placeholder for future implementation)

func (*Model) SetAPIClient

func (m *Model) SetAPIClient(client *core.Client)

SetAPIClient sets the API client for streaming

func (*Model) SetContextManager

func (m *Model) SetContextManager(manager *ctxmgr.Manager)

SetContextManager sets the context manager and initializes context tracking

func (*Model) SetDB

func (m *Model) SetDB(db *sql.DB)

SetDB sets the database connection for storage

func (*Model) SetForceLayoutMode

func (m *Model) SetForceLayoutMode(force bool, mode LayoutMode)

SetForceLayoutMode allows the user to override automatic layout mode detection

func (*Model) SetMuxBackend added in v0.3.10

func (m *Model) SetMuxBackend(backend MuxBackend)

SetMuxBackend sets the mux backend for streaming

func (*Model) SetProvider added in v0.3.18

func (m *Model) SetProvider(provider string)

SetProvider sets the LLM provider name for display

func (*Model) SetSessionLogger added in v0.3.6

func (m *Model) SetSessionLogger(logger *logging.SessionLogger)

SetSessionLogger sets the session logger for JSONL logging

func (*Model) SetSkipAllApprovals added in v0.1.9

func (m *Model) SetSkipAllApprovals(skip bool)

SetSkipAllApprovals enables/disables auto-approval of all tools (--dangerously-skip-permissions)

func (*Model) SetStatus

func (m *Model) SetStatus(status Status)

SetStatus sets the current UI status and syncs the Streaming flag

func (*Model) SetSystemPrompt

func (m *Model) SetSystemPrompt(prompt string)

SetSystemPrompt sets the system prompt for this conversation

func (*Model) SetToolSystem

func (m *Model) SetToolSystem(registry *tools.Registry, executor *tools.Executor)

SetToolSystem sets the tool registry and executor

func (*Model) ToggleFavorite

func (m *Model) ToggleFavorite() error

ToggleFavorite toggles the favorite status of the current conversation

func (*Model) ToggleHelp

func (m *Model) ToggleHelp()

ToggleHelp toggles the help display

func (*Model) ToggleTypewriter

func (m *Model) ToggleTypewriter()

ToggleTypewriter toggles typewriter mode

func (*Model) Update

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

Update handles Bubbletea messages with panic recovery

func (*Model) UpdateLayoutMode

func (m *Model) UpdateLayoutMode(width, height int)

UpdateLayoutMode updates the layout mode based on terminal dimensions If forceLayoutMode is true, this function does nothing (user override) Otherwise, determines layout mode from width and height

func (*Model) UpdateQuickActionsInput

func (m *Model) UpdateQuickActionsInput(input string)

UpdateQuickActionsInput updates the search query and filters actions

func (*Model) UpdateSearchQuery

func (m *Model) UpdateSearchQuery(query string)

UpdateSearchQuery updates the search query

func (*Model) UpdateTokens

func (m *Model) UpdateTokens(input, output int)

UpdateTokens updates the token counters (cumulative across all messages in this session)

func (*Model) UpdateViewport

func (m *Model) UpdateViewport()

UpdateViewport renders messages into viewport

func (*Model) UseMux added in v0.3.10

func (m *Model) UseMux() bool

UseMux returns whether the model is configured to use mux backend

func (*Model) View

func (m *Model) View() string

View renders the UI based on the current layout mode

type MuxApprovalRequest added in v0.3.10

type MuxApprovalRequest = mux.ApprovalRequest

MuxApprovalRequest is an alias for mux.ApprovalRequest for use in the UI

type MuxApprovalRequestMsg added in v0.3.10

type MuxApprovalRequestMsg struct {
	Request MuxApprovalRequest
	Done    bool // Channel was closed
}

MuxApprovalRequestMsg is a Bubbletea message for tool approval requests

type MuxBackend added in v0.3.10

type MuxBackend interface {
	Run(ctx context.Context, prompt string) <-chan mux.Event
	RunInteractive(
		ctx context.Context,
		prompt string,
		needsApproval func(toolName string, params map[string]any) bool,
	) (<-chan mux.Event, <-chan mux.ApprovalRequest)
}

MuxBackend is the interface for mux.Backend that the UI uses

type MuxEvent added in v0.3.10

type MuxEvent = mux.Event

MuxEvent is an alias for mux.Event for use in the UI

type MuxEventMsg added in v0.3.10

type MuxEventMsg struct {
	Event MuxEvent
	Done  bool // Channel was closed
}

MuxEventMsg is a Bubbletea message carrying a mux event

type Pane added in v0.1.9

type Pane int

Pane represents which UI pane has focus

const (
	PaneInput Pane = iota
	PaneChat
	PaneDisplay
)

type ProgressIndicator

type ProgressIndicator struct {
	State   ProgressState
	Message string
}

ProgressIndicator represents different states of operation progress

func NewProgressIndicator

func NewProgressIndicator(state ProgressState, message string) *ProgressIndicator

NewProgressIndicator creates a new progress indicator

func (*ProgressIndicator) View

func (p *ProgressIndicator) View() string

View renders the progress indicator

type ProgressState

type ProgressState int

ProgressState represents the state of an operation

const (
	// StateQueued indicates a tool is waiting to execute
	StateQueued ProgressState = iota
	// StateRunning indicates a tool is currently executing
	StateRunning
	// StateCompleted indicates a tool has finished execution
	StateCompleted
	// StateFailed indicates a tool execution failed
	StateFailed
)

type ProgressiveMarkdownRenderer

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

ProgressiveMarkdownRenderer handles progressive rendering of markdown during streaming

func NewProgressiveMarkdownRenderer

func NewProgressiveMarkdownRenderer() *ProgressiveMarkdownRenderer

NewProgressiveMarkdownRenderer creates a new progressive markdown renderer

func (*ProgressiveMarkdownRenderer) Reset

func (r *ProgressiveMarkdownRenderer) Reset()

Reset resets the renderer state

func (*ProgressiveMarkdownRenderer) ShouldRender

func (r *ProgressiveMarkdownRenderer) ShouldRender(text string) bool

ShouldRender determines if we should re-render based on new content

func (*ProgressiveMarkdownRenderer) UpdateRendered

func (r *ProgressiveMarkdownRenderer) UpdateRendered(textLength int)

UpdateRendered updates the last rendered length

type QuickAction

type QuickAction struct {
	Name        string
	Description string
	Usage       string
	Handler     func(args string) error
}

QuickAction represents a single quick action

type QuickActionsRegistry

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

QuickActionsRegistry manages quick actions

func NewQuickActionsRegistry

func NewQuickActionsRegistry() *QuickActionsRegistry

NewQuickActionsRegistry creates a new registry with built-in actions

func (*QuickActionsRegistry) Execute

func (r *QuickActionsRegistry) Execute(name, args string) error

Execute runs an action with the given arguments

func (*QuickActionsRegistry) FuzzySearch

func (r *QuickActionsRegistry) FuzzySearch(query string) []*QuickAction

FuzzySearch searches actions by name using fuzzy matching

func (*QuickActionsRegistry) GetAction

func (r *QuickActionsRegistry) GetAction(name string) (*QuickAction, error)

GetAction retrieves an action by name

func (*QuickActionsRegistry) ListActions

func (r *QuickActionsRegistry) ListActions() []*QuickAction

ListActions returns all registered actions

func (*QuickActionsRegistry) RegisterAction

func (r *QuickActionsRegistry) RegisterAction(name, description, usage string, handler func(string) error) error

RegisterAction adds a new quick action

type RiskLevel

type RiskLevel int

RiskLevel represents the risk level of a tool operation

const (
	// RiskSafe indicates a tool operation is safe and requires no approval
	RiskSafe RiskLevel = iota
	// RiskCaution indicates a tool operation should be reviewed before execution
	RiskCaution
	// RiskDanger indicates a tool operation is potentially dangerous
	RiskDanger
)

type SpinnerType

type SpinnerType int

SpinnerType represents different types of spinners

const (
	// SpinnerTypeDefault is the standard loading spinner
	SpinnerTypeDefault SpinnerType = iota
	// SpinnerTypeToolExecution is used when executing tools
	SpinnerTypeToolExecution
	// SpinnerTypeStreaming is used when streaming responses
	SpinnerTypeStreaming
	// SpinnerTypeLoading is used for general loading states
	SpinnerTypeLoading
)

type Status

type Status int

Status represents the current UI status

const (
	// StatusIdle indicates the assistant is not processing
	StatusIdle Status = iota
	// StatusTyping indicates the user is typing
	StatusTyping
	// StatusStreaming indicates the assistant is streaming a response
	StatusStreaming
	// StatusError indicates an error occurred
	StatusError
)

type StatusBar

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

StatusBar manages the bottom status bar display

func NewStatusBar

func NewStatusBar(model string, width int, theme themes.Theme) *StatusBar

NewStatusBar creates a new status bar

func (*StatusBar) ApplyUpdate

func (s *StatusBar) ApplyUpdate(update StatusBarUpdate)

ApplyUpdate applies a status bar update

func (*StatusBar) ClearCustomMessage

func (s *StatusBar) ClearCustomMessage()

ClearCustomMessage clears the custom message

func (*StatusBar) GetFullHelp

func (s *StatusBar) GetFullHelp() string

GetFullHelp returns full help text for display in a separate panel

func (*StatusBar) SetConnectionStatus

func (s *StatusBar) SetConnectionStatus(status ConnectionStatus)

SetConnectionStatus updates the connection status

func (*StatusBar) SetContextSize

func (s *StatusBar) SetContextSize(size int)

SetContextSize sets the context window size

func (*StatusBar) SetCustomMessage

func (s *StatusBar) SetCustomMessage(msg string)

SetCustomMessage sets a temporary custom message

func (*StatusBar) SetHelpVisible

func (s *StatusBar) SetHelpVisible(visible bool)

SetHelpVisible toggles help visibility

func (*StatusBar) SetMode

func (s *StatusBar) SetMode(mode string)

SetMode updates the current mode

func (*StatusBar) SetModel

func (s *StatusBar) SetModel(model string)

SetModel updates the model name

func (*StatusBar) SetTokens

func (s *StatusBar) SetTokens(input, output int)

SetTokens sets token counters (absolute values)

func (*StatusBar) SetWidth

func (s *StatusBar) SetWidth(width int)

SetWidth updates the status bar width

func (*StatusBar) UpdateTokens

func (s *StatusBar) UpdateTokens(input, output int)

UpdateTokens updates token counters

func (*StatusBar) View

func (s *StatusBar) View() string

View renders the status bar

type StatusBarUpdate

type StatusBarUpdate struct {
	Tokens     *TokenUpdate
	Connection *ConnectionStatus
	Mode       *string
	Message    *string
}

StatusBarUpdate represents an update to the status bar

type StreamChunk

type StreamChunk = core.StreamChunk

StreamChunk is an alias for core.StreamChunk for use in UI

type StreamChunkMsg

type StreamChunkMsg struct {
	Chunk *StreamChunk
	Error error
}

StreamChunkMsg is a Bubbletea message carrying a streaming chunk

type StreamingDisplay

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

StreamingDisplay manages streaming text display with enhancements

func NewStreamingDisplay

func NewStreamingDisplay() *StreamingDisplay

NewStreamingDisplay creates a new streaming display manager

func (*StreamingDisplay) AdvanceTypewriter

func (s *StreamingDisplay) AdvanceTypewriter()

AdvanceTypewriter advances the typewriter position

func (*StreamingDisplay) AppendText

func (s *StreamingDisplay) AppendText(chunk string)

AppendText adds new text to the streaming buffer

func (*StreamingDisplay) GetElapsedTime

func (s *StreamingDisplay) GetElapsedTime() time.Duration

GetElapsedTime returns time since streaming started

func (*StreamingDisplay) GetFullText

func (s *StreamingDisplay) GetFullText() string

GetFullText returns all text regardless of typewriter position

func (*StreamingDisplay) GetStats

func (s *StreamingDisplay) GetStats() StreamingStats

GetStats returns current streaming statistics

func (*StreamingDisplay) GetText

func (s *StreamingDisplay) GetText() string

GetText returns the current text (respecting typewriter mode)

func (*StreamingDisplay) GetTokenCount

func (s *StreamingDisplay) GetTokenCount() int

GetTokenCount returns total tokens received

func (*StreamingDisplay) GetTokenRate

func (s *StreamingDisplay) GetTokenRate() float64

GetTokenRate returns the current token rate (tokens/second)

func (*StreamingDisplay) IsTypewriterMode

func (s *StreamingDisplay) IsTypewriterMode() bool

IsTypewriterMode returns whether typewriter mode is active

func (*StreamingDisplay) IsWaitingForTokens

func (s *StreamingDisplay) IsWaitingForTokens() bool

IsWaitingForTokens returns whether we're still waiting for the first token

func (*StreamingDisplay) RenderStreamingIndicator

func (s *StreamingDisplay) RenderStreamingIndicator() string

RenderStreamingIndicator renders the streaming status indicator

func (*StreamingDisplay) RenderWithCursor

func (s *StreamingDisplay) RenderWithCursor(text string) string

RenderWithCursor renders text with a typewriter cursor if in typewriter mode

func (*StreamingDisplay) Reset

func (s *StreamingDisplay) Reset()

Reset clears the streaming display

func (*StreamingDisplay) SetTypewriterMode

func (s *StreamingDisplay) SetTypewriterMode(enabled bool)

SetTypewriterMode enables or disables typewriter effect

func (*StreamingDisplay) ToggleTypewriterMode

func (s *StreamingDisplay) ToggleTypewriterMode()

ToggleTypewriterMode toggles typewriter mode on/off

type StreamingStats

type StreamingStats struct {
	TotalTokens   int
	AverageRate   float64
	CurrentRate   float64
	Duration      time.Duration
	TypewriterPos int
	TotalChars    int
}

StreamingStats provides statistics about the streaming session

type Suggestion

type Suggestion = suggestions.Suggestion

Suggestion is an alias for suggestions.Suggestion

type SuggestionDetector

type SuggestionDetector = suggestions.Detector

SuggestionDetector is an alias for suggestions.Detector

func NewSuggestionDetector

func NewSuggestionDetector() *SuggestionDetector

NewSuggestionDetector creates a new detector

type SuggestionLearner

type SuggestionLearner = suggestions.Learner

SuggestionLearner is an alias for suggestions.Learner

func NewSuggestionLearner

func NewSuggestionLearner() *SuggestionLearner

NewSuggestionLearner creates a new learner

type TokenUpdate

type TokenUpdate struct {
	Input  int
	Output int
}

TokenUpdate represents a token count update

type ToolProvider

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

ToolProvider provides tool name completions

func NewToolProvider

func NewToolProvider(tools []string) *ToolProvider

NewToolProvider creates a new tool completion provider

func (*ToolProvider) GetCompletions

func (tp *ToolProvider) GetCompletions(input string) []Completion

GetCompletions returns fuzzy-matched tool completions

func (*ToolProvider) SetTools

func (tp *ToolProvider) SetTools(tools []string)

SetTools updates the available tools

type ToolResult

type ToolResult struct {
	ToolUseID string
	Result    *tools.Result
}

ToolResult represents a tool execution result for the API

type ToolSpinner

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

ToolSpinner manages spinner state for tool execution

func NewToolSpinner

func NewToolSpinner() *ToolSpinner

NewToolSpinner creates a new spinner for tool execution

func (*ToolSpinner) GetElapsed

func (s *ToolSpinner) GetElapsed() time.Duration

GetElapsed returns the elapsed time since spinner started

func (*ToolSpinner) GetMessage added in v0.1.9

func (s *ToolSpinner) GetMessage() string

GetMessage returns the current spinner message

func (*ToolSpinner) IsActive

func (s *ToolSpinner) IsActive() bool

IsActive returns whether the spinner is currently active

func (*ToolSpinner) Start

func (s *ToolSpinner) Start(spinnerType SpinnerType, message string) tea.Cmd

Start activates the spinner with a message

func (*ToolSpinner) Stop

func (s *ToolSpinner) Stop()

Stop deactivates the spinner

func (*ToolSpinner) Tick added in v0.1.9

func (s *ToolSpinner) Tick() tea.Cmd

Tick returns the spinner tick command for keeping animation alive Use this when you need to batch spinner animation with other commands

func (*ToolSpinner) Update

func (s *ToolSpinner) Update(msg tea.Msg) tea.Cmd

Update processes spinner tick messages

func (*ToolSpinner) UpdateTokens

func (s *ToolSpinner) UpdateTokens(count int)

UpdateTokens updates token count and calculates rate (for streaming)

func (*ToolSpinner) View

func (s *ToolSpinner) View() string

View renders the spinner

type Usage

type Usage = core.Usage

Usage is an alias for core.Usage for use in UI

type ViewMode

type ViewMode int

ViewMode represents different view modes in the UI

const (
	// ViewModeChat is the main chat interface view
	ViewModeChat ViewMode = iota
	// ViewModeHistory displays conversation history
	ViewModeHistory
	// ViewModeTools shows available tools and their status
	ViewModeTools
)

Directories

Path Synopsis
Package components provides reusable UI components for the TUI.
Package components provides reusable UI components for the TUI.
Package layout provides consistent border styles and spacing utilities for TUI layout.
Package layout provides consistent border styles and spacing utilities for TUI layout.
Package themes provides theming support for the TUI.
Package themes provides theming support for the TUI.
Package visualization provides real-time visualization of token usage and context windows.
Package visualization provides real-time visualization of token usage and context windows.

Jump to

Keyboard shortcuts

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