ui

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinRefreshInterval     = 500 * time.Millisecond
	MaxRefreshInterval     = 10 * time.Second
	DefaultRefreshInterval = 2 * time.Second
	RefreshStep            = 500 * time.Millisecond
)

Refresh interval bounds.

Variables

View Source
var (
	KeyQuit        = Keybinding{Key: "q", Desc: "Quit"}
	KeyQuitAlt     = Keybinding{Key: "ctrl+c", Desc: "Quit"}
	KeyHelp        = Keybinding{Key: "?", Desc: "Show help"}
	KeySettings    = Keybinding{Key: "S", Desc: "Settings"}
	KeySearch      = Keybinding{Key: "/", Desc: "Search/filter"}
	KeyToggleView  = Keybinding{Key: "v", Desc: "Toggle grouped/flat view"}
	KeySortMode    = Keybinding{Key: "s", Desc: "Enter sort mode"}
	KeyRefreshUp   = Keybinding{Key: "+", Desc: "Increase refresh rate"}
	KeyRefreshDown = Keybinding{Key: "-", Desc: "Decrease refresh rate"}
)

Global keybindings (always available)

View Source
var (
	KeyUp       = Keybinding{Key: "up", Desc: "Move up"}
	KeyUpAlt    = Keybinding{Key: "k", Desc: "Move up"}
	KeyDown     = Keybinding{Key: "down", Desc: "Move down"}
	KeyDownAlt  = Keybinding{Key: "j", Desc: "Move down"}
	KeyPageUp   = Keybinding{Key: "pgup", Desc: "Page up"}
	KeyPageDown = Keybinding{Key: "pgdown", Desc: "Page down"}
	KeyLeft     = Keybinding{Key: "left", Desc: "Move left (sort mode)"}
	KeyLeftAlt  = Keybinding{Key: "h", Desc: "Move left (sort mode)"}
	KeyRight    = Keybinding{Key: "right", Desc: "Move right (sort mode)"}
	KeyRightAlt = Keybinding{Key: "l", Desc: "Move right (sort mode)"}
	KeyEnter    = Keybinding{Key: "enter", Desc: "Select/drill-down"}
	KeySpace    = Keybinding{Key: " ", Desc: "Select/drill-down"}
	KeyEsc      = Keybinding{Key: "esc", Desc: "Back/cancel"}
	KeyBack     = Keybinding{Key: "backspace", Desc: "Back/cancel"}
)

Navigation keybindings

View Source
var (
	KeyKillTerm  = Keybinding{Key: "x", Desc: "Kill process (SIGTERM)"}
	KeyKillForce = Keybinding{Key: "X", Desc: "Force kill (SIGKILL)"}
)

Kill keybindings

View Source
var (
	KeyConfirmYes = Keybinding{Key: "y", Desc: "Confirm"}
	KeyConfirmNo  = Keybinding{Key: "n", Desc: "Cancel"}
)

Confirm/cancel keybindings

Functions

func AddedConnStyle

func AddedConnStyle() lipgloss.Style

AddedConnStyle returns the style for newly added connections.

func BorderStyle

func BorderStyle() lipgloss.Style

BorderStyle returns the style for borders.

func ConnStyle

func ConnStyle() lipgloss.Style

ConnStyle returns the style for connection rows.

func DangerBorderColor added in v0.1.2

func DangerBorderColor() lipgloss.Color

DangerBorderColor returns the red color for danger modals.

func DimmedStyle

func DimmedStyle() lipgloss.Style

DimmedStyle returns a style for dimmed background content when modal is visible.

func EmptyStyle

func EmptyStyle() lipgloss.Style

EmptyStyle returns the style for empty state messages.

func ErrorStyle

func ErrorStyle() lipgloss.Style

ErrorStyle returns the style for error messages.

func FooterDescStyle

func FooterDescStyle() lipgloss.Style

FooterDescStyle returns the style for key descriptions in footer.

func FooterGroupStyle

func FooterGroupStyle() lipgloss.Style

FooterGroupStyle returns the style for footer group labels (NAV, ACTION).

func FooterKeyStyle

func FooterKeyStyle() lipgloss.Style

FooterKeyStyle returns the style for keyboard shortcut keys in footer.

func FooterStyle

func FooterStyle() lipgloss.Style

FooterStyle returns the style for footer text.

func HeaderStyle

func HeaderStyle() lipgloss.Style

HeaderStyle returns the style for the main header title.

func LiveIndicatorStyle

func LiveIndicatorStyle() lipgloss.Style

LiveIndicatorStyle returns the style for the LIVE indicator (green).

func LoadingStyle

func LoadingStyle() lipgloss.Style

LoadingStyle returns the style for loading indicators.

func RemovedConnStyle

func RemovedConnStyle() lipgloss.Style

RemovedConnStyle returns the style for removed connections.

func RenderDangerFrameWithTitle added in v0.1.2

func RenderDangerFrameWithTitle(content string, title string, width, height int) string

RenderDangerFrameWithTitle renders content in a frame with danger/red styling. Used for destructive confirmations like kill process.

func RenderFrameWithTitle

func RenderFrameWithTitle(content string, title string, width, height int) string

RenderFrameWithTitle renders content in a frame with a centered title on the top border. Uses heavy box drawing for modal prominence.

func SelectedConnStyle

func SelectedConnStyle() lipgloss.Style

SelectedConnStyle returns the style for the selected row in table view.

func SortIndicatorStyle

func SortIndicatorStyle() lipgloss.Style

SortIndicatorStyle returns the style for sort direction indicators.

func StatsStyle

func StatsStyle() lipgloss.Style

StatsStyle returns the style for muted stats text.

func StatusStyle

func StatusStyle() lipgloss.Style

StatusStyle returns the style for status bar text.

func TableHeaderSelectedStyle

func TableHeaderSelectedStyle() lipgloss.Style

TableHeaderSelectedStyle returns the style for the selected column header.

func TableHeaderStyle

func TableHeaderStyle() lipgloss.Style

TableHeaderStyle returns the style for table column headers.

func WarnStyle

func WarnStyle() lipgloss.Style

WarnStyle returns the style for warning/attention text (amber).

Types

type AnimationTickMsg

type AnimationTickMsg time.Time

AnimationTickMsg is sent for UI animation updates (e.g., live indicator pulse).

type Change

type Change struct {
	Type      ChangeType
	Timestamp time.Time
}

Change represents a detected connection change.

type ChangeType

type ChangeType int

ChangeType indicates whether a connection was added or removed.

const (
	ChangeAdded ChangeType = iota
	ChangeRemoved
)

type ConnectionKey

type ConnectionKey struct {
	PID        int32
	Protocol   model.Protocol
	LocalAddr  string
	RemoteAddr string
}

ConnectionKey uniquely identifies a connection for diffing.

func KeyFromConnection

func KeyFromConnection(c model.Connection) ConnectionKey

KeyFromConnection creates a ConnectionKey from a Connection.

type DNSResolvedMsg

type DNSResolvedMsg struct {
	IP       string
	Hostname string
	Err      error
}

DNSResolvedMsg contains a DNS resolution result.

type DataMsg

type DataMsg struct {
	Snapshot *model.NetworkSnapshot
	Err      error
}

DataMsg contains updated network data.

type DockerResolvedMsg added in v0.1.11

type DockerResolvedMsg struct {
	Containers        map[int]*docker.ContainerPort // host port → container info
	VirtualContainers []model.VirtualContainer      // containers as virtual process rows
	Err               error
}

DockerResolvedMsg contains Docker container resolution results.

type Keybinding

type Keybinding struct {
	Key  string // actual key(s) to match
	Desc string // description for help display
}

Keybinding represents a keyboard shortcut with its display name.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the Bubble Tea model for the network monitor.

func NewModel

func NewModel() Model

NewModel creates a new Model with default settings.

func (*Model) AtRootLevel

func (m *Model) AtRootLevel() bool

AtRootLevel returns true if at the root navigation level.

func (*Model) CurrentView

func (m *Model) CurrentView() *ViewState

CurrentView returns the current view state (top of stack).

func (Model) GetChange

func (m Model) GetChange(c model.Connection) *Change

GetChange returns a pointer to the Change for a connection, or nil if no change. Returns nil if highlight changes is disabled.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (*Model) PopView

func (m *Model) PopView() bool

PopView pops the current view state from the stack. Returns false if already at the root level.

func (*Model) PushView

func (m *Model) PushView(state ViewState)

PushView pushes a new view state onto the stack.

func (Model) Update

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

Update handles messages and ensures viewport content/scroll is synced after any state change.

func (Model) View

func (m Model) View() string

View renders the UI.

func (Model) WithFilter

func (m Model) WithFilter(filter string) Model

WithFilter returns a copy of the model with an initial filter applied. CLI filters use exact port matching (port 80 only matches port 80, not 8080).

func (Model) WithPID

func (m Model) WithPID(pid int32) Model

WithPID returns a copy of the model that will drill into the given PID on first snapshot.

func (Model) WithVersion

func (m Model) WithVersion(v string) Model

WithVersion returns a copy of the model with version string set.

type NetIOMsg

type NetIOMsg struct {
	Stats map[int32]*model.NetIOStats // Keyed by PID
	Err   error
}

NetIOMsg contains network I/O statistics from background collection.

type SortColumn

type SortColumn int

SortColumn represents the column to sort by in table view.

const (
	SortPID SortColumn = iota
	SortProcess
	SortProtocol
	SortLocal
	SortRemote
	SortState
	// Process list specific columns
	SortConns
	SortEstablished
	SortListen
	SortTX
	SortRX
	// Docker-specific columns
	SortContainer
)

func (SortColumn) String

func (s SortColumn) String() string

String returns a human-readable name for the SortColumn.

type TickMsg

type TickMsg time.Time

TickMsg is sent on each refresh interval.

type VersionCheckMsg

type VersionCheckMsg struct {
	LatestVersion string // empty if up-to-date
	Err           error  // nil on success (even if up-to-date)
}

VersionCheckMsg contains result of GitHub release check.

type ViewLevel

type ViewLevel int

ViewLevel represents which level of navigation the user is at.

const (
	LevelProcessList    ViewLevel = iota // Level 0: list of processes
	LevelConnections                     // Level 1: connections for a specific process
	LevelAllConnections                  // Level 2: flat view of all connections
)

func (ViewLevel) String

func (v ViewLevel) String() string

String returns a human-readable name for the ViewLevel.

type ViewState

type ViewState struct {
	Level          ViewLevel         // Which view level (process list, connections)
	ProcessName    string            // Selected process name (empty at Level 0)
	Cursor         int               // Current cursor position in the list
	SelectedID     model.SelectionID // Stable selection identifier
	SortColumn     SortColumn        // Current sort column
	SortAscending  bool              // Sort direction
	SelectedColumn SortColumn        // Currently selected column for navigation
	SortMode       bool              // Whether sort mode is active
}

ViewState captures the navigation state at a given level.

Jump to

Keyboard shortcuts

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