diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-26 23:47:16 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-26 23:47:16 +0200 |
| commit | 34e70c9cd76b0231cfff3910bb24708624d7c72d (patch) | |
| tree | d17c70b4b1f467ba72fe238d9b1656c1dde564a2 /internal/tui/dashboard | |
| parent | dcdfbcc0a2ee9750e48a8db74b4ca70fdac2f9c6 (diff) | |
tui: clarify export help and toggle help bar with uppercase H
Diffstat (limited to 'internal/tui/dashboard')
| -rw-r--r-- | internal/tui/dashboard/model.go | 11 | ||||
| -rw-r--r-- | internal/tui/dashboard/model_test.go | 31 | ||||
| -rw-r--r-- | internal/tui/dashboard/tabs.go | 8 |
3 files changed, 46 insertions, 4 deletions
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 "", "" |
