Cron: route reminders by session namespace

This commit is contained in:
Vignesh Natarajan
2026-02-16 14:29:21 -08:00
committed by Peter Steinberger
parent f452a7a60b
commit f988abf202
19 changed files with 530 additions and 32 deletions

View File

@@ -247,4 +247,36 @@ describe("heartbeat-wake", () => {
expect(handler).toHaveBeenCalledWith({ reason: "manual" });
expect(hasPendingHeartbeatWake()).toBe(false);
});
it("forwards wake target fields and preserves them across retries", async () => {
vi.useFakeTimers();
const handler = vi
.fn()
.mockResolvedValueOnce({ status: "skipped", reason: "requests-in-flight" })
.mockResolvedValueOnce({ status: "ran", durationMs: 1 });
setHeartbeatWakeHandler(handler);
requestHeartbeatNow({
reason: "cron:job-1",
agentId: "ops",
sessionKey: "agent:ops:discord:channel:alerts",
coalesceMs: 0,
});
await vi.advanceTimersByTimeAsync(1);
expect(handler).toHaveBeenCalledTimes(1);
expect(handler.mock.calls[0]?.[0]).toEqual({
reason: "cron:job-1",
agentId: "ops",
sessionKey: "agent:ops:discord:channel:alerts",
});
await vi.advanceTimersByTimeAsync(1000);
expect(handler).toHaveBeenCalledTimes(2);
expect(handler.mock.calls[1]?.[0]).toEqual({
reason: "cron:job-1",
agentId: "ops",
sessionKey: "agent:ops:discord:channel:alerts",
});
});
});