Skip to content

Fix OpenCode event session routing#2634

Open
samjandris wants to merge 1 commit intopingdotgg:mainfrom
samjandris:feature/feat/opencode-content-delta
Open

Fix OpenCode event session routing#2634
samjandris wants to merge 1 commit intopingdotgg:mainfrom
samjandris:feature/feat/opencode-content-delta

Conversation

@samjandris
Copy link
Copy Markdown

@samjandris samjandris commented May 11, 2026

Summary

  • switch OpenCode runtime events from the now-empty /event stream to /global/event
  • unwrap global event payloads and ignore events for other directories before projecting provider events
  • add regression coverage that the adapter uses the global event stream and handles wrapped OpenCode message events

Fixes #2633

Test plan

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run --cwd apps/server test src/provider/Layers/OpenCodeAdapter.test.ts

Note

Fix OpenCode session event routing to use global.event filtered by directory

  • Switches startEventPump in OpenCodeAdapter.ts from client.event.subscribe to client.global.event, which provides a single stream of all runtime events.
  • Adds per-event filtering by session directory so only events matching the session's context.directory are forwarded to handleSubscribedEvent.
  • Updates type aliases to derive OpenCodeGlobalStreamEvent and OpenCodeSubscribedEvent from the global.event source.
  • Adds a test double for global.event in OpenCodeAdapter.test.ts and throws on any call to event.subscribe to enforce the new routing.
  • Behavioral Change: events from other directories or without a valid payload (with type and properties) are now silently dropped.

Macroscope summarized fb8297c.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4cc29bce-ef49-41d9-bac7-419fc3c9f4dc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 11, 2026
Comment thread apps/server/src/provider/Layers/OpenCodeAdapter.ts Outdated
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 11, 2026

Approvability

Verdict: Needs human review

Changes event routing logic from session-specific subscription to global event stream with directory filtering. While the bug fix intent is clear and well-tested, runtime behavior changes to event processing warrant human review, especially given the 'wip' designation in the title.

You can customize Macroscope's approvability policy. Learn more.

@samjandris samjandris force-pushed the feature/feat/opencode-content-delta branch from 8905c26 to a4eb68f Compare May 11, 2026 00:56
@samjandris samjandris changed the title Fix OpenCode assistant streaming Fix OpenCode event session routing May 11, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/server/src/provider/Layers/OpenCodeAdapter.ts
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 11, 2026
@samjandris samjandris force-pushed the feature/feat/opencode-content-delta branch from a4eb68f to fb98a2a Compare May 11, 2026 01:05
@macroscopeapp macroscopeapp Bot dismissed their stale review May 11, 2026 01:06

Dismissing prior approval to re-evaluate fb98a2a

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels May 11, 2026
@samjandris samjandris changed the title Fix OpenCode event session routing wip: Fix OpenCode event session routing May 11, 2026
@samjandris samjandris marked this pull request as draft May 11, 2026 01:08
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 11, 2026
@samjandris samjandris force-pushed the feature/feat/opencode-content-delta branch 2 times, most recently from d1e2892 to 45b5d2c Compare May 11, 2026 01:25
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels May 11, 2026
@samjandris samjandris force-pushed the feature/feat/opencode-content-delta branch from 45b5d2c to 58774a5 Compare May 11, 2026 02:08
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels May 11, 2026
@samjandris samjandris force-pushed the feature/feat/opencode-content-delta branch from 58774a5 to fb8297c Compare May 11, 2026 03:32
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels May 11, 2026
@samjandris samjandris marked this pull request as ready for review May 11, 2026 03:38
@macroscopeapp macroscopeapp Bot dismissed their stale review May 11, 2026 03:38

Dismissing prior approval to re-evaluate fb8297c

@samjandris samjandris changed the title wip: Fix OpenCode event session routing Fix OpenCode event session routing May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenCode not syncing/working

1 participant