mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 13:13:06 +00:00
fix(regression): scope channel setup reloads by channel registry
This commit is contained in:
@@ -64,7 +64,11 @@ import type { ChannelPluginCatalogEntry } from "../../channels/plugins/catalog.j
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { loadOpenClawPlugins } from "../../plugins/loader.js";
|
||||
import { createEmptyPluginRegistry } from "../../plugins/registry.js";
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import {
|
||||
pinActivePluginChannelRegistry,
|
||||
releasePinnedPluginChannelRegistry,
|
||||
setActivePluginRegistry,
|
||||
} from "../../plugins/runtime.js";
|
||||
import { createPluginRecord } from "../../plugins/status.test-helpers.js";
|
||||
import type { WizardPrompter } from "../../wizard/prompts.js";
|
||||
import { makePrompter, makeRuntime } from "../setup/__tests__/test-utils.js";
|
||||
@@ -448,6 +452,40 @@ describe("ensureChannelSetupPluginInstalled", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("scopes channel reloads when the global registry is populated but the pinned channel registry is empty", () => {
|
||||
const runtime = makeRuntime();
|
||||
const cfg: OpenClawConfig = {};
|
||||
const activeRegistry = createEmptyPluginRegistry();
|
||||
activeRegistry.plugins.push(
|
||||
createPluginRecord({
|
||||
id: "loaded-tools",
|
||||
name: "loaded-tools",
|
||||
source: "/tmp/loaded-tools.cjs",
|
||||
origin: "bundled",
|
||||
}),
|
||||
);
|
||||
setActivePluginRegistry(activeRegistry);
|
||||
const pinnedChannelRegistry = createEmptyPluginRegistry();
|
||||
pinActivePluginChannelRegistry(pinnedChannelRegistry);
|
||||
|
||||
try {
|
||||
reloadChannelSetupPluginRegistryForChannel({
|
||||
cfg,
|
||||
runtime,
|
||||
channel: "telegram",
|
||||
workspaceDir: "/tmp/openclaw-workspace",
|
||||
});
|
||||
} finally {
|
||||
releasePinnedPluginChannelRegistry(pinnedChannelRegistry);
|
||||
}
|
||||
|
||||
expect(loadOpenClawPlugins).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
onlyPluginIds: ["telegram"],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("can load a channel-scoped snapshot without activating the global registry", () => {
|
||||
const runtime = makeRuntime();
|
||||
const cfg: OpenClawConfig = {};
|
||||
|
||||
@@ -17,7 +17,7 @@ import { buildNpmResolutionInstallFields, recordPluginInstall } from "../../plug
|
||||
import { loadOpenClawPlugins } from "../../plugins/loader.js";
|
||||
import { createPluginLoaderLogger } from "../../plugins/logger.js";
|
||||
import type { PluginRegistry } from "../../plugins/registry.js";
|
||||
import { getActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { getActivePluginChannelRegistry } from "../../plugins/runtime.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import type { WizardPrompter } from "../../wizard/prompts.js";
|
||||
|
||||
@@ -265,7 +265,7 @@ export function reloadChannelSetupPluginRegistryForChannel(params: {
|
||||
pluginId?: string;
|
||||
workspaceDir?: string;
|
||||
}): void {
|
||||
const activeRegistry = getActivePluginRegistry();
|
||||
const activeRegistry = getActivePluginChannelRegistry();
|
||||
// On low-memory hosts, the empty-registry fallback should only recover the selected
|
||||
// plugin instead of importing every bundled extension during setup.
|
||||
const onlyPluginIds = activeRegistry?.plugins.length
|
||||
|
||||
Reference in New Issue
Block a user