Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Background colors BaseBackground = lipgloss.AdaptiveColor{Light: "#f8f8f2", Dark: "#1e1e2e"} // Main background PanelBackground = lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#313244"} // Panel backgrounds AltRowBackground = lipgloss.AdaptiveColor{Light: "#eff0eb", Dark: "#45475a"} // Alternate row // Text colors PrimaryText = lipgloss.AdaptiveColor{Light: "#282a36", Dark: "#cdd6f4"} // Main text SecondaryText = lipgloss.AdaptiveColor{Light: "#6272a4", Dark: "#a6adc8"} // Secondary/muted HeaderText = lipgloss.AdaptiveColor{Light: "#bd93f9", Dark: "#cba6f7"} // Headers // Accent colors SelectionAccent = lipgloss.AdaptiveColor{Light: "#8be9fd", Dark: "#89b4fa"} // Selected items BorderColor = lipgloss.AdaptiveColor{Light: "#44475a", Dark: "#585b70"} // Borders // Status colors SuccessColor = lipgloss.AdaptiveColor{Light: "#2e7d32", Dark: "#a6e3a1"} // Running/success ErrorColor = lipgloss.AdaptiveColor{Light: "#c62828", Dark: "#f38ba8"} // Errors WarningColor = lipgloss.AdaptiveColor{Light: "#e65100", Dark: "#fab387"} // Warnings InfoColor = lipgloss.AdaptiveColor{Light: "#1565c0", Dark: "#89b4fa"} // Info DebugColor = lipgloss.AdaptiveColor{Light: "#546e7a", Dark: "#6c7086"} // Debug TraceColor = lipgloss.AdaptiveColor{Light: "#7b1fa2", Dark: "#f5c2e7"} // Trace VerboseColor = lipgloss.AdaptiveColor{Light: "#00796b", Dark: "#94e2d5"} // Verbose // Semantic color aliases (for clarity in usage) PrimaryAccent = SelectionAccent // Cyan for selections SecondaryAccent = HeaderText // Purple for headers MutedColor = SecondaryText // Medium gray for muted text BackgroundColor = BaseBackground // Main background StatusBarBackground = BaseBackground // Same as main (no dark bar) SelectedBackground = SelectionAccent // Cyan selection // Helper styles for rendering colored text MutedStyle = lipgloss.NewStyle().Foreground(MutedColor) ErrorStyle = lipgloss.NewStyle().Foreground(ErrorColor) SuccessStyle = lipgloss.NewStyle().Foreground(SuccessColor) AccentStyle = lipgloss.NewStyle().Foreground(PrimaryAccent) // Flash animation styles FlashHighlightBg = lipgloss.AdaptiveColor{Light: "#8be9fd", Dark: "#45475a"} // bright cyan / dark overlay FlashFadeBg = lipgloss.AdaptiveColor{Light: "#e0f4fd", Dark: "#313244"} // light cyan / panel bg FlashHighlightStyle = lipgloss.NewStyle().Background(FlashHighlightBg).Bold(true).Foreground(PrimaryText) FlashFadeStyle = lipgloss.NewStyle().Background(FlashFadeBg).Foreground(PrimaryText) // UI Component Styles BorderStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(BorderColor) ActiveTabStyle = lipgloss.NewStyle(). Bold(true). Foreground(PrimaryText). Background(SelectionAccent). Padding(0, 1) InactiveTabStyle = lipgloss.NewStyle(). Foreground(SecondaryText). Background(BackgroundColor). Padding(0, 1) TableHeaderStyle = lipgloss.NewStyle(). Bold(true). Foreground(HeaderText). BorderStyle(lipgloss.NormalBorder()). BorderBottom(true). BorderForeground(BorderColor) TableRowStyle = lipgloss.NewStyle(). Foreground(PrimaryText) TableRowAltStyle = lipgloss.NewStyle(). Foreground(PrimaryText). Background(AltRowBackground) SelectedInstanceStyle = lipgloss.NewStyle(). Bold(true). Foreground(PrimaryText). Background(SelectionAccent). Padding(0, 1) UnselectedInstanceStyle = lipgloss.NewStyle(). Foreground(PrimaryText). Padding(0, 1) RunningIndicator = lipgloss.NewStyle().Foreground(SuccessColor).SetString("●") StoppedIndicator = lipgloss.NewStyle().Foreground(MutedColor).SetString("○") StatusBarStyle = lipgloss.NewStyle().Foreground(SecondaryText).Background(StatusBarBackground).Padding(0, 1) ConsoleTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(PrimaryAccent) LogLevelStyles = map[LogLevel]lipgloss.Style{ LogLevelVerbs: lipgloss.NewStyle().Foreground(VerboseColor), LogLevelTrace: lipgloss.NewStyle().Foreground(TraceColor), LogLevelDebug: lipgloss.NewStyle().Foreground(DebugColor), LogLevelInfo: lipgloss.NewStyle().Foreground(InfoColor), LogLevelWarn: lipgloss.NewStyle().Foreground(WarningColor), LogLevelError: lipgloss.NewStyle().Foreground(ErrorColor), LogLevelFatal: lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#880e4f", Dark: "#f38ba8"}).Bold(true), } )
Base palette colors
var ( // Box styles with dynamic width DynamicBoxStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(BorderColor) // Table cell styles (using light theme palette) TableCellStyle = lipgloss.NewStyle(). Foreground(PrimaryText) // #282a36 - dark text TableCellAltStyle = lipgloss.NewStyle(). Foreground(PrimaryText). Background(AltRowBackground) // #eff0eb - light gray TableHeaderCellStyle = lipgloss.NewStyle(). Bold(true). Foreground(HeaderText) // #bd93f9 - purple )
Adaptive layout styles - Catppuccin Mocha Theme
Functions ¶
This section is empty.
Types ¶
type InstanceInfo ¶
InstanceInfo represents an instance for the selector
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
LogBuffer is a thread-safe ring buffer for console logs
func NewLogBuffer ¶
NewLogBuffer creates a new log buffer with the given capacity
func (*LogBuffer) GetFilteredLines ¶
func (lb *LogBuffer) GetFilteredLines(filters LogLevelSet) []LogLine
GetFilteredLines returns log lines that match the given filters
func (*LogBuffer) GetLinesUnsafe ¶
GetLinesUnsafe returns lines without locking (caller must hold lock)
type LogTailer ¶
type LogTailer struct {
LogPath string
Filters LogLevelSet
BufferSize int
// contains filtered or unexported fields
}
LogTailer tails a log file and sends lines through a channel
func (*LogTailer) UpdateFilters ¶
func (lt *LogTailer) UpdateFilters(filters LogLevelSet)
UpdateFilters safely updates log level filters
type MonitorModel ¶
type MonitorModel struct {
// Configuration
RefreshInterval time.Duration
DBPath string
// UI State
SelectedDateRange DateRange
SelectedInstance string
ConsoleLogEnabled bool
ConsoleLogPaused bool
LogLevelFilters LogLevelSet
LastError error
// Data State
Stats *UsageStats
Instances []InstanceInfo
LogBuffer *LogBuffer
// Channels (buffered)
StatsChan chan *UsageStats
LogChan chan string
ErrChan chan error
// Component state
InstanceCursor int
WindowSize tea.WindowSizeMsg
// Lifecycle
Ctx context.Context
Cancel context.CancelFunc
WG sync.WaitGroup
// Log tailer context (separate)
LogCtx context.Context
LogCancel context.CancelFunc
// Background workers
StatsPoller *StatsPoller
LogTailer *LogTailer
// Layout calculations (updated on window resize)
LeftPanelWidth int
RightPanelWidth int
RouteColWidth int
ModelColWidth int
// contains filtered or unexported fields
}
MonitorModel is the root Bubble Tea model
func NewMonitorModel ¶
func NewMonitorModel(refreshInterval time.Duration, dbPath string) *MonitorModel
NewMonitorModel creates a new monitor model
func (*MonitorModel) Init ¶
func (m *MonitorModel) Init() tea.Cmd
Init starts the background workers
type RecoveryMsg ¶
type RecoveryMsg struct{}
RecoveryMsg is sent when the poller recovers from an error
type StatsPoller ¶
type StatsPoller struct {
Interval time.Duration
DBPath string
DateRange DateRange
InstanceID string
ConsecutiveErrors int
// contains filtered or unexported fields
}
StatsPoller polls the database for usage stats
func (*StatsPoller) Run ¶
func (sp *StatsPoller) Run(ctx context.Context, statsChan chan<- *UsageStats, errChan chan<- error)
Run executes the polling loop
func (*StatsPoller) UpdateDateRange ¶
func (sp *StatsPoller) UpdateDateRange(dr DateRange)
UpdateDateRange safely updates the date range
func (*StatsPoller) UpdateInstance ¶
func (sp *StatsPoller) UpdateInstance(instanceID string)
UpdateInstance safely updates the instance filter
type StatsUpdateMsg ¶
type StatsUpdateMsg struct {
Stats *UsageStats
}
StatsUpdateMsg is sent when stats are updated
type UsageStats ¶
type UsageStats struct {
Summary usage.Summary
ByRoute map[string]*usage.RouteStats
ByModel map[string]*usage.ModelStats
Timestamp time.Time
}
UsageStats represents aggregated usage data