opencode: notifier wrapper gains the packet id (id <n>)

This commit is contained in:
2026-09-25 15:06:31 +00:00
parent 34e7bfe0bb
commit 88b617f8b7
4 changed files with 30 additions and 23 deletions
+8 -6
View File
@@ -699,7 +699,9 @@ describe('MeshService opencode notifier', () => {
let notifyMock: ReturnType<typeof vi.fn>;
beforeEach(() => {
notifyMock = vi.fn(async (_text: string, _from?: number) => {});
notifyMock = vi.fn(
async (_id: number, _text: string, _from?: number) => {},
);
});
// myInfo frame as streamed during the initial sync — sets svc.myNodeNum
@@ -737,7 +739,7 @@ describe('MeshService opencode notifier', () => {
await waitFor(() => notifyMock.mock.calls.length === 1);
expect(notifyMock).toHaveBeenCalledTimes(1);
expect(notifyMock).toHaveBeenCalledWith('ping', KAMIL_NUM);
expect(notifyMock).toHaveBeenCalledWith(1, 'ping', KAMIL_NUM); // packet id threaded through
} finally {
delete process.env.MESH_NOTIFY_CHANNEL;
svc.onModuleDestroy();
@@ -773,10 +775,10 @@ describe('MeshService opencode notifier', () => {
process.env.MESH_NOTIFY_CHANNEL = '0';
const svc = makeSvc();
try {
svc.injectMessage('hi', 42);
const r = svc.injectMessage('hi', 42);
expect(notifyMock).toHaveBeenCalledTimes(1);
expect(notifyMock).toHaveBeenCalledWith('hi', 42);
expect(notifyMock).toHaveBeenCalledWith(r.id, 'hi', 42); // generated record id threaded through
} finally {
delete process.env.MESH_NOTIFY_CHANNEL;
}
@@ -786,10 +788,10 @@ describe('MeshService opencode notifier', () => {
process.env.MESH_NOTIFY_CHANNEL = '0';
const svc = makeSvc();
try {
svc.injectMessage('hi');
const r = svc.injectMessage('hi');
expect(notifyMock).toHaveBeenCalledTimes(1);
expect(notifyMock).toHaveBeenCalledWith('hi', undefined);
expect(notifyMock).toHaveBeenCalledWith(r.id, 'hi', undefined);
} finally {
delete process.env.MESH_NOTIFY_CHANNEL;
}