From 62d6cfedeedc76468c7ed46c95547db330ee2cc4 Mon Sep 17 00:00:00 2001 From: Dinakar Sarbada Date: Mon, 30 Mar 2026 14:06:04 -0700 Subject: [PATCH] fix(doctor/plugins): skip unused Matrix inspector loads and honor enabledByDefault startup plugins (#57931) Merged via squash. Prepared head SHA: 634794b954d147056dc716b14dbaf52d733e5a58 Co-authored-by: dinakars777 <250428393+dinakars777@users.noreply.github.com> Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Reviewed-by: @gumadeiras --- CHANGELOG.md | 1 + src/infra/matrix-legacy-crypto.test.ts | 27 ++++++++++++++++++++++++++ src/infra/matrix-legacy-crypto.ts | 22 ++++++++++++++++++++- src/plugins/channel-plugin-ids.test.ts | 14 +++++++++---- src/plugins/channel-plugin-ids.ts | 3 ++- 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f76dba0c52..c2e75fe997d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,6 +110,7 @@ Docs: https://docs.openclaw.ai - Agents/subagents: fix interim subagent runtime display so `/subagents list` and `/subagents info` stop inflating short runtimes and show second-level durations correctly. (#57739) Thanks @samzong. - Diffs/config: preserve schema-shaped plugin config parsing from `diffsPluginConfigSchema.safeParse()`, so direct callers keep `defaults` and `security` sections instead of receiving flattened tool defaults. (#57904) Thanks @gumadeiras. - Diffs: fall back to plain text when `lang` hints are invalid during diff render and viewer hydration, so bad or stale language values no longer break the diff viewer. (#57902) Thanks @gumadeiras. +- Doctor/plugins: skip false Matrix legacy-helper warnings when no migration plans exist, and keep bundled `enabledByDefault` plugins in the gateway startup set. (#57931) Thanks @dinakars777. ## 2026.3.28 diff --git a/src/infra/matrix-legacy-crypto.test.ts b/src/infra/matrix-legacy-crypto.test.ts index 03e210cd79a..6d413c690f1 100644 --- a/src/infra/matrix-legacy-crypto.test.ts +++ b/src/infra/matrix-legacy-crypto.test.ts @@ -176,6 +176,33 @@ describe("matrix legacy encrypted-state migration", () => { ); }); + it("skips inspector loading when no legacy Matrix plans exist", async () => { + await withTempHome( + async () => { + const matrixHelperModule = await import("./matrix-plugin-helper.js"); + const loadInspectorSpy = vi.spyOn(matrixHelperModule, "loadMatrixLegacyCryptoInspector"); + + const result = await autoPrepareLegacyMatrixCrypto({ + cfg: createDefaultMatrixConfig(), + env: process.env, + }); + + expect(result).toEqual({ + migrated: false, + changes: [], + warnings: [], + }); + expect(result.warnings).not.toContain(MATRIX_LEGACY_CRYPTO_INSPECTOR_UNAVAILABLE_MESSAGE); + expect(loadInspectorSpy).not.toHaveBeenCalled(); + }, + { + env: { + OPENCLAW_BUNDLED_PLUGINS_DIR: (home) => path.join(home, "empty-bundled"), + }, + }, + ); + }); + it("warns when legacy local-only room keys cannot be recovered automatically", async () => { await withTempHome(async (home) => { const { cfg, rootDir } = writeDefaultLegacyCryptoFixture(home); diff --git a/src/infra/matrix-legacy-crypto.ts b/src/infra/matrix-legacy-crypto.ts index e64251e27ae..1fdefdc39fc 100644 --- a/src/infra/matrix-legacy-crypto.ts +++ b/src/infra/matrix-legacy-crypto.ts @@ -328,9 +328,22 @@ export async function autoPrepareLegacyMatrixCrypto(params: { : detectLegacyMatrixCrypto({ cfg: params.cfg, env }); const warnings = [...detection.warnings]; const changes: string[] = []; - let inspectLegacyStore = params.deps?.inspectLegacyStore; const writeJsonFileAtomically = params.deps?.writeJsonFileAtomically ?? writeJsonFileAtomicallyImpl; + if (detection.plans.length === 0) { + if (warnings.length > 0) { + params.log?.warn?.( + `matrix: legacy encrypted-state warnings:\n${warnings.map((entry) => `- ${entry}`).join("\n")}`, + ); + } + return { + migrated: false, + changes, + warnings, + }; + } + + let inspectLegacyStore = params.deps?.inspectLegacyStore; if (!inspectLegacyStore) { try { inspectLegacyStore = await loadMatrixLegacyCryptoInspector({ @@ -354,6 +367,13 @@ export async function autoPrepareLegacyMatrixCrypto(params: { }; } } + if (!inspectLegacyStore) { + return { + migrated: false, + changes, + warnings, + }; + } for (const plan of detection.plans) { const existingState = loadLegacyCryptoMigrationState(plan.statePath); diff --git a/src/plugins/channel-plugin-ids.test.ts b/src/plugins/channel-plugin-ids.test.ts index f3adc712405..43d9ba9344f 100644 --- a/src/plugins/channel-plugin-ids.test.ts +++ b/src/plugins/channel-plugin-ids.test.ts @@ -138,19 +138,25 @@ describe("resolveGatewayStartupPluginIds", () => { enabledPluginIds: ["demo-bundled-sidecar"], modelId: "demo-cli/demo-model", }), - ["demo-channel", "demo-provider-plugin", "demo-bundled-sidecar", "demo-global-sidecar"], + [ + "demo-channel", + "demo-default-on-sidecar", + "demo-provider-plugin", + "demo-bundled-sidecar", + "demo-global-sidecar", + ], ], [ - "does not pull default-on bundled non-channel plugins into startup", + "includes bundled plugins with enabledByDefault: true", {} as OpenClawConfig, - ["demo-channel", "demo-global-sidecar"], + ["demo-channel", "demo-default-on-sidecar", "demo-global-sidecar"], ], [ "auto-loads bundled plugins referenced by configured provider ids", createStartupConfig({ providerIds: ["demo-provider"], }), - ["demo-channel", "demo-provider-plugin", "demo-global-sidecar"], + ["demo-channel", "demo-default-on-sidecar", "demo-provider-plugin", "demo-global-sidecar"], ], ] as const)("%s", (_name, config, expected) => { expectStartupPluginIdsCase({ config, expected }); diff --git a/src/plugins/channel-plugin-ids.ts b/src/plugins/channel-plugin-ids.ts index 51c7177f63c..a6a268bef54 100644 --- a/src/plugins/channel-plugin-ids.ts +++ b/src/plugins/channel-plugin-ids.ts @@ -337,7 +337,8 @@ export function resolveGatewayStartupPluginIds(params: { return ( pluginsConfig.allow.includes(plugin.id) || pluginsConfig.entries[plugin.id]?.enabled === true || - pluginsConfig.slots.memory === plugin.id + pluginsConfig.slots.memory === plugin.id || + plugin.enabledByDefault === true ); }) .map((plugin) => plugin.id);