From 0946fdf625da38707d77d4a397e678f3d5a37fe4 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 27 Mar 2026 22:29:09 -0500 Subject: [PATCH] fix(regression): widen preseeded cli plugin registry loads --- src/cli/plugin-registry.test.ts | 28 ++++++++++++++++++++++++++++ src/cli/plugin-registry.ts | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/cli/plugin-registry.test.ts b/src/cli/plugin-registry.test.ts index d4dd69dfb39..34035579348 100644 --- a/src/cli/plugin-registry.test.ts +++ b/src/cli/plugin-registry.test.ts @@ -145,4 +145,32 @@ describe("ensurePluginRegistryLoaded", () => { }), ); }); + + it("does not treat a pre-seeded partial registry as all scope", async () => { + const config = { + plugins: { enabled: true }, + channels: { "demo-channel-a": { enabled: true } }, + }; + + mocks.loadConfig.mockReturnValue(config); + mocks.applyPluginAutoEnable.mockReturnValue({ config, changes: [] }); + mocks.getActivePluginRegistry.mockReturnValue({ + plugins: [], + channels: [{ plugin: { id: "demo-channel-a" } }], + tools: [], + }); + + const { ensurePluginRegistryLoaded } = await import("./plugin-registry.js"); + + ensurePluginRegistryLoaded({ scope: "all" }); + + expect(mocks.loadOpenClawPlugins).toHaveBeenCalledTimes(1); + expect(mocks.loadOpenClawPlugins).toHaveBeenCalledWith( + expect.objectContaining({ + config, + throwOnLoadError: true, + workspaceDir: "/tmp/workspace", + }), + ); + }); }); diff --git a/src/cli/plugin-registry.ts b/src/cli/plugin-registry.ts index 7b48a771427..11151ea526f 100644 --- a/src/cli/plugin-registry.ts +++ b/src/cli/plugin-registry.ts @@ -37,11 +37,12 @@ export function ensurePluginRegistryLoaded(options?: { scope?: PluginRegistrySco // Tests (and callers) can pre-seed a registry (e.g. `test/setup.ts`); avoid // doing an expensive load when we already have plugins/channels/tools. if ( + scope !== "all" && pluginRegistryLoaded === "none" && active && (active.plugins.length > 0 || active.channels.length > 0 || active.tools.length > 0) ) { - pluginRegistryLoaded = "all"; + pluginRegistryLoaded = scope; return; } const config = loadConfig();