Fix OpenCode event session routing#2634
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR changes runtime event routing by switching to a global event API and adding directory-based filtering. While focused and well-tested, the change affects which sessions receive which events, representing a meaningful runtime behavior change that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
8905c26 to
a4eb68f
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a4eb68f. Configure here.
a4eb68f to
fb98a2a
Compare
Dismissing prior approval to re-evaluate fb98a2a
d1e2892 to
45b5d2c
Compare
45b5d2c to
58774a5
Compare
58774a5 to
fb8297c
Compare
Dismissing prior approval to re-evaluate fb8297c
fb8297c to
f4137b5
Compare

Summary
Fixes #2633
Test plan
Note
Medium Risk
Changes how OpenCode runtime events are consumed and filtered (switching to
global.eventand dropping non-matching directories), which could affect event delivery/completion semantics across sessions if the upstream event shape differs.Overview
Routes OpenCode runtime event consumption from the per-session
event.subscribestream toclient.global.event, and updates the adapter to unwrappayloadand ignore events not matching the sessiondirectorybefore projecting provider runtime events.Updates the event type aliasing to reflect the wrapped global-event shape, and extends the test double + adds a regression test that enforces use of
global.event(throwing ifevent.subscribeis called) and validatescontent.deltaemission from wrapped message events for the correct session directory.Reviewed by Cursor Bugbot for commit f4137b5. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix OpenCode event session routing by filtering global events by directory
OpenCodeAdapter.tsfromclient.event.subscribetoclient.global.event, which emits events for all directories.directorymatches the session's working directory are forwarded to the event handler.OpenCodeSubscribedEventtype alias to extract thepayloadfield from global events, resolving toneverfor events without a payload.OpenCodeAdapter.test.tsare updated to simulate long-lived, abortable global event streams and assert directory-scoped filtering behavior.event.subscribeis no longer used; the adapter now receives all directory events globally and filters client-side.Macroscope summarized f4137b5.