Documentation
¶
Overview ¶
Package components provides reusable Bubble Tea TUI components for dispatch.
Package components provides the sub-models (session list, search bar, filter panel, preview, help overlay, shell picker, reindex) that compose the Copilot CLI Session Browser TUI.
Index ¶
- func AbbrevHome(path string) string
- func AbbrevPath(path string) string
- func CleanSummary(s string) string
- func FormatInt(v int) string
- func PadLeft(s string, width int) string
- func PadRight(s string, width int) string
- func RelativeTime(timestamp string) string
- func RenderChatBubble(msg, label string, contentWidth int, isUser bool) string
- func RenderConversation(turns []data.Turn, contentWidth int) string
- func SplitDirLeaf(path string) (parent, leaf string)
- func Truncate(s string, width int) string
- type ConfigPanel
- func (c *ConfigPanel) CancelEdit()
- func (c *ConfigPanel) ConfirmEdit()
- func (c *ConfigPanel) HandleEnter() tea.Cmd
- func (c *ConfigPanel) IsEditing() bool
- func (c *ConfigPanel) MoveDown()
- func (c *ConfigPanel) MoveUp()
- func (c *ConfigPanel) SetShellOptions(shells []platform.ShellInfo)
- func (c *ConfigPanel) SetSize(w, h int)
- func (c *ConfigPanel) SetTerminals(names []string)
- func (c *ConfigPanel) SetThemeOptions(names []string)
- func (c *ConfigPanel) SetValues(v ConfigValues)
- func (c ConfigPanel) Update(msg tea.Msg) (ConfigPanel, tea.Cmd)
- func (c *ConfigPanel) Values() ConfigValues
- func (c ConfigPanel) View() string
- type ConfigValues
- type FilterCategory
- type FilterPanel
- func (f *FilterPanel) ActiveBadges() []string
- func (f *FilterPanel) Apply() []string
- func (f *FilterPanel) Cancel()
- func (f *FilterPanel) ClearAll()
- func (f *FilterPanel) CollapseGroup()
- func (f *FilterPanel) ExpandGroup()
- func (f *FilterPanel) HasActive() bool
- func (f *FilterPanel) MoveDown()
- func (f *FilterPanel) MoveUp()
- func (f *FilterPanel) SetActive(_ FilterCategory, _ string)
- func (f *FilterPanel) SetFolders(folders []string, excluded []string)
- func (f *FilterPanel) SetOptions(folders, repos, branches []string)
- func (f *FilterPanel) SetSize(w, h int)
- func (f *FilterPanel) Toggle() (FilterCategory, string, bool)
- func (f *FilterPanel) ToggleExclusion()
- func (f FilterPanel) View() string
- type HelpOverlay
- type PreviewPanel
- type ReindexFinishedMsg
- type ReindexHandle
- type ReindexLogPump
- type SearchBar
- func (s *SearchBar) Blur()
- func (s *SearchBar) Focus() tea.Cmd
- func (s *SearchBar) Focused() bool
- func (s *SearchBar) SetAIError(msg string)
- func (s *SearchBar) SetAIResults(n int)
- func (s *SearchBar) SetAISearching(v bool)
- func (s *SearchBar) SetAIStatus(status string)
- func (s *SearchBar) SetResultCount(n int)
- func (s *SearchBar) SetSearching(v bool)
- func (s *SearchBar) SetValue(v string)
- func (s *SearchBar) SetWidth(w int)
- func (s SearchBar) Update(msg tea.Msg) (SearchBar, tea.Cmd)
- func (s *SearchBar) Value() string
- func (s SearchBar) View() string
- type SessionList
- func (s *SessionList) CollapseAll()
- func (s *SessionList) CollapseFolder()
- func (s *SessionList) Cursor() int
- func (s *SessionList) ExpandFolder()
- func (s *SessionList) IsFolderSelected() bool
- func (s *SessionList) MoveDown()
- func (s *SessionList) MoveTo(idx int)
- func (s *SessionList) MoveUp()
- func (s *SessionList) ScrollBy(delta int)
- func (s *SessionList) ScrollOffset() int
- func (s *SessionList) Selected() (data.Session, bool)
- func (s *SessionList) SelectedFolderPath() string
- func (s *SessionList) SessionCount() int
- func (s *SessionList) SetAISessions(set map[string]struct{})
- func (s *SessionList) SetGroups(groups []data.SessionGroup)
- func (s *SessionList) SetHiddenSessions(set map[string]struct{})
- func (s *SessionList) SetSessions(sessions []data.Session)
- func (s *SessionList) SetSize(w, h int)
- func (s *SessionList) ToggleFolder() bool
- func (s SessionList) View() string
- func (s *SessionList) VisibleCount() int
- type ShellPicker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbbrevHome ¶
AbbrevHome returns the path with the user's home directory replaced by "~". Path separators are normalised to the OS-native format for display.
func AbbrevPath ¶
AbbrevPath returns the last two path components, prefixed with "…" and the OS path separator if the path is deeper.
func CleanSummary ¶
CleanSummary strips chat-style prefixes (e.g. "[user]: ", "[assistant]: ") from a session summary, collapses whitespace to a single line, and returns a display-friendly string. This prevents raw conversation fragments stored by the Copilot CLI from appearing as "chat messages" in the session list.
func FormatInt ¶
FormatInt formats an integer as a decimal string. It delegates to strconv.Itoa which handles all edge cases including math.MinInt (where negation overflows in two's complement).
func PadRight ¶
PadRight returns s padded with spaces on the right to exactly width runes. If s is longer than width it is truncated.
func RelativeTime ¶
RelativeTime parses a timestamp string and returns a human-friendly relative time such as "2h ago" or "3d ago".
func RenderChatBubble ¶
RenderChatBubble renders a single chat message as a styled bubble with a role label. When isUser is true, both the label and bubble are right-aligned; otherwise they are left-aligned.
func RenderConversation ¶
RenderConversation renders all turns as a chat-style conversation with right-aligned user messages and left-aligned assistant messages.
func SplitDirLeaf ¶
SplitDirLeaf splits a path into its parent directory and leaf (last component). Both are normalised to OS-native separators.
Types ¶
type ConfigPanel ¶
type ConfigPanel struct {
// contains filtered or unexported fields
}
ConfigPanel presents an overlay that lets users edit session-resume settings (yolo mode, agent, model, launch-in-place, terminal, shell, custom command).
func NewConfigPanel ¶
func NewConfigPanel() ConfigPanel
NewConfigPanel returns a ConfigPanel initialised with the provided values.
func (*ConfigPanel) CancelEdit ¶
func (c *ConfigPanel) CancelEdit()
CancelEdit discards the current text input without saving.
func (*ConfigPanel) ConfirmEdit ¶
func (c *ConfigPanel) ConfirmEdit()
ConfirmEdit saves the current text input value to the appropriate field.
func (*ConfigPanel) HandleEnter ¶
func (c *ConfigPanel) HandleEnter() tea.Cmd
HandleEnter toggles a boolean field, cycles a selection, or starts editing a text field. Returns a tea.Cmd when a text input needs focus.
func (*ConfigPanel) IsEditing ¶
func (c *ConfigPanel) IsEditing() bool
IsEditing returns true when a text field is being edited.
func (*ConfigPanel) MoveDown ¶
func (c *ConfigPanel) MoveDown()
MoveDown moves the cursor to the next field.
func (*ConfigPanel) MoveUp ¶
func (c *ConfigPanel) MoveUp()
MoveUp moves the cursor to the previous field.
func (*ConfigPanel) SetShellOptions ¶
func (c *ConfigPanel) SetShellOptions(shells []platform.ShellInfo)
SetShellOptions provides the list of available shells.
func (*ConfigPanel) SetSize ¶
func (c *ConfigPanel) SetSize(w, h int)
SetSize updates the overlay dimensions.
func (*ConfigPanel) SetTerminals ¶
func (c *ConfigPanel) SetTerminals(names []string)
SetTerminals provides the list of available terminal emulator names.
func (*ConfigPanel) SetThemeOptions ¶
func (c *ConfigPanel) SetThemeOptions(names []string)
SetThemeOptions provides the list of available scheme names for cycling. The first entry should be "auto".
func (*ConfigPanel) SetValues ¶
func (c *ConfigPanel) SetValues(v ConfigValues)
SetValues loads the config panel state from external values.
func (ConfigPanel) Update ¶
func (c ConfigPanel) Update(msg tea.Msg) (ConfigPanel, tea.Cmd)
Update delegates to the underlying text input when editing.
func (*ConfigPanel) Values ¶
func (c *ConfigPanel) Values() ConfigValues
Values returns the current state of all editable fields.
func (ConfigPanel) View ¶
func (c ConfigPanel) View() string
View renders the config panel as a centred overlay.
type ConfigValues ¶
type ConfigValues struct {
YoloMode bool
Agent string
Model string
LaunchMode string
PaneDirection string
Terminal string
Shell string
CustomCommand string
Theme string
}
ConfigValues bundles the editable fields exchanged between the config panel and the rest of the application.
type FilterCategory ¶
type FilterCategory int
FilterCategory identifies the kind of filter (kept for badge compatibility).
const ( // FilterFolder represents a directory-based filter category. FilterFolder FilterCategory = iota )
type FilterPanel ¶
type FilterPanel struct {
// contains filtered or unexported fields
}
FilterPanel is an overlay showing a hierarchical directory tree for multi-select exclusion. Users navigate with arrows, toggle with Space, apply with Enter, and cancel with Esc.
func (*FilterPanel) ActiveBadges ¶
func (f *FilterPanel) ActiveBadges() []string
ActiveBadges returns a slice of short badge strings representing the currently applied exclusions.
func (*FilterPanel) Apply ¶
func (f *FilterPanel) Apply() []string
Apply commits the pending exclusions and returns them as a string slice.
func (*FilterPanel) Cancel ¶
func (f *FilterPanel) Cancel()
Cancel discards the pending exclusions (reverts to last applied state).
func (*FilterPanel) ClearAll ¶
func (f *FilterPanel) ClearAll()
ClearAll removes all active filters.
func (*FilterPanel) CollapseGroup ¶
func (f *FilterPanel) CollapseGroup()
CollapseGroup collapses the group under the cursor.
func (*FilterPanel) ExpandGroup ¶
func (f *FilterPanel) ExpandGroup()
ExpandGroup expands the group under the cursor.
func (*FilterPanel) HasActive ¶
func (f *FilterPanel) HasActive() bool
HasActive returns true if any exclusions are applied.
func (*FilterPanel) SetActive ¶
func (f *FilterPanel) SetActive(_ FilterCategory, _ string)
SetActive is a no-op kept for backward compatibility with time-range quick-key calls (time ranges are now handled outside the filter panel).
func (*FilterPanel) SetFolders ¶
func (f *FilterPanel) SetFolders(folders []string, excluded []string)
SetFolders populates the filter panel with folder paths and initialises the pending exclusion set from the given excluded dirs.
func (*FilterPanel) SetOptions ¶
func (f *FilterPanel) SetOptions(folders, repos, branches []string)
SetOptions is a backward-compatible shim (deprecated — use SetFolders).
func (*FilterPanel) SetSize ¶
func (f *FilterPanel) SetSize(w, h int)
SetSize updates the overlay dimensions.
func (*FilterPanel) Toggle ¶
func (f *FilterPanel) Toggle() (FilterCategory, string, bool)
Toggle is provided for backward compatibility. It calls ToggleExclusion and returns placeholder values.
func (*FilterPanel) ToggleExclusion ¶
func (f *FilterPanel) ToggleExclusion()
ToggleExclusion toggles the exclusion state of the item under the cursor. On a child: toggles that directory. On a parent: toggles all children.
func (FilterPanel) View ¶
func (f FilterPanel) View() string
View renders the filter panel as a centred overlay.
type HelpOverlay ¶
type HelpOverlay struct {
// contains filtered or unexported fields
}
HelpOverlay renders a hand-crafted keyboard shortcut reference as a centred overlay panel. It replaces the bubbles/help.Model approach with a clean two-column layout grouped by category.
func NewHelpOverlay ¶
func NewHelpOverlay() HelpOverlay
NewHelpOverlay returns a ready-to-use HelpOverlay.
func (*HelpOverlay) SetSize ¶
func (h *HelpOverlay) SetSize(width, height int)
SetSize updates the overlay dimensions.
func (HelpOverlay) ShortView ¶
func (h HelpOverlay) ShortView() string
ShortView renders a compact single-line help hint for the status bar.
func (HelpOverlay) View ¶
func (h HelpOverlay) View() string
View renders the full help overlay centred on screen.
type PreviewPanel ¶
type PreviewPanel struct {
// contains filtered or unexported fields
}
PreviewPanel renders a right-side detail panel for the selected session.
func NewPreviewPanel ¶
func NewPreviewPanel() PreviewPanel
NewPreviewPanel returns an empty PreviewPanel.
func (*PreviewPanel) PageDown ¶
func (p *PreviewPanel) PageDown()
PageDown scrolls down by half the viewport height.
func (*PreviewPanel) PageUp ¶
func (p *PreviewPanel) PageUp()
PageUp scrolls up by half the viewport height.
func (*PreviewPanel) ScrollDown ¶
func (p *PreviewPanel) ScrollDown(n int)
ScrollDown scrolls the preview content down by n lines.
func (*PreviewPanel) ScrollUp ¶
func (p *PreviewPanel) ScrollUp(n int)
ScrollUp scrolls the preview content up by n lines.
func (*PreviewPanel) SetDetail ¶
func (p *PreviewPanel) SetDetail(d *data.SessionDetail)
SetDetail updates the displayed session detail.
func (*PreviewPanel) SetSize ¶
func (p *PreviewPanel) SetSize(w, h int)
SetSize updates the panel dimensions.
func (PreviewPanel) View ¶
func (p PreviewPanel) View() string
View renders the preview panel content.
type ReindexFinishedMsg ¶
type ReindexFinishedMsg struct {
Err error
}
ReindexFinishedMsg is sent when a reindex completes. The model re-queries the session store database on receipt.
type ReindexHandle ¶
type ReindexHandle struct {
Cancel context.CancelFunc
}
ReindexHandle holds the cancel function for a running reindex so the caller can abort it from the UI.
func StartChronicleReindex ¶
func StartChronicleReindex() (ReindexHandle, []tea.Cmd)
StartChronicleReindex launches a full chronicle reindex via the Copilot CLI in a pseudo-terminal. It returns a ReindexHandle (for cancellation) and two Cmds: one that runs the reindex (sending ReindexFinishedMsg on completion), and one that pumps log lines into ReindexLogPump messages.
Falls back to Maintain() if the copilot binary is not found.
type ReindexLogPump ¶
type ReindexLogPump struct {
Lines []string
// contains filtered or unexported fields
}
ReindexLogPump carries a batch of log lines and the channel reference so the model can request the next batch.
func (ReindexLogPump) NextLogCmd ¶
func (p ReindexLogPump) NextLogCmd() tea.Cmd
NextLogCmd returns the Cmd to wait for the next batch of log lines.
type SearchBar ¶
type SearchBar struct {
// contains filtered or unexported fields
}
SearchBar wraps a bubbles textinput for FTS5 session search.
func (*SearchBar) SetAIError ¶
SetAIError sets the AI error message shown when status is "error".
func (*SearchBar) SetAIResults ¶
SetAIResults sets the count of AI-found sessions from the last search.
func (*SearchBar) SetAISearching ¶
SetAISearching sets the Copilot SDK search-in-progress indicator.
func (*SearchBar) SetAIStatus ¶
SetAIStatus sets the Copilot SDK connection status. Valid values: "" (not started), "connecting", "ready", "error".
func (*SearchBar) SetResultCount ¶
SetResultCount updates the displayed result count.
func (*SearchBar) SetSearching ¶
SetSearching sets the deep-search-in-progress indicator.
type SessionList ¶
type SessionList struct {
// contains filtered or unexported fields
}
SessionList renders a vertical list of sessions with optional collapsible folder tree grouping when pivoting is active.
func NewSessionList ¶
func NewSessionList() SessionList
NewSessionList returns an empty SessionList.
func (*SessionList) CollapseAll ¶
func (s *SessionList) CollapseAll()
CollapseAll sets all folder groups to collapsed state and rebuilds the visible item list. Used by the screenshot generator.
func (*SessionList) CollapseFolder ¶
func (s *SessionList) CollapseFolder()
CollapseFolder collapses the folder under the cursor (no-op if not a folder or already collapsed).
func (*SessionList) Cursor ¶
func (s *SessionList) Cursor() int
Cursor returns the current cursor position within visible items.
func (*SessionList) ExpandFolder ¶
func (s *SessionList) ExpandFolder()
ExpandFolder expands the folder under the cursor (no-op if not a folder or already expanded).
func (*SessionList) IsFolderSelected ¶
func (s *SessionList) IsFolderSelected() bool
IsFolderSelected returns true when the cursor is on a folder node.
func (*SessionList) MoveDown ¶
func (s *SessionList) MoveDown()
MoveDown moves the cursor to the next visible item.
func (*SessionList) MoveTo ¶
func (s *SessionList) MoveTo(idx int)
MoveTo sets the cursor to a specific visible-item index, clamping to bounds.
func (*SessionList) MoveUp ¶
func (s *SessionList) MoveUp()
MoveUp moves the cursor to the previous visible item.
func (*SessionList) ScrollBy ¶
func (s *SessionList) ScrollBy(delta int)
ScrollBy adjusts the scroll offset by delta lines (positive = down).
func (*SessionList) ScrollOffset ¶
func (s *SessionList) ScrollOffset() int
ScrollOffset returns the current scroll position.
func (*SessionList) Selected ¶
func (s *SessionList) Selected() (data.Session, bool)
Selected returns the currently highlighted session.
func (*SessionList) SelectedFolderPath ¶
func (s *SessionList) SelectedFolderPath() string
SelectedFolderPath returns the path/label of the selected folder, or "".
func (*SessionList) SessionCount ¶
func (s *SessionList) SessionCount() int
SessionCount returns the number of (non-folder) items across all items.
func (*SessionList) SetAISessions ¶
func (s *SessionList) SetAISessions(set map[string]struct{})
SetAISessions updates the set of AI-found session IDs, used to render those sessions with a "✦" marker.
func (*SessionList) SetGroups ¶
func (s *SessionList) SetGroups(groups []data.SessionGroup)
SetGroups replaces the list content with grouped sessions (tree mode). Folders are collapsible; initial state is expanded.
func (*SessionList) SetHiddenSessions ¶
func (s *SessionList) SetHiddenSessions(set map[string]struct{})
SetHiddenSessions updates the set of hidden session IDs, used to render hidden sessions with a dimmed style.
func (*SessionList) SetSessions ¶
func (s *SessionList) SetSessions(sessions []data.Session)
SetSessions replaces the list content with a flat slice of sessions.
func (*SessionList) SetSize ¶
func (s *SessionList) SetSize(w, h int)
SetSize updates the available rendering dimensions.
func (*SessionList) ToggleFolder ¶
func (s *SessionList) ToggleFolder() bool
ToggleFolder expands or collapses the folder under the cursor. Returns true if the cursor was on a folder.
func (SessionList) View ¶
func (s SessionList) View() string
View renders the visible portion of the list.
func (*SessionList) VisibleCount ¶
func (s *SessionList) VisibleCount() int
VisibleCount returns the number of currently visible items.
type ShellPicker ¶
type ShellPicker struct {
// contains filtered or unexported fields
}
ShellPicker renders a modal list of detected shells for session launch.
func NewShellPicker ¶
func NewShellPicker() ShellPicker
NewShellPicker returns an empty ShellPicker.
func (*ShellPicker) Selected ¶
func (s *ShellPicker) Selected() (platform.ShellInfo, bool)
Selected returns the currently highlighted shell.
func (*ShellPicker) SetShells ¶
func (s *ShellPicker) SetShells(shells []platform.ShellInfo, defaultShell string)
SetShells replaces the available shells. If defaultShell is non-empty, it is placed first in the list with a "(default)" label.
func (*ShellPicker) SetSize ¶
func (s *ShellPicker) SetSize(w, h int)
SetSize updates the overlay dimensions.