diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-13 09:45:09 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-13 09:45:09 +0300 |
| commit | 6c7a5d5fb3e88068799fb414e316b6bec31015e9 (patch) | |
| tree | c47a73f3fd3d3a1089f77e00934bcdb45168965c /internal/tui/eventstream | |
| parent | 50d5220ed5a2187dbf548d70f3d795a39f7bfd00 (diff) | |
split globalfilter presentation and parsing into sub-packages
Move ParseDurationNs to globalfilter/parser and move CompareOpSymbol,
AppendStringSummary, AppendNumericSummary, FilterSummary to
globalfilter/presenter. The domain Filter type retains only matching,
equality, clone, and active-predicate logic. All callers updated;
tests for the new sub-packages added.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui/eventstream')
| -rw-r--r-- | internal/tui/eventstream/filter.go | 9 | ||||
| -rw-r--r-- | internal/tui/eventstream/filter_test.go | 8 | ||||
| -rw-r--r-- | internal/tui/eventstream/render.go | 3 |
3 files changed, 14 insertions, 6 deletions
diff --git a/internal/tui/eventstream/filter.go b/internal/tui/eventstream/filter.go index 61d8c33..801b8ba 100644 --- a/internal/tui/eventstream/filter.go +++ b/internal/tui/eventstream/filter.go @@ -1,6 +1,9 @@ package eventstream -import "ior/internal/globalfilter" +import ( + "ior/internal/globalfilter" + "ior/internal/globalfilter/parser" +) type CompareOp = globalfilter.CompareOp type NumericFilter = globalfilter.NumericFilter @@ -16,6 +19,8 @@ const ( OpLte = globalfilter.OpLte ) +// ParseDurationNs delegates to parser.ParseDurationNs, re-exporting the +// duration parsing helper for eventstream callers. func ParseDurationNs(input string) (int64, error) { - return globalfilter.ParseDurationNs(input) + return parser.ParseDurationNs(input) } diff --git a/internal/tui/eventstream/filter_test.go b/internal/tui/eventstream/filter_test.go index 0413904..efedbe4 100644 --- a/internal/tui/eventstream/filter_test.go +++ b/internal/tui/eventstream/filter_test.go @@ -3,6 +3,8 @@ package eventstream import ( "strings" "testing" + + "ior/internal/globalfilter/presenter" ) func sampleEvent() StreamEvent { @@ -31,8 +33,8 @@ func TestFilterZeroValueMatchesAll(t *testing.T) { if f.IsActive() { t.Fatalf("zero-value filter should be inactive") } - if got := f.Summary(); got != "all" { - t.Fatalf("Summary() = %q, want all", got) + if got := presenter.FilterSummary(f); got != "all" { + t.Fatalf("FilterSummary() = %q, want all", got) } } @@ -120,7 +122,7 @@ func TestFilterSummaryIncludesActivePredicates(t *testing.T) { PID: &NumericFilter{Op: OpEq, Value: 1234}, LatencyNs: &NumericFilter{Op: OpGt, Value: 1000000}, } - got := f.Summary() + got := presenter.FilterSummary(f) for _, wantPart := range []string{"errors", "syscall~read", "pid=1234", "latency>1ms"} { if !strings.Contains(got, wantPart) { t.Fatalf("Summary() = %q, missing %q", got, wantPart) diff --git a/internal/tui/eventstream/render.go b/internal/tui/eventstream/render.go index 4d7970b..cd4d528 100644 --- a/internal/tui/eventstream/render.go +++ b/internal/tui/eventstream/render.go @@ -5,6 +5,7 @@ import ( "strconv" "strings" + "ior/internal/globalfilter/presenter" "ior/internal/tui/common" "charm.land/lipgloss/v2" @@ -75,7 +76,7 @@ func renderStatusLine(paused bool, totalCount, filteredCount, bufferLen, bufferC } func renderFilterLine(filter Filter) string { - summary := filter.Summary() + summary := presenter.FilterSummary(filter) if summary == "all" { summary = common.HighlightStyle.Render(summary) } |
