Files
pi-goals/test/intercom-fixture.ts
T
wassname 88bfcc1c42 Fix symmetric supervision reconnect and cancel stale Ready attempts
Use explicit hello requests and replies, keep workers unready until model restoration succeeds, distinguish paused peers, and align all goal readers at the Log boundary. Add two-real-adapter handshake and failed-Ready/clear-during-wait regressions; warn once for unavailable supervisor context usage.
2026-09-08 19:27:09 +08:00

29 lines
1.1 KiB
TypeScript

export function intercomFixture() {
let autoHello = true;
let registration: any;
const sent: any[] = [];
let connected = true;
const receive = (payload: any, fromSessionId = "peer") => registration.onEvent({ type: "message", fromSessionId, payload });
return {
sent, receive,
replyToHello: (value: boolean) => { autoHello = value; },
event: (event: any) => registration.onEvent(event),
connect: (value: boolean) => { connected = value; registration.onEvent({ type: "connection", connected: value, supported: true }); },
events: {
on: () => () => {},
emit: (name: string, value: any) => {
if (name !== "intercom:extension-register") return false;
registration = value;
value.onReady({
snapshot: () => ({ connected, supported: true }),
publish: (message: any) => {
sent.push(message);
if (message.kind === "hello" && !message.reply && autoHello) queueMicrotask(() => receive({ ...message, role: message.role === "worker" ? "supervisor" : "worker", ready: true, reply: true }));
},
});
return true;
},
},
};
}