feat(cli): scope buzz messages search by channel, kind, and upper time bound - #3561
Open
mvanhorn wants to merge 1 commit into
Open
feat(cli): scope buzz messages search by channel, kind, and upper time bound#3561mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
…e bound buzz messages search accepted --query, --author, --since, and --limit, and built its relay filter with a hardcoded kinds array and no channel constraint. The relay-side SearchQuery already declares until and kinds, and every other channel-scoped read path in the crate already sends #h, so the capability existed server-side but was unreachable from the CLI. Add three optional flags that map onto NIP-01 filter fields the relay already honors on this code path: --channel <UUID> -> filter["#h"] = [uuid] --until <UNIX> -> filter["until"] = n --kinds <N,N> -> replaces the default kinds array AGENTS.md already tells agents to pass --kinds 9,45001,45003 to avoid the relay p-gate; this makes that documented invocation real. Omitting all three emits a filter byte-identical to the previous one, covered by a regression test. --since later than --until and a malformed --channel both fail locally with CliError::Usage before any network call. The filter build moves into build_search_filter so the shape is testable without a relay. Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
Chessing234
reviewed
Jul 29, 2026
Chessing234
left a comment
Contributor
There was a problem hiding this comment.
Natural CLI extension — --channel, --kinds, and --until were already on the wire via SearchQuery, so exposing them on buzz messages search removes a whole class of client-side filter work for agents. README + clap wiring look consistent with the rest of the messages command family. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simulated demo. Every terminal frame is verbatim captured output — the opening is this branch's parent commit rejecting
--channelbefore the flags existed. No search results are shown; the filter shapes are the ones the new unit tests assert.buzz messages searchaccepts--query,--author,--since, and--limit. It builds its relay filter with a hardcodedkindsarray and no channel constraint, so an agent asking "what did we say about the checkout bug in #eng-relay last week" has to pull unscoped hits and filter client-side.All three capabilities already exist on the other side of the wire:
SearchQueryinbuzz-searchdeclares bothsinceanduntil("NIP-01 until (Unix seconds). Inclusive upper bound oncreated_at").--sincewas reachable;--untilwas not."#h"—cmd_get_messages(messages.rs:277),cmd_thread(:321), pluschannels.rsandworkflows.rs. Search was the one read path that could not narrow to a room.SearchQuery.kindsisOption<Vec<i32>>, but the CLI pinned four values.This adds three optional flags that map onto NIP-01 filter fields the relay already honors on this exact code path:
--channel <UUID>"#h": [uuid]--until <UNIX_SECONDS>"until": n--kinds <N,N,...>kindsarray--kindsis named to matchAGENTS.md, which already instructs agents to "pass at least--kinds 9,45001,45003to scope the query" to avoid the relay p-gate. That flag did not exist yet, so the documented invocation was not previously possible.Two guards fire locally, before any network call, matching the existing "at least one of --query or --author is required" check:
--sincelater than--untilreturnsCliError::Usage.--channelgoes through the crate's existingvalidate_uuidrather than becoming a silent zero-hit query.The filter construction moves into
build_search_filterso its shape is testable without a relay.cmd_searchcalls it; behavior is otherwise unchanged.Related issue
None found. Searched open issues and PRs for
messages search,search channel, andsearch until— no duplicates.Closest prior art is #1665 (
feat(cli): --author and --since filters on buzz messages search, merged), which widened this command's filter surface and stopped short of channel scope and the upper time bound. #712 (feat(cli): add channels search, merged) is the same shape of change one command group over.Testing
cargo test -p buzz-cli— 258 passed, 0 failed. Six new unit tests incommands::messages::search_filter_testscover the filter shape without needing a relay:--kindsis omitted →[9, 40002, 45001, 45003]--channel→filter["#h"] == [uuid]--channelabsent → no#hkey at all (regression guard on the existing unscoped path)--untilpresent and absentjust fmtandcargo clippy -p buzz-cli --all-targets -- -D warningsare both clean.Local verification against the built binary:
Both guards return before any relay connection is attempted.
No UI change.
crates/buzz-cli/README.mddocuments the three flags.AI was used for assistance. I wrote, ran, and reviewed the final code and tests.