diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-09 22:35:53 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-09 22:35:53 +0200 |
| commit | a4c72ad2cbe4ca857a5880675563b2ab4d24e1b5 (patch) | |
| tree | d589398e9d02b760622716d9b2146c074eb4d66d /internal/tui/common | |
| parent | e40116ab0ecbbfd5cab5a33bc89e9bf6f98746aa (diff) | |
tui: add sortable syscalls dashboard table (task 363)
Diffstat (limited to 'internal/tui/common')
| -rw-r--r-- | internal/tui/common/keys.go | 6 | ||||
| -rw-r--r-- | internal/tui/common/keys_test.go | 24 |
2 files changed, 29 insertions, 1 deletions
diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go index 6289997..3f3d807 100644 --- a/internal/tui/common/keys.go +++ b/internal/tui/common/keys.go @@ -21,6 +21,7 @@ type KeyMap struct { Seven key.Binding Visualize key.Binding Metric key.Binding + Sort key.Binding DirGroup key.Binding SelectPID key.Binding SelectTID key.Binding @@ -51,6 +52,7 @@ func DefaultKeyMap() KeyMap { 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")), + Sort: key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "sort table")), 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")), @@ -94,6 +96,7 @@ func (k KeyMap) DashboardStatusHelpSections() []HelpSection { k.Seven, k.Visualize, k.Metric, + k.Sort, k.Filter, k.FilterUndo, k.SelectPID, @@ -109,6 +112,7 @@ func (k KeyMap) DashboardStatusHelpSections() []HelpSection { k.DirGroup, k.Visualize, k.Metric, + k.Sort, helpTextBinding("space", "stream pause"), helpTextBinding("enter", "selected filter"), helpTextBinding("esc", "stream undo filter"), @@ -138,7 +142,7 @@ 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, k.FilterUndo) + controls = append(controls, k.Visualize, k.Metric, k.Sort, k.Filter, k.FilterUndo) return [][]key.Binding{ {k.One, k.Two, k.Three, k.Four, k.Five, k.Six, k.Seven}, diff --git a/internal/tui/common/keys_test.go b/internal/tui/common/keys_test.go index 43f4b8b..8d34285 100644 --- a/internal/tui/common/keys_test.go +++ b/internal/tui/common/keys_test.go @@ -39,6 +39,11 @@ func TestDefaultKeyMapIncludesDirGroupBinding(t *testing.T) { t.Fatalf("unexpected metric binding help: key=%q desc=%q", metricHelp.Key, metricHelp.Desc) } + sortHelp := keys.Sort.Help() + if sortHelp.Key != "s" || sortHelp.Desc != "sort table" { + t.Fatalf("unexpected sort binding help: key=%q desc=%q", sortHelp.Key, sortHelp.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) @@ -139,6 +144,18 @@ func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { found = false for _, binding := range groups[1] { help := binding.Help() + if help.Key == "s" && help.Desc == "sort table" { + found = true + break + } + } + if !found { + t.Fatalf("expected sort 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 @@ -156,6 +173,7 @@ func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { foundSelectTID := false foundOne := false foundUndo := false + foundSort := false for _, binding := range short { help := binding.Help() if help.Key == "o" && help.Desc == "probes" { @@ -170,6 +188,9 @@ func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { if help.Key == "F" && help.Desc == "undo filter" { foundUndo = true } + if help.Key == "s" && help.Desc == "sort table" { + foundSort = true + } } if !found { t.Fatalf("expected probes binding in dashboard short help") @@ -183,4 +204,7 @@ func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { if !foundUndo { t.Fatalf("expected undo filter binding in dashboard short help") } + if !foundSort { + t.Fatalf("expected sort binding in dashboard short help") + } } |
