Files
openclaw/src
lbo728 d7a15c31fe fix(session): archive old transcript on daily/scheduled reset to prevent orphaned files
Daily (and other scheduled) session resets created a new session ID and left
the previous transcript file unreferenced on disk.  Unlike explicit /new and
/reset commands — which already called archiveSessionTranscripts via the
resetTriggered path — scheduled resets only set freshEntry=false without
setting resetTriggered, so previousSessionEntry was never populated and the
archive call was skipped.

Fix: compute freshEntry before previousSessionEntry so that the stale-session
case (entry exists AND !freshEntry) can also be captured.  Change the
previousSessionEntry condition from `resetTriggered && entry` to
`(resetTriggered || !freshEntry) && entry`.

The existing archiveSessionTranscripts call then handles both cases with the
same "reset" reason, renaming the old file with a .reset.<timestamp> suffix
(consistent with compaction archival) instead of leaving it orphaned.

Test: adds a case that freezes time at 5 AM, sets updatedAt to 3 AM (before
the 4 AM daily boundary), and asserts archiveSessionTranscripts is called with
the previous sessionId on the first message of the new day.

Fixes #35481
2026-03-05 11:31:59 -08:00
..