fix: avoid duplicate plugin lookup diagnostics

This commit is contained in:
Shakker
2026-04-27 07:19:09 +01:00
parent 635af612d5
commit 123dee0513
2 changed files with 19 additions and 3 deletions

View File

@@ -80,6 +80,18 @@ function createIndex(plugins: readonly PluginManifestRecord[]): PluginRegistrySn
};
}
const indexDiagnostic = {
level: "warn",
source: "/plugins/demo/openclaw.plugin.json",
message: "indexed warning",
} as const;
const manifestDiagnostic = {
level: "warn",
source: "/plugins/demo/openclaw.plugin.json",
message: "manifest warning",
} as const;
describe("loadPluginLookUpTable", () => {
beforeEach(() => {
listPotentialConfiguredChannelIds
@@ -105,10 +117,13 @@ describe("loadPluginLookUpTable", () => {
},
}),
];
const index = createIndex(plugins);
const index = {
...createIndex(plugins),
diagnostics: [indexDiagnostic],
};
const manifestRegistry: PluginManifestRegistry = {
plugins,
diagnostics: [],
diagnostics: [indexDiagnostic, manifestDiagnostic],
};
loadPluginManifestRegistryForInstalledIndex.mockReturnValue(manifestRegistry);
const { loadPluginLookUpTable } = await import("./plugin-lookup-table.js");
@@ -127,6 +142,7 @@ describe("loadPluginLookUpTable", () => {
});
expect(table.manifestRegistry).toBe(manifestRegistry);
expect(table.diagnostics).toEqual([indexDiagnostic, manifestDiagnostic]);
expect(table.byPluginId.get("telegram")?.id).toBe("telegram");
expect(table.normalizePluginId("openai-codex")).toBe("openai");
expect(table.owners.channels.get("telegram")).toEqual(["telegram"]);

View File

@@ -148,7 +148,7 @@ export function loadPluginLookUpTable(params: LoadPluginLookUpTableParams): Plug
registryDiagnostics: registryResult.diagnostics,
manifestRegistry,
plugins: manifestRegistry.plugins,
diagnostics: [...index.diagnostics, ...manifestRegistry.diagnostics],
diagnostics: manifestRegistry.diagnostics,
byPluginId,
normalizePluginId,
owners,