Skip to content

The Open Standard for Generative UI

Share one observability bus across duplicate copies (#1036)

ABb30b1073882f
diff --git a/packages/devtools/package.json b/packages/devtools/package.json
index 19903e42b..1c7926b09 100644
--- a/packages/devtools/package.json
+++ b/packages/devtools/package.json
@@ -1,6 +1,6 @@
{
"name": "@openuidev/devtools",
- "version": "0.0.7",
+ "version": "0.0.8",
"description": "Development-only UI widget for OpenUI apps: surfaces errors captured by @openuidev/observability",
"license": "MIT",
"type": "module",
diff --git a/packages/observability/package.json b/packages/observability/package.json
index ef541cc6f..4c4eb0999 100644
--- a/packages/observability/package.json
+++ b/packages/observability/package.json
@@ -1,6 +1,6 @@
{
"name": "@openuidev/observability",
- "version": "0.0.3",
+ "version": "0.0.4",
"description": "Framework-free observability event bus for OpenUI: emit and listen to events",
"license": "MIT",
"type": "module",
diff --git a/packages/observability/src/observability.test.ts b/packages/observability/src/observability.test.ts
index aeeabc330..c260c24f3 100644
--- a/packages/observability/src/observability.test.ts
+++ b/packages/observability/src/observability.test.ts
@@ -108,6 +108,12 @@ describe("observability bus", () => {
expect(received?.detail.id).toBe("event-1");
});
+ it("shares one bus across duplicate copies via Symbol.for", () => {
+ const key = Symbol.for("openui.observability");
+ const store = globalThis as { [key]?: typeof observability };
+ expect(store[key]).toBe(observability);
+ });
+
it("a throwing listener does not break the others", () => {
const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
const good = vi.fn();
diff --git a/packages/observability/src/observability.ts b/packages/observability/src/observability.ts
index da70bcfe6..533ee599a 100644
--- a/packages/observability/src/observability.ts
+++ b/packages/observability/src/observability.ts
@@ -63,5 +63,11 @@ function createObservability(): Observability {
return bus;
}
-/** The shared observability bus. Import this everywhere — there is one per app. */
-export const observability: Observability = createObservability();
+/**
+ * The shared observability bus. Keyed on globalThis via `Symbol.for` so
+ * duplicate copies of this module (ESM/CJS dual builds, nested package
+ * versions) still share one instance.
+ */
+const BUS_KEY = Symbol.for("openui.observability");
+const store = globalThis as { [BUS_KEY]?: Observability };
+export const observability: Observability = (store[BUS_KEY] ??= createObservability());
diff --git a/packages/react-headless/package.json b/packages/react-headless/package.json
index 779d01b05..11440701a 100644
--- a/packages/react-headless/package.json
+++ b/packages/react-headless/package.json
@@ -1,6 +1,6 @@
{
"name": "@openuidev/react-headless",
- "version": "0.9.9",
+ "version": "0.9.10",
"description": "Headless React primitives for AI chat — state management, streaming adapters for OpenAI, Vercel AI SDK, and AG-UI, message format converters, and thread management for OpenUI generative UI apps",
"license": "MIT",
"type": "module",
diff --git a/packages/react-lang/package.json b/packages/react-lang/package.json
index 8a8fa99fe..58a410073 100644
--- a/packages/react-lang/package.json
+++ b/packages/react-lang/package.json
@@ -1,6 +1,6 @@
{
"name": "@openuidev/react-lang",
- "version": "0.2.13",
+ "version": "0.2.14",
"description": "Define component libraries, generate LLM system prompts, and render streaming OpenUI Lang output in React — the core runtime for OpenUI generative UI",
"license": "MIT",
"type": "module",
diff --git a/packages/react-ui/package.json b/packages/react-ui/package.json
index 8e7f973e5..0d2a3fcd9 100644
--- a/packages/react-ui/package.json
+++ b/packages/react-ui/package.json
@@ -2,7 +2,7 @@
"type": "module",
"name": "@openuidev/react-ui",
"license": "MIT",
- "version": "0.13.7",
+ "version": "0.13.8",
"description": "Component library for Generative UI SDK",
"main": "dist/index.cjs",
"module": "dist/index.mjs",