fix(gateway): restore dreaming startup reconciliation (#64258)

* gateway: restore dreaming startup reconciliation

* gateway: harden dreaming startup reconciliation

---------

Co-authored-by: mbelinky <mbelinky@users.noreply.github.com>
This commit is contained in:
Mariano
2026-04-10 15:02:19 +02:00
committed by GitHub
parent 383ea34efe
commit 03e19c5436
12 changed files with 283 additions and 17 deletions

View File

@@ -2,7 +2,12 @@ import fs from "node:fs";
import path from "node:path";
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
import { clearInternalHooks, getRegisteredEventKeys } from "../hooks/internal-hooks.js";
import {
clearInternalHooks,
createInternalHookEvent,
getRegisteredEventKeys,
triggerInternalHook,
} from "../hooks/internal-hooks.js";
import { emitDiagnosticEvent } from "../infra/diagnostic-events.js";
import { withEnv } from "../test-utils/env.js";
import { clearPluginCommands, getPluginCommandSpecs } from "./command-registry-state.js";
@@ -1483,6 +1488,49 @@ module.exports = { id: "throws-after-import", register() {} };`,
clearInternalHooks();
});
it("replaces prior plugin hook registrations on activating reloads", async () => {
useNoBundledPlugins();
const plugin = writePlugin({
id: "internal-hook-reload",
filename: "internal-hook-reload.cjs",
body: `module.exports = {
id: "internal-hook-reload",
register(api) {
api.registerHook(
"gateway:startup",
(event) => {
event.messages.push("reload-hook-fired");
},
{ name: "reload-hook" },
);
},
};`,
});
clearInternalHooks();
const loadOptions = {
cache: false,
workspaceDir: plugin.dir,
config: {
plugins: {
load: { paths: [plugin.file] },
allow: ["internal-hook-reload"],
},
},
onlyPluginIds: ["internal-hook-reload"],
} as const;
loadOpenClawPlugins(loadOptions);
loadOpenClawPlugins(loadOptions);
const event = createInternalHookEvent("gateway", "startup", "gateway:startup");
await triggerInternalHook(event);
expect(event.messages.filter((message) => message === "reload-hook-fired")).toHaveLength(1);
clearInternalHooks();
});
it("can scope bundled provider loads to deepseek without hanging", () => {
resetPluginLoaderTestStateForTest();