[PR #12354] fix: clean up orphaned store data on session deletion and message removal #14182

Closed
opened 2026-02-16 18:18:59 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12354

State: closed
Merged: No


Fixes #12351

The session.deleted handler in the TUI sync store only removes the session from store.session[] but leaves everything else behind — message, part, session_diff, todo, permission, question, session_status all stick around as orphaned entries. Over time this leaks memory with every deleted session.

The web app already handles this properly in cleanupSessionCaches() (packages/app/src/context/global-sync.tsx lines 676-706), the TUI just never got the same treatment.

Also fixed message.removed — it was removing the message from the array but not cleaning up its part entries.

Changes:

  • session.deleted: now cleans up all 7 keyed maps + removes from fullSyncedSessions
  • message.removed: now also deletes orphaned part[messageID]
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12354 **State:** closed **Merged:** No --- Fixes #12351 The `session.deleted` handler in the TUI sync store only removes the session from `store.session[]` but leaves everything else behind — `message`, `part`, `session_diff`, `todo`, `permission`, `question`, `session_status` all stick around as orphaned entries. Over time this leaks memory with every deleted session. The web app already handles this properly in `cleanupSessionCaches()` (`packages/app/src/context/global-sync.tsx` lines 676-706), the TUI just never got the same treatment. Also fixed `message.removed` — it was removing the message from the array but not cleaning up its `part` entries. Changes: - `session.deleted`: now cleans up all 7 keyed maps + removes from `fullSyncedSessions` - `message.removed`: now also deletes orphaned `part[messageID]`
yindo added the pull-request label 2026-02-16 18:18:59 -05:00
yindo closed this issue 2026-02-16 18:18:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14182