From 41016abf8c35c648967e1f3e95d26c4dff3f92e3 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Mon, 19 Oct 2026 13:02:06 -0700 Subject: [PATCH] fix(core): publish sdk.plugin.updated globally across locations (#57181) --- packages/core/src/plugin/sdk.ts | 2 +- packages/core/test/plugin/supervisor.test.ts | 40 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/core/src/plugin/sdk.ts b/packages/core/src/plugin/sdk.ts index a71b2f98c46..7deb71e85ad 100644 --- a/packages/core/src/plugin/sdk.ts +++ b/packages/core/src/plugin/sdk.ts @@ -35,7 +35,7 @@ export const layer = Layer.effect( register: (plugin) => Effect.sync(() => { plugins.set(plugin.id, { ...plugin, revision: String(++revision), source: { type: "sdk" } }) - }).pipe(Effect.andThen(bus.publish(Updated, {})), Effect.asVoid), + }).pipe(Effect.andThen(bus.publish(Updated, {}, { global: true })), Effect.asVoid), all: () => [...plugins.values()], }) }), diff --git a/packages/core/test/plugin/supervisor.test.ts b/packages/core/test/plugin/supervisor.test.ts index 111a02b2074..ffbc2f709cd 100644 --- a/packages/core/test/plugin/supervisor.test.ts +++ b/packages/core/test/plugin/supervisor.test.ts @@ -258,4 +258,44 @@ describe("PluginSupervisor", () => { expect(source.activations).toBe(2) }), ) + + it.effect("reloads all booted locations when sdk.register is called inside a location context", () => + Effect.gen(function* () { + source.activations = 0 + const sdk = yield* SdkPlugins.Service + const dirA = yield* tmpdirScoped() + const dirB = yield* tmpdirScoped() + const refA = Location.Ref.make({ directory: AbsolutePath.make(dirA.path) }) + const refB = Location.Ref.make({ directory: AbsolutePath.make(dirB.path) }) + const locations = yield* LocationServiceMap.Service + + yield* Effect.gen(function* () { + const plugins = yield* Plugin.Service + yield* plugins.awaitActivation + }).pipe(Effect.provide(locations.get(refA))) + + yield* Effect.gen(function* () { + const plugins = yield* Plugin.Service + yield* plugins.awaitActivation + }).pipe(Effect.provide(locations.get(refB))) + + expect(source.activations).toBe(2) + + yield* sdk + .register(greeter("greet-cross-location", "cross-location")) + .pipe(Effect.provide(locations.get(refA))) + + yield* advance(() => source.activations === 4) + + for (const ref of [refA, refB]) { + const command = yield* Effect.gen(function* () { + const plugins = yield* Plugin.Service + const commands = yield* Command.Service + yield* plugins.awaitActivation + return yield* commands.get("greet-cross-location") + }).pipe(Effect.provide(locations.get(ref))) + expect(command).toBeDefined() + } + }), + ) })