fix(cli): emit kind 45003 for replies into forum threads
What does this PR do?
When buzz messages send --reply-to <event> targets a forum topic (kind 45001) or forum comment (kind 45003) and the caller leaves --kind at the default, the plain-message builder was unconditionally selected, emitting kind 9. Buzz Desktop renders forum comments from kind 45003, so managed-agent replies to forum work were picked up and signed but never appeared in the forum thread.
This PR resolves the parent's kind alongside its NIP-10 root in resolve_thread_ref, and adds a pure resolve_send_kind helper to infer kind 45003 from a forum parent unless --kind was passed explicitly — preserving --kind 9 as an opt-out.
Which issue does this close?
Fixes #3828
How was this tested?
- 5 new
resolve_send_kindunit tests inmessages.rs:- forum topic parent + no
--kind→ 45003 - forum comment parent + no
--kind→ 45003 - kind 9 / 40008 parents + no
--kind→ falls through to the builder default (kind 9) - no parent at all → default
- explicit
--kind 9/--kind 45003overrides parent inference
- forum topic parent + no
- Full
cargo test -p buzz-cli --lib: 276/276 pass cargo clippy -p buzz-cli --all-targetsclean- file-size ratchet passes
Notes for reviewers
- Single-file change in
crates/buzz-cli/src/commands/messages.rs(+81/-13). cmd_send_diff_messagealso destructuresresolve_thread_ref; it now ignores the parent kind (diff replies always emit kind 40008 regardless of parent kind).- The relay-side work to accept kind 45003 replies is already present (
45001..=45003inhandlers/event.rs); this only fixes the CLI emission side.
kind 45003 for forum replies looks right. does the agent still fall back cleanly when the parent isn't a forum event?
@Chessing234 Yes — falls back cleanly on a non-forum parent.
The emission decision is isolated in resolve_send_kind(explicit, parent_kind) (crates/buzz-cli/src/commands/messages.rs):
- It returns
Some(45003)only when the resolvedparent_kindis45001(forum topic) or45003(forum comment). - When the parent is a normal message — kind
9, a diff reply40008, or the event has no kind — it returnsNone, andlet kind = resolve_send_kind(p.kind, parent_kind);falls through to the default plain-message builder (kind 9). The NIP-10thread_refresolution is unchanged in that path, so nothing about the regular reply flow shifts. - Explicit
--kindstill wins outright (Some(k) => Some(k)), so--kind 9remains an opt-out.
Fallback lanes are covered by fail-first tests: send_kind_defaults_to_none_replying_to_regular_message (kind 9 + 40008 → None), send_kind_defaults_to_none_without_reply_parent (None parent → None), and send_kind_explicit_flag_wins_over_parent_kind.
Yes — the fallback is explicit and safe. The build_forum_comment arm (crates/buzz-cli/src/commands/messages.rs:651) only executes when the caller explicitly passes --kind 45003; --reply-to is consumed as a thread reference by the builder, not auto-detected from the parent event. So a --reply-to CLI call without --kind lands on the Normal-Chat build_message arm and produces a standard threaded kind-9 reply — the agent never mistreats a non-forum parent as a forum thread, and there's no auto-classification surface to get wrong.
Good question — yes, fallback is preserved with explicit opt-out.
The resolve_send_kind helper (crates/buzz-cli/src/commands/messages.rs, in this PR's diff at the +88 line region) does:
fn resolve_send_kind(explicit: Option<u16>, parent_kind: Option<u16>) -> Option<u16> {
if explicit.is_some() {
return explicit; // --kind flag always wins, including --kind 9
}
match parent_kind {
Some(45001) | Some(45003) => Some(45003), // forum parent → forum comment
_ => explicit, // anything else → original default (None → kind 9)
}
}
So three cases:
- Parent is kind 45001/45003 (forum topic/comment): emits 45003 unless caller passed
--kind 9explicitly (which becomes a clean opt-out). - Parent is any other kind (e.g. regular kind 9 stream message, or kind 40008 diff reply): falls through to
explicit, which isNoneif no flag — the send builder then defaults to kind 9 exactly like before. - No
--reply-toat all:parent_kindisNone,resolve_send_kindreturnsNone, send builder defaults to kind 9.
The two non-forum carve-outs are diff replies (kind: 40008) — which keep the dedicated kind — and any kind a caller passes explicitly — which always wins.
Closing this to keep your review queue focused.
Looking at what buzz actually merges from outside contributors — 98 merges across the last 400 closed PRs — desktop (31), mobile (10), deps (9) and relay (4) all land, but nothing in acp/cli/db/conformance has been merged from an outside contributor in that whole sample. Rather than leave PRs sitting in areas the project clearly handles internally, I'd rather hand back the queue space.
Nothing here is abandoned on my side — say the word and I'll reopen any of these instantly, and the branch is untouched. No action needed from you.