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.
The model renders the live 3-pane run view (runs / logs / result). Page navigation (conversation drill-down, file browsing) is owned by the hub shell (tui/app): the model exposes the run the user selected via TakeSelectedRun so the hub can push a conversation page onto its stack.
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 AudioLevelMsg
- 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) EnableTUIMode()
- func (m *Model) Init() tea.Cmd
- func (m *Model) Logs() []LogEntry
- func (m *Model) SetAudioMonitor(monitor audioMonitor)
- func (m *Model) SetStateStore(store runResultStorer)
- func (m *Model) TakeSelectedRun() (RunInfo, bool)
- 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 AudioLevelMsg ¶ added in v1.4.7
AudioLevelMsg carries normalized RMS levels (0.0–1.0) for the level meter.
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(send func(tea.Msg)) *EventAdapter
NewEventAdapter creates an adapter that forwards events via send. A *tea.Program's Send method satisfies func(tea.Msg), so callers pass program.Send to drive a running TUI program.
func NewEventAdapterWithModel ¶ added in v1.1.4
func NewEventAdapterWithModel(model *Model) *EventAdapter
NewEventAdapterWithModel creates an adapter for headless mode.
func (*EventAdapter) AttachAudioMonitor ¶ added in v1.4.7
func (a *EventAdapter) AttachAudioMonitor(monitor *arenaaudio.Monitor)
AttachAudioMonitor subscribes the TUI adapter to the process-wide audio Monitor's RMS stream. Frames originate from the LocalSink as it consumes samples, so the meter reflects whatever the user is actually hearing — regardless of which run is currently routed to playback.
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.Bus)
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 = events.MessageToolCall
MessageToolCall is a type alias for events.MessageToolCall to avoid duplicate definitions.
type MessageToolResult ¶ added in v1.1.5
type MessageToolResult = events.MessageToolResult
MessageToolResult is a type alias for events.MessageToolResult to avoid duplicate definitions.
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 for the live run view.
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) EnableTUIMode ¶ added in v1.5.3
func (m *Model) EnableTUIMode()
EnableTUIMode forces the model to render its interactive view regardless of the standalone terminal-size probe. The hub shell (tui/app) owns terminal detection and the bubbletea program, so a model wrapped by a hub Page should always render; the isTUIMode gate only applies to the standalone Run path.
func (*Model) Logs ¶ added in v1.1.4
Logs returns a snapshot of the current log entries. Safe for concurrent use.
func (*Model) SetAudioMonitor ¶ added in v1.4.7
func (m *Model) SetAudioMonitor(monitor audioMonitor)
SetAudioMonitor attaches an audio monitor so the TUI can re-route host playback when the user navigates between concurrent runs. Nil-safe. Retained pending hub audio re-wire — see AltairaLabs/PromptKit#1460.
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.
func (*Model) TakeSelectedRun ¶ added in v1.5.3
TakeSelectedRun returns the run the user last selected for drill-down (Enter on the runs pane), clearing the pending selection. The bool reports whether a selection was pending. Safe for concurrent use.
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 app is declared in page.go; this file adds the App root model.
|
Package app is declared in page.go; this file adds the App root model. |
|
Package layout provides a pure-geometry layout engine for the Arena TUI.
|
Package layout provides a pure-geometry layout engine for the Arena TUI. |
|
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. |