























@@ -11,7 +11,11 @@ import type {
1111ConfigWriteNotification,
1212OpenClawConfig,
1313} from "../config/config.js";
14-import { setActivePluginRegistry } from "../plugins/runtime.js";
14+import {
15+pinActivePluginChannelRegistry,
16+resetPluginRuntimeStateForTest,
17+setActivePluginRegistry,
18+} from "../plugins/runtime.js";
1519import { createTestRegistry } from "../test-utils/channel-plugins.js";
1620import {
1721buildGatewayReloadPlan,
@@ -171,6 +175,7 @@ describe("buildGatewayReloadPlan", () => {
171175});
172176173177afterEach(() => {
178+resetPluginRuntimeStateForTest();
174179setActivePluginRegistry(emptyRegistry);
175180});
176181@@ -211,6 +216,23 @@ describe("buildGatewayReloadPlan", () => {
211216expect(plan.restartChannels).toEqual(expected);
212217});
213218219+it("refreshes channel reload rules when only the tracked channel registry changes", () => {
220+const activeOnlyRegistry = createTestRegistry([]);
221+const channelOnlyRegistry = createTestRegistry([
222+{ pluginId: "telegram", plugin: telegramPlugin, source: "test" },
223+]);
224+225+setActivePluginRegistry(activeOnlyRegistry);
226+const beforePinPlan = buildGatewayReloadPlan(["channels.telegram.botToken"]);
227+expect(beforePinPlan.restartGateway).toBe(true);
228+expect(beforePinPlan.restartChannels).toEqual(new Set());
229+230+pinActivePluginChannelRegistry(channelOnlyRegistry);
231+const afterPinPlan = buildGatewayReloadPlan(["channels.telegram.botToken"]);
232+expect(afterPinPlan.restartGateway).toBe(false);
233+expect(afterPinPlan.restartChannels).toEqual(new Set(["telegram"]));
234+});
235+214236it("restarts heartbeat when model-related config changes", () => {
215237const plan = buildGatewayReloadPlan([
216238"models.providers.openai.models",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。