fix(cli): default root send to kind 45001 in forum channels - #5082
Open
iroiro147 wants to merge 1 commit into
Open
fix(cli): default root send to kind 45001 in forum channels#5082iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
When `buzz-cli messages send` publishes to a forum channel without an explicit `--kind` override, the emitted event must be `kind: 45001` so it appears in Buzz Desktop's canonical forum topic list. Prior behavior defaulted to `kind: 9` regardless of channel kind, which silently published forum-root messages into the invisible stream surface. Reporter: block#5075. The fix is channel-type-aware: - `fetch_channel_type` queries the relay for the channel's kind:39000 metadata event and extracts its `t` tag (`forum` | `stream`). - `resolve_send_root_kind` picks kind 45001 for forum channels, keeps kind 9 for stream channels, and falls back to kind 9 when the channel type cannot be resolved (missing metadata, absent `t` tag). - An explicit `--kind` still wins, preserving the operator opt-out. - Reply sends are untouched; `--reply-to` follows the existing thread-resolution path (issue block#3828 covers kind-45003 inference). Adds pure-function regression tests in `commands::messages::tests`: forum default becomes 45001, stream default stays 9, unknown type falls back to 9, and explicit override wins over the forum default. Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
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.
Resolves #5075.
Problem
buzz-cli messages send <channel-uuid> "..."publishes every root message askind: 9regardless of the channel's actual kind. When the target channel is a forum, the message lands on the invisible stream surface — it never appears in Buzz Desktop's forum topic list, even thoughsubmit_eventreturns success. Operators must currently pass--kind 45001by hand every time, and there is no in-CLI signal that the default would misroute the message.Fix
Make the default kind channel-type-aware. On a root send (no
--reply-to, no explicit--kind):kind: 39000metadata event and extract its["t", ...]tag (forum|stream).forum: emitkind: 45001viabuild_forum_postso the new topic shows up in the canonical forum view.streamor unresolvable (no metadata, nottag): fall back tokind: 9viabuild_message, preserving existing behaviour.Two hard rules:
--kindalways wins.--kind 9into a forum channel is still allowed and still misroutes — that is the operator's call, not ours. The bug in buzz messages send defaults to an invisible stream event for forum roots #5075 is the default, not the override.--reply-tofollows the existing thread-resolution path unchanged; issue [Bug] Agent forum replies publish as kind 9 and disappear from the forum thread #3828 covers kind-45003 inference from the parent event and is deliberately a separate fix.Implementation
fetch_channel_type:POST /querywith{"kinds":[39000],"#d":[uuid],"limit":1}; parses the tags array for["t", <value>]; returnsOk(Option<String>). Errors only on transport/wire-shape failures so malformed 39000 does not silently fall through to kind 9.resolve_send_root_kind: pure function(explicit: Option<u16>, channel_type: Option<&str>) -> u16. Encoding the decision as a pure fn (rather than inline incmd_send_message) lets the regression tests run without network mocking.p.kindandp.reply_toare absent — no extra round-trip on paths that don't need it.Tests
cargo test --package buzz-cli --lib commands::messages::tests— 29 passed, 4 new:resolve_send_root_kind_forum_default_becomes_45001resolve_send_root_kind_stream_default_stays_9resolve_send_root_kind_unknown_type_falls_back_to_9resolve_send_root_kind_explicit_overrides_forum_defaultNotes
reply_to.is_none().fetch_channel_typeshape intentionally mirrorsresolve_channel_idin the same file so the relay query pattern stays idiomatic.