Documentation
¶
Overview ¶
Package monitor provides the TUI monitor for td.
Index ¶
- Constants
- Variables
- func OverlayModal(background, modal string, width, height int) string
- type ActivityItem
- type ClearStatusMsg
- type EditorField
- type EditorFinishedMsg
- type FormMode
- type FormState
- type HandoffsDataMsg
- type IssueDetailsMsg
- type MarkdownRenderedMsg
- type ModalEntry
- type Model
- func (m *Model) Close() error
- func (m Model) CurrentContextString() string
- func (m *Model) CurrentModal() *ModalEntry
- func (m Model) HitTestDivider(x, y int) int
- func (m Model) HitTestPanel(x, y int) Panel
- func (m Model) HitTestRow(panel Panel, y int) int
- func (m Model) Init() tea.Cmd
- func (m Model) ModalBreadcrumb() string
- func (m Model) ModalDepth() int
- func (m Model) ModalOpen() bool
- func (m Model) ModalSourcePanel() Panel
- func (m Model) SelectedIssueID(panel Panel) string
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
- type PaneHeightsSavedMsg
- type Panel
- type RecentHandoff
- type Rect
- type RefreshDataMsg
- type SortMode
- type StatsData
- type StatsDataMsg
- type TaskListCategory
- type TaskListData
- type TaskListRow
- type TickMsg
- type TypeFilterMode
Constants ¶
const ( MinWidth = 40 MinHeight = 15 )
Minimum dimensions for the monitor
Variables ¶
var DimStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("242"))
DimStyle applies a dim gray color to background content behind modals. We strip existing ANSI codes and apply gray because SGR 2 (faint) doesn't reliably combine with existing color codes in most terminals.
Functions ¶
func OverlayModal ¶ added in v0.4.20
OverlayModal composites a modal on top of a dimmed background. The modal is centered, with dimmed background visible on all sides.
Types ¶
type ActivityItem ¶
type ActivityItem struct {
Timestamp time.Time
SessionID string
Type string // "log", "action", "comment"
IssueID string
IssueTitle string // title of the associated issue
Message string
LogType models.LogType // for logs
Action models.ActionType // for actions
}
ActivityItem represents a unified activity item (log, action, or comment)
type ClearStatusMsg ¶ added in v0.4.12
type ClearStatusMsg struct{}
ClearStatusMsg clears the status message
type EditorField ¶ added in v0.4.16
type EditorField int
EditorField identifies which form field is being edited externally
const ( EditorFieldDescription EditorField = iota EditorFieldAcceptance )
type EditorFinishedMsg ¶ added in v0.4.16
type EditorFinishedMsg struct {
Field EditorField
Content string
Error error
}
EditorFinishedMsg carries the result from external editor
type FormState ¶ added in v0.4.14
type FormState struct {
Mode FormMode
Form *huh.Form
IssueID string // For edit mode - the issue being edited
ParentID string // For create mode - auto-populated parent epic
// Bound form values (standard fields)
Title string
Type string
Priority string
Description string
Labels string // Comma-separated
// Extended fields (toggled with Tab)
ShowExtended bool
Parent string // Parent epic ID
Points string // String for select options
Acceptance string
Minor bool
Dependencies string // Comma-separated issue IDs
}
FormState holds the state for the issue form modal
func NewFormState ¶ added in v0.4.14
NewFormState creates a new form state for creating an issue
func NewFormStateForEdit ¶ added in v0.4.14
NewFormStateForEdit creates a form state populated with existing issue data
func (*FormState) GetDependencies ¶ added in v0.4.14
GetDependencies returns parsed dependency IDs
func (*FormState) ToggleExtended ¶ added in v0.4.14
func (fs *FormState) ToggleExtended()
ToggleExtended toggles the extended fields visibility and rebuilds the form
type HandoffsDataMsg ¶ added in v0.4.12
HandoffsDataMsg carries fetched handoffs data for the modal
type IssueDetailsMsg ¶
type IssueDetailsMsg struct {
IssueID string
Issue *models.Issue
Handoff *models.Handoff
Logs []models.Log
Comments []models.Comment
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 ¶
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
ContentLines int // Cached content line count for scroll clamping
// Async data
Loading bool
Error error
Issue *models.Issue
Handoff *models.Handoff
Logs []models.Log
Comments []models.Comment
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
// Used when opening issues from within an epic to scope navigation to siblings
NavigationScope []models.Issue
// Blocked-by section (dependencies blocking this issue)
BlockedBySectionFocused bool
BlockedByCursor int
// Blocks section (issues blocked by this one)
BlocksSectionFocused bool
BlocksCursor int
// Line tracking for mouse click support (set during render)
BlockedByStartLine int // Line index where blocked-by section starts
BlockedByEndLine int // Line index where blocked-by section ends
BlocksStartLine int // Line index where blocks section starts
BlocksEndLine int // Line index where blocks section ends
}
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)
ScrollIndependent map[Panel]bool // True when user scrolled viewport away from cursor
HelpOpen bool // Whether help modal is open
HelpScroll int // Current scroll position in help
HelpTotalLines int // Cached total line count in help
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
SearchInput textinput.Model // Text input for search (cursor support)
IncludeClosed bool // Whether to include closed tasks
SortMode SortMode // Task list sort order
TypeFilterMode TypeFilterMode // Type filter (epic, task, bug, etc.)
// Confirmation dialog state
ConfirmOpen bool
ConfirmAction string // "delete"
ConfirmIssueID string
ConfirmTitle string
// Close confirmation dialog state
CloseConfirmOpen bool
CloseConfirmIssueID string
CloseConfirmTitle string
CloseConfirmInput textinput.Model
// Stats modal state
StatsOpen bool
StatsLoading bool
StatsData *StatsData
StatsScroll int
StatsError error
// Handoffs modal state
HandoffsOpen bool
HandoffsLoading bool
HandoffsData []models.Handoff
HandoffsCursor int
HandoffsScroll int
HandoffsError error
// Form modal state
FormOpen bool
FormState *FormState
// Configuration
RefreshInterval time.Duration
// Keymap registry for keyboard shortcuts
Keymap *keymap.Registry
// Status message (temporary feedback, e.g., "Copied to clipboard")
StatusMessage string
StatusIsError bool // true for error messages, false for success
// Version checking
Version string // Current version
UpdateAvail *version.UpdateAvailableMsg
// Mouse support - panel bounds for hit-testing
PanelBounds map[Panel]Rect
HoverPanel Panel // Panel currently under mouse cursor (-1 for none)
LastClickTime time.Time // For double-click detection
LastClickPanel Panel // Panel of last click
LastClickRow int // Row of last click
// Pane resizing (drag-to-resize)
PaneHeights [3]float64 // Height ratios (sum=1.0)
DividerBounds [2]Rect // Hit regions for the 2 dividers between 3 panes
DraggingDivider int // -1 = not dragging, 0 = first divider, 1 = second
DividerHover int // -1 = none, 0 or 1 = which divider is hovered
DragStartY int // Y position when drag started
DragStartHeights [3]float64 // Pane heights when drag started
BaseDir string // Base directory for config persistence
}
Model is the main Bubble Tea model for the monitor TUI
func NewEmbedded ¶
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, ver string, baseDir string) Model
NewModel creates a new monitor model
func (*Model) Close ¶
Close releases resources held by an embedded monitor. Only call this if the model was created with NewEmbedded.
func (Model) CurrentContextString ¶ added in v0.4.14
CurrentContextString returns the current keymap context as a sidecar-formatted string. This is used by sidecar's TD plugin to determine which shortcuts to display.
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) HitTestDivider ¶ added in v0.4.16
HitTestDivider returns which divider (0 or 1) contains the point, or -1 if none
func (Model) HitTestPanel ¶ added in v0.4.14
HitTestPanel returns which panel contains the point (x, y), or -1 if none
func (Model) HitTestRow ¶ added in v0.4.14
HitTestRow returns the row index within a panel for a given y coordinate, or -1 if none. Accounts for scroll indicators, category headers, and separator lines.
func (Model) ModalBreadcrumb ¶ added in v0.4.9
ModalBreadcrumb returns a breadcrumb string for the modal stack
func (Model) ModalDepth ¶ added in v0.4.9
ModalDepth returns the current modal stack depth (0 = no modal)
func (Model) ModalSourcePanel ¶
ModalSourcePanel returns the source panel of the base modal (depth 1)
func (Model) SelectedIssueID ¶
SelectedIssueID returns the issue ID of the currently selected row in a panel
type PaneHeightsSavedMsg ¶ added in v0.4.16
type PaneHeightsSavedMsg struct {
Error error
}
PaneHeightsSavedMsg is sent after pane heights are persisted to config
type RecentHandoff ¶
RecentHandoff represents a recent handoff for display
type Rect ¶ added in v0.4.14
type Rect struct {
X, Y, W, H int
}
Rect represents a rectangular region for hit-testing
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
type SortMode ¶ added in v0.4.9
type SortMode int
SortMode represents task list sorting
func (SortMode) ToDBOptions ¶ added in v0.4.9
ToDBOptions returns SortBy and SortDesc for ListIssuesOptions
func (SortMode) ToSortClause ¶ added in v0.4.15
ToSortClause returns the TDQ sort clause string for this mode
type StatsData ¶
type StatsData struct {
ExtendedStats *models.ExtendedStats
Error error
}
StatsData holds statistics for the stats modal
type StatsDataMsg ¶
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 TypeFilterMode ¶ added in v0.4.16
type TypeFilterMode int
TypeFilterMode represents type filtering for the task list
const ( TypeFilterNone TypeFilterMode = iota // No type filter TypeFilterEpic // type=epic TypeFilterTask // type=task TypeFilterBug // type=bug TypeFilterFeature // type=feature TypeFilterChore // type=chore )
func (TypeFilterMode) String ¶ added in v0.4.16
func (t TypeFilterMode) String() string
String returns display name for type filter mode
func (TypeFilterMode) ToTypeClause ¶ added in v0.4.16
func (t TypeFilterMode) ToTypeClause() string
ToTypeClause returns the TDQ type clause string for this mode