summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-26 23:47:16 +0200
committerPaul Buetow <paul@buetow.org>2026-02-26 23:47:16 +0200
commit34e70c9cd76b0231cfff3910bb24708624d7c72d (patch)
treed17c70b4b1f467ba72fe238d9b1656c1dde564a2
parentdcdfbcc0a2ee9750e48a8db74b4ca70fdac2f9c6 (diff)
tui: clarify export help and toggle help bar with uppercase H
-rw-r--r--internal/tui/common/keys.go10
-rw-r--r--internal/tui/dashboard/model.go11
-rw-r--r--internal/tui/dashboard/model_test.go31
-rw-r--r--internal/tui/dashboard/tabs.go8
-rw-r--r--internal/tui/tui_test.go6
5 files changed, 54 insertions, 12 deletions
diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go
index 26a9968..8c0b13b 100644
--- a/internal/tui/common/keys.go
+++ b/internal/tui/common/keys.go
@@ -43,7 +43,7 @@ func DefaultKeyMap() KeyMap {
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")),
+ 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")),
@@ -58,6 +58,10 @@ func (k KeyMap) DashboardStatusHelp() []key.Binding {
bindings = append(bindings, k.Export)
}
bindings = append(bindings,
+ helpTextBinding("x", "stream export"),
+ helpTextBinding("X", "stream export as"),
+ helpTextBinding("E", "stream open last"),
+ helpTextBinding("esc", "stream undo filter"),
k.DirGroup,
k.SelectPID,
k.SelectTID,
@@ -69,14 +73,10 @@ func (k KeyMap) DashboardStatusHelp() []key.Binding {
helpTextBinding("g/G", "stream top/tail"),
helpTextBinding("c", "stream clear"),
helpTextBinding("enter", "stream add filter"),
- helpTextBinding("esc", "stream undo filter"),
helpTextBinding("left/right", "stream col"),
helpTextBinding("h/l", "stream col"),
helpTextBinding("j/k", "scroll"),
helpTextBinding("up/down", "scroll"),
- helpTextBinding("x", "stream export"),
- helpTextBinding("X", "stream export as"),
- helpTextBinding("E", "stream open last"),
)
return bindings
}
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go
index 0e485d5..0e850d4 100644
--- a/internal/tui/dashboard/model.go
+++ b/internal/tui/dashboard/model.go
@@ -45,6 +45,7 @@ type Model struct {
filesDirOffset int
processesOffset int
streamModel eventstream.Model
+ showHelp bool
}
// NewModel creates a dashboard model with default refresh cadence.
@@ -115,6 +116,10 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
prevActiveTab := m.activeTab
var cmd tea.Cmd
keyStr := msg.String()
+ if keyStr == "H" {
+ m.showHelp = !m.showHelp
+ return m, nil
+ }
handled, scrollCmd := m.handleScrollKey(msg)
if scrollCmd != nil {
cmd = scrollCmd
@@ -299,7 +304,11 @@ func (m Model) View() string {
m.processesOffset,
))
b.WriteString("\n")
- b.WriteString(renderHelpBar(m.keys, width))
+ if m.showHelp {
+ b.WriteString(renderHelpBar(m.keys, width))
+ } else {
+ b.WriteString(renderHelpHint(width))
+ }
return common.ScreenStyle.Render(b.String())
}
diff --git a/internal/tui/dashboard/model_test.go b/internal/tui/dashboard/model_test.go
index 37dbe28..931fcff 100644
--- a/internal/tui/dashboard/model_test.go
+++ b/internal/tui/dashboard/model_test.go
@@ -369,8 +369,11 @@ func TestViewRendersTabBarAndHelp(t *testing.T) {
if !strings.Contains(out, "Overview") {
t.Fatalf("expected overview label in view")
}
- if !strings.Contains(out, "tab next tab") {
- t.Fatalf("expected help bar text in view")
+ if !strings.Contains(out, "press H for help") {
+ t.Fatalf("expected help hint text in view")
+ }
+ if strings.Contains(out, "tab next tab") {
+ t.Fatalf("did not expect expanded help bar by default")
}
}
@@ -405,7 +408,29 @@ func TestStreamTabViewKeepsTabAndHelpChromeVisible(t *testing.T) {
if !strings.Contains(out, "1:Overview") {
t.Fatalf("expected tab bar to remain visible in stream view")
}
+ if !strings.Contains(out, "press H for help") {
+ t.Fatalf("expected help hint to remain visible in stream view")
+ }
+}
+
+func TestHelpToggleWithH(t *testing.T) {
+ m := NewModelWithConfig(nil, nil, 1000, common.DefaultKeyMap())
+ out := m.View()
+ if !strings.Contains(out, "press H for help") {
+ t.Fatalf("expected default help hint")
+ }
+
+ next, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'H'}})
+ m = next.(Model)
+ out = m.View()
if !strings.Contains(out, "tab next tab") {
- t.Fatalf("expected help bar to remain visible in stream view")
+ t.Fatalf("expected expanded help after pressing h")
+ }
+
+ next, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'H'}})
+ m = next.(Model)
+ out = m.View()
+ if !strings.Contains(out, "press H for help") {
+ t.Fatalf("expected help hint after pressing h again")
}
}
diff --git a/internal/tui/dashboard/tabs.go b/internal/tui/dashboard/tabs.go
index 99a3d5b..4b9d339 100644
--- a/internal/tui/dashboard/tabs.go
+++ b/internal/tui/dashboard/tabs.go
@@ -129,6 +129,14 @@ func renderHelpBar(keys common.KeyMap, width int) string {
return common.HelpBarStyle.Width(width).Render(text)
}
+func renderHelpHint(width int) string {
+ hint := "press H for help"
+ if width > 0 && width < 90 {
+ return hint
+ }
+ return common.HelpBarStyle.Width(width).Render(hint)
+}
+
func wrapHelpLines(parts []string, width int) (string, string) {
if len(parts) == 0 {
return "", ""
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 7fd909a..b0e1861 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -496,8 +496,8 @@ func TestViewShowsDashboardWithoutHelpOverlay(t *testing.T) {
m.height = 30
out := m.View()
- if !strings.Contains(out, "tab next tab") {
- t.Fatalf("expected status/help bar keybinding text in dashboard")
+ if !strings.Contains(out, "press H for help") {
+ t.Fatalf("expected bottom help hint in dashboard")
}
}
@@ -548,7 +548,7 @@ func TestStatusBarHidesExportBindingWhenExportDisabled(t *testing.T) {
m.height = 30
out := m.View()
- if strings.Contains(out, "e export") {
+ if strings.Contains(out, "e snapshot export") {
t.Fatalf("did not expect export shortcut in status bar when export is disabled")
}
}