From 2d97dcebb5fca0bdba6a6792a52258cf8c4a6225 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 6 May 2026 19:05:58 +0100 Subject: [PATCH] perf(config): skip bootstrap for false env channel probes --- src/config/plugin-auto-enable.shared.ts | 47 +++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/config/plugin-auto-enable.shared.ts b/src/config/plugin-auto-enable.shared.ts index 10644abbe98..df27178c228 100644 --- a/src/config/plugin-auto-enable.shared.ts +++ b/src/config/plugin-auto-enable.shared.ts @@ -1,6 +1,13 @@ import { collectConfiguredAgentHarnessRuntimes } from "../agents/harness-runtimes.js"; import { normalizeProviderId } from "../agents/provider-id.js"; -import { listPotentialConfiguredChannelPresenceSignals } from "../channels/config-presence.js"; +import { + listPotentialConfiguredChannelPresenceSignals, + type ChannelPresenceSignalSource, +} from "../channels/config-presence.js"; +import { + hasBundledChannelConfiguredState, + listBundledChannelIdsWithConfiguredState, +} from "../channels/plugins/configured-state.js"; import { getChatChannelMeta, normalizeChatChannelId } from "../channels/registry.js"; import { getCurrentPluginMetadataSnapshot } from "../plugins/current-plugin-metadata-snapshot.js"; import { @@ -253,11 +260,45 @@ function collectPluginIdsForConfiguredChannel( } function collectConfiguredChannelIds(cfg: OpenClawConfig, env: NodeJS.ProcessEnv): string[] { + const configuredStateChannelIds = new Set(listBundledChannelIdsWithConfiguredState()); return listPotentialConfiguredChannelPresenceSignals(cfg, env, { includePersistedAuthState: false, }) - .map((signal) => normalizeChatChannelId(signal.channelId) ?? signal.channelId) - .filter((channelId) => isChannelConfigured(cfg, channelId, env)); + .map((signal) => ({ + source: signal.source, + channelId: normalizeChatChannelId(signal.channelId) ?? signal.channelId, + })) + .filter(({ channelId, source }) => + isAutoEnableConfiguredChannelSignal({ + cfg, + env, + channelId, + source, + configuredStateChannelIds, + }), + ) + .map(({ channelId }) => channelId); +} + +function isAutoEnableConfiguredChannelSignal(params: { + cfg: OpenClawConfig; + env: NodeJS.ProcessEnv; + channelId: string; + source: ChannelPresenceSignalSource; + configuredStateChannelIds: ReadonlySet; +}): boolean { + if ( + params.source === "env" && + params.configuredStateChannelIds.has(params.channelId) && + !hasBundledChannelConfiguredState({ + channelId: params.channelId, + cfg: params.cfg, + env: params.env, + }) + ) { + return false; + } + return isChannelConfigured(params.cfg, params.channelId, params.env); } function hasConfiguredWebSearchPluginEntry(cfg: OpenClawConfig): boolean {