Skip to content

Heartbeat skipped when last inbound message is from a group chat #20

@tmustier

Description

@tmustier

Problem

When using web mode with heartbeatMinutes configured, heartbeats are skipped if the most recent inbound WhatsApp message was from a group chat:

{"level":30,"time":"2025-12-05T14:27:12.696Z","module":"web-heartbeat",...,"reason":"last-inbound-group","msg":"reply heartbeat skipped"}

This affects same-phone mode users who are members of active group chats. Since group messages frequently arrive, lastInboundMsg often has chatType === "group", causing heartbeats to be skipped indefinitely until a direct message is received.

Current behavior

In src/web/auto-reply.ts:

if (lastInboundMsg?.chatType === "group") {
  // skip entirely
  return;
}

Expected behavior

Heartbeats should fall back to getFallbackRecipient() when the last message was from a group, rather than skipping entirely. The fallback logic already exists for when !lastInboundMsg:

if (!lastInboundMsg || lastInboundMsg.chatType === "group") {
  const fallbackTo = getFallbackRecipient(cfg);
  // ... existing fallback logic
}

Context

This was introduced in commit 6afe6f4 ("feat(web): add group chat mention support"). The intent was likely to avoid sending heartbeats TO a group chat, which is correct. But for same-phone mode users, heartbeats should still go to the self-chat via fallback.

Workaround

Send a direct message to reset lastInboundMsg before the heartbeat timer fires.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions