fix(plugins): guard runtime facade activation (#59412)

* fix(plugins): guard runtime facade activation

* refactor(plugin-sdk): localize facade load policy

* fix(plugin-sdk): narrow facade activation guards

* fix(browser): keep cleanup helpers outside activation guard

* style(browser): apply formatter follow-ups

* chore(changelog): note plugin activation guard regressions

* fix(discord): keep cleanup thread unbinds outside activation guard

* fix(browser): fallback when trash exits non-zero
This commit is contained in:
Vincent Koc
2026-04-02 14:37:12 +09:00
committed by GitHub
parent ed6012eb5b
commit 52a018680d
27 changed files with 509 additions and 57 deletions

View File

@@ -1,11 +1,13 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
const loadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
vi.mock("../plugin-sdk/facade-runtime.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../plugin-sdk/facade-runtime.js")>();
return {
...actual,
loadActivatedBundledPluginPublicSurfaceModuleSync,
loadBundledPluginPublicSurfaceModuleSync,
};
});
@@ -14,6 +16,7 @@ describe("tts runtime facade", () => {
let ttsModulePromise: Promise<typeof import("./tts.js")> | undefined;
beforeEach(() => {
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();
loadBundledPluginPublicSurfaceModuleSync.mockReset();
});
@@ -30,15 +33,15 @@ describe("tts runtime facade", () => {
it("loads speech-core lazily on first runtime access", async () => {
const buildTtsSystemPromptHint = vi.fn().mockReturnValue("hint");
loadBundledPluginPublicSurfaceModuleSync.mockReturnValue({
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReturnValue({
buildTtsSystemPromptHint,
});
const tts = await importTtsModule();
expect(loadBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
expect(tts.buildTtsSystemPromptHint({} as never)).toBe("hint");
expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledTimes(1);
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledTimes(1);
expect(buildTtsSystemPromptHint).toHaveBeenCalledTimes(1);
});
});