Skip to content

Commit c094667

Browse files
fix: preserve configured channel plugin access (#116540)
1 parent d1d2ad7 commit c094667

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎src/config/plugin-auto-enable.core.test.ts‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,54 @@ describe("applyPluginAutoEnable core", () => {
108108
]);
109109
});
110110

111+
it("keeps configured channel candidates when plugin config is already present", () => {
112+
const result = applyPluginAutoEnable({
113+
config: {
114+
channels: {
115+
discord: {
116+
enabled: true,
117+
accounts: { default: { token: "redacted" } },
118+
},
119+
},
120+
plugins: {
121+
entries: {
122+
discord: { config: {} },
123+
},
124+
},
125+
},
126+
env,
127+
manifestRegistry: makeRegistry([{ id: "discord", channels: ["discord"], origin: "global" }]),
128+
});
129+
130+
expect(result.config.plugins?.entries?.discord).toEqual({ config: {}, enabled: true });
131+
expect(result.changes).toContain("Discord configured, enabled automatically.");
132+
});
133+
134+
it("keeps configured channel candidates under a material plugin allowlist", () => {
135+
const candidates = detectPluginAutoEnableCandidates({
136+
config: {
137+
channels: { discord: { token: "redacted" } },
138+
plugins: {
139+
allow: ["existing"],
140+
entries: {
141+
existing: { enabled: true },
142+
},
143+
},
144+
},
145+
env,
146+
manifestRegistry: makeRegistry([
147+
{ id: "discord", channels: ["discord"], origin: "global" },
148+
{ id: "existing", channels: [], origin: "global" },
149+
]),
150+
});
151+
152+
expect(candidates).toContainEqual({
153+
pluginId: "discord",
154+
kind: "channel-configured",
155+
channelId: "discord",
156+
});
157+
});
158+
111159
it("reuses policy-compatible current manifest registry when runtime config differs", () => {
112160
const manifestRegistry = makeRegistry([{ id: "custom-chat", channels: ["custom-chat"] }]);
113161
const snapshotConfig: OpenClawConfig = { plugins: { allow: ["existing"] } };
@@ -1272,7 +1320,7 @@ describe("applyPluginAutoEnable core", () => {
12721320
const result = applyPluginAutoEnable({
12731321
config: {
12741322
channels: { slack: { botToken: "x" } },
1275-
plugins: { entries: { slack: { enabled: false } } },
1323+
plugins: { entries: { slack: { enabled: false, config: {} } } },
12761324
},
12771325
env,
12781326
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,13 @@ export function resolvePluginAutoEnableReadiness(
573573
if (arePluginsGloballyDisabled(cfg)) {
574574
return { mayNeedAutoEnable: false, configuredChannelIds: [] };
575575
}
576+
const configuredChannelIds = collectConfiguredChannelIds(cfg, env, discovery, ambientEnvTriggers);
576577
if (hasPluginAllowlistWithMaterialEntries(cfg)) {
577-
return { mayNeedAutoEnable: true, configuredChannelIds: [] };
578+
return { mayNeedAutoEnable: true, configuredChannelIds };
578579
}
579580
if (hasConfiguredPluginConfigEntry(cfg)) {
580-
return { mayNeedAutoEnable: true, configuredChannelIds: [] };
581+
return { mayNeedAutoEnable: true, configuredChannelIds };
581582
}
582-
const configuredChannelIds = collectConfiguredChannelIds(cfg, env, discovery, ambientEnvTriggers);
583583
if (configuredChannelIds.length > 0) {
584584
return { mayNeedAutoEnable: true, configuredChannelIds };
585585
}

0 commit comments

Comments
 (0)