[PR #11376] fix(enterprise): clean up share_event and share_compaction on unshare #13762

Open
opened 2026-02-16 18:18:35 -05:00 by yindo · 0 comments
Owner

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

State: open
Merged: No


What does this PR do?

Fixes #11372

When a session is unshared and then reshared, stale data from the previous share appeared mixed with the new data.
This happened because share_event and share_compaction storage entries were not being cleaned up during unshare,
causing old sync events to be replayed when the session was reshared.

Changes:

  • Clean up share_compaction entries in Share.remove()
  • Clean up share_event entries in Share.remove()
  • Add test for the reshare scenario

Memory storage adapter:

A simple in-memory storage adapter was added to enable local development and testing of the enterprise package
without requiring R2/S3 credentials. It is only activated when explicitly setting OPENCODE_STORAGE_ADAPTER=memory - production deployments are unaffected and will continue using r2 or s3 adapters.
If this is not okay then tell me to remove it.

How did you verify your code works?

You can take a look at the attached video.

https://github.com/user-attachments/assets/f0f135ad-8451-4a0a-94d4-6ba2f7258c32

  1. Create a session and send a message ("hi 1" in the shared video)
  2. Share the session with /share
  3. Open the share URL in a browser (this triggers compaction cache)
  4. Unshare with /unshare
  5. /undo and edit the previous message ("hi 2" in the shared video)
  6. Share again with /share
  7. Open/refresh the share URL in browser
  8. Only the new message ("hi 2") is visible, which is the expected behaviour.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11376 **State:** open **Merged:** No --- ### What does this PR do? Fixes #11372 When a session is unshared and then reshared, stale data from the previous share appeared mixed with the new data. This happened because `share_event` and `share_compaction` storage entries were not being cleaned up during unshare, causing old sync events to be replayed when the session was reshared. #### Changes: - Clean up `share_compaction` entries in `Share.remove()` - Clean up `share_event` entries in `Share.remove()` - Add test for the reshare scenario #### Memory storage adapter: A simple in-memory storage adapter was added to enable local development and testing of the enterprise package without requiring R2/S3 credentials. It is only activated when explicitly setting `OPENCODE_STORAGE_ADAPTER=memory` - production deployments are unaffected and will continue using r2 or s3 adapters. If this is not okay then tell me to remove it. ### How did you verify your code works? You can take a look at the attached video. https://github.com/user-attachments/assets/f0f135ad-8451-4a0a-94d4-6ba2f7258c32 1. Create a session and send a message ("hi 1" in the shared video) 2. Share the session with `/share` 3. Open the share URL in a browser (this triggers compaction cache) 4. Unshare with `/unshare` 5. `/undo` and edit the previous message ("hi 2" in the shared video) 6. Share again with `/share` 7. Open/refresh the share URL in browser 8. Only the new message ("hi 2") is visible, which is the expected behaviour.
yindo added the pull-request label 2026-02-16 18:18:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13762