monitor

package
v0.4.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MinHeight = 15

MinHeight is the minimum terminal height for proper display

View Source
const MinWidth = 40

MinWidth is the minimum terminal width for proper display

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityItem

type ActivityItem struct {
	Timestamp time.Time
	SessionID string
	Type      string // "log", "action", "comment"
	IssueID   string
	Message   string
	LogType   models.LogType    // for logs
	Action    models.ActionType // for actions
}

ActivityItem represents a unified activity item (log, action, or comment)

type IssueDetailsMsg

type IssueDetailsMsg struct {
	IssueID    string
	Issue      *models.Issue
	Handoff    *models.Handoff
	Logs       []models.Log
	BlockedBy  []models.Issue // Dependencies (issues blocking this one)
	Blocks     []models.Issue // Dependents (issues blocked by this one)
	EpicTasks  []models.Issue // Child tasks (when issue is an epic)
	ParentEpic *models.Issue  // Parent epic (when issue.ParentID is set)
	Error      error
}

IssueDetailsMsg carries fetched issue details for the modal

type MarkdownRenderedMsg

type MarkdownRenderedMsg struct {
	IssueID      string
	DescRender   string
	AcceptRender string
}

MarkdownRenderedMsg carries pre-rendered markdown for the modal

type ModalEntry added in v0.4.9

type ModalEntry struct {
	// Core
	IssueID     string
	SourcePanel Panel // Only meaningful for base entry (depth 1)

	// Display
	Scroll int

	// Async data
	Loading      bool
	Error        error
	Issue        *models.Issue
	Handoff      *models.Handoff
	Logs         []models.Log
	BlockedBy    []models.Issue
	Blocks       []models.Issue
	DescRender   string
	AcceptRender string

	// Epic-specific (when Issue.Type == "epic")
	EpicTasks          []models.Issue
	EpicTasksCursor    int
	TaskSectionFocused bool

	// Parent epic (when issue has ParentID pointing to an epic)
	ParentEpic        *models.Issue
	ParentEpicFocused bool
}

ModalEntry represents a single modal in the stack

type Model

type Model struct {
	// Database and session
	DB        *db.DB
	SessionID string

	// Window dimensions
	Width  int
	Height int

	// Panel data
	FocusedIssue   *models.Issue
	InProgress     []models.Issue
	Activity       []ActivityItem
	TaskList       TaskListData
	RecentHandoffs []RecentHandoff // Handoffs since monitor started
	ActiveSessions []string        // Sessions with recent activity

	// UI state
	ActivePanel  Panel
	ScrollOffset map[Panel]int
	Cursor       map[Panel]int    // Per-panel cursor position (selected row)
	SelectedID   map[Panel]string // Per-panel selected issue ID (preserved across refresh)
	ShowHelp     bool
	ShowTDQHelp  bool // Show TDQ query syntax help (when in search mode)
	LastRefresh  time.Time
	StartedAt    time.Time // When monitor started, to track new handoffs
	Err          error     // Last error, if any
	Embedded     bool      // When true, skip footer (embedded in sidecar)

	// Flattened rows for selection
	TaskListRows    []TaskListRow // Flattened task list for selection
	CurrentWorkRows []string      // Issue IDs for current work panel (focused + in-progress)

	// Modal stack for stacking modals (empty = no modal open)
	ModalStack []ModalEntry

	// Search state
	SearchMode    bool     // Whether search mode is active
	SearchQuery   string   // Current search query
	IncludeClosed bool     // Whether to include closed tasks
	SortMode      SortMode // Task list sort order

	// Confirmation dialog state
	ConfirmOpen    bool
	ConfirmAction  string // "delete"
	ConfirmIssueID string
	ConfirmTitle   string

	// Stats modal state
	StatsOpen    bool
	StatsLoading bool
	StatsData    *StatsData
	StatsScroll  int
	StatsError   error

	// Configuration
	RefreshInterval time.Duration

	// Keymap registry for keyboard shortcuts
	Keymap *keymap.Registry
}

Model is the main Bubble Tea model for the monitor TUI

func NewEmbedded

func NewEmbedded(baseDir string, interval time.Duration) (*Model, error)

NewEmbedded creates a monitor model for embedding in external applications. It opens the database and creates/gets a session automatically. The caller must call Close() when done to release resources.

func NewModel

func NewModel(database *db.DB, sessionID string, interval time.Duration) Model

NewModel creates a new monitor model

func (*Model) Close

func (m *Model) Close() error

Close releases resources held by an embedded monitor. Only call this if the model was created with NewEmbedded.

func (*Model) CurrentModal added in v0.4.9

func (m *Model) CurrentModal() *ModalEntry

CurrentModal returns a pointer to the current (top) modal entry, or nil if none

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model

func (Model) ModalBreadcrumb added in v0.4.9

func (m Model) ModalBreadcrumb() string

ModalBreadcrumb returns a breadcrumb string for the modal stack

func (Model) ModalDepth added in v0.4.9

func (m Model) ModalDepth() int

ModalDepth returns the current modal stack depth (0 = no modal)

func (Model) ModalOpen

func (m Model) ModalOpen() bool

ModalOpen returns true if any modal is open

func (Model) ModalSourcePanel

func (m Model) ModalSourcePanel() Panel

ModalSourcePanel returns the source panel of the base modal (depth 1)

func (Model) SelectedIssueID

func (m Model) SelectedIssueID(panel Panel) string

SelectedIssueID returns the issue ID of the currently selected row in a panel

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (Model) View

func (m Model) View() string

View implements tea.Model

type Panel

type Panel int

Panel represents which panel is active

const (
	PanelCurrentWork Panel = iota
	PanelTaskList
	PanelActivity
)

type RecentHandoff

type RecentHandoff struct {
	IssueID   string
	SessionID string
	Timestamp time.Time
}

RecentHandoff represents a recent handoff for display

type RefreshDataMsg

type RefreshDataMsg struct {
	FocusedIssue   *models.Issue
	InProgress     []models.Issue
	Activity       []ActivityItem
	TaskList       TaskListData
	RecentHandoffs []RecentHandoff
	ActiveSessions []string
	Timestamp      time.Time
}

RefreshDataMsg carries refreshed data

func FetchData

func FetchData(database *db.DB, sessionID string, startedAt time.Time, searchQuery string, includeClosed bool, sortMode SortMode) RefreshDataMsg

FetchData retrieves all data needed for the monitor display

type SortMode added in v0.4.9

type SortMode int

SortMode represents task list sorting

const (
	SortByPriority    SortMode = iota // Default: priority ASC
	SortByCreatedDesc                 // created_at DESC (newest first)
	SortByUpdatedDesc                 // updated_at DESC (recently changed first)
)

func (SortMode) String added in v0.4.9

func (s SortMode) String() string

String returns display name for sort mode

func (SortMode) ToDBOptions added in v0.4.9

func (s SortMode) ToDBOptions() (sortBy string, sortDesc bool)

ToDBOptions returns SortBy and SortDesc for ListIssuesOptions

type StatsData

type StatsData struct {
	ExtendedStats *models.ExtendedStats
	Error         error
}

StatsData holds statistics for the stats modal

type StatsDataMsg

type StatsDataMsg struct {
	Data  *StatsData
	Error error
}

StatsDataMsg carries fetched stats data

func FetchStats

func FetchStats(database *db.DB) StatsDataMsg

FetchStats retrieves extended statistics for the stats modal

type TaskListCategory

type TaskListCategory string

TaskListCategory represents the category of a task list row

const (
	CategoryReviewable TaskListCategory = "REVIEW"
	CategoryReady      TaskListCategory = "READY"
	CategoryBlocked    TaskListCategory = "BLOCKED"
	CategoryClosed     TaskListCategory = "CLOSED"
)

type TaskListData

type TaskListData struct {
	Ready      []models.Issue
	Reviewable []models.Issue
	Blocked    []models.Issue
	Closed     []models.Issue
}

TaskListData holds categorized issues for the task list panel

type TaskListRow

type TaskListRow struct {
	Issue    models.Issue
	Category TaskListCategory
}

TaskListRow represents a single selectable row in the task list panel

type TickMsg

type TickMsg time.Time

TickMsg triggers a data refresh

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL