Fix cross-conversation message interference in streaming event routing#73
Merged
Merged
Conversation
- Add session_id to MessagePartUpdatedData (captures server's sessionID) - Add session_id to MessageUpdatedData and fix path type (String -> Value) - Add ProviderEvent::MessageUpdated variant for broadcast - Filter MessagePartUpdated and QuestionAsked by session_id in mapper - Map MessageUpdated with session_id check to ProviderEvent - Cancel stale reader task before spawning new one in subscribe_and_spawn - Add 6 new unit tests for session_id filtering and deserialization - Update existing test fixtures with required session_id field
- Convert inconsistent if/else session_id checks to early-return pattern - Replace nested if-else with match in SessionStatus handler - Deduplicate ProviderEvent::Done pattern matching - Remove intermediate variables (local_completed, proj_str, active_sessions_inner clones) - Move completed_normally store inside the is_done block
olsonjeffery
force-pushed
the
task/16-multiple-conversations-in-diff
branch
from
July 24, 2026 23:55
8d5f377 to
b850022
Compare
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.
Problem
Two concurrent conversations (tasks) sharing one
opencode serveprocess per user experience message interference. The SSE/eventstream multiplexes events from all sessions onto a single connection, and the only filtering was per-eventsession_idchecks — but many event types lacked asession_idfield entirely.Root cause:
MessagePartUpdatedDatahad nosession_idfield. The server sends"sessionID":"ses_..."inside every event'spropertiesobject, but serde silently dropped it during deserialization. As a result, everyTextChunk,ToolUse,ToolResult,Thinking, etc. from session A was forwarded to session B's provider and vice versa.Changes
Phase 1-3: Event data struct fixes
session_idfield toMessagePartUpdatedDataandMessageUpdatedDatainsrc/opencode_sdk/types.rsAssistantMessage.pathtype fromOption<String>toOption<serde_json::Value>to match the server's object formatPhase 4: New ProviderEvent variant
ProviderEvent::MessageUpdatedvariant insrc/providers/types.rsto carry serializedMessageUpdateddata through to the broadcast taskPhase 5: Session-based event filtering
Event::MessagePartUpdated,Event::QuestionAsked, andEvent::MessageUpdatedbysession_idinmap_sdk_event_to_provider_event()Phase 6: Reader task lifecycle fix
subscribe_and_spawn()to prevent stale reader tasks from processing duplicate eventsTesting
Closes #16