fix(opencode): preserve pending messages on session error#2094
Merged
qin-ctx merged 3 commits intoMay 18, 2026
Merged
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
There was a problem hiding this comment.
Pull request overview
Fixes an OpenCode session lifecycle edge case in the example OpenViking memory plugin so that pending (not-yet-captured) messages aren’t dropped when a session.error event occurs, by treating pendingMessages as unsaved work and triggering the existing commit/cleanup path.
Changes:
- Updated the
session.errorhandler to considerpendingMessages.size > 0as unsaved work (in addition tocapturedMessagesandcommitInFlight). - Ensures the plugin takes the “best-effort background commit” path instead of deleting the session mapping when only pending messages exist.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Thanks for expanding the recovery path. I’ll keep an eye on the checks. |
qin-ctx
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Preserve pending OpenCode messages when a
session.errorevent occurs.Before this change, the
session.errorhandler only treatedcapturedMessagesandcommitInFlightas unsaved work. If a session had messages inpendingMessagesbut no captured messages yet, the session mapping could be cleaned up and those pending messages could be lost.This change includes
pendingMessages.size > 0in the unsaved-work check so the plugin triggers a best-effort background commit instead of deleting the session mapping.Related Issue
Fixes #2093
Type of Change
Changes Made
session.errorhandler inexamples/opencode-memory-plugin/openviking-memory.tspendingMessagesas unsaved work before session cleanupTesting
Manual verification:
git diff --checksession.errorhandlersession.deletedbehavior is unchangedChecklist
Screenshots (if applicable)
N/A
Additional Notes
No tests were added because this example plugin does not appear to have a dedicated test harness in this directory. The change is intentionally scoped to the existing
session.errorrecovery condition.