Skip to content

fix(core): scope plugin events to their location - #56346

Open
KairuiLiu wants to merge 1 commit into
anomalyco:devfrom
KairuiLiu:plugin-event-scope
Open

KairuiLiu wants to merge 1 commit into
anomalyco:devfrom
KairuiLiu:plugin-event-scope

Conversation

@KairuiLiu

@KairuiLiu KairuiLiu commented Oct 17, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #56290

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Bind plugin event streams to their host’s Location, restoring filtering lost when activation narrows the Effect context. Global broadcasts and Session-move routing remain unchanged.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

Regression covers Location/workspace isolation and global events

Screenshots / recordings

no UI changes.

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.


Added by the opencode bot (AI-generated).

Related: #54140

Public API: changes plugin ctx.event.subscribe() to deliver only the plugin's own location's events plus global ones (each event still reaches one instance per plugin)

Copilot AI balanced review requested due to automatic review settings October 17, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. I ran the #56290 reproduction from source: with three locations loaded and one session created in p1, the base delivers session.created to all 3 plugin instances; with this change only p1's instance gets it. Global events still arrive. The new test fails on the base and passes here, test/plugin.test.ts passes (21/21), and packages/core type-checks.

Public API: no additions or removals, but what plugins get from ctx.event.subscribe() changes from every event in the server to events for the plugin's own location plus global (unlocated) events. Every location still gets its own instance, so each event still reaches one instance of the plugin. Only a plugin that counted on a single instance seeing other locations' events would notice. Built-in subscribers (the plan-mode reminder, the config plugins' config.updated reloads) now react only to their own location's events, which looks like an improvement.

No blocking concerns.

Related: #54140

@moritzWa

Copy link
Copy Markdown

Hit this with a memory plugin loaded across ~11 Locations: each completed session triggered 11 identical memory-save runs. Independently verified that binding the stream to the host Location fixes it: regression fails without the change; 57 related tests and Core typecheck pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugins: event subscribers fire once per client connection — N× side effects, undocumented

3 participants