Skip to content

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

Description

@Limme-swe

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentuiperfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions