diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-27 00:00:48 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-27 00:00:48 +0200 |
| commit | 62e9fc030a7ad7c6522c2db1010609441818b0a9 (patch) | |
| tree | ca9e7715ee2223f3454bd1f83cffdf46bef79606 /internal/tui/dashboard | |
| parent | 34e70c9cd76b0231cfff3910bb24708624d7c72d (diff) | |
tui: add stream regex search and unify help visibility
Diffstat (limited to 'internal/tui/dashboard')
| -rw-r--r-- | internal/tui/dashboard/model.go | 6 | ||||
| -rw-r--r-- | internal/tui/dashboard/tabs.go | 23 | ||||
| -rw-r--r-- | internal/tui/dashboard/tabs_test.go | 10 |
3 files changed, 26 insertions, 13 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index 0e850d4..c9c96c3 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -272,7 +272,7 @@ func (m Model) LatestSnapshot() *statsengine.Snapshot { // BlocksGlobalShortcuts reports whether modal UI in the active tab should // suppress top-level shortcuts (for example global export key handling). func (m Model) BlocksGlobalShortcuts() bool { - return m.activeTab == TabStream && (m.streamModel.FilterModalVisible() || m.streamModel.ExportModalVisible()) + return m.activeTab == TabStream && (m.streamModel.FilterModalVisible() || m.streamModel.ExportModalVisible() || m.streamModel.SearchModalVisible()) } // SetStreamSource updates the live stream source used by the stream tab. @@ -284,6 +284,8 @@ func (m *Model) SetStreamSource(source *eventstream.RingBuffer) { func (m Model) View() string { width, height := common.EffectiveViewport(m.width, m.height) activeHeight := height + streamModel := m.streamModel + streamModel.SetFooterVisible(m.showHelp) if m.activeTab == TabStream { _, activeHeight = streamViewport(width, height) } @@ -294,7 +296,7 @@ func (m Model) View() string { b.WriteString(renderActiveTab( m.activeTab, m.latest, - &m.streamModel, + &streamModel, width, activeHeight, m.syscallsOffset, diff --git a/internal/tui/dashboard/tabs.go b/internal/tui/dashboard/tabs.go index 4b9d339..df8f03e 100644 --- a/internal/tui/dashboard/tabs.go +++ b/internal/tui/dashboard/tabs.go @@ -113,16 +113,21 @@ func renderTabBar(active Tab, width int) string { } func renderHelpBar(keys common.KeyMap, width int) string { - parts := make([]string, 0, len(keys.DashboardStatusHelp())) - for _, binding := range keys.DashboardStatusHelp() { - help := binding.Help() - parts = append(parts, help.Key+" "+help.Desc) - } - line1, line2 := wrapHelpLines(parts, width) - text := line1 - if line2 != "" { - text += "\n" + line2 + sections := keys.DashboardStatusHelpSections() + lines := make([]string, 0, len(sections)) + for _, section := range sections { + parts := make([]string, 0, len(section.Bindings)) + for _, binding := range section.Bindings { + help := binding.Help() + parts = append(parts, help.Key+" "+help.Desc) + } + line := section.Title + ": " + strings.Join(parts, " • ") + if width > 0 { + line = truncatePlain(line, width) + } + lines = append(lines, line) } + text := strings.Join(lines, "\n") if width > 0 && width < 90 { return text } diff --git a/internal/tui/dashboard/tabs_test.go b/internal/tui/dashboard/tabs_test.go index a457153..1148103 100644 --- a/internal/tui/dashboard/tabs_test.go +++ b/internal/tui/dashboard/tabs_test.go @@ -42,7 +42,13 @@ func TestRenderTabBarSmallWidthUsesSingleLine(t *testing.T) { func TestRenderHelpBarSmallWidthCanWrapToTwoLines(t *testing.T) { out := renderHelpBar(common.DefaultKeyMap(), 70) lines := strings.Split(out, "\n") - if len(lines) < 1 || len(lines) > 2 { - t.Fatalf("expected one or two help bar lines at width 70, got %d lines", len(lines)) + if len(lines) != 2 { + t.Fatalf("expected exactly two section lines at width 70, got %d lines", len(lines)) + } + if !strings.Contains(lines[0], "Global:") { + t.Fatalf("expected Global section line, got %q", lines[0]) + } + if !strings.Contains(lines[1], "Dashboard:") { + t.Fatalf("expected Dashboard section line, got %q", lines[1]) } } |
