Skip to content

Add streaming support to filter list + counter#1

Merged
kungfusheep merged 5 commits into
kungfusheep:masterfrom
themastersheep:master
Mar 3, 2026
Merged

Add streaming support to filter list + counter#1
kungfusheep merged 5 commits into
kungfusheep:masterfrom
themastersheep:master

Conversation

@themastersheep

@themastersheep themastersheep commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Problem

When using a filter there is no counter to surface how many items there are in the list (in total nor visible/filtered).

It is also not possible, with the filtered list to "stream" results in whilst displaying the UI as soon as possible rather than await a full content fetch.

Solution

  • FilterList gains a StreamWriter that lets callers append items from a goroutine. Each write triggers an incremental O(k) filter update and render signal, so the list stays responsive regardless of total size.
  • A match/total counter appears below the input, with a spinner that animates while a stream is active. The counter uses pointer indirection and a stack-allocated scratch buffer for zero heap allocations per frame.
  • Filter gains appended() for incremental index updates and refresh() for full re-evaluation, backing the StreamWriter workflow.

Changes

  • components.go — counterC component (alloc-free current/total display)
  • template.go — OpCounter compile/layout/render pipeline
  • filter.go — scored high-water mark, appended(), refresh()
  • filterlist.go — StreamWriter type, spinner lifecycle, counter wiring
  • filter_test.go — tests for write, filtered write, lifecycle, counter updates; benchmarks across 100–10k items
  • cmd/forme-fzf-stream/ — streaming log viewer demo

FilterList now displays a match/total counter below the input.
The counter is backed by an internal counterC component that
renders via pointer indirection with zero allocations per frame.

Filter gains appended() for O(k) incremental updates and
refresh() for full re-evaluation, preparing the groundwork
for streaming item insertion.
StreamWriter provides a managed write interface for appending
items into a FilterList from a goroutine. Each Write triggers
an incremental filter update and render signal. A spinner
animates next to the counter while the stream is active.

Includes tests for write, filtered write, lifecycle, counter
updates, and a benchmark across 100–10k items.
@kungfusheep
kungfusheep merged commit 3a5ca51 into kungfusheep:master Mar 3, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants