Documentation
¶
Overview ¶
Package display provides utilities for formatting output to the terminal.
Index ¶
- Variables
- func DisableColorIfNotTTY()
- func FormatBytes(bytes int64) string
- func IsColorEnabled() bool
- func IsTTY() bool
- func RenderAgentList(w io.Writer, agents []*history.ConversationMeta, parentID string, asJSON bool, ...) error
- func RenderStats(w io.Writer, stats *Stats, asJSON bool) error
- func SetColorEnabled(enabled bool)
- type ConversationDisplay
- type ConversationDisplayOptions
- type ConversationTable
- type PaginationOptions
- type ProjectTable
- type SearchResultTable
- type Stats
- type TableOptions
Constants ¶
This section is empty.
Variables ¶
var ( // Headers and titles Bold = color.New(color.Bold).SprintFunc() Title = color.New(color.Bold, color.FgCyan).SprintFunc() Header = color.New(color.Bold, color.FgWhite).SprintFunc() Section = color.New(color.Bold, color.FgBlue).SprintFunc() // Roles UserRole = color.New(color.Bold, color.FgGreen).SprintFunc() AssistantRole = color.New(color.Bold, color.FgBlue).SprintFunc() SystemRole = color.New(color.Bold, color.FgYellow).SprintFunc() // Content types Thinking = color.New(color.Italic, color.FgMagenta).SprintFunc() ToolCall = color.New(color.FgCyan).SprintFunc() ToolName = color.New(color.Bold, color.FgCyan).SprintFunc() Error = color.New(color.FgRed).SprintFunc() // Metadata Dim = color.New(color.Faint).SprintFunc() Timestamp = color.New(color.Faint).SprintFunc() ID = color.New(color.FgYellow).SprintFunc() Project = color.New(color.FgMagenta).SprintFunc() Model = color.New(color.Faint, color.FgCyan).SprintFunc() // Search Match = color.New(color.Bold, color.FgYellow).SprintFunc() // Status Success = color.New(color.FgGreen).SprintFunc() Warning = color.New(color.FgYellow).SprintFunc() Info = color.New(color.FgCyan).SprintFunc() // Numbers Number = color.New(color.FgYellow).SprintFunc() Size = color.New(color.FgCyan).SprintFunc() )
Color shortcuts
Functions ¶
func DisableColorIfNotTTY ¶
func DisableColorIfNotTTY()
DisableColorIfNotTTY disables color output if stdout is not a terminal.
func FormatBytes ¶
FormatBytes formats a byte count as human-readable string.
func IsColorEnabled ¶
func IsColorEnabled() bool
IsColorEnabled returns true if color output is enabled.
func RenderAgentList ¶
func RenderAgentList(w io.Writer, agents []*history.ConversationMeta, parentID string, asJSON bool, filter string) error
RenderAgentList renders a list of agents for a conversation.
func RenderStats ¶
RenderStats renders usage statistics.
func SetColorEnabled ¶
func SetColorEnabled(enabled bool)
SetColorEnabled enables or disables color output.
Types ¶
type ConversationDisplay ¶
type ConversationDisplay struct {
// contains filtered or unexported fields
}
ConversationDisplay renders a full conversation.
func NewConversationDisplay ¶
func NewConversationDisplay(opts ConversationDisplayOptions) *ConversationDisplay
NewConversationDisplay creates a new conversation display.
func (*ConversationDisplay) Render ¶
func (d *ConversationDisplay) Render(conv *history.Conversation) error
Render renders the conversation.
type ConversationDisplayOptions ¶
type ConversationDisplayOptions struct {
Writer io.Writer
ShowThinking bool // Include thinking blocks
ShowTools bool // Include tool calls
ShowNumbering bool // Show message indices [N] prefix
RoleFilter string // Filter by role: user, assistant, system (empty = all)
JSON bool // Output as JSON
Raw bool // Output raw JSONL
AgentCount int // Number of agents spawned by this conversation
Pagination PaginationOptions // Pagination controls
}
ConversationDisplayOptions configures conversation display.
func DefaultConversationDisplayOptions ¶
func DefaultConversationDisplayOptions() ConversationDisplayOptions
DefaultConversationDisplayOptions returns default display options.
type ConversationTable ¶
type ConversationTable struct {
// contains filtered or unexported fields
}
ConversationTable renders a table of conversations.
func NewConversationTable ¶
func NewConversationTable(opts TableOptions) *ConversationTable
NewConversationTable creates a new conversation table.
func (*ConversationTable) Render ¶
func (t *ConversationTable) Render(conversations []*history.ConversationMeta) error
Render renders the conversations as a table.
type PaginationOptions ¶
type PaginationOptions struct {
First int // Show first N messages (0 = no limit)
Last int // Show last N messages (0 = no limit)
RangeStart int // Start of range (1-based, 0 = not set)
RangeEnd int // End of range (1-based, 0 = not set)
FitTokens int // Auto-select messages to fit token budget (0 = disabled)
AfterIndex int // Start after message N for cursor pagination (0 = start from beginning)
Limit int // Max messages to show with AfterIndex (0 = no limit)
}
PaginationOptions controls message pagination for display.
func (PaginationOptions) IsSet ¶
func (p PaginationOptions) IsSet() bool
IsSet returns true if any pagination option is configured.
type ProjectTable ¶
type ProjectTable struct {
// contains filtered or unexported fields
}
ProjectTable renders a table of projects.
func NewProjectTable ¶
func NewProjectTable(opts TableOptions) *ProjectTable
NewProjectTable creates a new project table.
type SearchResultTable ¶
type SearchResultTable struct {
// contains filtered or unexported fields
}
SearchResultTable renders search results.
func NewSearchResultTable ¶
func NewSearchResultTable(opts TableOptions) *SearchResultTable
NewSearchResultTable creates a new search result table.
func (*SearchResultTable) Render ¶
func (t *SearchResultTable) Render(results []*history.SearchResult) error
Render renders search results.
type Stats ¶
type Stats struct {
ProjectCount int `json:"project_count"`
ConversationCount int `json:"conversation_count"`
AgentCount int `json:"agent_count"`
TotalMessages int `json:"total_messages"`
TotalSize int64 `json:"total_size"`
OldestConversation string `json:"oldest_conversation,omitempty"`
NewestConversation string `json:"newest_conversation,omitempty"`
}
Stats represents usage statistics.
type TableOptions ¶
type TableOptions struct {
Writer io.Writer
ShowAgent bool // Show agent indicator
JSON bool // Output as JSON
ShowIndices bool // Show message indices in search results
// Context for headers/footers
ProjectPath string // Current project path (empty if global)
IsGlobal bool // Showing all projects
ProjectCount int // Number of projects (for global view)
TotalAgents int // Total agents across all shown conversations
CurrentProject string // Current working directory's project (for marking)
Query string // Search query (for search results)
}
TableOptions configures table output.
func DefaultTableOptions ¶
func DefaultTableOptions() TableOptions
DefaultTableOptions returns default table options.