Documentation
¶
Overview ¶
Package tui implements the interactive terminal UI using Bubble Tea.
Index ¶
- func Run(ctx context.Context, cfg Config) error
- type AgentReadyMsg
- type Config
- type InputModel
- func (m *InputModel) Blur()
- func (m *InputModel) Focus()
- func (m *InputModel) LoadHistory(path string)
- func (m *InputModel) PushHistory(s string)
- func (m *InputModel) Reset()
- func (m *InputModel) SetAttachment(s string)
- func (m *InputModel) SetCommands(cmds []string)
- func (m *InputModel) SetValue(s string)
- func (m *InputModel) SetWidth(w int)
- func (m InputModel) Update(msg tea.Msg) (InputModel, tea.Cmd)
- func (m *InputModel) Value() string
- func (m InputModel) View() string
- type MessageView
- type ModalCloseMsg
- type ModalItem
- type ModalModel
- type ModalSelectMsg
- type Model
- type OverlayModel
- func (o *OverlayModel) Close(key string)
- func (o *OverlayModel) DismissTop()
- func (o *OverlayModel) ScrollDown()
- func (o *OverlayModel) ScrollUp()
- func (o *OverlayModel) SetSize(w, h int)
- func (o *OverlayModel) Show(key, title, content, anchor, width string)
- func (o OverlayModel) View() string
- func (o OverlayModel) Visible() bool
- type StatusBar
- type Styles
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AgentReadyMsg ¶ added in v0.16.20
AgentReadyMsg signals background setup is complete and the agent is ready.
type Config ¶
type Config struct {
Shell *shell.Shell
Agent *core.Agent
Session *session.Session
Model core.Model
Models []core.Model // available models from registry
SessDir string // session directory path
Theme Theme
App *ext.App // extension API surface
Settings *config.Settings // user settings (nil-safe)
// SetupFn runs as a background Cmd from Init(). It performs heavy startup
// work (loading extensions, building agent) and returns an AgentReadyMsg.
SetupFn func() AgentReadyMsg
}
Config configures the TUI app.
type InputModel ¶
type InputModel struct {
// contains filtered or unexported fields
}
InputModel manages the composer textarea with slash command autocomplete.
func NewInputModel ¶
func NewInputModel(styles Styles, commands []string) InputModel
NewInputModel creates a new composer input.
func (*InputModel) LoadHistory ¶ added in v0.16.24
func (m *InputModel) LoadHistory(path string)
LoadHistory reads persistent history from disk and sets the path for future saves. Missing file is a no-op.
func (*InputModel) PushHistory ¶ added in v0.5.0
func (m *InputModel) PushHistory(s string)
PushHistory adds an entry to the input history, resets the cursor, and persists the history to disk.
func (*InputModel) SetAttachment ¶ added in v0.5.0
func (m *InputModel) SetAttachment(s string)
SetAttachment sets the attachment indicator shown above the input.
func (*InputModel) SetCommands ¶ added in v0.16.20
func (m *InputModel) SetCommands(cmds []string)
SetCommands updates the registered command names for autocomplete.
func (*InputModel) SetValue ¶
func (m *InputModel) SetValue(s string)
SetValue sets the textarea content.
func (*InputModel) SetWidth ¶
func (m *InputModel) SetWidth(w int)
SetWidth updates the input width.
func (InputModel) Update ¶
func (m InputModel) Update(msg tea.Msg) (InputModel, tea.Cmd)
Update handles input events.
type MessageView ¶
type MessageView struct {
// contains filtered or unexported fields
}
MessageView renders conversation messages.
func NewMessageView ¶
func NewMessageView(styles Styles, width int) MessageView
NewMessageView creates a message renderer.
func (*MessageView) RenderMessage ¶
func (v *MessageView) RenderMessage(msg core.Message) string
RenderMessage renders a single message.
func (*MessageView) RenderStreaming ¶
func (v *MessageView) RenderStreaming(text string, thinking string, cache *streamCache) string
RenderStreaming renders a partial assistant response being streamed. Uses glamour with caching — only re-renders when newline count changes. Newline-only triggering avoids mid-line re-renders during code blocks, where incomplete syntax causes glamour to produce unstable output (flicker).
func (*MessageView) SetWidth ¶
func (v *MessageView) SetWidth(w int)
SetWidth updates the rendering width.
type ModalModel ¶
type ModalModel struct {
// contains filtered or unexported fields
}
ModalModel is a generic list selector modal.
func NewModalModel ¶
func NewModalModel(title string, items []ModalItem, styles Styles) ModalModel
NewModalModel creates a modal.
func (*ModalModel) SetItems ¶
func (m *ModalModel) SetItems(items []ModalItem)
SetItems updates the items list.
func (*ModalModel) SetSize ¶
func (m *ModalModel) SetSize(w, h int)
SetSize updates the modal dimensions.
func (ModalModel) Update ¶
func (m ModalModel) Update(msg tea.Msg) (ModalModel, tea.Cmd)
Update handles modal events.
func (ModalModel) Visible ¶
func (m ModalModel) Visible() bool
Visible returns whether the modal is shown.
type ModalSelectMsg ¶
type ModalSelectMsg struct {
Item ModalItem
}
ModalSelectMsg is sent when an item is selected.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubble Tea model for the TUI.
type OverlayModel ¶ added in v0.18.0
type OverlayModel struct {
// contains filtered or unexported fields
}
OverlayModel manages a stack of named overlays. Escape dismisses the topmost.
func NewOverlayModel ¶ added in v0.18.0
func NewOverlayModel(styles Styles) OverlayModel
NewOverlayModel creates an overlay manager.
func (*OverlayModel) Close ¶ added in v0.18.0
func (o *OverlayModel) Close(key string)
Close removes a specific overlay by key.
func (*OverlayModel) DismissTop ¶ added in v0.18.0
func (o *OverlayModel) DismissTop()
DismissTop removes the topmost overlay (Escape behavior).
func (*OverlayModel) ScrollDown ¶ added in v0.18.0
func (o *OverlayModel) ScrollDown()
ScrollDown scrolls the topmost overlay down.
func (*OverlayModel) ScrollUp ¶ added in v0.18.0
func (o *OverlayModel) ScrollUp()
ScrollUp scrolls the topmost overlay up.
func (*OverlayModel) SetSize ¶ added in v0.18.0
func (o *OverlayModel) SetSize(w, h int)
SetSize updates the available dimensions.
func (*OverlayModel) Show ¶ added in v0.18.0
func (o *OverlayModel) Show(key, title, content, anchor, width string)
Show pushes an overlay onto the stack. If an overlay with the same key exists, it is replaced (moved to the top).
func (OverlayModel) View ¶ added in v0.18.0
func (o OverlayModel) View() string
View renders the topmost overlay. The caller composites this on top of the main view.
func (OverlayModel) Visible ¶ added in v0.18.0
func (o OverlayModel) Visible() bool
Visible returns true if at least one overlay is showing.
type StatusBar ¶
type StatusBar struct {
// contains filtered or unexported fields
}
StatusBar renders the footer status bar. Sections are registered through ext.RegisterStatusSection. Values are set via Set(key, value).
func (*StatusBar) Set ¶ added in v0.5.0
Set updates a named status section's display value. Pass empty string to clear the section.
func (*StatusBar) SetRegistry ¶ added in v0.5.0
func (s *StatusBar) SetRegistry(sections []ext.StatusSection)
SetRegistry updates the registered section definitions. Sections are sorted once here so renderSide does not need to sort on every render.
func (*StatusBar) SetSpinnerView ¶ added in v0.5.0
SetSpinnerView updates the spinner display (empty string = hidden).
type Styles ¶
type Styles struct {
App lipgloss.Style
Header lipgloss.Style
UserMsg lipgloss.Style
AssistantLabel lipgloss.Style
ToolError lipgloss.Style
Thinking lipgloss.Style
Spinner lipgloss.Style
InputBorder lipgloss.Style
Muted lipgloss.Style
Error lipgloss.Style
Success lipgloss.Style
Warning lipgloss.Style
BorderColor color.Color
}
Styles holds precomputed lipgloss styles derived from a Theme.