fix(regression): widen preseeded cli plugin registry loads

This commit is contained in:
Tak Hoffman
2026-03-27 22:29:09 -05:00
parent 967702d928
commit 0946fdf625
2 changed files with 30 additions and 1 deletions

View File

@@ -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",
}),
);
});
});

View File

@@ -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();