diff --git a/src/channels/plugins/read-only.test.ts b/src/channels/plugins/read-only.test.ts index ad7404baa00..dc738e80aca 100644 --- a/src/channels/plugins/read-only.test.ts +++ b/src/channels/plugins/read-only.test.ts @@ -216,6 +216,40 @@ describe("listReadOnlyChannelPluginsForConfig", () => { expect(fs.existsSync(fullMarker)).toBe(false); }); + it("clones setup-only plugins for every configured owned channel when setup id matches one channel", () => { + const { pluginDir, fullMarker, setupMarker } = writeExternalSetupChannelPlugin({ + pluginId: "external-chat-plugin", + channelId: "alpha-chat", + manifestChannelIds: ["alpha-chat", "beta-chat"], + setupChannelId: "alpha-chat", + }); + const plugins = listReadOnlyChannelPluginsForConfig( + { + channels: { + "alpha-chat": { token: "configured" }, + "beta-chat": { token: "configured" }, + }, + plugins: { + load: { paths: [pluginDir] }, + allow: ["external-chat-plugin"], + }, + } as never, + { + env: { ...process.env }, + includePersistedAuthState: false, + }, + ); + + const alphaPlugin = plugins.find((entry) => entry.id === "alpha-chat"); + const betaPlugin = plugins.find((entry) => entry.id === "beta-chat"); + expect(alphaPlugin?.meta.id).toBe("alpha-chat"); + expect(betaPlugin?.meta.id).toBe("beta-chat"); + expect(alphaPlugin?.meta.blurb).toBe("setup entry"); + expect(betaPlugin?.meta.blurb).toBe("setup entry"); + expect(fs.existsSync(setupMarker)).toBe(true); + expect(fs.existsSync(fullMarker)).toBe(false); + }); + it("keeps configured external channels visible when no setup entry exists", () => { const { pluginDir, fullMarker, setupMarker } = writeExternalSetupChannelPlugin({ setupEntry: false, diff --git a/src/channels/plugins/read-only.ts b/src/channels/plugins/read-only.ts index fcffad95211..80ac4989d05 100644 --- a/src/channels/plugins/read-only.ts +++ b/src/channels/plugins/read-only.ts @@ -101,6 +101,16 @@ function addSetupChannelPlugins( onlyIds: new Set(ownedMissingChannelIds), allowOverwrite: false, }); + addChannelPlugins( + byId, + ownedMissingChannelIds + .filter((channelId) => channelId !== setup.plugin.id) + .map((channelId) => cloneChannelPluginForChannelId(setup.plugin, channelId)), + { + onlyIds: new Set(ownedMissingChannelIds), + allowOverwrite: false, + }, + ); continue; } if (setup.plugin.id !== setup.pluginId) {