repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by admin
extensions/vcs-status/__tests__/branch-change-emitter.ts
Raw// Test-only stand-in for the footer extension.
//
// The owned Pi fixture path-loads extension entrypoints, so this file is
// loaded alongside vcs-status's `index.ts` and exposes a raw
// `footer:branch-change` emitter bound to the shared extension event bus. It
// communicates through `globalThis` because the fixture loads extensions in a
// separate module realm (jiti) that does not share the test file's module graph.
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export interface BranchChangeBridge {
/** Emit a raw `footer:branch-change` payload onto the shared event bus. */
emit?: (payload: unknown) => void;
}
const BRIDGE_KEY = "__vcsStatusBranchChangeBridge";
export default function branchChangeEmitter(pi: ExtensionAPI): void {
const bridge = (globalThis as Record<string, unknown>)[BRIDGE_KEY] as
| BranchChangeBridge
| undefined;
if (!bridge) return;
bridge.emit = (payload) => pi.events.emit("footer:branch-change", payload);
}