Skip to content
Source
Sign inSign up
pingdotgg/t3code

Fix OpenCode event session routing #2634

Closedsamjandris(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2634/headopened View on GitHub

Summary

  • switch OpenCode runtime events from the now-empty /event stream to /global/event
  • unwrap global event payloads for the active session directory before using the existing provider event projection
  • 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

Medium Risk Changes how OpenCode runtime events are consumed and filtered (switching to global.event and 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.subscribe stream to client.global.event, and updates the adapter to unwrap payload and ignore events not matching the session directory before 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 if event.subscribe is called) and validates content.delta emission from wrapped message events for the correct session directory.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f4137b564002806f7465ad322d58362cfdcd2477. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix OpenCode event session routing by filtering global events by directory

  • Switches the event subscription in OpenCodeAdapter.ts from client.event.subscribe to client.global.event, which emits events for all directories.
  • Adds directory-based filtering so only events whose directory matches the session's working directory are forwarded to the event handler.
  • Updates the OpenCodeSubscribedEvent type alias to extract the payload field from global events, resolving to never for events without a payload.
  • Test doubles in OpenCodeAdapter.test.ts are updated to simulate long-lived, abortable global event streams and assert directory-scoped filtering behavior.
  • Behavioral Change: event.subscribe is no longer used; the adapter now receives all directory events globally and filters client-side.
Macroscope summarized f4137b5.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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: 55b9fcd7-0c11-4402-8a03-ba38fa940586

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 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](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a4eb68fadae2d34da3243a35ab10dee2725a08d5. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. samjandris(GitHub profile, opens in a new tab)commented

      Replacement PR opened from the corrected fork branch: #2673 (samjandris:fix/opencode-event-stream).

Sign in to join this conversation.