← Back to PRs

#12069: fix(whatsapp): handle native group @mentions with requireMention

by abhishek0450 open 2026-02-08 20:15 View on GitHub →
channel: whatsapp-web
## Issue Fixes #11758 WhatsApp native `@mention` detection fails in group chats when `requireMention: true` is enabled and the owner number is included in `allowFrom` (owner/self messages). ## Root Cause When `requireMention` is enabled, native WhatsApp mentions using LID identifiers (e.g. `181891881787642@lid`) were not correctly recognized, causing valid group mentions to be ignored. Two issues contributed to this: 1. Owner JID comparison was performed between incompatible formats (bare JID vs E164), which could never match. 2. WhatsApp automatically includes the owner’s JID in `mentionedJids` even when no explicit `@mention` is made, leading to false positives. ## Fix - Removed the incorrect JID format comparison - Added explicit owner/self-sender detection: - If the sender **is the owner**, suppress auto-included JID mentions - If the sender **is not the owner**, validate native `@mention`s - Ensured explicit `false` return to prevent fallback to text-based mention detection when JID mentions are present ## Tests - Added unit tests in `mentions.test.ts` covering owner/self message cases - Updated integration expectations in `supports-always-group-activation-silent-token-preserves.test.ts` - All mention unit tests pass - All group mention integration tests pass - Full web provider test suite passes (157/157) - Linting and formatting checks pass ## 🤖 AI / Vibe-coded PR disclosure - [x] **AI-assisted:** Yes — used AI tools for debugging, reasoning about edge cases, and reviewing the solution. All code was written, verified, and understood by me. - [x] **Testing level:** Fully tested. - Unit tests added/updated - Integration tests updated - Full web provider test suite passes (157/157) - [x] **Prompts / session logs:** No production session logs included. Debugging and reasoning were based on local reproduction and tests. - [x] **Author understanding:** I understand what the code does and why these changes are required, and I’m confident the fix preserves existing behavior. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts WhatsApp group @mention detection when `requireMention: true` is enabled in “self-chat mode” (where `allowFrom` contains the owner/self number). The mention logic in `src/web/auto-reply/mentions.ts` now: - Treats any presence of `mentionedJids` as authoritative (no regex fallback) for non-self-chat mode. - In self-chat mode, ignores auto-included self mentions only when the sender is the owner, while still honoring explicit JID/LID mentions from other senders. Tests were updated/added to cover self/owner message suppression, non-owner native mentions, and adjusted integration expectations for group activation behavior. <h3>Confidence Score: 4/5</h3> - Mostly safe to merge, but there is a self-chat false-positive edge case if senderE164 is missing. - The core logic change is small and tests cover the intended scenarios, but the new owner/self detection depends on `msg.senderE164` being present. If it’s absent on some inbound messages, owner messages with auto-included self JIDs can incorrectly trigger the bot in self-chat mode. - src/web/auto-reply/mentions.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs