Skip to content

Commit c032f98

Browse files
committed
fix: preserve built-in channel auto-enable fallback
1 parent d2d20b5 commit c032f98

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/config/plugin-auto-enable.channels.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,37 @@ describe("applyPluginAutoEnable channels", () => {
273273
);
274274
});
275275

276+
it("keeps built-in channel enablement when a same-id plugin does not claim the channel", () => {
277+
const result = materializePluginAutoEnableCandidates({
278+
config: {
279+
channels: {
280+
telegram: {
281+
botToken: "token",
282+
},
283+
},
284+
},
285+
candidates: [
286+
{
287+
pluginId: "telegram",
288+
kind: "channel-configured",
289+
channelId: "telegram",
290+
},
291+
],
292+
env: makeIsolatedEnv(),
293+
manifestRegistry: makeRegistry([
294+
{
295+
id: "telegram",
296+
channels: ["unrelated-channel"],
297+
origin: "global",
298+
},
299+
]),
300+
});
301+
302+
expect(result.config.channels?.telegram?.enabled).toBe(true);
303+
expect(result.config.plugins?.entries?.telegram).toBeUndefined();
304+
expect(result.changes).toContain("Telegram configured, enabled automatically.");
305+
});
306+
276307
it("uses the plugin manifest id, not the channel id, for plugins.entries", () => {
277308
const result = applyWithApnChannelConfig();
278309

src/config/plugin-auto-enable.shared.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,13 @@ function resolveAutoEnableChannelId(params: {
868868
(record) => record.id === params.entry.pluginId,
869869
);
870870
if (plugin && plugin.origin !== "bundled") {
871-
return null;
871+
if (params.entry.kind !== "channel-configured") {
872+
return null;
873+
}
874+
const channelId = normalizeManifestChannelId(params.entry.channelId);
875+
if ((plugin.channels ?? []).some((id) => normalizeManifestChannelId(id) === channelId)) {
876+
return null;
877+
}
872878
}
873879
const builtInChannelId = normalizeChatChannelId(params.entry.pluginId);
874880
if (builtInChannelId) {

0 commit comments

Comments
 (0)