From 6fde581a25fc9bd27d574f37a404829a74127e83 Mon Sep 17 00:00:00 2001 From: zerone0x Date: Sun, 22 Feb 2026 12:45:25 +0100 Subject: [PATCH] test(node): add coverage for notifyOnExit=false suppressing exec events --- src/gateway/server-node-events.test.ts | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/gateway/server-node-events.test.ts b/src/gateway/server-node-events.test.ts index a4e3539e835..9face4b662a 100644 --- a/src/gateway/server-node-events.test.ts +++ b/src/gateway/server-node-events.test.ts @@ -52,6 +52,7 @@ vi.mock("./session-utils.js", () => ({ import type { CliDeps } from "../cli/deps.js"; import { agentCommand } from "../commands/agent.js"; import type { HealthSummary } from "../commands/health.js"; +import { loadConfig } from "../config/config.js"; import { updateSessionStore } from "../config/sessions.js"; import { requestHeartbeatNow } from "../infra/heartbeat-wake.js"; import { enqueueSystemEvent } from "../infra/system-events.js"; @@ -61,6 +62,7 @@ import { loadSessionEntry } from "./session-utils.js"; const enqueueSystemEventMock = vi.mocked(enqueueSystemEvent); const requestHeartbeatNowMock = vi.mocked(requestHeartbeatNow); +const loadConfigMock = vi.mocked(loadConfig); const agentCommandMock = vi.mocked(agentCommand); const updateSessionStoreMock = vi.mocked(updateSessionStore); const loadSessionEntryMock = vi.mocked(loadSessionEntry); @@ -185,6 +187,45 @@ describe("node exec events", () => { ); expect(requestHeartbeatNowMock).toHaveBeenCalledWith({ reason: "exec-event" }); }); + + it("suppresses exec.started when notifyOnExit is false", async () => { + loadConfigMock.mockReturnValueOnce({ + session: { mainKey: "agent:main:main" }, + tools: { exec: { notifyOnExit: false } }, + } as ReturnType); + const ctx = buildCtx(); + await handleNodeEvent(ctx, "node-1", { + event: "exec.started", + payloadJSON: JSON.stringify({ + sessionKey: "agent:main:main", + runId: "run-silent-1", + command: "ls -la", + }), + }); + + expect(enqueueSystemEventMock).not.toHaveBeenCalled(); + expect(requestHeartbeatNowMock).not.toHaveBeenCalled(); + }); + + it("suppresses exec.finished when notifyOnExit is false", async () => { + loadConfigMock.mockReturnValueOnce({ + session: { mainKey: "agent:main:main" }, + tools: { exec: { notifyOnExit: false } }, + } as ReturnType); + const ctx = buildCtx(); + await handleNodeEvent(ctx, "node-2", { + event: "exec.finished", + payloadJSON: JSON.stringify({ + runId: "run-silent-2", + exitCode: 0, + timedOut: false, + output: "some output", + }), + }); + + expect(enqueueSystemEventMock).not.toHaveBeenCalled(); + expect(requestHeartbeatNowMock).not.toHaveBeenCalled(); + }); }); describe("voice transcript events", () => {