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
+10 -5
View File
@@ -433,19 +433,24 @@ export class MeshService implements OnModuleInit, OnModuleDestroy {
};
this.pushHistory(rec);
// injected records ride channel 0 — the notifier fires only when MESH_NOTIFY_CHANNEL is set to match
this.notifyRx(0, text, from);
this.notifyRx(0, text, from, rec.id);
return { id: rec.id };
}
/** Fire-and-forget opencode notifier push for an rx text on `channel` (no-op unless channels match and a notifier is wired). */
private notifyRx(channel: number, text: string, from?: number): void {
/** Fire-and-forget opencode notifier push for an rx text on `channel` (no-op unless channels match and a notifier is wired). Both call sites pass the packet id. */
private notifyRx(
channel: number,
text: string,
from?: number,
id?: number,
): void {
if (!this.opencode || channel !== this.notifyChannel) return;
// self-echo filter: our own node must never trigger a notification of itself
if (from !== undefined && from === this.myNodeNum) {
this.logger.debug(`notify skipped: rx from our own node ${from}`);
return;
}
void this.opencode.notify(text, from);
void this.opencode.notify(id!, text, from); // both call sites always pass the packet id
}
/**
@@ -631,7 +636,7 @@ export class MeshService implements OnModuleInit, OnModuleDestroy {
channel: pkt.channel ?? 0,
at: Date.now(),
});
this.notifyRx(pkt.channel ?? 0, text, pkt.from);
this.notifyRx(pkt.channel ?? 0, text, pkt.from, pkt.id);
} else if (decoded && decoded.portnum === PORT_POSITION_APP) {
// live position update: the Position is serialized in Data.payload
let pos: Proto.Mesh.Position | undefined;