Announce incoming messages on the node's terminal

The node now checks for new messages every 10 s in the background (before,
only when the web UI asked), and Inbox.Collect reports newly filed visible
messages through OnArrivals. The CLI logs one line per conversation with the
listing title and a link to it, never the buyer's text. Hidden messages are not
announced, a backlog is capped at 5 lines, and a lock stops a background check
and a UI request from filing the same message twice.

The e2e checks that node A announces the message before its API is called.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 21:29:49 +01:00
co-authored by Claude Sonnet 5.5
parent 20ea9b32f7
commit a81595e9ee
8 changed files with 316 additions and 16 deletions
+7
View File
@@ -81,6 +81,13 @@ BUYER=$ROOT/scripts/e2e/buyer.ts
AUTHOR=$(curl -s http://127.0.0.1:18101/api/v1/status | python3 -c 'import json,sys; print(json.load(sys.stdin)["author"])')
SECRET=$(node $BUYER send http://127.0.0.1:18102 $AUTHOR $ID) || bad "buyer could not send via B"
ok "buyer posted an encrypted message to node B"
# Nobody has called A's API yet: the node itself must notice and tell its owner.
wait_for "A's terminal announces the new conversation" 30 grep -q 'msg="new conversation"' "$W/a.log"
grep 'msg="new conversation"' "$W/a.log" | grep -q 'listing="Helle Wohnung, renoviert"' && ok "owner's terminal names the listing" || bad "notice does not name the listing"
grep 'msg="new conversation"' "$W/a.log" | grep -q "open=http://127.0.0.1:18101/#/mine/$ID/" && ok "and links to the conversation" || bad "notice has no link"
grep -q "Ist die Wohnung noch frei" "$W/a.log" && bad "the buyer's text was printed to the terminal"
ok "the notice does not show what the buyer wrote"
[ "$(grep -c 'msg="new conversation"' "$W/a.log")" = 1 ] || bad "the notice was repeated"
inbox_a() { curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:18101/api/v1/inbox | python3 -c 'import json,sys; print(len(json.load(sys.stdin)))'; }
wait_for "A receives the message" 20 test "$(inbox_a)" = 1
ok "owner's node A decrypted it (via gossip through B)"