TUI store memory leak: session deletion and message removal leave orphaned data #8637

Open
opened 2026-02-16 18:10:28 -05:00 by yindo · 1 comment
Owner

Originally created by @zampxdev on GitHub (Feb 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

When a session is deleted in the TUI, only the session entry itself is removed from the store. The associated data in message, part, session_diff, todo, permission, question, and session_status maps are never cleaned up, causing a memory leak that grows with each deleted session.

Similarly, when a message is removed (message.removed event), the corresponding part entries for that message are never deleted.

The web app (packages/app/src/context/global-sync.tsx) already handles this correctly via cleanupSessionCaches() (lines 676-706), but the TUI sync store was never updated to match.

Steps to reproduce:

  1. Open TUI, create several sessions with messages
  2. Delete sessions
  3. Observe that memory usage doesn't decrease — orphaned data remains in the store

Expected behavior:
Deleting a session should clean up all associated keyed data (message, part, session_diff, todo, permission, question, session_status) and remove from fullSyncedSessions. Removing a message should also delete its part entries.

Affected file: packages/opencode/src/cli/cmd/tui/context/sync.tsx

Originally created by @zampxdev on GitHub (Feb 5, 2026). Originally assigned to: @rekram1-node on GitHub. When a session is deleted in the TUI, only the session entry itself is removed from the store. The associated data in `message`, `part`, `session_diff`, `todo`, `permission`, `question`, and `session_status` maps are never cleaned up, causing a memory leak that grows with each deleted session. Similarly, when a message is removed (`message.removed` event), the corresponding `part` entries for that message are never deleted. The web app (`packages/app/src/context/global-sync.tsx`) already handles this correctly via `cleanupSessionCaches()` (lines 676-706), but the TUI sync store was never updated to match. **Steps to reproduce:** 1. Open TUI, create several sessions with messages 2. Delete sessions 3. Observe that memory usage doesn't decrease — orphaned data remains in the store **Expected behavior:** Deleting a session should clean up all associated keyed data (`message`, `part`, `session_diff`, `todo`, `permission`, `question`, `session_status`) and remove from `fullSyncedSessions`. Removing a message should also delete its `part` entries. **Affected file:** `packages/opencode/src/cli/cmd/tui/context/sync.tsx`
yindo added the opentuiperf labels 2026-02-16 18:10:28 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 5, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #12218: TUI store leaks memory on session deletion and message removal

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 5, 2026): This issue might be a duplicate of existing issues. Please check: - #12218: TUI store leaks memory on session deletion and message removal Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8637