fix(cli): resolve @mentions wrapped in markdown emphasis and skip code regions#2547
fix(cli): resolve @mentions wrapped in markdown emphasis and skip code regions#2547bosoud wants to merge 1 commit into
Conversation
…e regions An @mention written as **@name**, *@name*, _@Name_, (@name) or ||@name|| was silently dropped by `buzz messages send`: the Rust parser only accepted an @ preceded by whitespace, so the event carried zero p tags and nobody was notified. Desktop's TypeScript parser was fixed for this in 0f93ef4 (block#328); the Rust side never got the equivalent. Bring buzz-sdk's mention parser to behavioural parity with desktop/src/features/messages/lib/hasMention.ts: - Accept `*`, `_`, `(` and `||` as leading delimiters, via a single shared `is_mention_lead` predicate used by both `extract_at_names` and `extract_at_mentions_with_known` (no second delimiter list to drift). - Widen `is_word_boundary` to accept trailing `*`, `_` and `||`, so emphasis no longer breaks multi-word display-name matching. - Strip code regions before @name extraction in the CLI send path (previously only NIP-27 URI extraction was stripped), so @NAMEs in code samples no longer fire notifications. - Warn on stderr when content carries @mention candidates but zero mentions resolved — silent zero-recipient sends were the costly part. Fixes block#2526 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CqMxL1inNtU7icywZxbrGY Signed-off-by: Abdulwahab <bosoud@me.com>
3e7dcdb to
7da0dd6
Compare
|
Nice — this matches the direction from the triage notes, and the zero-resolved-mentions warning is a good addition. Two things worth a look:
|
Fixes #2526
Problem
buzz messages sendsilently dropped any@mentionwrapped in markdown emphasis —**@Name**,*@Name*,_@Name_— or preceded by(/||. The message posted with zeroptags, exit 0, no warning, so no one was notified and no buzz-acp agent woke. Desktop's TypeScript parser (hasMention.ts) was fixed for exactly this in0f93ef44(#328); the Rust parser never got the equivalent, and none of the 69 existing mention tests contained an emphasis character next to an@.Changes
Following the direction in the issue — widen the existing Rust predicates against one shared delimiter definition rather than porting the TS regex:
crates/buzz-sdk/src/mentions.rsis_mention_lead(prev, prev2)— the single definition of "what may precede an@": start-of-string, ASCII whitespace,(, emphasis*/_, or spoiler||. Bothextract_at_namesandextract_at_mentions_with_knownnow use it, so the two extraction paths can no longer drift from each other.is_word_boundarywidened to accept trailing*,_, and||(single|intentionally stays a non-boundary, matching TS), so**@Will Pfleger**matches the known multi-word name instead of falling through to a uselesswilltoken.hasMention.tsas the counterpart that must stay in agreement.crates/buzz-cli/src/commands/messages.rsresolve_content_mentionsnow appliesstrip_code_regionsbefore@nameextraction (previously only NIP-27 URI extraction was stripped). An@nameinside a fenced block or backtick span no longer fires a notification — the false-positive mirror of the reported false negative.buzz messages sendprints a warning to stderr when the (code-stripped) content contains@mentioncandidates but zero mentions resolved — the independent mitigation suggested in the issue, so a zero-recipient send is no longer silent. Email addresses and@never count as candidates, so ordinary prose does not warn.Tests
buzz-sdkcovering bold/italic/spoiler/paren leads, trailing emphasis on multi-word names, the single-|non-delimiter, emails inside emphasis, code-region stripping, and the deliberate_@carol_fallback-tokenizer trade-off (the_glues to the name in the fallback path only; the known-names path resolves it correctly — pinned in a test with a comment).buzz-clicovering the send-pipeline regression case (**@Atlas**), code-region skipping, and thementions_went_unresolvedwarning predicate.cargo test -p buzz-sdk -p buzz-cli,cargo clippy --all-targets, andcargo fmtall clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01CqMxL1inNtU7icywZxbrGY