Files
porthole/internal/ui/keys.go
OpenCode Test 1421b4659e feat: implement ControlTower TUI for cluster and host monitoring
Add complete TUI application for monitoring Kubernetes clusters and host
systems. Features include:

Core features:
- Collector framework with concurrent scheduling
- Host collectors: disk, memory, load, network
- Kubernetes collectors: pods, nodes, workloads, events with informers
- Issue deduplication, state management, and resolve-after logic
- Bubble Tea TUI with table view, details pane, and filtering
- JSON export functionality

UX improvements:
- Help overlay with keybindings
- Priority/category filters with visual indicators
- Direct priority jump (0/1/2/3)
- Bulk acknowledge (Shift+A)
- Clipboard copy (y)
- Theme toggle (T)
- Age format toggle (d)
- Wide title toggle (t)
- Vi-style navigation (j/k)
- Home/End jump (g/G)
- Rollup drill-down in details

Robustness:
- Grace period for unreachable clusters
- Rollups for high-volume issues
- Flap suppression
- RBAC error handling

Files: All core application code with tests for host collectors,
engine, store, model, and export packages.
2025-12-24 13:29:51 -08:00

142 lines
3.2 KiB
Go

package ui
import "github.com/charmbracelet/bubbles/key"
// KeyMap defines UI keybindings.
//
// Note: Bubble Tea will also handle ctrl+c; we additionally bind q for quit.
type KeyMap struct {
Quit key.Binding
RefreshNow key.Binding
Search key.Binding
Priority key.Binding
PriorityP0 key.Binding
PriorityP1 key.Binding
PriorityP2 key.Binding
PriorityP3 key.Binding
Category key.Binding
Sort key.Binding
FocusNext key.Binding
AckToggle key.Binding
AckAll key.Binding
Export key.Binding
ToggleTheme key.Binding
Help key.Binding
JumpToTop key.Binding
JumpToBottom key.Binding
Down key.Binding
Up key.Binding
Copy key.Binding
ToggleWideTitle key.Binding
ToggleAgeFormat key.Binding
ClearFilters key.Binding
Cancel key.Binding
Apply key.Binding
}
func defaultKeyMap() KeyMap {
return KeyMap{
Quit: key.NewBinding(
key.WithKeys("q"),
key.WithHelp("q", "quit"),
),
RefreshNow: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "refresh now"),
),
Search: key.NewBinding(
key.WithKeys("/"),
key.WithHelp("/", "search"),
),
Priority: key.NewBinding(
key.WithKeys("p"),
key.WithHelp("p", "priority filter"),
),
PriorityP0: key.NewBinding(
key.WithKeys("0"),
key.WithHelp("0", "P0 only"),
),
PriorityP1: key.NewBinding(
key.WithKeys("1"),
key.WithHelp("1", "P1 only"),
),
PriorityP2: key.NewBinding(
key.WithKeys("2"),
key.WithHelp("2", "P2 only"),
),
PriorityP3: key.NewBinding(
key.WithKeys("3"),
key.WithHelp("3", "P3 only"),
),
Category: key.NewBinding(
key.WithKeys("c"),
key.WithHelp("c", "category filter"),
),
Sort: key.NewBinding(
key.WithKeys("s"),
key.WithHelp("s", "cycle sort"),
),
FocusNext: key.NewBinding(
key.WithKeys("tab"),
key.WithHelp("tab", "focus"),
),
AckToggle: key.NewBinding(
key.WithKeys("a"),
key.WithHelp("a", "ack/unack"),
),
AckAll: key.NewBinding(
key.WithKeys("A", "shift+a"),
key.WithHelp("A", "ack all visible"),
),
Export: key.NewBinding(
key.WithKeys("E"),
key.WithHelp("E", "export"),
),
ToggleTheme: key.NewBinding(
key.WithKeys("T", "shift+t"),
key.WithHelp("T", "toggle theme"),
),
Help: key.NewBinding(
key.WithKeys("?"),
key.WithHelp("?", "show help"),
),
JumpToTop: key.NewBinding(
key.WithKeys("g"),
key.WithHelp("g", "jump to top"),
),
JumpToBottom: key.NewBinding(
key.WithKeys("G", "shift+g"),
key.WithHelp("G", "jump to bottom"),
),
Down: key.NewBinding(
key.WithKeys("j"),
key.WithHelp("j", "down"),
),
Up: key.NewBinding(
key.WithKeys("k"),
key.WithHelp("k", "up"),
),
Copy: key.NewBinding(
key.WithKeys("y"),
key.WithHelp("y", "copy fix"),
),
ToggleWideTitle: key.NewBinding(
key.WithKeys("t"),
key.WithHelp("t", "wide title"),
),
ToggleAgeFormat: key.NewBinding(
key.WithKeys("d"),
key.WithHelp("d", "age format"),
),
ClearFilters: key.NewBinding(
key.WithKeys("esc"),
key.WithHelp("esc", "clear filters"),
),
Cancel: key.NewBinding(key.WithKeys("esc")),
Apply: key.NewBinding(key.WithKeys("enter")),
}
}