openclaw - 💡(How to fix) Fix feat: Add session:disconnect event for automatic memory archival on TUI close

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

Events: command:new, command:reset, session:end
RAW_BUFFERClick to expand / collapse

Problem

Currently, the session-memory hook only triggers on /new or /reset commands. When a user closes the TUI through any other means, the session context is not automatically archived to memory files. This means if the agent didn't manually write to memory/YYYY-MM-DD.md during the conversation, that day's context is lost from the agent's working memory after a daily reset.

When to Trigger Archival

Trigger memory archival when a session is permanently ending and cannot be resumed:

MethodDescription
/new or /resetExplicitly starts a new session (already works)
/exit commandUser explicitly exits
Ctrl+D (EOF)Terminal signals end of input
Ctrl+C × 2User force-quits
Close terminal window (⌘+W)Terminal tab/window closed
Close terminal app (⌘+Q)Terminal app quit
Daily reset (4 AM auto)Session automatically rolls over
Idle timeout resetSession expires due to inactivity

Proposed Solution

Add a new event type: session:end that fires when a session is permanently ending.

Hook integration

Extend the existing session-memory hook:

Events: command:new, command:reset, session:end

Benefits

  1. Zero lost memories: Every session's context is preserved when it truly ends
  2. Zero user friction: Works automatically, no habit change needed

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix feat: Add session:disconnect event for automatic memory archival on TUI close