fix: prevent ghost reminder notifications (#13317)

The heartbeat runner was incorrectly triggering CRON_EVENT_PROMPT
whenever ANY system events existed during a cron heartbeat, even if
those events were unrelated (e.g., HEARTBEAT_OK acks, exec completions).

This caused phantom 'scheduled reminder' notifications with no actual
reminder content.

Fix: Only treat as cron event if pending events contain actual
cron-related messages, excluding standard heartbeat acks and
exec completion messages.

Fixes #13317
This commit is contained in:
pvtclawn
2026-02-12 22:52:32 +00:00
committed by Vignesh
parent 2655041f69
commit 4f687a7440

View File

@@ -489,7 +489,18 @@ export async function runHeartbeatOnce(opts: {
const isCronEvent = Boolean(opts.reason?.startsWith("cron:"));
const pendingEvents = isExecEvent || isCronEvent ? peekSystemEvents(sessionKey) : [];
const hasExecCompletion = pendingEvents.some((evt) => evt.includes("Exec finished"));
const hasCronEvents = isCronEvent && pendingEvents.length > 0;
// Fix for #13317: Only treat as cron event if there are actual cron-related messages,
// not just any system events (which could be heartbeat acks, exec completions, etc.)
const hasCronEvents = isCronEvent && pendingEvents.some((evt) => {
const trimmed = evt.trim();
// Exclude standard heartbeat acks and exec completion messages
return (
trimmed.length > 0 &&
!trimmed.includes("HEARTBEAT_OK") &&
!trimmed.includes("Exec finished")
);
});
const prompt = hasExecCompletion
? EXEC_EVENT_PROMPT
: hasCronEvents