Files
buzz/desktop/src/shared/api/observerRelay.test.mjs
Will Pfleger 959fc6e9d0 fix: give agent-observer sub a replay-capable limit (#1100)
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
2026-06-17 19:21:39 -04:00

33 lines
1.2 KiB
JavaScript

import assert from "node:assert/strict";
import test, { mock } from "node:test";
import { relayClient } from "./relayClient.ts";
import { subscribeToAgentObserverFrames } from "./observerRelay.ts";
// Regression guard: the observer subscription MUST request a replay-capable
// limit. With `limit: 0` the relay truncates reconnect replay to zero rows
// (NIP-01: limit 0 = no historical rows), so a turn_started missed during a
// network drop never re-delivers and the active-agents badge never appears.
test("subscribeToAgentObserverFrames requests a replay-capable limit with a since window", () => {
const calls = [];
mock.method(relayClient, "subscribeLive", (filter) => {
calls.push(filter);
return () => {};
});
subscribeToAgentObserverFrames("owner-pubkey", () => {});
assert.equal(calls.length, 1);
assert.equal(
calls[0].limit,
1000,
"observer sub must use limit:1000 so reconnect replay can recover missed frames — limit:0 drops the gap",
);
assert.ok(
calls[0].since && calls[0].since > 0,
"observer sub must carry `since` so launch history stays suppressed — only the reconnect replay window is backfilled",
);
mock.reset();
});