From 3f97d2d50d5765829b28d53eaaad02d0372c7497 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 15 Oct 2026 23:27:24 +0200 Subject: [PATCH] mesh-mail-notifier: Send names its own machine's node-notifier (issue 865) --- .../cmd/mesh-mail-notifier/main.go | 8 +++++++- .../cmd/mesh-mail-notifier/send_test.go | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 modules/mesh-mail-notifier/cmd/mesh-mail-notifier/send_test.go diff --git a/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/main.go b/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/main.go index 8f482fb3..1e37f663 100644 --- a/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/main.go +++ b/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/main.go @@ -33,7 +33,7 @@ const ShownEvent = "shown" func main() { n := &Notifier{ Send: func(args map[string]any) error { - _, err := stdio.Ask("seat:node-notifier.send", args) + _, err := stdio.Ask(sendKey(), args) return err }, Accounts: readAccounts, @@ -67,6 +67,12 @@ func main() { } } +// sendKey is the ask key Send uses: this machine's own node-notifier, named exactly as desk-channel asks +// another machine's ("seat:node-notifier.send@"+machine) and as the SDK's own Emit reads this machine's name +// (MESH_NODE, which the runtime sets) — not the bare seat, which any machine's node-notifier may answer +// first, leaving this one's notices undelivered (novox/hq issue 865). +func sendKey() string { return "seat:node-notifier.send@" + os.Getenv("MESH_NODE") } + // run is main's startup path, factored so a test can run it: the watcher started before stdio.Serve, exactly // as mesh-knowledge's serve starts go hear(k) and go background(k) before stdio.Serve — so the watcher keeps // running whatever stdio.Serve does with the stream it is given, including returning at once when stdin is diff --git a/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/send_test.go b/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/send_test.go new file mode 100644 index 00000000..d1f32000 --- /dev/null +++ b/modules/mesh-mail-notifier/cmd/mesh-mail-notifier/send_test.go @@ -0,0 +1,17 @@ +package main + +import "testing" + +// TestSendKeyNamesThisMachine proves Send asks its own machine's node-notifier, not the bare seat: a bare +// "seat:node-notifier.send" is answered by whichever machine's node-notifier takes it first, so notices sent +// from g14 and shanks were lost to "503 no responders" or another machine's desktop (novox/hq issue 865). +// desk-channel names the machine it asks the same way ("seat:node-notifier.send@"+machine, +// modules/desk-channel/cmd/desk-channel/main.go); sendKey must read this machine's own name the same way the +// SDK's own Emit does, from MESH_NODE, which the runtime sets. +func TestSendKeyNamesThisMachine(t *testing.T) { + t.Setenv("MESH_NODE", "g14") + + if got, want := sendKey(), "seat:node-notifier.send@g14"; got != want { + t.Fatalf("sendKey() = %q, want %q (it must name this machine, as desk-channel does)", got, want) + } +}