mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:57:40 +00:00
fix: clear delivery routing state when creating isolated cron sessions (#27778)
* fix: clear delivery routing state when creating isolated cron sessions When `resolveCronSession()` creates a new session (forceNew / isolated), the `...entry` spread preserves `lastThreadId`, `lastTo`, `lastChannel`, and `lastAccountId` from the prior session. This causes announce-mode cron deliveries to post as thread replies instead of channel top-level messages when `delivery.to` matches the channel of a prior conversation. Clear delivery routing metadata on new session creation so isolated cron sessions start with a clean delivery state. Closes #27751 ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved) * fix: also clear deliveryContext to prevent lastThreadId repopulation normalizeSessionEntryDelivery (called on store writes) repopulates lastThreadId from deliveryContext.threadId. Clearing only the last* fields is insufficient — deliveryContext must also be cleared when creating a new isolated session. ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
This commit is contained in:
@@ -65,6 +65,19 @@ export function resolveCronSession(params: {
|
||||
sessionId,
|
||||
updatedAt: params.nowMs,
|
||||
systemSent,
|
||||
// When starting a fresh session (forceNew / isolated), clear delivery routing
|
||||
// state inherited from prior sessions. Without this, lastThreadId leaks into
|
||||
// the new session and causes announce-mode cron deliveries to post as thread
|
||||
// replies instead of channel top-level messages.
|
||||
// deliveryContext must also be cleared because normalizeSessionEntryDelivery
|
||||
// repopulates lastThreadId from deliveryContext.threadId on store writes.
|
||||
...(isNewSession && {
|
||||
lastChannel: undefined,
|
||||
lastTo: undefined,
|
||||
lastAccountId: undefined,
|
||||
lastThreadId: undefined,
|
||||
deliveryContext: undefined,
|
||||
}),
|
||||
};
|
||||
return { storePath, store, sessionEntry, systemSent, isNewSession };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user