summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-08 20:43:31 +0200
committerPaul Buetow <paul@buetow.org>2026-03-08 20:43:31 +0200
commitf3f4bd343965c62a66666e7b2cd0b5b27024c0ed (patch)
tree70cd0c0da82ac1b787338f575a355e0e054fb3b2
parentb6e84c402938b0ffb311f5f90ec41b33637b688f (diff)
task 375: show active global filter in dashboard help
-rw-r--r--internal/tui/common/keys.go11
-rw-r--r--internal/tui/dashboard/model.go10
-rw-r--r--internal/tui/dashboard/tabs.go25
-rw-r--r--internal/tui/dashboard/tabs_test.go14
4 files changed, 49 insertions, 11 deletions
diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go
index bf356ee..fd7bef1 100644
--- a/internal/tui/common/keys.go
+++ b/internal/tui/common/keys.go
@@ -92,6 +92,7 @@ func (k KeyMap) DashboardStatusHelpSections() []HelpSection {
k.Seven,
k.Visualize,
k.Metric,
+ k.Filter,
k.SelectPID,
k.SelectTID,
k.Probes,
@@ -106,11 +107,7 @@ func (k KeyMap) DashboardStatusHelpSections() []HelpSection {
k.Visualize,
k.Metric,
helpTextBinding("space", "stream pause"),
- helpTextBinding("f", "stream filter"),
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"),
@@ -135,18 +132,14 @@ func (k KeyMap) DashboardFullHelp() [][]key.Binding {
controls = append(controls, k.Export)
}
controls = append(controls, k.DirGroup, k.SelectPID, k.SelectTID, k.Probes, k.Refresh, k.Quit)
- controls = append(controls, k.Visualize, k.Metric)
+ controls = append(controls, k.Visualize, k.Metric, k.Filter)
return [][]key.Binding{
{k.One, k.Two, k.Three, k.Four, k.Five, k.Six, k.Seven},
controls,
{
helpTextBinding("space", "stream pause"),
- helpTextBinding("f", "stream filter"),
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"),
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go
index 5b13642..c5effe2 100644
--- a/internal/tui/dashboard/model.go
+++ b/internal/tui/dashboard/model.go
@@ -64,6 +64,7 @@ type Model struct {
refreshEvery time.Duration
keys common.KeyMap
+ globalFilter globalfilter.Filter
pidFilter int
syscallsOffset int
syscallsTreemapSelection int
@@ -538,6 +539,7 @@ func (m *Model) SetStreamSource(source eventstream.Source) {
// SetGlobalFilter forwards the shared TUI filter into the stream tab so
// buffered rows can be re-filtered immediately.
func (m *Model) SetGlobalFilter(filter globalfilter.Filter) {
+ m.globalFilter = filter.Clone()
m.streamModel.SetFilter(eventstream.Filter(filter))
}
@@ -602,13 +604,17 @@ func (m Model) View() tea.View {
b.WriteString(m.renderActiveContent(width, activeHeight, &streamModel))
b.WriteString("\n")
if m.showHelp {
- b.WriteString(renderHelpBar(m.keys, width))
+ b.WriteString(renderHelpBarWithStatus(m.keys, width, m.filterSummary()))
} else {
- b.WriteString(renderHelpHint(width))
+ b.WriteString(renderHelpHintWithStatus(width, m.filterSummary()))
}
return tea.NewView(common.ScreenStyle.Render(b.String()))
}
+func (m Model) filterSummary() string {
+ return "filter: " + m.globalFilter.Summary()
+}
+
func (m Model) renderActiveContent(width, activeHeight int, streamModel *eventstream.Model) string {
if m.activeTab == TabSyscalls && m.syscallsVizMode == tabVizModeTreemap {
return renderSyscallsTreemap(m.latest, width, activeHeight, m.syscallsChart.Metric(), m.syscallsTreemapSelection, m.isDark)
diff --git a/internal/tui/dashboard/tabs.go b/internal/tui/dashboard/tabs.go
index 5d15acc..ab9365f 100644
--- a/internal/tui/dashboard/tabs.go
+++ b/internal/tui/dashboard/tabs.go
@@ -119,6 +119,10 @@ func renderTabBar(active Tab, width int) string {
}
func renderHelpBar(keys common.KeyMap, width int) string {
+ return renderHelpBarWithStatus(keys, width, "")
+}
+
+func renderHelpBarWithStatus(keys common.KeyMap, width int, status string) string {
sections := keys.DashboardStatusHelpSections()
lines := make([]string, 0, len(sections))
for _, section := range sections {
@@ -133,6 +137,9 @@ func renderHelpBar(keys common.KeyMap, width int) string {
}
lines = append(lines, line)
}
+ if status != "" && len(lines) > 0 {
+ lines[len(lines)-1] = appendStatusText(lines[len(lines)-1], status, width)
+ }
text := strings.Join(lines, "\n")
if width > 0 && width < 90 {
return text
@@ -141,13 +148,31 @@ func renderHelpBar(keys common.KeyMap, width int) string {
}
func renderHelpHint(width int) string {
+ return renderHelpHintWithStatus(width, "")
+}
+
+func renderHelpHintWithStatus(width int, status string) string {
hint := "press H for help"
+ if status != "" {
+ hint = appendStatusText(hint, status, width)
+ }
if width > 0 && width < 90 {
return hint
}
return common.HelpBarStyle.Width(width).Render(hint)
}
+func appendStatusText(base, status string, width int) string {
+ if status == "" {
+ return base
+ }
+ line := base + " | " + status
+ if width > 0 {
+ return truncatePlain(line, width)
+ }
+ return line
+}
+
func wrapHelpLines(parts []string, width int) (string, string) {
if len(parts) == 0 {
return "", ""
diff --git a/internal/tui/dashboard/tabs_test.go b/internal/tui/dashboard/tabs_test.go
index 16f8b76..54a1d16 100644
--- a/internal/tui/dashboard/tabs_test.go
+++ b/internal/tui/dashboard/tabs_test.go
@@ -55,3 +55,17 @@ func TestRenderHelpBarSmallWidthCanWrapToTwoLines(t *testing.T) {
t.Fatalf("expected Dashboard section line, got %q", lines[1])
}
}
+
+func TestRenderHelpHintWithStatusIncludesFilterSummary(t *testing.T) {
+ out := renderHelpHintWithStatus(120, "filter: syscall~read")
+ if !strings.Contains(out, "filter: syscall~read") {
+ t.Fatalf("expected filter summary in help hint, got %q", out)
+ }
+}
+
+func TestRenderHelpBarWithStatusIncludesFilterSummary(t *testing.T) {
+ out := renderHelpBarWithStatus(common.DefaultKeyMap(), 0, "filter: pid=42")
+ if !strings.Contains(out, "filter: pid=42") {
+ t.Fatalf("expected filter summary in help bar, got %q", out)
+ }
+}