fix(config): keep built-in auto-enable idempotent

This commit is contained in:
Vincent Koc 2026-03-23 08:33:57 -07:00
parent 2615402a2b
commit 7299b42e2a
2 changed files with 27 additions and 1 deletions

View File

@ -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: {

View File

@ -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
? (() => {