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 ConversationStartedMsg
- type ErrorInfo
- type EventAdapter
- type LogEntry
- type MessageCreatedMsg
- type MessageToolCall
- type MessageToolResult
- type MessageUpdatedMsg
- type Model
- func (m *Model) ActiveRuns() []RunInfo
- func (m *Model) BuildSummary(outputDir, htmlReport string) *Summary
- func (m *Model) CompletedCount() int
- func (m *Model) Init() tea.Cmd
- func (m *Model) Logs() []LogEntry
- func (m *Model) SetStateStore(store runResultStorer)
- func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *Model) View() string
- type RunCompletedMsg
- type RunFailedMsg
- type RunInfo
- type RunStartedMsg
- type RunStatus
- type Summary
- type TurnCompletedMsg
- type TurnStartedMsg
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 summary in plain text for CI/non-TUI environments
Types ¶
type ConversationStartedMsg ¶ added in v1.1.5
ConversationStartedMsg is sent when a new conversation starts with its system prompt.
type EventAdapter ¶ added in v1.1.4
type EventAdapter struct {
// contains filtered or unexported fields
}
EventAdapter converts runtime events to bubbletea messages.
func NewEventAdapter ¶ added in v1.1.4
func NewEventAdapter(program *tea.Program) *EventAdapter
NewEventAdapter creates an adapter that forwards events to the TUI program.
func NewEventAdapterWithModel ¶ added in v1.1.4
func NewEventAdapterWithModel(model *Model) *EventAdapter
NewEventAdapterWithModel creates an adapter for headless mode.
func (*EventAdapter) HandleEvent ¶ added in v1.1.4
func (a *EventAdapter) HandleEvent(event *events.Event)
HandleEvent converts runtime events into TUI messages.
func (*EventAdapter) Subscribe ¶ added in v1.1.4
func (a *EventAdapter) Subscribe(bus *events.EventBus)
Subscribe subscribes the adapter to an event bus.
type MessageCreatedMsg ¶ added in v1.1.5
type MessageCreatedMsg struct {
ConversationID string
Role string
Content string
Index int
ToolCalls []MessageToolCall // Tool calls requested by assistant
ToolResult *MessageToolResult // Tool result for tool messages
Time time.Time
}
MessageCreatedMsg is sent when a message is created during execution.
type MessageToolCall ¶ added in v1.1.5
type MessageToolCall struct {
ID string // Unique identifier for this tool call
Name string // Name of the tool to invoke
Args string // JSON-encoded tool arguments
}
MessageToolCall represents a tool call in a message (mirrors events.MessageToolCall).
type MessageToolResult ¶ added in v1.1.5
type MessageToolResult struct {
ID string // References the MessageToolCall.ID
Name string // Tool name that was executed
Content string // Result content
Error string // Error message if tool failed
LatencyMs int64 // Tool execution latency
}
MessageToolResult represents a tool result in a message (mirrors events.MessageToolResult).
type MessageUpdatedMsg ¶ added in v1.1.5
type MessageUpdatedMsg struct {
ConversationID string
Index int
LatencyMs int64
InputTokens int
OutputTokens int
TotalCost float64
Time time.Time
}
MessageUpdatedMsg is sent when a message is updated with cost/latency info.
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) ActiveRuns ¶ added in v1.1.4
ActiveRuns returns a snapshot of active runs for inspection or testing. Safe for concurrent use.
func (*Model) BuildSummary ¶
BuildSummary creates a Summary from the current model state with output directory and HTML report path. Thread-safe for external callers.
func (*Model) CompletedCount ¶ added in v1.1.4
CompletedCount returns the number of completed runs (success + failure). Safe for concurrent use.
func (*Model) Logs ¶ added in v1.1.4
Logs returns a snapshot of the current log entries. Safe for concurrent use.
func (*Model) SetStateStore ¶ added in v1.1.4
func (m *Model) SetStateStore(store runResultStorer)
SetStateStore attaches a state store for building summaries from run results.
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
CurrentTurnIndex int
CurrentTurnRole string
Selected bool
}
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 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
AssertionTotal int
AssertionFailed int
}
Summary represents the final execution summary displayed after all runs complete
Directories
¶
| Path | Synopsis |
|---|---|
|
Package logging provides log interception functionality for the TUI.
|
Package logging provides log interception functionality for the TUI. |
|
Package pages provides top-level page components for the TUI.
|
Package pages provides top-level page components for the TUI. |
|
Package panels provides reusable panel components for the TUI.
|
Package panels provides reusable panel components for the TUI. |
|
Package theme provides centralized styling, colors, and formatting for the TUI.
|
Package theme provides centralized styling, colors, and formatting for the TUI. |
|
Package viewmodels provides data transformation and presentation logic for TUI views.
|
Package viewmodels provides data transformation and presentation logic for TUI views. |
|
Package views provides pure rendering components for TUI views.
|
Package views provides pure rendering components for TUI views. |