Skip to content

Commit 74f243a

Browse files
authored
fix(cli): keep plugin toggles out of channel config (#76525)
1 parent f27ecff commit 74f243a

4 files changed

Lines changed: 34 additions & 8 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Docs: https://docs.openclaw.ai
1919

2020
### Fixes
2121

22+
- CLI/plugins: keep `plugins enable` and `plugins disable` from creating unconfigured channel config sections, so channel plugins with required setup fields no longer fail validation during lifecycle probes. Thanks @vincentkoc.
2223
- Agents/sessions: keep delayed `sessions_send` A2A replies alive after soft wait-window timeouts, while preserving terminal run timeouts and avoiding stale target replies in requester sessions. Fixes #76443. Thanks @ryswork1993 and @vincentkoc.
2324
- CLI/sessions: keep intentional empty agent replies silent after tool-delivered channel output, instead of surfacing a misleading "No reply from agent." fallback. Thanks @vincentkoc.
2425
- Config/doctor: cap `.clobbered.*` forensic snapshots per config path and serialize snapshot writes so repeated `doctor --fix` recovery loops cannot flood the config directory. Fixes #76454; carries forward #65649. Thanks @JUSTICEESSIELP, @rsnow, and @vincentkoc.

‎src/cli/plugins-cli-test-helpers.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,15 @@ vi.mock("../plugins/marketplace.js", () => ({
198198
}));
199199

200200
vi.mock("../plugins/enable.js", () => ({
201-
enablePluginInConfig: ((cfg: OpenClawConfig, pluginId: string) =>
202-
invokeMock<[OpenClawConfig, string], unknown>(
201+
enablePluginInConfig: ((
202+
...args: Parameters<(typeof import("../plugins/enable.js"))["enablePluginInConfig"]>
203+
) =>
204+
invokeMock<
205+
Parameters<(typeof import("../plugins/enable.js"))["enablePluginInConfig"]>,
206+
unknown
207+
>(
203208
enablePluginInConfig,
204-
cfg,
205-
pluginId,
209+
...args,
206210
)) as (typeof import("../plugins/enable.js"))["enablePluginInConfig"],
207211
}));
208212

‎src/cli/plugins-cli.policy.test.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ describe("plugins cli policy mutations", () => {
3232
}
3333

3434
it("refreshes the persisted plugin registry after enabling a plugin", async () => {
35+
const sourceConfig = {} as OpenClawConfig;
3536
const enabledConfig = {
3637
plugins: {
3738
entries: {
3839
alpha: { enabled: true },
3940
},
4041
},
4142
} as OpenClawConfig;
42-
loadConfig.mockReturnValue({} as OpenClawConfig);
43+
loadConfig.mockReturnValue(sourceConfig);
4344
enablePluginInConfig.mockReturnValue({
4445
config: enabledConfig,
4546
enabled: true,
@@ -49,6 +50,9 @@ describe("plugins cli policy mutations", () => {
4950

5051
await runPluginsCommand(["plugins", "enable", "alpha"]);
5152

53+
expect(enablePluginInConfig).toHaveBeenCalledWith(sourceConfig, "alpha", {
54+
updateChannelConfig: false,
55+
});
5256
expect(writeConfigFile).toHaveBeenCalledWith(enabledConfig);
5357
expect(refreshPluginRegistry).toHaveBeenCalledWith({
5458
config: enabledConfig,
@@ -100,7 +104,9 @@ describe("plugins cli policy mutations", () => {
100104

101105
await runPluginsCommand(["plugins", "enable", alias]);
102106

103-
expect(enablePluginInConfig).toHaveBeenCalledWith(sourceConfig, pluginId);
107+
expect(enablePluginInConfig).toHaveBeenCalledWith(sourceConfig, pluginId, {
108+
updateChannelConfig: false,
109+
});
104110
expect(writeConfigFile).toHaveBeenCalledWith(enabledConfig);
105111
},
106112
);
@@ -142,4 +148,15 @@ describe("plugins cli policy mutations", () => {
142148
expect(refreshPluginRegistry).not.toHaveBeenCalled();
143149
},
144150
);
151+
152+
it("does not create a channel config when disabling a channel plugin by policy", async () => {
153+
loadConfig.mockReturnValue({} as OpenClawConfig);
154+
mockPluginRegistry(["twitch"]);
155+
156+
await runPluginsCommand(["plugins", "disable", "twitch"]);
157+
158+
const nextConfig = writeConfigFile.mock.calls[0]?.[0] as OpenClawConfig;
159+
expect(nextConfig.plugins?.entries?.twitch?.enabled).toBe(false);
160+
expect(nextConfig.channels?.twitch).toBeUndefined();
161+
});
145162
});

‎src/cli/plugins-cli.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ export function registerPluginsCli(program: Command) {
126126
if (!report.plugins.some((plugin) => matchesPluginId(plugin, id))) {
127127
return reportMissingPlugin(id);
128128
}
129-
const enableResult = enablePluginInConfig(cfg, id);
129+
const enableResult = enablePluginInConfig(cfg, id, {
130+
updateChannelConfig: false,
131+
});
130132
let next: OpenClawConfig = enableResult.config;
131133
const slotResult = applySlotSelectionForPlugin(next, id);
132134
next = slotResult.config;
@@ -171,7 +173,9 @@ export function registerPluginsCli(program: Command) {
171173
if (!report.plugins.some((plugin) => matchesPluginId(plugin, id))) {
172174
return reportMissingPlugin(id);
173175
}
174-
const next = setPluginEnabledInConfig(cfg, id, false);
176+
const next = setPluginEnabledInConfig(cfg, id, false, {
177+
updateChannelConfig: false,
178+
});
175179
await replaceConfigFile({
176180
nextConfig: next,
177181
...(snapshot.hash !== undefined ? { baseHash: snapshot.hash } : {}),

0 commit comments

Comments
 (0)