fix(plugins): preserve default enablement for relocation

This commit is contained in:
Vincent Koc
2026-04-25 04:55:06 -07:00
parent f70d77b0bd
commit 2b822f6ed0
4 changed files with 44 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ function buildBridgeFromPersistedBundledRecord(
bundledPluginId: record.pluginId,
pluginId: record.pluginId,
npmSpec,
...(record.enabledByDefault === true ? { enabledByDefault: true } : {}),
channelIds: record.contributions.channels,
};
}

View File

@@ -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. */

View File

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

View File

@@ -325,6 +325,7 @@ function isExternalizedBundledPluginEnabled(params: {
origin: "bundled",
config: normalized,
rootConfig: params.config,
enabledByDefault: params.bridge.enabledByDefault,
}).enabled
) {
return true;