From 7299b42e2a0b6fc84fe11614ddbd01097c34cfcc Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 23 Mar 2026 08:33:57 -0700 Subject: [PATCH] fix(config): keep built-in auto-enable idempotent --- src/config/plugin-auto-enable.test.ts | 25 +++++++++++++++++++++++++ src/config/plugin-auto-enable.ts | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/config/plugin-auto-enable.test.ts b/src/config/plugin-auto-enable.test.ts index 088ba2c4ae0..297784e4242 100644 --- a/src/config/plugin-auto-enable.test.ts +++ b/src/config/plugin-auto-enable.test.ts @@ -200,6 +200,31 @@ describe("applyPluginAutoEnable", () => { expect(validated.ok).toBe(true); }); + it("does not re-emit built-in auto-enable changes when rerun with plugins.allow set", () => { + const first = applyPluginAutoEnable({ + config: { + channels: { + whatsapp: { + allowFrom: ["+15555550123"], + }, + }, + plugins: { + allow: ["telegram"], + }, + }, + env: {}, + }); + + const second = applyPluginAutoEnable({ + config: first.config, + env: {}, + }); + + expect(first.changes).toHaveLength(1); + expect(second.changes).toEqual([]); + expect(second.config).toEqual(first.config); + }); + it("respects explicit disable", () => { const result = applyPluginAutoEnable({ config: { diff --git a/src/config/plugin-auto-enable.ts b/src/config/plugin-auto-enable.ts index ceedd38a12b..1892d882502 100644 --- a/src/config/plugin-auto-enable.ts +++ b/src/config/plugin-auto-enable.ts @@ -458,7 +458,8 @@ export function applyPluginAutoEnable(params: { continue; } const allow = next.plugins?.allow; - const allowMissing = Array.isArray(allow) && !allow.includes(entry.pluginId); + const allowMissing = + builtInChannelId == null && Array.isArray(allow) && !allow.includes(entry.pluginId); const alreadyEnabled = builtInChannelId != null ? (() => {