From de99e5c10064c13c58836146527b3157aacfd4df Mon Sep 17 00:00:00 2001 From: Sami Date: Sat, 15 Aug 2026 21:14:20 -0400 Subject: [PATCH] docs(cli): name the server path --depth-limit selects and the root's extra row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two measured facts about `messages thread` that its flags do not suggest, both surfaced in review. The relay reads the thread cursor only on the depth-limited server path (bridge.rs:1155 `extract_depth_limit ... None => continue`), so `--depth-limit` selects WHICH server code path serves the request. That is why a cursor without an explicit depth bound sends the sentinel; the help now says so rather than leaving it as an implementation detail. Verified on the built binary: `--after 1786800000` returns n=1 with no `--depth-limit`, so the sentinel does reach the cursor, and `--after 1785163671` returns 21 of the thread's 44 replies. The root arrives on a second filter carrying no cursor, no depth bound and its own `limit: 1`, so it is un-budgeted: a page holds `--limit` replies PLUS the root, and the root reappears on every page. Measured at caps 3/5/11 — n = cap+1 each time, and the page-to-page id overlap is exactly the root and nothing else. Callers concatenating pages must dedupe it. Also measured: `--limit N --depth-limit 5` returns N+1 for N in {1,2,5,10}, and `--depth-limit 0` returns the root alone. Co-authored-by: Sami Signed-off-by: Sami --- crates/buzz-cli/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/buzz-cli/src/lib.rs b/crates/buzz-cli/src/lib.rs index 489bb16475..61cdff22d4 100644 --- a/crates/buzz-cli/src/lib.rs +++ b/crates/buzz-cli/src/lib.rs @@ -488,7 +488,7 @@ pub enum MessagesCmd { }, /// Get a message thread (replies to a root message) #[command( - after_help = "Pagination:\n Returns up to --limit replies (default 100, max 500) plus the root event.\n Replies without a cursor and without --depth-limit are NEWEST-first; either\n one selects the OLDEST-first walk, so the cursor picks which end you see.\n\n To page a thread larger than the cap, walk FORWARD from the oldest reply.\n Seed with --after 0, then pass the newest reply of each page back in:\n\n buzz messages thread --channel --event --limit 500 --after 0\n buzz messages thread --channel --event --limit 500 \\\n --after --after-id \n\n Always pass --after-id. The timestamp-only cursor is STRICTLY greater-than,\n so a page boundary landing inside a second shared by several replies skips\n the rest of that second silently (rc=0). --after-id carries the tiebreak, so\n no reply is skipped regardless of where the boundary lands.\n\nKind scope:\n Replies are limited to kinds 9,40002,40003,40008,45003 (message, message\n v2, edit, diff, forum comment) and NOTHING ELSE. Notably EXCLUDED:\n reactions (7) and deletions (5) — on a busy thread these outnumber the\n replies, and no flag here surfaces them, so a reply count is not a thread\n event count. This list intentionally differs from `messages get`, which\n omits edits (40003) and includes forum posts (45001)." + after_help = "Pagination:\n Returns up to --limit replies (default 100, max 500) plus the root event.\n Replies without a cursor and without --depth-limit are NEWEST-first; either\n one selects the OLDEST-first walk, so the cursor picks which end you see.\n\n To page a thread larger than the cap, walk FORWARD from the oldest reply.\n Seed with --after 0, then pass the newest reply of each page back in:\n\n buzz messages thread --channel --event --limit 500 --after 0\n buzz messages thread --channel --event --limit 500 \\\n --after --after-id \n\n Always pass --after-id. The timestamp-only cursor is STRICTLY greater-than,\n so a page boundary landing inside a second shared by several replies skips\n the rest of that second silently (rc=0). --after-id carries the tiebreak, so\n no reply is skipped regardless of where the boundary lands.\n\nServer path and counts:\n The cursor is honoured only on the depth-limited server path; a filter\n without a depth bound routes to a generic query that has no cursor. So\n --depth-limit selects WHICH server code path serves the request, which\n its name does not suggest. Passing --after implies a depth bound meaning\n \"no effective limit\" so the cursor is always reached.\n\n The root event is fetched by a SECOND filter that carries no cursor, no\n depth bound and its own limit of 1. It therefore reappears on every page\n and does not consume a reply slot: expect --limit + 1 events per page,\n and dedupe the root when concatenating pages.\n\nKind scope:\n Replies are limited to kinds 9,40002,40003,40008,45003 (message, message\n v2, edit, diff, forum comment) and NOTHING ELSE. Notably EXCLUDED:\n reactions (7) and deletions (5) — on a busy thread these outnumber the\n replies, and no flag here surfaces them, so a reply count is not a thread\n event count. This list intentionally differs from `messages get`, which\n omits edits (40003) and includes forum posts (45001)." )] Thread { /// Channel UUID @@ -497,11 +497,14 @@ pub enum MessagesCmd { /// Root message event ID (64-char hex) #[arg(long)] event: String, - /// Maximum number of replies to return (default 100, max 500) + /// Maximum number of replies to return (default 100, max 500). + /// The root event arrives on its own filter, so a page holds + /// --limit replies PLUS the root #[arg(long)] limit: Option, /// Maximum reply nesting depth to include. Also selects the - /// oldest-first reply ordering (see Pagination below) + /// oldest-first reply ordering and the cursor-capable server path + /// (see Pagination below) #[arg(long)] depth_limit: Option, /// Unix timestamp cursor — return replies created after this time