#12774: fix: webchat heartbeat should respect showAlerts config
gateway
stale
Cluster:
Heartbeat Message Filtering
# Fix: Webchat heartbeat suppression should respect showAlerts
## Problem
The `shouldSuppressHeartbeatBroadcast()` function in webchat only checks `showOk`, causing all heartbeat responses (including alerts) to be suppressed when `showOk: false`.
### Current Behavior
```javascript
function shouldSuppressHeartbeatBroadcast(runId) {
if (!getAgentRunContext(runId)?.isHeartbeat) return false;
return !resolveHeartbeatVisibility({
cfg: loadConfig(),
channel: "webchat"
}).showOk; // ← Ignores showAlerts!
}
```
**Result:** Setting `showAlerts: true, showOk: false` still suppresses alert messages.
### Expected Behavior
- `showOk: false` → suppress HEARTBEAT_OK acknowledgments
- `showAlerts: true` → deliver alert messages
- Both should work independently
## Solution
Check the actual response content to determine whether it's an OK or an alert:
```javascript
function shouldSuppressHeartbeatBroadcast(runId) {
if (!getAgentRunContext(runId)?.isHeartbeat) return false;
const visibility = resolveHeartbeatVisibility({
cfg: loadConfig(),
channel: "webchat"
});
// If it's a HEARTBEAT_OK-only response, check showOk
// Otherwise, check showAlerts
const isOkResponse = checkIfHeartbeatOkResponse(runId);
return isOkResponse ? !visibility.showOk : !visibility.showAlerts;
}
```
## Impact
- Fixes webchat heartbeat delivery to match behavior of other channels (Telegram, WhatsApp, etc.)
- Allows users to configure fine-grained heartbeat visibility
- No breaking changes (defaults remain the same)
## Testing
Tested with:
- OpenClaw 2026.2.6-3
- macOS 15.5 (arm64)
- Webchat (TUI + Browser)
**Before fix:** Required `showOk: true` workaround to see alerts
**After fix:** `showAlerts: true, showOk: false` works correctly
## Related
- Channels: webchat
- Component: heartbeat delivery
- Files: `gateway-cli-*.js`
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates webchat heartbeat broadcast suppression so it can respect both `showOk` and `showAlerts`. It changes `shouldSuppressHeartbeatBroadcast` in `src/gateway/server-chat.ts` to accept the emitted message text and uses `stripHeartbeatToken(..., { mode: "heartbeat" })` to decide whether the message is an OK-only acknowledgment (use `showOk`) or an alert (use `showAlerts`). The helper is then used in both delta and final chat emission paths before broadcasting to webchat.
<h3>Confidence Score: 3/5</h3>
- This PR is close to safe, but the new heartbeat classification logic will incorrectly suppress some alert messages.
- The change is localized and intended behavior is clear, but it relies on `stripHeartbeatToken(...).shouldSkip` as a proxy for “OK-only” responses. Per the implementation, `shouldSkip` can be true for any short heartbeat message containing the token, so alerts under ~300 chars may be misclassified and filtered by `showOk` instead of `showAlerts`.
- src/gateway/server-chat.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
#11661: fix: Filter HEARTBEAT_OK from chat.history when showOk is false
by veast · 2026-02-08
87.6%
#11889: fix(chat): filter HEARTBEAT_OK messages in chat.history when showOk...
by bendyclaw · 2026-02-08
87.1%
#12240: fix: suppress heartbeat agent events from webchat broadcast
by Yida-Dev · 2026-02-09
86.5%
#11647: fix(webchat): filter HEARTBEAT_OK messages from chat.history response
by liuxiaopai-ai · 2026-02-08
86.5%
#11859: fix: filter HEARTBEAT_OK messages from chat.history when showOk is ...
by Zjianru · 2026-02-08
85.6%
#17006: fix(heartbeat): skip delivery when showOk is false
by Limitless2023 · 2026-02-15
80.4%
#16321: Fix #12767: suppress HEARTBEAT_OK leakage in Telegram DM replies
by tdjackey · 2026-02-14
77.6%
#14993: fix(webchat): add heartbeat detection to prevent zombie WebSocket c...
by BenediktSchackenberg · 2026-02-12
77.5%
#21014: fix(cron): suppress main-session summary for HEARTBEAT_OK responses
by nickjlamb · 2026-02-19
76.8%
#15575: fix(heartbeat): suppress prefixed HEARTBEAT_OK ack replies (#15505)
by TsekaLuk · 2026-02-13
76.1%