tui

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tui implements the terminal user interface for Ghost's interactive chat mode using the BubbleTea framework. It handles user input, message display, viewport management, and LLM streaming integration.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLLMClientInit indicates the LLM client was not properly initialized before use.
	ErrLLMClientInit = errors.New("failed to initialize LLM client")

	// ErrLLMRequest indicates an LLM request processing failure in the TUI context.
	ErrLLMRequest = errors.New("failed to process LLM request")
)

Functions

func Run

func Run(model Model, systemPrompt string, greetingPrompt string) error

Run starts the BubbleTea TUI program with the provided model. It runs in alternate screen mode and returns any error that occurs.

Types

type Model

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

Model represents the TUI application state for the chat interface. It implements the BubbleTea Model interface (Init, Update, View).

func NewModel

func NewModel(ctx context.Context, llmClient llm.LLMClient, timeout time.Duration, logger *log.Logger) Model

NewModel creates a new TUI model initialized with the provided dependencies. The model is pre-configured with a system prompt and greeting instruction that will be sent to the LLM on initialization.

func (Model) Init

func (model Model) Init() tea.Cmd

Init initializes the TUI and returns a command to send the initial greeting. This is called once when the BubbleTea program starts.

func (Model) Update

func (model Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles all incoming messages and updates the model state accordingly. It processes terminal events (window resize, key presses) and custom messages (streaming chunks, completion, errors) from LLM requests.

func (Model) View

func (model Model) View() string

View renders the TUI layout with the chat viewport, separator, and input field.

Jump to

Keyboard shortcuts

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