tui

package
v0.0.0-...-348835b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tui provides the Bubbletea TUI for interactive Claude sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeUnifiedDiff

func ComputeUnifiedDiff(path, oldContent, newContent string) string

ComputeUnifiedDiff creates a simple unified diff between old and new content.

func RenderDiff

func RenderDiff(diff string, theme Theme) string

RenderDiff colorizes a unified diff string using the theme.

Types

type ApprovalDialog

type ApprovalDialog struct {
	Request  claude.EventToolRequest
	Selected int // 0 = Accept, 1 = Reject
	Theme    Theme
	Width    int
}

ApprovalDialog renders a tool approval prompt.

func (ApprovalDialog) View

func (a ApprovalDialog) View() string

View renders the approval dialog.

type KeyMap

type KeyMap struct {
	Quit       key.Binding
	AutoAccept key.Binding
	Approve    key.Binding
	Reject     key.Binding
	ScrollUp   key.Binding
	ScrollDown key.Binding
	NavLeft    key.Binding
	NavRight   key.Binding
}

KeyMap defines all keybindings for the TUI.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default keybindings.

type Model

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

Model is the root Bubbletea model for the Claude session TUI.

func New

func New(session *claude.Session, model string, autoAccept bool) Model

New creates a new TUI model.

func (Model) Err

func (m Model) Err() error

Err returns any error that occurred during the session.

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model.

func (Model) Update

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

Update implements tea.Model.

func (Model) View

func (m Model) View() string

View implements tea.Model.

type State

type State int

State represents the TUI state.

const (
	StateStreaming        State = iota // receiving streaming output
	StateAwaitingApproval              // waiting for user tool approval
	StateCompleted                     // session finished successfully
	StateError                         // session ended with an error
)

State constants for the TUI model.

type StatusBar

type StatusBar struct {
	Model      string
	State      string
	AutoAccept bool
	Theme      Theme
	Width      int
}

StatusBar renders the bottom status bar.

func (StatusBar) View

func (s StatusBar) View() string

View renders the status bar.

type Theme

type Theme struct {
	Bg        lipgloss.Color
	Fg        lipgloss.Color
	Accent    lipgloss.Color
	Success   lipgloss.Color
	Error     lipgloss.Color
	Warning   lipgloss.Color
	Muted     lipgloss.Color
	Highlight lipgloss.Color
}

Theme holds the color scheme for the TUI.

func DefaultTheme

func DefaultTheme() Theme

DefaultTheme returns the hardcoded fallback theme.

func LoadTheme

func LoadTheme() Theme

LoadTheme loads colors with the following priority (highest to lowest):

  1. ~/.hydra.yml colors (explicit user override)
  2. pywal ~/.cache/wal/colors.json
  3. DefaultTheme() hardcoded values

func (Theme) AccentStyle

func (t Theme) AccentStyle() lipgloss.Style

AccentStyle returns a style for accented text.

func (Theme) ChromaStyle

func (t Theme) ChromaStyle() *chroma.Style

ChromaStyle returns a chroma syntax-highlighting style derived from the theme. When pywal is active (~/.cache/wal/colors.json exists), the style automatically uses the pywal palette via LoadTheme. The mapping is:

color1 (Error)     → keywords, operators
color2 (Success)   → strings, attributes
color3 (Warning)   → literals, dates
color4 (Accent)    → tags, builtins, headings
color5 (Highlight) → numbers
color8 (Muted)     → comments

func (Theme) DiffAddStyle

func (t Theme) DiffAddStyle() lipgloss.Style

DiffAddStyle returns a style for added diff lines.

func (Theme) DiffHeaderStyle

func (t Theme) DiffHeaderStyle() lipgloss.Style

DiffHeaderStyle returns a style for diff headers.

func (Theme) DiffRemoveStyle

func (t Theme) DiffRemoveStyle() lipgloss.Style

DiffRemoveStyle returns a style for removed diff lines.

func (Theme) ErrorStyle

func (t Theme) ErrorStyle() lipgloss.Style

ErrorStyle returns a style for error text.

func (Theme) HighlightStyle

func (t Theme) HighlightStyle() lipgloss.Style

HighlightStyle returns a style for highlighted text.

func (Theme) MutedStyle

func (t Theme) MutedStyle() lipgloss.Style

MutedStyle returns a style for muted/secondary text.

func (Theme) SuccessStyle

func (t Theme) SuccessStyle() lipgloss.Style

SuccessStyle returns a style for success text.

func (Theme) TextStyle

func (t Theme) TextStyle() lipgloss.Style

TextStyle returns the base text style.

func (Theme) WarningStyle

func (t Theme) WarningStyle() lipgloss.Style

WarningStyle returns a style for warning text.

Jump to

Keyboard shortcuts

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