fix: preserve built-in channel auto-enable fallback

This commit is contained in:
Shakker
2026-07-02 17:05:33 +01:00
committed by Shakker
parent d2d20b5fed
commit c032f9809d
2 changed files with 38 additions and 1 deletions

View File

@@ -273,6 +273,37 @@ describe("applyPluginAutoEnable channels", () => {
);
});
it("keeps built-in channel enablement when a same-id plugin does not claim the channel", () => {
const result = materializePluginAutoEnableCandidates({
config: {
channels: {
telegram: {
botToken: "token",
},
},
},
candidates: [
{
pluginId: "telegram",
kind: "channel-configured",
channelId: "telegram",
},
],
env: makeIsolatedEnv(),
manifestRegistry: makeRegistry([
{
id: "telegram",
channels: ["unrelated-channel"],
origin: "global",
},
]),
});
expect(result.config.channels?.telegram?.enabled).toBe(true);
expect(result.config.plugins?.entries?.telegram).toBeUndefined();
expect(result.changes).toContain("Telegram configured, enabled automatically.");
});
it("uses the plugin manifest id, not the channel id, for plugins.entries", () => {
const result = applyWithApnChannelConfig();

View File

@@ -868,7 +868,13 @@ function resolveAutoEnableChannelId(params: {
(record) => record.id === params.entry.pluginId,
);
if (plugin && plugin.origin !== "bundled") {
return null;
if (params.entry.kind !== "channel-configured") {
return null;
}
const channelId = normalizeManifestChannelId(params.entry.channelId);
if ((plugin.channels ?? []).some((id) => normalizeManifestChannelId(id) === channelId)) {
return null;
}
}
const builtInChannelId = normalizeChatChannelId(params.entry.pluginId);
if (builtInChannelId) {