← Back to PRs

#12774: fix: webchat heartbeat should respect showAlerts config

by a2093930 open 2026-02-09 17:07 View on GitHub →
gateway stale
# 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