mesh-mail-notifier: Send names its own machine's node-notifier (issue 865)
mesh/merge-gate head 3f97d2d50d57 merged into trunk 6a5e6510cab2 — pass: builds mesh-mail-notifier → g14, shanks; no bus step; every machine composes with …
mesh/repo-check head 3f97d2d50d57 merged into trunk 6a5e6510cab2 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered

This commit is contained in:
jochen
2026-10-15 23:27:24 +02:00
parent 8c2d7e5f97
commit 3f97d2d50d
2 changed files with 24 additions and 1 deletions
@@ -33,7 +33,7 @@ const ShownEvent = "shown"
func main() { func main() {
n := &Notifier{ n := &Notifier{
Send: func(args map[string]any) error { Send: func(args map[string]any) error {
_, err := stdio.Ask("seat:node-notifier.send", args) _, err := stdio.Ask(sendKey(), args)
return err return err
}, },
Accounts: readAccounts, 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 // 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 // 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 // running whatever stdio.Serve does with the stream it is given, including returning at once when stdin is
@@ -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)
}
}