mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
fix(plugins): preserve default enablement for relocation
This commit is contained in:
@@ -19,6 +19,7 @@ function buildBridgeFromPersistedBundledRecord(
|
||||
bundledPluginId: record.pluginId,
|
||||
pluginId: record.pluginId,
|
||||
npmSpec,
|
||||
...(record.enabledByDefault === true ? { enabledByDefault: true } : {}),
|
||||
channelIds: record.contributions.channels,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ export type ExternalizedBundledPluginBridge = {
|
||||
npmSpec: string;
|
||||
/** Bundled directory name, when it differs from bundledPluginId. */
|
||||
bundledDirName?: string;
|
||||
/** Previous bundled manifest default enablement from the persisted registry. */
|
||||
enabledByDefault?: boolean;
|
||||
/** Legacy ids that should be treated as this plugin during enablement checks. */
|
||||
legacyPluginIds?: readonly string[];
|
||||
/** Channel ids that imply this plugin is enabled when configured. */
|
||||
|
||||
@@ -1063,6 +1063,46 @@ describe("syncPluginsForUpdateChannel", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("externalizes bundled plugins that were enabled by default", async () => {
|
||||
resolveBundledPluginSourcesMock.mockReturnValue(new Map());
|
||||
installPluginFromNpmSpecMock.mockResolvedValue(
|
||||
createSuccessfulNpmUpdateResult({
|
||||
pluginId: "default-chat",
|
||||
targetDir: "/tmp/openclaw-plugins/default-chat",
|
||||
version: "2.0.0",
|
||||
}),
|
||||
);
|
||||
|
||||
const result = await syncPluginsForUpdateChannel({
|
||||
channel: "stable",
|
||||
externalizedBundledPluginBridges: [
|
||||
{
|
||||
bundledPluginId: "default-chat",
|
||||
enabledByDefault: true,
|
||||
npmSpec: "@openclaw/default-chat",
|
||||
channelIds: ["default-chat"],
|
||||
},
|
||||
],
|
||||
config: {},
|
||||
});
|
||||
|
||||
expect(installPluginFromNpmSpecMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
spec: "@openclaw/default-chat",
|
||||
mode: "update",
|
||||
expectedPluginId: "default-chat",
|
||||
}),
|
||||
);
|
||||
expect(result.changed).toBe(true);
|
||||
expect(result.summary.switchedToNpm).toEqual(["default-chat"]);
|
||||
expect(result.config.plugins?.installs?.["default-chat"]).toMatchObject({
|
||||
source: "npm",
|
||||
spec: "@openclaw/default-chat",
|
||||
installPath: "/tmp/openclaw-plugins/default-chat",
|
||||
version: "2.0.0",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not externalize disabled bundled plugins", async () => {
|
||||
resolveBundledPluginSourcesMock.mockReturnValue(new Map());
|
||||
|
||||
|
||||
@@ -325,6 +325,7 @@ function isExternalizedBundledPluginEnabled(params: {
|
||||
origin: "bundled",
|
||||
config: normalized,
|
||||
rootConfig: params.config,
|
||||
enabledByDefault: params.bridge.enabledByDefault,
|
||||
}).enabled
|
||||
) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user