fix: suppress stray HEARTBEAT_OK replies

This commit is contained in:
Peter Steinberger
2026-01-01 23:53:29 +01:00
parent 7c0379ce05
commit 06e379a239
5 changed files with 68 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ vi.mock("../agents/pi-embedded.js", () => ({
import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
import { getReplyFromConfig } from "./reply.js";
import { HEARTBEAT_TOKEN } from "./tokens.js";
const webMocks = vi.hoisted(() => ({
webAuthExists: vi.fn().mockResolvedValue(true),
@@ -160,6 +161,31 @@ describe("trigger handling", () => {
});
});
it("suppresses HEARTBEAT_OK replies outside heartbeat runs", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
payloads: [{ text: HEARTBEAT_TOKEN }],
meta: {
durationMs: 1,
agentMeta: { sessionId: "s", provider: "p", model: "m" },
},
});
const res = await getReplyFromConfig(
{
Body: "hello",
From: "+1002",
To: "+2000",
},
{},
makeCfg(home),
);
expect(res).toBeUndefined();
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
});
});
it("updates group activation when the owner sends /activation", async () => {
await withTempHome(async (home) => {
const cfg = makeCfg(home);