Skip to content

fix(mentions): resolve emphasis/spoiler-wrapped @mentions in CLI (#2526) - #2684

Open
boxed-dev wants to merge 1 commit into
block:mainfrom
boxed-dev:fix/2526-emphasis-wrapped-mentions
Open

fix(mentions): resolve emphasis/spoiler-wrapped @mentions in CLI (#2526)#2684
boxed-dev wants to merge 1 commit into
block:mainfrom
boxed-dev:fix/2526-emphasis-wrapped-mentions

Conversation

@boxed-dev

Copy link
Copy Markdown

Fixes #2526.

Problem

The Rust mention parser (buzz-sdk/src/mentions.rs) only accepted an @ at start-of-string or after ASCII whitespace. Any @mention wrapped in markdown emphasis — **@Name**, *@Name*, _@Name_, (@Name), ||@Name|| — was silently dropped: buzz messages send exited 0 with zero p tags, so nobody was notified and no buzz-acp agent woke.

Agents post exclusively through buzz messages send, so this broke agent handoffs with no signal to anyone — a handoff would stall until a human noticed. Desktop's hasMention.ts fixed the same class of bug months ago (#328); the Rust parser never got parity. This is parser divergence: two implementations of "is this an @mention" giving different answers on the two surfaces that have to agree.

Fix

Bring mentions.rs to behavioural parity with hasMention.ts by widening the two existing predicates against one shared delimiter definition — rather than porting the TS regex, which would create a second hand-maintained list that drifts exactly as the first one did.

  • is_mention_lead — accept *, _, (, | as leading delimiters, used at both extract_at_names and extract_at_mentions_with_known. Email locals (user@host) stay excluded.
  • is_word_boundary — accept trailing *, _, | so @Will Pfleger** matches the full known name instead of falling through to the single-word tokenizer and yielding will.
  • CLI — strip code regions before @name extraction in resolve_content_mentions, mirroring the existing NIP-27 URI path, so an @name inside a code sample no longer fires a false notification.

Tests

The gap that let this ship: of 69 existing mention tests, not one had an emphasis character next to an @. Added:

  • buzz-sdk (+7): bold/italic/spoiler/paren leading delimiters, trailing emphasis on multi-word names, and email-still-rejected regression guards.
  • buzz-cli (+2): full resolution chain (**@Atlas** / _@Atlas_ / (@Will Pfleger) → resolved pubkeys, proving a p tag is emitted) and the code-region exclusion.

Verification

  • cargo test -p buzz-sdk -p buzz-cli — 492 passed
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo fmt --all --check — clean
  • cargo build --release -p buzz-cli — clean
  • just test-unit — passed

Scope

Fixes the three parser divergences the issue prescribes. Deliberately out of scope: the optional stderr "zero mentions resolved" warning (better as a focused follow-up — a naive version would spam on every email) and the longer-term unification of the Rust and TS parsers.

@boxed-dev
boxed-dev requested a review from a team as a code owner July 24, 2026 07:48
…ck#2526)

The Rust mention parser only accepted an `@` at start-of-string or after
ASCII whitespace, so `**@name**`, `*@name*`, `_@Name_`, `(@name)` and
`||@name||` were silently dropped — `buzz messages send` exited 0 with zero
p-tags and nobody was notified. Agents post exclusively through this path,
so handoffs stalled with no signal. Desktop's `hasMention.ts` fixed the same
class of bug months ago (block#328); the Rust side never got parity.

Bring `mentions.rs` to behavioural parity with `hasMention.ts` by widening
the two existing predicates against one shared delimiter definition, rather
than porting the TS regex (which would create a second drifting list):

- `is_mention_lead`: accept `*`, `_`, `(`, `|` as leading delimiters at both
  `extract_at_names` and `extract_at_mentions_with_known`. Email locals
  (`user@host`) stay excluded.
- `is_word_boundary`: accept trailing `*`, `_`, `|` so `@Will Pfleger**`
  matches the full known name instead of tokenizing to `will`.
- CLI: strip code regions before `@name` extraction in
  `resolve_content_mentions`, mirroring the NIP-27 URI path, so an `@name`
  inside a code sample no longer fires a false notification.

Adds unit tests pinning emphasis/spoiler/paren cases and the code-region
exclusion — the gap that let this divergence survive a release.

Signed-off-by: boxed-dev <rishabh.kumar2022a@vitstudent.ac.in>
@boxed-dev
boxed-dev force-pushed the fix/2526-emphasis-wrapped-mentions branch from b1a7b7d to 3128593 Compare July 24, 2026 07:51
@cameronhotchkies cameronhotchkies added the triage-ready Appropriate for agentic review label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-ready Appropriate for agentic review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Bold-wrapped @mentions (**@Name**) send zero p tags from buzz-cli — no notification, exit 0, no warning

2 participants