Membership/metadata reads used limit:1 + first(), picking an arbitrary
kind:39002/39000 copy when relays disagreed. A stale copy on one relay
(e.g. a dropped write) could be read and then clobber members on the next
read-modify-write. Add latest_event/latest_by_d_tag (max created_at, id
tie-break) and apply at all four read sites; drop the limit truncation in
get_channels.
Agents only published presence (kind:20001), never a kind:0 profile, so
clients showed a raw hex pubkey. Add publish_profile (name/display_name/
about/picture) at startup, sourced from the persona display_name with a
title-cased fallback from the agent command (goose -> Goose).
Tests: membership latest-wins resolution + profile metadata/name fallback.
- Replace relay.nostr.band (indexer relay that never completes a plain
client WS handshake — observed 0/10 connects, only ever cost connect
timeouts) with relay.primal.net (fast, free, anon read/write).
- query_relay_ws no longer uses join_all (which waited for the slowest
relay). It now returns on the first relay's response plus an 800ms
grace window for stragglers, so a slow-but-alive relay can't drag every
read out to the full 6s per-relay QUERY_TIMEOUT. Dead relays were
already skipped via the pool's failure cooldown; this fixes the
slow-but-connected case.
Post-merge fixes for desktop-tauri compile (clippy compiles tests):
- build_message gained custom_emoji_tags param from main; pass &[] in the
three serverless test/helper call sites (channels_tests, encrypted)
- remove duplicate #[allow(too_many_arguments)] left by the merge
The desktop encrypted_recipients() lookup used .first() on a multi-relay
merge of the addressable kind:39002 membership event and silently fell
back to encrypting to only self when the lookup came back empty. With the
membership event present on only some relays (split-brain / propagation
lag), a private-channel message could be gift-wrapped to just the sender —
so the agent (and other members) never received it, with no visible error.
Now: pick the NEWEST 39002 by created_at, and if an encrypted channel
resolves to no other members, return an error so the send fails loudly and
can be retried, instead of silently dropping every other recipient.
Replies in encrypted serverless channels (DM/private) were falling through
to the plaintext path — a privacy leak: the reply content went to public
relays as a cleartext kind-9. The encrypt branch was gated on
parent_event_id.is_none(), so only top-level messages were gift-wrapped.
Fix: encrypt replies too. The NIP-10 thread tags now live INSIDE the rumor
(the encrypted inner event), so threading is preserved without leaking the
reply. The thread root is resolved locally from decrypted messages (the
parent rumor isn't queryable in plaintext on the relay) and passed via a new
root_event_id command arg.
Proven by encrypted_threaded_reply_is_wrapped_and_preserves_thread: asserts
the wire event is kind-1059 (not plaintext kind-9), content never leaks, and
the decrypted rumor carries the NIP-10 root + reply e-tags.
- Route agent typing indicators (kind 20002) through the serverless pool
subscription so the 'agent is typing…' signal shows in serverless mode
(previously dropped — CHANNEL_EVENT_KINDS excluded 20002). useChannelTyping
now listens on serverless-event:<channel> when serverless; appendMessage
skips ephemeral typing events so they never enter the timeline.
- Retry serverless history fetch with short backoff on cold start: public
relays return 0/partial while pooled connections warm up, causing the
'blank for a minute after launch' feeling. Retry until events arrive.
Agent restore at startup raced ahead of the frontend applying the active
workspace, so serverless agents launched with the stale relay list frozen
into their record at creation time (including paid relays that 403) and one
even ran in server mode. When the only healthy relay rate-limited a reply,
there was no failover and the reply silently vanished.
- AppState.workspace_applied: agent restore now waits (bounded 15s) for the
frontend to call apply_workspace before launching, so agents inherit the
CURRENT workspace relays + serverless mode instead of record defaults.
- apply_workspace sets the flag once config is live.
- justfile _ensure-sidecar-stubs builds REAL sprout-acp + sprout sidecars
(serverless agents need them) instead of 0-byte stubs that silently fail
to launch/reply under just dev.
- Agent reply retries the full relay fan-out with backoff when every relay
rate-limited (transient), instead of silently dropping the reply. Hard
rejections are not retried.
- Prune relays that fail the WebSocket handshake (403/paid/unreachable) from
the agent's working set so discovery and publish only use healthy relays.
- Launch managed agents with the CURRENT workspace relay list (serverless)
rather than the list frozen into the agent record at creation time, so
stale/paid relays drop out without recreating the agent.
- Auto-fill the recommended public relays when the serverless toggle is
enabled in the Add Workspace dialog (no more tapping each chip).
The serverless agent never actually posted a reply: three real bugs,
each found by an end-to-end test against live public relays (no LLM).
1. CLI replies hit a single relay. `sprout messages send` used only the
first relay, so when that relay rate-limited the agent ("noting too
much") the reply was dropped. SproutClient now fans out reads/writes
across the full relay list — publish succeeds if ANY relay accepts,
queries merge+dedup. lib.rs passes the whole ws list, not just the first.
2. Agent harness died on a single relay 503. RestClient (channel discovery,
sibling checks) queried only the primary relay; a damus 503 crashed
discovery with "channel discovery error". RestClient now holds the full
relay list and fans out the same way — one relay down no longer kills the
agent. HarnessRelay carries relay_urls; rest_client() passes them through.
3. CLI panicked on wss:// (no rustls CryptoProvider). The serverless WS
transport (tokio-tungstenite) builds TLS directly and, unlike reqwest,
does not auto-install a provider. Install aws_lc_rs at CLI startup.
This is the standard Nostr client model (damus RelayPool, nostr-tools
SimplePool): relays don't gossip, so a client publishes-to-many,
reads-from-many, and dedups. Server mode is unchanged (single URL, HTTP bridge).
New e2e test (crates/sprout-acp/tests/e2e_agent_responds.rs + stub_agent.sh):
creates a channel + adds the agent, spawns the real sprout-acp harness with a
no-LLM ACP stub, posts an @mention, and asserts the agent's reply lands on the
relay. Passes in ~6s even while damus is 503-ing the whole time.
Also: fix pre-existing channels-subcommand stability test drift (PR #712 added
`channels search`); remove paid/auth relays already done; drop dead helpers.