Documentation
¶
Overview ¶
Package tui provides a terminal user interface for PromptArena execution monitoring. It implements a multi-pane display showing active runs, metrics, and logs in real-time.
Index ¶
- Constants
- func CheckTerminalSize() (width, height int, supported bool, reason string)
- func RenderSummary(summary *Summary, width int) string
- func RenderSummaryCIMode(summary *Summary) string
- func Run(ctx context.Context, model *Model) error
- type ErrorInfo
- type LogEntry
- type LogInterceptor
- func (l *LogInterceptor) Close() error
- func (l *LogInterceptor) Enabled(ctx context.Context, level slog.Level) bool
- func (l *LogInterceptor) FlushBuffer()
- func (l *LogInterceptor) Handle(ctx context.Context, record slog.Record) error
- func (l *LogInterceptor) WithAttrs(attrs []slog.Attr) slog.Handler
- func (l *LogInterceptor) WithGroup(name string) slog.Handler
- type LogMsg
- type Model
- type Observer
- type RunCompletedMsg
- type RunFailedMsg
- type RunInfo
- type RunStartedMsg
- type RunStatus
- type ShowSummaryMsg
- type Summary
Constants ¶
const ( MinTerminalWidth = 80 MinTerminalHeight = 24 )
Terminal size requirements
Variables ¶
This section is empty.
Functions ¶
func CheckTerminalSize ¶
CheckTerminalSize checks if the terminal is large enough for TUI mode
func RenderSummary ¶
RenderSummary renders the final summary screen for TUI mode
func RenderSummaryCIMode ¶
RenderSummaryCIMode renders the final summary for CI/simple mode (no colors)
Types ¶
type LogInterceptor ¶
type LogInterceptor struct {
// contains filtered or unexported fields
}
LogInterceptor wraps an slog.Handler to intercept log messages and send them to the TUI. It also optionally writes logs to a file in verbose mode.
func NewLogInterceptor ¶
func NewLogInterceptor( originalHandler slog.Handler, program *tea.Program, logFilePath string, suppressStderr bool, ) (*LogInterceptor, error)
NewLogInterceptor creates a log interceptor that sends logs to the TUI. If logFilePath is not empty, logs will also be written to that file. If suppressStderr is true, logs won't be sent to the original handler (useful for TUI mode).
func SetupLogger ¶
func SetupLogger(logger *slog.Logger, program *tea.Program, logFilePath string, suppressStderr bool) (*LogInterceptor, error)
SetupLogger configures the provided logger to intercept logs and send them to the TUI. If logFilePath is not empty, logs will also be written to that file. If suppressStderr is true, logs won't be sent to stderr (useful for TUI mode). Returns the interceptor (to be closed when done) and an error if setup fails.
func (*LogInterceptor) Close ¶
func (l *LogInterceptor) Close() error
Close closes the log file if one was opened.
func (*LogInterceptor) Enabled ¶
Enabled reports whether the handler handles records at the given level.
func (*LogInterceptor) FlushBuffer ¶
func (l *LogInterceptor) FlushBuffer()
FlushBuffer writes all buffered logs to the original handler (stderr). Call this after the TUI exits to show any logs that occurred during execution.
func (*LogInterceptor) Handle ¶
Handle processes a log record by sending it to the TUI and optionally writing to file.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model represents the bubbletea application state
func NewModel ¶
NewModel creates a new TUI model with the specified configuration file and total run count.
func (*Model) BuildSummary ¶
BuildSummary creates a Summary from the current model state with output directory and HTML report path.
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
Observer implements the ExecutionObserver interface to bridge engine callbacks to bubbletea messages. It converts engine events into bubbletea messages that can be processed by the TUI Model.
func NewObserver ¶
NewObserver creates a new TUI observer that sends messages to the given bubbletea program.
func NewObserverWithModel ¶
NewObserverWithModel creates an observer that updates the model directly (headless mode)
func (*Observer) OnRunCompleted ¶
OnRunCompleted is called when a test run finishes successfully. This method is goroutine-safe and converts the callback to a bubbletea message.
func (*Observer) OnRunFailed ¶
OnRunFailed is called when a test run fails with an error. This method is goroutine-safe and converts the callback to a bubbletea message.
func (*Observer) OnRunStarted ¶
OnRunStarted is called when a test run begins execution. This method is goroutine-safe and converts the callback to a bubbletea message.
type RunCompletedMsg ¶
RunCompletedMsg is sent when a run completes successfully.
type RunFailedMsg ¶
RunFailedMsg is sent when a run fails with an error.
type RunInfo ¶
type RunInfo struct {
RunID string
Scenario string
Provider string
Region string
Status RunStatus
Duration time.Duration
Cost float64
Error string
StartTime time.Time
}
RunInfo tracks information about a single run
type RunStartedMsg ¶
type RunStartedMsg struct {
RunID string
Scenario string
Provider string
Region string
Time time.Time
}
RunStartedMsg is sent when a run begins execution.
type ShowSummaryMsg ¶
type ShowSummaryMsg struct {
Summary *Summary
}
ShowSummaryMsg is sent when execution completes and the final summary should be displayed
type Summary ¶
type Summary struct {
TotalRuns int
SuccessCount int
FailedCount int
TotalCost float64
TotalTokens int64
TotalDuration time.Duration
AvgDuration time.Duration
ProviderCounts map[string]int
ScenarioCount int
Regions []string
Errors []ErrorInfo
OutputDir string
HTMLReport string
}
Summary represents the final execution summary displayed after all runs complete