fix(doctor): drop stale bundled install records

This commit is contained in:
Vincent Koc
2026-05-04 02:22:40 -07:00
parent 061af13bf3
commit 6b7f9eafed
3 changed files with 48 additions and 5 deletions

View File

@@ -743,6 +743,52 @@ describe("repairMissingConfiguredPluginInstalls", () => {
});
});
it("removes stale bundled install records even when the plugin is not configured", async () => {
const records = {
"google-meet": {
source: "npm",
spec: "@openclaw/google-meet",
resolvedName: "@openclaw/google-meet",
installPath: "/missing/google-meet",
},
};
mocks.loadInstalledPluginIndexInstallRecords.mockResolvedValue(records);
mocks.loadPluginMetadataSnapshot.mockReturnValue({
plugins: [],
diagnostics: [],
});
mocks.loadInstalledPluginIndex.mockReturnValue({
plugins: [
{
pluginId: "google-meet",
origin: "bundled",
packageName: "@openclaw/google-meet",
},
],
diagnostics: [],
installRecords: {},
});
const { repairMissingConfiguredPluginInstalls } =
await import("./missing-configured-plugin-install.js");
const result = await repairMissingConfiguredPluginInstalls({
cfg: {},
env: {},
});
expect(mocks.installPluginFromNpmSpec).not.toHaveBeenCalled();
expect(mocks.writePersistedInstalledPluginIndexInstallRecords).toHaveBeenCalledWith(
{},
{
env: {},
},
);
expect(result).toEqual({
changes: ['Removed stale managed install record for bundled plugin "google-meet".'],
warnings: [],
});
});
it.each([
[
"npm",

View File

@@ -646,11 +646,7 @@ async function repairMissingPluginInstalls(params: {
for (const [pluginId, record] of Object.entries(records)) {
const bundled = bundledPluginsById.get(pluginId);
if (
!bundled ||
!params.pluginIds.has(pluginId) ||
!recordMatchesBundledPackage(record, bundled)
) {
if (!bundled || !recordMatchesBundledPackage(record, bundled)) {
continue;
}
if (nextRecords === records) {