Skip to content

fix(whatsapp): gate connect-time presence on selfChatMode to preserve phone notifications - #59410

Merged
mcaxtr merged 1 commit into
mainfrom
fix/whatsapp-selfchat-presence
Apr 2, 2026
Merged

mcaxtr merged 1 commit into
mainfrom
fix/whatsapp-selfchat-presence

Conversation

@mcaxtr

@mcaxtr mcaxtr commented Apr 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Problem: WhatsApp inbound monitor sends sendPresenceUpdate("available") on connect, overriding markOnlineOnConnect: false in session.ts and causing WhatsApp to suppress all phone push notifications for the linked number.
  • Why it matters: 100% of personal-phone WhatsApp users lose all push notifications while the gateway is running — not just for monitored chats, but for every conversation.
  • What changed: the connect-time presence now reads the existing selfChatMode flag — sends "unavailable" for personal-phone setups and keeps "available" for dedicated bot numbers.
  • What did NOT change (scope boundary): per-chat "composing" presence, read receipt behavior, message processing, reconnect logic, config types, and zod schema are all untouched. No new config fields.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: extensions/whatsapp/src/inbound/monitor.ts:72 called sendPresenceUpdate("available") unconditionally on connect, overriding the markOnlineOnConnect: false Baileys option in session.ts:129.
  • Missing detection / guardrail: no test asserted which presence value was sent relative to the account mode.
  • Prior context: the "available" call was added early in the WhatsApp channel implementation. markOnlineOnConnect: false was later set in session.ts with the right intent, but the explicit call was never updated to match.
  • Why this regressed now: it was always broken for personal-phone users; the issue was reported after wider adoption.
  • If unknown, what was ruled out: N/A — root cause is confirmed via Baileys docs and Beeper comparison.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/whatsapp/src/monitor-inbox.streams-inbound-messages.test.ts
  • Scenario the test should lock in: when selfChatMode: true, the first sendPresenceUpdate call sends "unavailable" instead of "available".
  • Why this is the smallest reliable guardrail: directly asserts the presence value at the exact call site that caused the bug.
  • Existing test that already covers this (if any): existing tests asserted sendPresenceUpdate("available") — they now assert the nth-call pattern and a new test covers the selfChatMode: true path.

User-visible / Behavior Changes

  • Personal-phone users (selfChatMode: true): phone push notifications are restored. The WhatsApp account shows "last seen at..." instead of permanent "online" status. Per-chat "typing..." indicators remain.
  • Dedicated-bot users (selfChatMode: false or unset): no change.

Diagram (if applicable)

Before (selfChatMode: true):
[gateway connects] -> sendPresenceUpdate("available") -> phone notifications suppressed

After (selfChatMode: true):
[gateway connects] -> sendPresenceUpdate("unavailable") -> phone notifications preserved

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No — same Baileys sendPresenceUpdate call, different argument.
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Node 22+
  • Integration/channel (if any): WhatsApp (Baileys/WhatsApp Web)

Steps

  1. Configure WhatsApp channel with selfChatMode: true (or select "personal phone" during onboarding)
  2. Start the gateway
  3. Send a message to the linked phone number from another device

Expected

  • Phone receives push notification normally

Actual (before fix)

  • Phone receives no push notification (WhatsApp suppresses them for the "online" linked device)

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

All 23 scoped tests pass (14 in streams-inbound-messages, 9 in captures-media-path-image-messages). pnpm check clean.

Human Verification (required)

  • Verified scenarios: scoped tests for both default (available) and selfChatMode (unavailable) paths; full lint/format gate.
  • Edge cases checked: selfChatMode undefined (falls back to false, sends "available" — no behavior change for existing users).
  • What you did not verify: live WhatsApp session (requires paired phone).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No — uses the existing selfChatMode field.
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: users with selfChatMode: true who relied on permanent "online" status.
    • Mitigation: unlikely scenario — selfChatMode indicates a personal phone where losing all notifications is almost certainly undesirable. The "online" indicator was a side effect, not a feature.

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XS maintainer Maintainer-authored PR labels Apr 2, 2026
@mcaxtr
mcaxtr force-pushed the fix/whatsapp-selfchat-presence branch from f8032cb to 30d4466 Compare April 2, 2026 04:19
@greptile-apps

greptile-apps Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where monitorWebInbox unconditionally sent sendPresenceUpdate("available") on connect, overriding the markOnlineOnConnect: false Baileys option and causing WhatsApp to suppress all phone push notifications for personal-phone (selfChatMode: true) users.

The fix is minimal and well-scoped: a single ternary in inbound/monitor.ts reads options.selfChatMode to select "unavailable" vs "available" at connect time, and auto-reply/monitor.ts threads account.selfChatMode through to the listener factory call. Per-chat "composing" presence, read receipts, and all other behavior are intentionally untouched.

Key changes:

  • inbound/monitor.ts: adds selfChatMode?: boolean to monitorWebInbox options; selects presence value via options.selfChatMode ? "unavailable" : "available".
  • auto-reply/monitor.ts: passes selfChatMode: account.selfChatMode to the listener factory (previously this field was not forwarded).
  • monitor-inbox.test-harness.ts: startInboxMonitor now accepts an options: { selfChatMode?: boolean } second argument, with default {}, keeping all existing call-sites unchanged.
  • Tests: existing presence assertions tightened from toHaveBeenCalledWith("available") to toHaveBeenNthCalledWith(1, "available") (more precise), and a new test "stays unavailable on connect in self-chat mode" covers the new path.
  • CHANGELOG.md: entry added for the fix.

Confidence Score: 5/5

  • Safe to merge — targeted single-line logic change, backward-compatible, well-tested, no new dependencies or config fields introduced.
  • The fix is a minimal and clearly correct ternary. Default behavior (selfChatMode absent or false) is unchanged, so existing users are unaffected. The new selfChatMode: true path is covered by a dedicated test. The test assertion upgrades (toHaveBeenNthCalledWith) are more precise and still correct. The selfChatMode field forwarded in auto-reply/monitor.ts uses an existing account property — no type changes required. No logic paths other than the presence value at connect-time are altered.
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix(whatsapp): gate connect-time presenc..." | Re-trigger Greptile

@mcaxtr
mcaxtr merged commit e1c9678 into main Apr 2, 2026
42 checks passed
@mcaxtr
mcaxtr deleted the fix/whatsapp-selfchat-presence branch April 2, 2026 04:40
steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WhatsApp personal number connection (Baileys) announces online presence on connect, suppressing all phone push notifications

1 participant