diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-08 22:03:01 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-08 22:03:01 +0200 |
| commit | 0d1492291a3e20665d8a3a6b16d2eb4e13938cee (patch) | |
| tree | ec09f7d660403478d23841cf541bdfa7f33aa70f /internal/tui/common | |
| parent | d84902555621cc10b16a9641274b088e495f3714 (diff) | |
tui: restore global filter stack and anchored matches
Diffstat (limited to 'internal/tui/common')
| -rw-r--r-- | internal/tui/common/keys.go | 93 | ||||
| -rw-r--r-- | internal/tui/common/keys_test.go | 24 |
2 files changed, 74 insertions, 43 deletions
diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go index fd7bef1..f2e1271 100644 --- a/internal/tui/common/keys.go +++ b/internal/tui/common/keys.go @@ -10,27 +10,28 @@ type HelpSection struct { // KeyMap groups all key bindings shared by TUI screens. type KeyMap struct { - Tab key.Binding - ShiftTab key.Binding - One key.Binding - Two key.Binding - Three key.Binding - Four key.Binding - Five key.Binding - Six key.Binding - Seven key.Binding - Visualize key.Binding - Metric key.Binding - DirGroup key.Binding - SelectPID key.Binding - SelectTID key.Binding - Probes key.Binding - Filter key.Binding - Export key.Binding - Quit key.Binding - Enter key.Binding - Esc key.Binding - Refresh key.Binding + Tab key.Binding + ShiftTab key.Binding + One key.Binding + Two key.Binding + Three key.Binding + Four key.Binding + Five key.Binding + Six key.Binding + Seven key.Binding + Visualize key.Binding + Metric key.Binding + DirGroup key.Binding + SelectPID key.Binding + SelectTID key.Binding + Probes key.Binding + Filter key.Binding + FilterUndo key.Binding + Export key.Binding + Quit key.Binding + Enter key.Binding + Esc key.Binding + Refresh key.Binding } // Keys contains the default shared key map. @@ -39,27 +40,28 @@ var Keys = DefaultKeyMap() // DefaultKeyMap builds the default key bindings used by models. func DefaultKeyMap() KeyMap { return KeyMap{ - Tab: key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "next tab")), - ShiftTab: key.NewBinding(key.WithKeys("shift+tab"), key.WithHelp("shift+tab", "prev tab")), - One: key.NewBinding(key.WithKeys("1"), key.WithHelp("1", "flame")), - Two: key.NewBinding(key.WithKeys("2"), key.WithHelp("2", "overview")), - Three: key.NewBinding(key.WithKeys("3"), key.WithHelp("3", "syscalls")), - Four: key.NewBinding(key.WithKeys("4"), key.WithHelp("4", "files")), - Five: key.NewBinding(key.WithKeys("5"), key.WithHelp("5", "processes")), - Six: key.NewBinding(key.WithKeys("6"), key.WithHelp("6", "lat+gaps")), - Seven: key.NewBinding(key.WithKeys("7"), key.WithHelp("7", "stream")), - Visualize: key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "viz")), - Metric: key.NewBinding(key.WithKeys("b"), key.WithHelp("b", "metric")), - DirGroup: key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "dir group")), - SelectPID: key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "select pid")), - SelectTID: key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "select tid")), - Probes: key.NewBinding(key.WithKeys("o"), key.WithHelp("o", "probes")), - Filter: key.NewBinding(key.WithKeys("f"), key.WithHelp("f", "filter")), - Export: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "snapshot export")), - Quit: key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")), - Enter: key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")), - Esc: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")), - Refresh: key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "reset baseline")), + Tab: key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "next tab")), + ShiftTab: key.NewBinding(key.WithKeys("shift+tab"), key.WithHelp("shift+tab", "prev tab")), + One: key.NewBinding(key.WithKeys("1"), key.WithHelp("1", "flame")), + Two: key.NewBinding(key.WithKeys("2"), key.WithHelp("2", "overview")), + Three: key.NewBinding(key.WithKeys("3"), key.WithHelp("3", "syscalls")), + Four: key.NewBinding(key.WithKeys("4"), key.WithHelp("4", "files")), + Five: key.NewBinding(key.WithKeys("5"), key.WithHelp("5", "processes")), + Six: key.NewBinding(key.WithKeys("6"), key.WithHelp("6", "lat+gaps")), + Seven: key.NewBinding(key.WithKeys("7"), key.WithHelp("7", "stream")), + Visualize: key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "viz")), + Metric: key.NewBinding(key.WithKeys("b"), key.WithHelp("b", "metric")), + DirGroup: key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "dir group")), + SelectPID: key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "select pid")), + SelectTID: key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "select tid")), + Probes: key.NewBinding(key.WithKeys("o"), key.WithHelp("o", "probes")), + Filter: key.NewBinding(key.WithKeys("f"), key.WithHelp("f", "filter")), + FilterUndo: key.NewBinding(key.WithKeys("F"), key.WithHelp("F", "undo filter")), + Export: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "snapshot export")), + Quit: key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")), + Enter: key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")), + Esc: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")), + Refresh: key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "reset baseline")), } } @@ -93,6 +95,7 @@ func (k KeyMap) DashboardStatusHelpSections() []HelpSection { k.Visualize, k.Metric, k.Filter, + k.FilterUndo, k.SelectPID, k.SelectTID, k.Probes, @@ -107,6 +110,8 @@ func (k KeyMap) DashboardStatusHelpSections() []HelpSection { k.Visualize, k.Metric, helpTextBinding("space", "stream pause"), + helpTextBinding("enter", "stream push filter"), + helpTextBinding("esc", "stream undo filter"), helpTextBinding("g/G", "stream top/tail"), helpTextBinding("left/right", "stream col"), helpTextBinding("h/l", "stream col"), @@ -132,13 +137,15 @@ func (k KeyMap) DashboardFullHelp() [][]key.Binding { controls = append(controls, k.Export) } controls = append(controls, k.DirGroup, k.SelectPID, k.SelectTID, k.Probes, k.Refresh, k.Quit) - controls = append(controls, k.Visualize, k.Metric, k.Filter) + controls = append(controls, k.Visualize, k.Metric, k.Filter, k.FilterUndo) return [][]key.Binding{ {k.One, k.Two, k.Three, k.Four, k.Five, k.Six, k.Seven}, controls, { helpTextBinding("space", "stream pause"), + helpTextBinding("enter", "stream push filter"), + helpTextBinding("esc", "stream undo filter"), helpTextBinding("g/G", "stream top/tail"), helpTextBinding("left/right", "stream col"), helpTextBinding("h/l", "stream col"), diff --git a/internal/tui/common/keys_test.go b/internal/tui/common/keys_test.go index a2b5940..43f4b8b 100644 --- a/internal/tui/common/keys_test.go +++ b/internal/tui/common/keys_test.go @@ -38,6 +38,11 @@ func TestDefaultKeyMapIncludesDirGroupBinding(t *testing.T) { if metricHelp.Key != "b" || metricHelp.Desc != "metric" { t.Fatalf("unexpected metric binding help: key=%q desc=%q", metricHelp.Key, metricHelp.Desc) } + + undoHelp := keys.FilterUndo.Help() + if undoHelp.Key != "F" || undoHelp.Desc != "undo filter" { + t.Fatalf("unexpected filter undo binding help: key=%q desc=%q", undoHelp.Key, undoHelp.Desc) + } } func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { @@ -130,6 +135,18 @@ func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { if !found { t.Fatalf("expected metric binding in dashboard full help controls") } + + found = false + for _, binding := range groups[1] { + help := binding.Help() + if help.Key == "F" && help.Desc == "undo filter" { + found = true + break + } + } + if !found { + t.Fatalf("expected undo filter binding in dashboard full help controls") + } } func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { @@ -138,6 +155,7 @@ func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { found := false foundSelectTID := false foundOne := false + foundUndo := false for _, binding := range short { help := binding.Help() if help.Key == "o" && help.Desc == "probes" { @@ -149,6 +167,9 @@ func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { if help.Key == "1" && help.Desc == "flame" { foundOne = true } + if help.Key == "F" && help.Desc == "undo filter" { + foundUndo = true + } } if !found { t.Fatalf("expected probes binding in dashboard short help") @@ -159,4 +180,7 @@ func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { if !foundOne { t.Fatalf("expected flame tab binding in dashboard short help") } + if !foundUndo { + t.Fatalf("expected undo filter binding in dashboard short help") + } } |
