fix(plugins): keep onboarding install records out of config

This commit is contained in:
Vincent Koc
2026-04-25 11:52:04 -07:00
parent bbc0884e23
commit c410e48382
3 changed files with 19 additions and 6 deletions

View File

@@ -313,9 +313,7 @@ describe("ensureChannelSetupPluginInstalled", () => {
expect(result.installed).toBe(true);
expect(result.cfg.plugins?.entries?.["bundled-chat"]?.enabled).toBe(true);
expect(result.cfg.plugins?.allow).toContain("bundled-chat");
expect(result.cfg.plugins?.installs?.["bundled-chat"]?.source).toBe("npm");
expect(result.cfg.plugins?.installs?.["bundled-chat"]?.spec).toBe(bundledChatNpmSpec);
expect(result.cfg.plugins?.installs?.["bundled-chat"]?.installPath).toBe("/tmp/bundled-chat");
expect(result.cfg.plugins?.installs).toBeUndefined();
expect(installPluginFromNpmSpec).toHaveBeenCalledWith(
expect.objectContaining({
expectedIntegrity: bundledChatIntegrity,

View File

@@ -32,7 +32,18 @@ vi.mock("../plugins/enable.js", () => ({
enablePluginInConfig,
}));
const recordPluginInstall = vi.hoisted(() => vi.fn((cfg) => cfg));
const recordPluginInstall = vi.hoisted(() =>
vi.fn((cfg: OpenClawConfig, update: { pluginId: string }) => ({
...cfg,
plugins: {
...cfg.plugins,
installs: {
...cfg.plugins?.installs,
[update.pluginId]: update,
},
},
})),
);
const buildNpmResolutionInstallFields = vi.hoisted(() => vi.fn(() => ({})));
vi.mock("../plugins/installs.js", () => ({
recordPluginInstall,
@@ -123,6 +134,7 @@ describe("ensureOnboardingPluginInstalled", () => {
);
expect(result.installed).toBe(true);
expect(result.status).toBe("installed");
expect(result.cfg.plugins?.installs).toBeUndefined();
});
it("returns a timed out status and notes the retry path when npm install hangs", async () => {
@@ -443,6 +455,7 @@ describe("ensureOnboardingPluginInstalled", () => {
);
expect(result.installed).toBe(true);
expect(result.status).toBe("installed");
expect(result.cfg.plugins?.installs).toBeUndefined();
});
});
@@ -502,6 +515,7 @@ describe("ensureOnboardingPluginInstalled", () => {
);
expect(result.installed).toBe(true);
expect(result.status).toBe("installed");
expect(result.cfg.plugins?.installs).toBeUndefined();
},
);
});

View File

@@ -11,6 +11,7 @@ import { enablePluginInConfig, type PluginEnableResult } from "../plugins/enable
import {
loadPluginInstallRecords,
recordPluginInstallInRecords,
withoutPluginInstallRecords,
writePersistedPluginInstallLedger,
} from "../plugins/install-ledger-store.js";
import { installPluginFromNpmSpec } from "../plugins/install.js";
@@ -166,7 +167,7 @@ async function recordLocalPluginInstall(params: {
cfg: params.cfg,
install,
});
return recordPluginInstall(params.cfg, install);
return withoutPluginInstallRecords(recordPluginInstall(params.cfg, install));
}
function resolveLocalPath(params: {
@@ -574,7 +575,7 @@ export async function ensureOnboardingPluginInstalled(params: {
cfg: next,
install,
});
next = recordPluginInstall(next, install);
next = withoutPluginInstallRecords(recordPluginInstall(next, install));
return {
cfg: next,
installed: true,