tui

package
v0.0.146 Latest Latest
Warning

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

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

Documentation

Overview

Package tui provides terminal UI components for comanda using bubbletea and lipgloss

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunChart

func RunChart(workflowName string, nodes []*ChartNode, stats ChartStats) error

RunChart starts the chart TUI

Types

type Activity

type Activity struct {
	Timestamp time.Time
	Type      string // "tool", "output", "error", "info"
	Message   string
}

Activity represents a recent activity in the dashboard

type ChartModel

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

ChartModel is the bubbletea model for the chart view

func NewChartModel

func NewChartModel(workflowName string, nodes []*ChartNode, stats ChartStats) ChartModel

NewChartModel creates a new chart model

func (ChartModel) Init

func (m ChartModel) Init() tea.Cmd

Init initializes the model

func (ChartModel) Update

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

Update handles messages

func (ChartModel) View

func (m ChartModel) View() string

View renders the model

type ChartNode

type ChartNode struct {
	Name        string
	Model       string
	Type        string // "step", "parallel", "loop", "condition"
	IsValid     bool
	Children    []*ChartNode
	Input       string
	Output      string
	Action      string
	LoopConfig  *LoopConfig
	IsDeferred  bool
	Description string
}

ChartNode represents a node in the workflow chart

type ChartStats

type ChartStats struct {
	TotalSteps    int
	ParallelSteps int
	LoopCount     int
	ValidSteps    int
	DeferredSteps int
	Models        map[string]int
}

ChartStats holds workflow statistics

type DashboardModel

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

DashboardModel is the bubbletea model for the live dashboard

func NewDashboardModel

func NewDashboardModel(workflowName string, reporter *ProgressReporter) *DashboardModel

NewDashboardModel creates a new dashboard model

func RunDashboard

func RunDashboard(workflowName string, reporter *ProgressReporter) (*DashboardModel, *tea.Program)

RunDashboard starts the dashboard TUI and returns the program for external control

func (*DashboardModel) Init

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

Init initializes the model

func (*DashboardModel) Update

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

Update handles messages

func (*DashboardModel) View

func (m *DashboardModel) View() string

View renders the dashboard

type EventMsg

type EventMsg struct {
	Event ProgressEvent
}

EventMsg wraps a progress event

type LogWatcher

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

LogWatcher monitors a stream log file and emits progress events

func NewLogWatcher

func NewLogWatcher(path string, reporter *ProgressReporter) *LogWatcher

NewLogWatcher creates a new log watcher

func (*LogWatcher) Start

func (w *LogWatcher) Start()

Start begins watching the log file

func (*LogWatcher) Stop

func (w *LogWatcher) Stop()

Stop stops watching

type LoopConfig

type LoopConfig struct {
	MaxIterations int
	ExitCondition string
	ContextWindow int
}

LoopConfig contains loop-specific configuration

type Output

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

Output provides styled output for non-TUI mode

func NewOutput

func NewOutput(width int) *Output

NewOutput creates a new output helper

func (*Output) Bold

func (o *Output) Bold(message string) string

Bold prints bold text

func (*Output) Box

func (o *Output) Box(content string) string

Box wraps content in a styled box

func (*Output) Divider

func (o *Output) Divider() string

Divider prints a horizontal divider

func (*Output) Error

func (o *Output) Error(message string) string

Error prints an error message

func (*Output) Header

func (o *Output) Header(title string) string

Header prints a styled header box

func (*Output) HighlightBox

func (o *Output) HighlightBox(content string) string

HighlightBox wraps content in a highlighted box

func (*Output) Info

func (o *Output) Info(message string) string

Info prints an info message

func (*Output) ModelTag

func (o *Output) ModelTag(model string) string

ModelTag prints a colored model tag

func (*Output) Muted

func (o *Output) Muted(message string) string

Muted prints muted text

func (*Output) Progress

func (o *Output) Progress(current, total int, label string) string

Progress prints a styled progress line

func (*Output) Section

func (o *Output) Section(title, content string) string

Section prints a styled section box

func (*Output) SetEnabled

func (o *Output) SetEnabled(enabled bool)

SetEnabled enables or disables styled output

func (*Output) StatsBox

func (o *Output) StatsBox(stats map[string]interface{}) string

StatsBox prints a statistics box

func (*Output) Step

func (o *Output) Step(name, model, status string) string

Step prints a styled step indicator

func (*Output) SubHeader

func (o *Output) SubHeader(title string) string

SubHeader prints a styled subheader

func (*Output) Success

func (o *Output) Success(message string) string

Success prints a success message

func (*Output) Table

func (o *Output) Table(headers []string, rows [][]string) string

Table prints a simple styled table

func (*Output) Warning

func (o *Output) Warning(message string) string

Warning prints a warning message

type ProgressEvent

type ProgressEvent struct {
	Type        string // "step_start", "step_end", "loop_iter", "tool_call", "output", "error", "complete"
	Timestamp   time.Time
	StepName    string
	LoopName    string
	Iteration   int
	MaxIter     int
	Message     string
	TokensUsed  int
	TokensAvail int
	Error       error
}

ProgressEvent represents an event during workflow processing

type ProgressReporter

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

ProgressReporter sends progress events to subscribers

func NewProgressReporter

func NewProgressReporter() *ProgressReporter

NewProgressReporter creates a new progress reporter

func (*ProgressReporter) Close

func (p *ProgressReporter) Close()

Close cleans up all subscribers

func (*ProgressReporter) Complete

func (p *ProgressReporter) Complete(err error)

Complete emits a completion event

func (*ProgressReporter) Emit

func (p *ProgressReporter) Emit(event ProgressEvent)

Emit sends an event to all subscribers

func (*ProgressReporter) GetResourceUsage

func (p *ProgressReporter) GetResourceUsage() (cpuPercent float64, memoryMB float64)

GetResourceUsage returns current CPU and memory usage

func (*ProgressReporter) LoopIteration

func (p *ProgressReporter) LoopIteration(loopName string, iteration, maxIter int)

LoopIteration emits a loop iteration event

func (*ProgressReporter) Output

func (p *ProgressReporter) Output(message string)

Output emits an output event

func (*ProgressReporter) StepEnd

func (p *ProgressReporter) StepEnd(name string, err error)

StepEnd emits a step end event

func (*ProgressReporter) StepStart

func (p *ProgressReporter) StepStart(name string)

StepStart emits a step start event

func (*ProgressReporter) Subscribe

func (p *ProgressReporter) Subscribe() chan ProgressEvent

Subscribe adds a subscriber channel

func (*ProgressReporter) TokenUpdate

func (p *ProgressReporter) TokenUpdate(used, available int)

TokenUpdate emits a token usage update

func (*ProgressReporter) ToolCall

func (p *ProgressReporter) ToolCall(message string)

ToolCall emits a tool call event

func (*ProgressReporter) Unsubscribe

func (p *ProgressReporter) Unsubscribe(ch chan ProgressEvent)

Unsubscribe removes a subscriber channel

type Theme

type Theme struct {
	// Base colors
	Primary   lipgloss.Color
	Secondary lipgloss.Color
	Accent    lipgloss.Color
	Muted     lipgloss.Color
	Success   lipgloss.Color
	Warning   lipgloss.Color
	Error     lipgloss.Color

	// Background colors
	BgPrimary   lipgloss.Color
	BgSecondary lipgloss.Color

	// Model colors (for distinguishing different AI providers)
	ModelColors map[string]lipgloss.Color

	// Pre-built styles
	Title       lipgloss.Style
	Subtitle    lipgloss.Style
	Body        lipgloss.Style
	MutedText   lipgloss.Style
	SuccessText lipgloss.Style
	WarningText lipgloss.Style
	ErrorText   lipgloss.Style

	// Box styles
	BoxNormal    lipgloss.Style
	BoxHighlight lipgloss.Style
	BoxError     lipgloss.Style
	BoxSuccess   lipgloss.Style

	// Progress bar colors
	ProgressFull  lipgloss.Color
	ProgressEmpty lipgloss.Color
}

Theme defines the color scheme and styles for the TUI

func DefaultTheme

func DefaultTheme() *Theme

DefaultTheme returns the default comanda theme

func (*Theme) ModelColor

func (t *Theme) ModelColor(model string) lipgloss.Color

ModelColor returns the color for a given model name

func (*Theme) ModelStyle

func (t *Theme) ModelStyle(model string) lipgloss.Style

ModelStyle returns a style configured for a given model

func (*Theme) ProgressBar

func (t *Theme) ProgressBar(percent float64, width int) string

ProgressBar creates a progress bar string

func (*Theme) StatusIcon

func (t *Theme) StatusIcon(status string) (string, lipgloss.Style)

StatusIcon returns an icon and style for a status

type TickMsg

type TickMsg time.Time

TickMsg is sent on each tick for time/resource updates

Jump to

Keyboard shortcuts

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