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/dashboard | |
| parent | 39a11ed5997a3829751dfbe4b666d3568d466276 (diff) | |
tui: revamp status keys and add pid/tid reselection flow
Diffstat (limited to 'internal/tui/dashboard')
| -rw-r--r-- | internal/tui/dashboard/model.go | 2 | ||||
| -rw-r--r-- | internal/tui/dashboard/model_test.go | 7 | ||||
| -rw-r--r-- | internal/tui/dashboard/tabs.go | 44 | ||||
| -rw-r--r-- | internal/tui/dashboard/tabs_test.go | 6 |
4 files changed, 44 insertions, 15 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index 2ed53a1..026e63e 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -290,8 +290,6 @@ func (m Model) View() string { m.processesOffset, )) b.WriteString("\n") - b.WriteString(common.HighlightStyle.Render("Press ? for help")) - b.WriteString("\n") b.WriteString(renderHelpBar(m.keys, width)) return common.ScreenStyle.Render(b.String()) } diff --git a/internal/tui/dashboard/model_test.go b/internal/tui/dashboard/model_test.go index 6baa62c..a0e0539 100644 --- a/internal/tui/dashboard/model_test.go +++ b/internal/tui/dashboard/model_test.go @@ -369,9 +369,6 @@ func TestViewRendersTabBarAndHelp(t *testing.T) { if !strings.Contains(out, "Overview") { t.Fatalf("expected overview label in view") } - if !strings.Contains(out, "Press ? for help") { - t.Fatalf("expected inline help hint in view") - } if !strings.Contains(out, "tab next tab") { t.Fatalf("expected help bar text in view") } @@ -408,7 +405,7 @@ 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 ? for help") { - t.Fatalf("expected help hint to remain visible in stream view") + if !strings.Contains(out, "tab next tab") { + t.Fatalf("expected help bar to remain visible in stream view") } } diff --git a/internal/tui/dashboard/tabs.go b/internal/tui/dashboard/tabs.go index 7f1908a..99a3d5b 100644 --- a/internal/tui/dashboard/tabs.go +++ b/internal/tui/dashboard/tabs.go @@ -113,14 +113,15 @@ func renderTabBar(active Tab, width int) string { } func renderHelpBar(keys common.KeyMap, width int) string { - parts := make([]string, 0, len(keys.DashboardShortHelp())) - for _, binding := range keys.DashboardShortHelp() { + parts := make([]string, 0, len(keys.DashboardStatusHelp())) + for _, binding := range keys.DashboardStatusHelp() { help := binding.Help() parts = append(parts, help.Key+" "+help.Desc) } - text := strings.Join(parts, " • ") - if width > 0 { - text = truncatePlain(text, width) + line1, line2 := wrapHelpLines(parts, width) + text := line1 + if line2 != "" { + text += "\n" + line2 } if width > 0 && width < 90 { return text @@ -128,6 +129,39 @@ func renderHelpBar(keys common.KeyMap, width int) string { return common.HelpBarStyle.Width(width).Render(text) } +func wrapHelpLines(parts []string, width int) (string, string) { + if len(parts) == 0 { + return "", "" + } + if width <= 0 { + return strings.Join(parts, " • "), "" + } + max := width + lines := []string{"", ""} + line := 0 + for _, part := range parts { + token := part + if lines[line] != "" { + token = " • " + part + } + if utf8.RuneCountInString(lines[line]+token) <= max { + lines[line] += token + continue + } + if line == 0 { + line = 1 + if utf8.RuneCountInString(part) <= max { + lines[line] = part + } + continue + } + break + } + lines[0] = truncatePlain(lines[0], max) + lines[1] = truncatePlain(lines[1], max) + return lines[0], lines[1] +} + func tabLabel(tab Tab, short bool) string { if !short { return tab.String() diff --git a/internal/tui/dashboard/tabs_test.go b/internal/tui/dashboard/tabs_test.go index bf96864..a457153 100644 --- a/internal/tui/dashboard/tabs_test.go +++ b/internal/tui/dashboard/tabs_test.go @@ -39,10 +39,10 @@ func TestRenderTabBarSmallWidthUsesSingleLine(t *testing.T) { } } -func TestRenderHelpBarSmallWidthUsesSingleLine(t *testing.T) { +func TestRenderHelpBarSmallWidthCanWrapToTwoLines(t *testing.T) { out := renderHelpBar(common.DefaultKeyMap(), 70) lines := strings.Split(out, "\n") - if len(lines) != 1 { - t.Fatalf("expected single-line help bar at width 70, got %d lines", len(lines)) + if len(lines) < 1 || len(lines) > 2 { + t.Fatalf("expected one or two help bar lines at width 70, got %d lines", len(lines)) } } |
