diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-26 22:59:16 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-26 22:59:16 +0200 |
| commit | dc7478d7dadf544787a9718608f11312bd2ea944 (patch) | |
| tree | dc445798ab132e08d8885672fcca0a37facd25ea /internal/tui/common | |
| parent | 39a11ed5997a3829751dfbe4b666d3568d466276 (diff) | |
tui: revamp status keys and add pid/tid reselection flow
Diffstat (limited to 'internal/tui/common')
| -rw-r--r-- | internal/tui/common/keys.go | 29 | ||||
| -rw-r--r-- | internal/tui/common/keys_test.go | 39 |
2 files changed, 51 insertions, 17 deletions
diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go index 87c947c..acb066b 100644 --- a/internal/tui/common/keys.go +++ b/internal/tui/common/keys.go @@ -15,10 +15,10 @@ type KeyMap struct { Seven key.Binding DirGroup key.Binding SelectPID key.Binding + SelectTID key.Binding Probes key.Binding Export key.Binding Quit key.Binding - Help key.Binding Enter key.Binding Esc key.Binding Refresh key.Binding @@ -40,24 +40,35 @@ func DefaultKeyMap() KeyMap { Six: key.NewBinding(key.WithKeys("6"), key.WithHelp("6", "stream")), Seven: key.NewBinding(key.WithKeys("7"), key.WithHelp("7", "stream")), DirGroup: key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "dir group")), - SelectPID: key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "select pid")), - Probes: key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "probes")), + 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")), Export: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "export")), Quit: key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")), - Help: key.NewBinding(key.WithKeys("?"), key.WithHelp("?", "help")), 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", "refresh")), } } -// DashboardShortHelp returns compact bindings for dashboard help bars. -func (k KeyMap) DashboardShortHelp() []key.Binding { - bindings := []key.Binding{k.Tab, k.ShiftTab} +// DashboardStatusHelp returns expanded bindings for dashboard status bars. +func (k KeyMap) DashboardStatusHelp() []key.Binding { + bindings := []key.Binding{k.Tab, k.ShiftTab, k.One, k.Two, k.Three, k.Four, k.Five, k.Six} if help := k.Export.Help(); help.Key != "" || help.Desc != "" { bindings = append(bindings, k.Export) } - bindings = append(bindings, k.SelectPID, k.Probes, k.Help, k.Quit) + bindings = append(bindings, + k.DirGroup, + k.SelectPID, + k.SelectTID, + k.Probes, + k.Refresh, + k.Quit, + helpTextBinding("left/right", "tab"), + helpTextBinding("h/l", "tab"), + helpTextBinding("j/k", "scroll"), + helpTextBinding("up/down", "scroll"), + ) return bindings } @@ -67,7 +78,7 @@ func (k KeyMap) DashboardFullHelp() [][]key.Binding { if help := k.Export.Help(); help.Key != "" || help.Desc != "" { controls = append(controls, k.Export) } - controls = append(controls, k.DirGroup, k.SelectPID, k.Probes, k.Refresh, k.Help, k.Quit) + controls = append(controls, k.DirGroup, k.SelectPID, k.SelectTID, k.Probes, k.Refresh, k.Quit) return [][]key.Binding{ {k.One, k.Two, k.Three, k.Four, k.Five, k.Six}, diff --git a/internal/tui/common/keys_test.go b/internal/tui/common/keys_test.go index 3636107..42e47ab 100644 --- a/internal/tui/common/keys_test.go +++ b/internal/tui/common/keys_test.go @@ -10,14 +10,19 @@ func TestDefaultKeyMapIncludesDirGroupBinding(t *testing.T) { } probesHelp := keys.Probes.Help() - if probesHelp.Key != "p" || probesHelp.Desc != "probes" { + if probesHelp.Key != "o" || probesHelp.Desc != "probes" { t.Fatalf("unexpected probes binding help: key=%q desc=%q", probesHelp.Key, probesHelp.Desc) } selectHelp := keys.SelectPID.Help() - if selectHelp.Key != "s" || selectHelp.Desc != "select pid" { + if selectHelp.Key != "p" || selectHelp.Desc != "select pid" { t.Fatalf("unexpected select pid binding help: key=%q desc=%q", selectHelp.Key, selectHelp.Desc) } + + selectTIDHelp := keys.SelectTID.Help() + if selectTIDHelp.Key != "t" || selectTIDHelp.Desc != "select tid" { + t.Fatalf("unexpected select tid binding help: key=%q desc=%q", selectTIDHelp.Key, selectTIDHelp.Desc) + } } func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { @@ -42,7 +47,7 @@ func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { found = false for _, binding := range groups[1] { help := binding.Help() - if help.Key == "p" && help.Desc == "probes" { + if help.Key == "o" && help.Desc == "probes" { found = true break } @@ -54,7 +59,7 @@ func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { found = false for _, binding := range groups[1] { help := binding.Help() - if help.Key == "s" && help.Desc == "select pid" { + if help.Key == "p" && help.Desc == "select pid" { found = true break } @@ -62,20 +67,38 @@ func TestDashboardFullHelpIncludesDirGroupBinding(t *testing.T) { if !found { t.Fatalf("expected select pid binding in dashboard full help controls") } + + found = false + for _, binding := range groups[1] { + help := binding.Help() + if help.Key == "t" && help.Desc == "select tid" { + found = true + break + } + } + if !found { + t.Fatalf("expected select tid binding in dashboard full help controls") + } } -func TestDashboardShortHelpIncludesProbesBinding(t *testing.T) { +func TestDashboardStatusHelpIncludesProbesBinding(t *testing.T) { keys := DefaultKeyMap() - short := keys.DashboardShortHelp() + short := keys.DashboardStatusHelp() found := false + foundSelectTID := false for _, binding := range short { help := binding.Help() - if help.Key == "p" && help.Desc == "probes" { + if help.Key == "o" && help.Desc == "probes" { found = true - break + } + if help.Key == "t" && help.Desc == "select tid" { + foundSelectTID = true } } if !found { t.Fatalf("expected probes binding in dashboard short help") } + if !foundSelectTID { + t.Fatalf("expected select tid binding in dashboard short help") + } } |
